:root {
    --bg: #fafafa;
    --bg-elevated: #ffffff;
    --text: #18181b;
    --text-muted: #71717a;
    --border: #e4e4e7;
    --primary: #18181b;
    --primary-hover: #27272a;
    --primary-text: #ffffff;
    --accent: #f97316;
    --success: #16a34a;
    --warning: #eab308;
    --danger: #dc2626;
    --radius: 8px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

.topbar { background: var(--bg-elevated); border-bottom: 1px solid var(--border); padding: 16px 0; position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 32px; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 600; color: var(--text); text-decoration: none; font-size: 15px; }
.topbar-nav { display: flex; gap: 24px; flex: 1; margin-left: 24px; }
.topbar-nav a { color: var(--text-muted); text-decoration: none; font-size: 14px; font-weight: 500; }
.topbar-nav a:hover { color: var(--text); }
.topbar-user { display: flex; align-items: center; gap: 16px; }

.main { padding: 40px 24px; min-height: calc(100vh - 200px); }
.footer { padding: 32px 0; border-top: 1px solid var(--border); margin-top: 80px; }
.small { font-size: 13px; }
.muted { color: var(--text-muted); }

.page-header { margin-bottom: 32px; display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 28px; font-weight: 700; margin: 0 0 4px; }
.page-header p { margin: 0; }

.product-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-bottom: 48px; }
.product-card {
    display: block; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 28px; text-decoration: none; color: var(--text); transition: all 0.15s ease;
}
.product-card:hover { border-color: var(--text); transform: translateY(-2px); box-shadow: var(--shadow); }
.product-card-badge { display: inline-block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 12px; }
.product-card h2 { margin: 0 0 8px; font-size: 22px; }
.product-card p { margin: 0 0 20px; color: var(--text-muted); font-size: 14px; }
.product-card-action { font-weight: 600; font-size: 14px; }

.section { margin-bottom: 24px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.section h2 { margin: 0 0 16px; font-size: 16px; font-weight: 600; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
.table th { font-weight: 600; color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.table tbody tr:last-child td { border-bottom: none; }
.table a.link { color: var(--text); font-weight: 500; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.badge-rascunho { background: #e4e4e7; color: #52525b; }
.badge-enviado { background: #fef3c7; color: #92400e; }
.badge-assinado_cliente { background: #dbeafe; color: #1e40af; }
.badge-assinado_completo { background: #dcfce7; color: #166534; }
.badge-expirado { background: #fee2e2; color: #991b1b; }
.badge-cancelado { background: #f3f4f6; color: #6b7280; }

.filters { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.filters a {
    padding: 6px 14px; border-radius: 999px; background: var(--bg-elevated); border: 1px solid var(--border);
    color: var(--text-muted); text-decoration: none; font-size: 13px; font-weight: 500; transition: all 0.15s;
}
.filters a.active, .filters a:hover { background: var(--text); color: var(--primary-text); border-color: var(--text); }

.form { display: flex; flex-direction: column; gap: 16px; }
.form-large { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px 24px; margin: 0 0 20px; }
legend { padding: 0 8px; font-weight: 600; font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field label { font-size: 13px; font-weight: 500; color: var(--text); }
.field input, .field textarea {
    padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px;
    font-family: inherit; background: var(--bg-elevated); color: var(--text); transition: border-color 0.15s;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--text); }
.field textarea { resize: vertical; min-height: 80px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-2 .field, .grid-3 .field { margin-bottom: 0; }

.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }
.inline-form { display: inline; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 20px; border-radius: var(--radius); font-weight: 600; font-size: 14px;
    border: 1px solid transparent; cursor: pointer; text-decoration: none; transition: all 0.15s;
    font-family: inherit;
}
.btn-primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg-elevated); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--text); }
.btn-block { width: 100%; }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-link { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 0; font-size: 14px; font-family: inherit; }
.btn-link:hover { color: var(--text); }

.link { color: var(--text-muted); text-decoration: none; font-size: 14px; }
.link:hover { color: var(--text); }
.link.small { font-size: 13px; }

.alert { padding: 14px 18px; border-radius: var(--radius); margin-bottom: 20px; font-size: 14px; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert ul { margin: 8px 0 0; padding-left: 20px; }

.auth-body { background: var(--bg); display: flex; align-items: center; min-height: 100vh; }
.auth-container { width: 100%; max-width: 420px; margin: 0 auto; padding: 24px; }
.auth-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 40px 32px; box-shadow: var(--shadow); }
.auth-logo { display: flex; justify-content: center; margin-bottom: 24px; }
.auth-logo img { width: 48px; height: 48px; }
.auth-card h1 { text-align: center; margin: 0 0 8px; font-size: 22px; }
.auth-card .muted { text-align: center; margin: 0 0 24px; }
.auth-card form { margin-top: 24px; }

.status-card { display: flex; align-items: center; gap: 16px; padding: 16px 20px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 24px; flex-wrap: wrap; }

.link-blocks { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.link-block { padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.link-block h3 { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
.link-block p { margin: 0 0 12px; font-size: 13px; color: var(--text-muted); }
.link-block input[type=text] { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 12px; font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace; background: var(--bg-elevated); margin-bottom: 12px; }

.data-list { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 32px; margin: 0; }
.data-list dt { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 2px; font-weight: 600; }
.data-list dd { margin: 0; font-size: 14px; }
.data-list dt::first-letter { text-transform: uppercase; }

.error-page { text-align: center; padding: 60px 20px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); }
.error-page h1 { font-size: 72px; margin: 0 0 8px; color: var(--text-muted); font-weight: 700; }
.error-page p { color: var(--text-muted); margin: 0 0 24px; }
.error-page a { color: var(--text); text-decoration: underline; font-weight: 500; }

@media (max-width: 720px) {
    .topbar-inner { flex-wrap: wrap; gap: 12px; }
    .topbar-nav { order: 3; width: 100%; justify-content: center; margin-left: 0; padding-top: 12px; border-top: 1px solid var(--border); }
    .grid-2, .grid-3, .link-blocks, .data-list { grid-template-columns: 1fr; }
    .form-actions { flex-direction: column-reverse; }
    .form-actions .btn { width: 100%; }
    .page-header { flex-direction: column; align-items: flex-start; }
}
