:root {
    --bg: #f5efe5;
    --panel: rgba(255, 248, 238, 0.88);
    --ink: #172126;
    --muted: #5f6b70;
    --line: rgba(23, 33, 38, 0.1);
    --accent: #c96535;
    --accent-deep: #9d4b1f;
    --teal: #1d7d7b;
    --gold: #d6a44d;
    --danger: #b44336;
    --shadow: 0 24px 60px rgba(77, 47, 22, 0.14);
    --radius: 24px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Aptos", "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(201, 101, 53, 0.18), transparent 28%),
        radial-gradient(circle at right 20%, rgba(29, 125, 123, 0.14), transparent 24%),
        linear-gradient(180deg, #fcf7f1, #f0e5d6 64%, #eadbc8);
    min-height: 100vh;
}

h1, h2, h3, .invoice-label {
    font-family: "Georgia", "Palatino Linotype", serif;
    letter-spacing: -0.03em;
    margin: 0;
}

a { color: inherit; }

.ambient {
    position: fixed;
    width: 32rem;
    height: 32rem;
    border-radius: 999px;
    filter: blur(30px);
    opacity: 0.4;
    z-index: 0;
}

.ambient-one { background: rgba(201, 101, 53, 0.3); top: -10rem; left: -8rem; }
.ambient-two { background: rgba(29, 125, 123, 0.2); bottom: -10rem; right: -8rem; }

.login-shell, .page-shell, .invoice-shell { position: relative; z-index: 1; }

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem;
}

.login-card, .panel, .setup-card, .metric-card, .subpanel, .invoice-sheet {
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.65);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.login-card {
    width: min(100%, 34rem);
    padding: 2.5rem;
    border-radius: calc(var(--radius) + 6px);
}

.lead, .subtle, .hint, .renewal-client, .renewal-details, .mini-card span, .field span, .chat-speaker {
    color: var(--muted);
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.22em;
    font-size: 0.72rem;
    color: var(--accent-deep);
    margin-bottom: 0.65rem;
    font-weight: 700;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.field { display: grid; gap: 0.45rem; }
.field.full { grid-column: 1 / -1; }

.input, .select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 0.9rem 1rem;
    background: rgba(255, 255, 255, 0.78);
    font: inherit;
    color: var(--ink);
}

.chat-input { flex: 1; }

.button, .quick-chip {
    border: 0;
    border-radius: 999px;
    padding: 0.9rem 1.2rem;
    font: inherit;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.button:hover, .quick-chip:hover { transform: translateY(-1px); }
.button.primary { background: linear-gradient(135deg, var(--accent), var(--accent-deep)); color: #fff; box-shadow: 0 14px 30px rgba(157, 75, 31, 0.28); }
.button.secondary { background: rgba(29, 125, 123, 0.13); color: var(--teal); }
.button.ghost, .quick-chip { background: rgba(255, 255, 255, 0.7); color: var(--ink); border: 1px solid var(--line); }

.alert {
    margin: 1rem 0 0;
    padding: 1rem 1.2rem;
    border-radius: 18px;
    border: 1px solid transparent;
}

.alert-danger { background: rgba(180, 67, 54, 0.12); border-color: rgba(180, 67, 54, 0.22); }
.alert-info { background: rgba(29, 125, 123, 0.12); border-color: rgba(29, 125, 123, 0.22); }
.alert-success { background: rgba(95, 160, 95, 0.12); border-color: rgba(95, 160, 95, 0.22); }
.alert-warning { background: rgba(214, 164, 77, 0.15); border-color: rgba(214, 164, 77, 0.28); }

.page-shell { padding: 2rem; }

.topbar, .panel-head, .invoice-toolbar, .setup-card, .renewal-meta, .card-actions, .chat-entry, .topbar-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.topbar { margin-bottom: 1.5rem; }

.user-pill, .status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0.45rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 700;
}

.user-pill, .status-pill.neutral { background: rgba(255, 255, 255, 0.75); border: 1px solid var(--line); }
.status-pill.critical { background: rgba(180, 67, 54, 0.16); color: var(--danger); }
.status-pill.warning { background: rgba(214, 164, 77, 0.18); color: #8b641a; }
.status-pill.stable { background: rgba(29, 125, 123, 0.14); color: var(--teal); }

.metrics-grid, .content-grid, .two-up { display: grid; gap: 1.25rem; }
.metrics-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 1.25rem; }
.metric-card { padding: 1.4rem; border-radius: 22px; }
.metric-card span { display: block; color: var(--muted); margin-bottom: 0.55rem; }
.metric-card strong { font-size: 2rem; }

.content-grid { grid-template-columns: minmax(0, 1.5fr) minmax(20rem, 0.95fr); }
.stack { display: grid; gap: 1.25rem; }
.panel, .setup-card { border-radius: var(--radius); padding: 1.5rem; }
.panel-head.compact { margin-bottom: 1rem; }

.renewal-list, .mini-list { display: grid; gap: 1rem; margin-top: 1rem; }
.renewal-card, .mini-card {
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--line);
    padding: 1.1rem;
}

.renewal-card h3, .mini-card strong { margin-top: 0.7rem; }
.renewal-details { display: grid; gap: 0.25rem; margin: 0.8rem 0 1rem; }
.two-up { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.subpanel { padding: 1.3rem; border-radius: 22px; }

.quick-actions { display: flex; flex-wrap: wrap; gap: 0.65rem; margin: 1rem 0; }
.chat-entry { align-items: stretch; }
.chat-log { display: grid; gap: 0.75rem; margin-top: 1rem; }
.chat-bubble { max-width: 100%; border-radius: 20px; padding: 0.95rem 1rem; }
.chat-bubble.user { background: rgba(255, 255, 255, 0.78); border: 1px solid var(--line); }
.chat-bubble.agent { background: rgba(29, 125, 123, 0.12); border: 1px solid rgba(29, 125, 123, 0.16); }
.chat-bubble p { margin: 0.25rem 0 0; }

.invoice-shell { max-width: 960px; margin: 0 auto; padding: 2rem; }
.invoice-sheet { padding: 2rem; border-radius: 28px; }
.invoice-header, .invoice-grid { display: flex; justify-content: space-between; gap: 1rem; }
.invoice-label { color: var(--accent-deep); font-size: 0.95rem; text-transform: uppercase; }
.section-title { font-size: 0.78rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.6rem; }
.invoice-table { width: 100%; border-collapse: collapse; margin-top: 1.6rem; }
.invoice-table th, .invoice-table td { text-align: left; padding: 0.9rem 0.5rem; border-bottom: 1px solid var(--line); }
.invoice-total { margin-top: 1.4rem; text-align: right; font-size: 1.15rem; }
.invoice-note { color: var(--muted); margin-top: 1.1rem; }
.inline-link { color: var(--accent-deep); font-weight: 700; }

@media (max-width: 980px) {
    .metrics-grid, .content-grid, .two-up, .field-grid { grid-template-columns: 1fr; }
    .topbar, .panel-head, .invoice-header, .invoice-grid, .invoice-toolbar, .chat-entry { flex-direction: column; align-items: stretch; }
}
