/* =====================================================
   Receipt Intelligence — Design System
   ===================================================== */

:root {
    /* Brand */
    --brand: #0f766e;
    --brand-strong: #115e59;
    --brand-soft: #e6f4f1;
    --brand-ink: #ffffff;

    /* Surfaces */
    --app-bg: #f5f7fa;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --surface-raised: #ffffff;
    --sidebar-bg: #0b1220;
    --sidebar-ink: #e2e8f0;
    --sidebar-ink-muted: #94a3b8;
    --sidebar-active: rgba(15, 118, 110, 0.20);
    --sidebar-active-ink: #5eead4;
    --sidebar-border: rgba(255, 255, 255, 0.06);

    /* Text */
    --ink: #0f172a;
    --ink-soft: #1f2937;
    --muted: #64748b;
    --muted-strong: #475569;

    /* Lines & shadows */
    --line: #e2e8f0;
    --line-strong: #cbd5e1;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.12);

    /* Accents */
    --accent-blue: #2563eb;
    --accent-blue-soft: #e0e7ff;
    --accent-amber: #d97706;
    --accent-amber-soft: #fef3c7;
    --accent-rose: #be123c;
    --accent-rose-soft: #ffe4e6;
    --accent-violet: #7c3aed;
    --accent-violet-soft: #ede9fe;

    /* Status */
    --status-good: #16a34a;
    --status-warn: #d97706;
    --status-bad: #dc2626;
    --status-good-soft: #dcfce7;
    --status-bad-soft: #fee2e2;
    --status-warn-soft: #fef3c7;

    /* Chat */
    --chat-bg: #f1f5f9;
    --bubble-incoming-bg: #ffffff;
    --bubble-outgoing-bg: #d1f4ed;
    --bubble-system-bg: #eef2f6;

    /* Geometry */
    --radius-xs: 6px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 22px;

    --sidebar-w: 248px;
    --topbar-h: 68px;
}

:root[data-theme="dark"] {
    --brand: #2dd4bf;
    --brand-strong: #14b8a6;
    --brand-soft: rgba(45, 212, 191, 0.14);
    --brand-ink: #042f2e;

    --app-bg: #0b1220;
    --surface: #111a2c;
    --surface-muted: #0f192a;
    --surface-raised: #15233a;
    --sidebar-bg: #070d1a;
    --sidebar-ink: #e2e8f0;
    --sidebar-ink-muted: #94a3b8;
    --sidebar-active: rgba(45, 212, 191, 0.18);
    --sidebar-active-ink: #5eead4;
    --sidebar-border: rgba(255, 255, 255, 0.06);

    --ink: #e2e8f0;
    --ink-soft: #cbd5e1;
    --muted: #94a3b8;
    --muted-strong: #cbd5e1;

    --line: #1f2a44;
    --line-strong: #2a3656;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.32);
    --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.5);

    --accent-blue: #60a5fa;
    --accent-blue-soft: rgba(96, 165, 250, 0.18);
    --accent-amber: #fbbf24;
    --accent-amber-soft: rgba(251, 191, 36, 0.18);
    --accent-rose: #fb7185;
    --accent-rose-soft: rgba(251, 113, 133, 0.16);
    --accent-violet: #a78bfa;
    --accent-violet-soft: rgba(167, 139, 250, 0.18);

    --status-good: #4ade80;
    --status-warn: #fbbf24;
    --status-bad: #f87171;
    --status-good-soft: rgba(74, 222, 128, 0.16);
    --status-bad-soft: rgba(248, 113, 113, 0.16);
    --status-warn-soft: rgba(251, 191, 36, 0.16);

    --chat-bg: #0c1525;
    --bubble-incoming-bg: #15233a;
    --bubble-outgoing-bg: rgba(45, 212, 191, 0.18);
    --bubble-system-bg: #0f192a;
}

/* ===================== Reset & base ===================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

html {
    overflow-x: hidden;
}

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--app-bg);
    color: var(--ink);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}

button {
    font-family: inherit;
    cursor: pointer;
}

a {
    color: var(--brand);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

input, select, textarea {
    font-family: inherit;
}

/* ===================== App shell ===================== */

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ===================== Sidebar ===================== */

.app-sidebar {
    background: var(--sidebar-bg);
    color: var(--sidebar-ink);
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    gap: 22px;
    position: sticky;
    top: 0;
    height: 100vh;
    border-right: 1px solid var(--sidebar-border);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 6px 14px;
    border-bottom: 1px solid var(--sidebar-border);
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #14b8a6, #0ea5e9);
    color: #ffffff;
    font-size: 16px;
    flex: 0 0 auto;
    box-shadow: 0 8px 18px rgba(20, 184, 166, 0.3);
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
}

.brand-text strong {
    color: #ffffff;
    font-size: 14.5px;
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-text span {
    color: var(--sidebar-ink-muted);
    font-size: 11.5px;
    margin-top: 2px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-height: 0;
}

.nav-item {
    appearance: none;
    background: transparent;
    border: 1px solid transparent;
    color: var(--sidebar-ink-muted);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13.5px;
    font-weight: 500;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-item i {
    font-size: 14px;
    width: 18px;
    text-align: center;
    flex: 0 0 auto;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--sidebar-ink);
}

.nav-item.is-active {
    background: var(--sidebar-active);
    color: var(--sidebar-active-ink);
    font-weight: 600;
}

.sidebar-footer {
    padding-top: 12px;
    border-top: 1px solid var(--sidebar-border);
}

.sidebar-status {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.status-row {
    display: grid;
    grid-template-columns: 8px 1fr auto;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--sidebar-ink-muted);
}

.status-row strong {
    color: var(--sidebar-ink);
    font-weight: 600;
    font-size: 12px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #475569;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.04);
}

.status-dot.is-good { background: var(--status-good); box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.18); }
.status-dot.is-bad  { background: var(--status-bad); box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18); }
.status-dot.is-warn { background: var(--status-warn); box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.18); }

/* ===================== Main + topbar ===================== */

.app-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 100vw;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 28px;
    min-height: var(--topbar-h);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
}

:root[data-theme="dark"] .app-topbar {
    background: rgba(11, 18, 32, 0.85);
}

.topbar-title {
    flex: 1;
    min-width: 0;
}

.topbar-title h1 {
    font-size: 19px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: var(--ink);
}

.topbar-title p {
    margin-top: 2px;
    font-size: 12.5px;
    color: var(--muted);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.topbar-auth {
    display: none;
    align-items: center;
    gap: 8px;
}

.topbar-auth[data-auth-state="disabled"],
.topbar-auth[data-auth-state="signed-out"],
.topbar-auth[data-auth-state="signed-in"],
.topbar-auth[data-auth-state="needs-link"] {
    display: inline-flex;
}

.auth-status {
    display: inline-flex;
    align-items: center;
    height: 26px;
    padding: 0 9px;
    border-radius: 999px;
    background: var(--surface-alt);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.auth-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 38px;
    border: 1px solid var(--brand);
    border-radius: 999px;
    background: var(--brand);
    color: #ffffff;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
}

.auth-action-btn i {
    font-size: 14px;
}

.auth-action-btn.is-secondary {
    background: var(--surface);
    color: var(--brand);
}

.auth-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(13, 148, 136, 0.18);
}

.topbar-auth[data-auth-state="signed-out"] #clerkUserButton,
.topbar-auth[data-auth-state="signed-out"] .auth-status,
.topbar-auth[data-auth-state="disabled"] #signInBtn,
.topbar-auth[data-auth-state="disabled"] #clerkUserButton,
.topbar-auth[data-auth-state="signed-in"] .auth-status,
.topbar-auth[data-auth-state="signed-in"] #signInBtn,
.topbar-auth[data-auth-state="needs-link"] #signInBtn {
    display: none;
}

.clerk-user-button {
    display: flex;
    align-items: center;
}

.topbar-github-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 38px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.15s;
}

.topbar-github-link i {
    font-size: 17px;
}

.topbar-github-link:hover {
    border-color: var(--brand);
    color: var(--brand);
    transform: translateY(-1px);
}

.topbar-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-soft);
    display: grid;
    place-items: center;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.topbar-icon-btn:hover {
    border-color: var(--brand);
    color: var(--brand);
}

.sidebar-toggle {
    display: none;
}

.topbar-user {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    height: 38px;
}

.topbar-user > i {
    color: var(--muted);
    font-size: 16px;
}

.topbar-user[data-link-state="unlinked"] {
    display: none;
}

.topbar-user[data-link-state="unlinked"] .topbar-user-select {
    color: var(--muted);
}

.topbar-user-select {
    appearance: none;
    background: transparent;
    border: none;
    color: var(--ink);
    font-size: 13px;
    font-weight: 500;
    padding-right: 18px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%2364748b'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right center;
    background-size: 14px;
    max-width: 240px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    outline: none;
}

.topbar-user-select:disabled {
    cursor: default;
    opacity: 1;
}

.topbar-user-select option {
    background: var(--surface);
    color: var(--ink);
}

/* ===================== Content + views ===================== */

.app-content {
    flex: 1;
    padding: 28px;
    max-width: 1320px;
    width: 100%;
    margin: 0 auto;
}

.view {
    display: none;
    animation: fadeIn 0.2s ease;
}

.view.is-active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.section {
    margin-top: 28px;
}

.section-head {
    margin-bottom: 14px;
}

.section-head h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.section-head p {
    margin-top: 2px;
    font-size: 13px;
    color: var(--muted);
}

/* ===================== Cards ===================== */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 20px 6px;
}

.card-head-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.card-head h3 {
    font-size: 15.5px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.card-head p {
    margin-top: 2px;
    font-size: 12.5px;
    color: var(--muted);
}

.card-body {
    padding: 14px 20px 20px;
}

.card-body-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.generated-invoice-list {
    display: grid;
    gap: 10px;
}

.generated-invoice-row,
.history-row {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(130px, 0.55fr) minmax(170px, auto);
    gap: 14px;
    align-items: center;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface-muted);
}

.history-list {
    display: grid;
    gap: 10px;
}

.connection-primary {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface-muted);
    margin-bottom: 14px;
}

.connection-icon,
.connected-number-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: rgba(13, 148, 136, 0.14);
    color: var(--brand-strong);
    flex: 0 0 auto;
}

.connection-primary strong,
.connected-number-main strong {
    display: block;
    color: var(--ink);
    font-size: 14px;
}

.connection-primary span,
.connected-number-main span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.4;
}

.connected-number-list {
    display: grid;
    gap: 10px;
}

.connected-number-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface-muted);
}

.connected-number-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.connected-number-row .btn:disabled {
    opacity: 0.7;
    cursor: default;
}

.generated-invoice-main,
.history-main {
    min-width: 0;
}

.history-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.history-thumb {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    border: 1px solid var(--line);
    object-fit: cover;
    background: var(--surface);
    flex: 0 0 auto;
}

.history-file-icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--brand-strong);
    flex: 0 0 auto;
}

.generated-invoice-main strong,
.history-main strong {
    display: block;
    color: var(--ink);
    font-size: 14px;
}

.generated-invoice-main span,
.generated-invoice-meta span,
.history-main span,
.history-meta span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12.5px;
}

.history-main .history-approval-note {
    color: var(--brand-strong);
    font-weight: 700;
    line-height: 1.35;
}

.generated-invoice-actions,
.history-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.generated-invoice-actions a,
.history-actions a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 11px;
    border-radius: 9px;
    border: 1px solid var(--line);
    color: var(--ink);
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 700;
    background: var(--surface);
}

.empty-state {
    display: grid;
    place-items: center;
    gap: 8px;
    min-height: 130px;
    padding: 22px;
    border: 1px dashed var(--line);
    border-radius: var(--radius-md);
    color: var(--muted);
    text-align: center;
}

.empty-state i {
    color: var(--brand-strong);
    font-size: 22px;
}

/* ===================== Buttons ===================== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 600;
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
    background: var(--brand);
    color: var(--brand-ink);
    box-shadow: 0 6px 16px rgba(15, 118, 110, 0.25);
}

.btn-primary:hover {
    background: var(--brand-strong);
}

.btn-ghost {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--line);
}

.btn-secondary {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--line);
}

.btn-ghost:hover {
    border-color: var(--brand);
    color: var(--brand);
}

.btn-secondary:hover {
    border-color: var(--brand);
    color: var(--brand);
}

.btn-danger {
    background: rgba(220, 38, 38, 0.12);
    color: #dc2626;
    border-color: rgba(220, 38, 38, 0.24);
}

.btn-danger:hover {
    background: rgba(220, 38, 38, 0.18);
    border-color: rgba(220, 38, 38, 0.36);
}

.btn-small {
    padding: 7px 12px;
    font-size: 12.5px;
}

.icon-btn {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--muted-strong);
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.icon-btn:hover {
    border-color: var(--brand);
    color: var(--brand);
}

.icon-btn.danger {
    color: #dc2626;
}

.icon-btn.danger:hover {
    border-color: rgba(220, 38, 38, 0.42);
    background: rgba(220, 38, 38, 0.1);
}

/* ===================== Hero card (overview) ===================== */

.hero-card {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    gap: 28px;
    padding: 32px;
    border-radius: var(--radius-xl);
    background:
        radial-gradient(1200px 400px at -10% -30%, rgba(45, 212, 191, 0.18), transparent 60%),
        radial-gradient(800px 300px at 110% 130%, rgba(99, 102, 241, 0.16), transparent 55%),
        var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    align-items: center;
}

.hero-copy .eyebrow {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand-strong);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero-copy h2 {
    margin-top: 14px;
    font-size: 30px;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: var(--ink);
}

.hero-copy p {
    margin-top: 12px;
    font-size: 15px;
    color: var(--muted-strong);
    max-width: 560px;
    line-height: 1.55;
}

.hero-actions {
    display: flex;
    gap: 10px;
    margin-top: 22px;
    flex-wrap: wrap;
}

.hero-illustration {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 18px;
    background: var(--surface-muted);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    min-height: 220px;
}

.hero-bubble {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface);
    font-size: 13px;
    box-shadow: var(--shadow-xs);
    max-width: 86%;
}

.hero-bubble.bubble-incoming {
    align-self: flex-start;
    border-top-left-radius: 4px;
}

.hero-bubble.bubble-outgoing {
    align-self: flex-end;
    background: var(--brand-soft);
    border-color: rgba(15, 118, 110, 0.18);
    color: var(--brand-strong);
    border-top-right-radius: 4px;
}

.bubble-tag {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.hero-bubble.bubble-outgoing .bubble-tag {
    color: var(--brand-strong);
    opacity: 0.9;
}

.hero-bubble i {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

/* ===================== Pipeline ===================== */

.pipeline-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.pipeline-card {
    position: relative;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    transition: transform 0.15s, box-shadow 0.15s;
}

.pipeline-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.pipeline-step-num {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.05em;
}

.pipeline-card i {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--brand-soft);
    color: var(--brand-strong);
    margin-top: 10px;
    font-size: 15px;
}

.pipeline-card h4 {
    margin-top: 12px;
    font-size: 14.5px;
    font-weight: 700;
    color: var(--ink);
}

.pipeline-card p {
    margin-top: 4px;
    font-size: 12.5px;
    color: var(--muted-strong);
    line-height: 1.5;
}

/* ===================== Metric cards ===================== */

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.metric-grid-tight {
    margin-bottom: 14px;
}

.metric-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
}

.metric-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    font-size: 16px;
}

.metric-icon.tone-green  { background: var(--brand-soft);          color: var(--brand-strong); }
.metric-icon.tone-blue   { background: var(--accent-blue-soft);    color: var(--accent-blue); }
.metric-icon.tone-amber  { background: var(--accent-amber-soft);   color: var(--accent-amber); }
.metric-icon.tone-violet { background: var(--accent-violet-soft);  color: var(--accent-violet); }

.metric-body {
    min-width: 0;
}

.metric-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.metric-value {
    display: block;
    margin-top: 4px;
    font-size: 26px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.02em;
    line-height: 1.1;
    word-break: break-word;
}

.metric-value-text {
    font-size: 17px;
    text-transform: capitalize;
}

.metric-hint {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.3;
}

/* ===================== Quick actions ===================== */

.quick-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.quick-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: var(--ink);
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
    box-shadow: var(--shadow-xs);
}

.quick-card:hover {
    border-color: var(--brand);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.quick-card i {
    font-size: 18px;
    color: var(--brand-strong);
    margin-bottom: 4px;
}

.quick-card strong {
    font-size: 14px;
    font-weight: 700;
}

.quick-card span {
    font-size: 12.5px;
    color: var(--muted-strong);
}

/* ===================== Chat shell ===================== */

.view-chat {
    height: calc(100vh - var(--topbar-h) - 56px);
}

.chat-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.chat-shell-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.chat-shell-title {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.avatar-soft {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--brand-soft);
    color: var(--brand-strong);
    font-size: 16px;
    flex: 0 0 auto;
}

.chat-shell-title h3 {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.chat-shell-title p {
    font-size: 12.5px;
    color: var(--muted);
    margin-top: 1px;
}

.chat-shell-actions {
    display: flex;
    gap: 8px;
}

.chat-quick-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-muted);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--ink);
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 500;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.chip i {
    font-size: 12px;
    color: var(--brand-strong);
}

.chip:hover {
    border-color: var(--brand);
    color: var(--brand-strong);
}

.chip:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: var(--chat-bg);
    display: flex;
    flex-direction: column;
}

.message {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
    max-width: 78%;
}

.message.incoming { align-self: flex-start; }
.message.outgoing { align-self: flex-end; }
.message.system   { align-self: center; max-width: 92%; }

.message-content {
    padding: 10px 14px;
    border-radius: 14px;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: var(--shadow-xs);
}

.incoming .message-content {
    background: var(--bubble-incoming-bg);
    border: 1px solid var(--line);
    border-top-left-radius: 4px;
    color: var(--ink);
}

.outgoing .message-content {
    background: var(--bubble-outgoing-bg);
    border-top-right-radius: 4px;
    color: var(--ink);
}

.system .message-content {
    background: var(--bubble-system-bg);
    border: 1px dashed var(--line);
    text-align: center;
    color: var(--muted-strong);
    font-size: 13px;
    padding: 8px 14px;
}

.message-content p { margin-bottom: 4px; }
.message-content p:last-child { margin-bottom: 0; }

.message-time {
    font-size: 11px;
    color: var(--muted);
    margin-top: 4px;
    align-self: flex-end;
}

.message-content img {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 6px;
}

.file-attachment {
    display: flex;
    align-items: center;
    background: var(--surface-muted);
    padding: 10px;
    border-radius: 10px;
    margin-top: 8px;
    border: 1px solid var(--line);
}

.file-attachment i {
    font-size: 22px;
    margin-right: 10px;
    color: var(--brand-strong);
}

.file-attachment .file-info { flex: 1; }
.file-attachment .file-name { font-weight: 600; margin-bottom: 2px; font-size: 13px; }
.file-attachment .file-size { font-size: 11px; color: var(--muted); }

.file-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
    flex: 1;
    cursor: pointer;
}

.file-link:hover { text-decoration: none; }

.view-file-btn {
    background: var(--brand);
    color: var(--brand-ink);
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    cursor: pointer;
    margin-left: 8px;
}

.view-file-btn:hover { background: var(--brand-strong); }

.upload-form { display: none; }

.chat-composer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: var(--surface);
    border-top: 1px solid var(--line);
}

.composer-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--surface-muted);
    color: var(--muted-strong);
    display: grid;
    place-items: center;
    transition: border-color 0.15s, color 0.15s;
}

.composer-icon-btn:hover {
    border-color: var(--brand);
    color: var(--brand);
}

.composer-input {
    flex: 1;
}

.composer-input input {
    width: 100%;
    padding: 11px 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--ink);
    outline: none;
    font-size: 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.composer-input input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
    background: var(--surface);
}

.composer-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--brand);
    color: var(--brand-ink);
    display: grid;
    place-items: center;
    transition: background 0.15s, transform 0.05s;
}

.composer-send-btn:hover { background: var(--brand-strong); }
.composer-send-btn:active { transform: scale(0.96); }

/* ===================== Inspector / Settings grids ===================== */

.inspector-grid,
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.card-span-2 {
    grid-column: span 2;
}

/* Workflow steps */

.workflow-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.step {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--surface-muted);
    border: 1px solid var(--line);
    border-left: 3px solid var(--line-strong);
    color: var(--ink-soft);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.step:hover { background: var(--surface); border-color: var(--brand); }

.step-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--line-strong);
}

.step.active        { border-left-color: var(--accent-amber); }
.step.active .step-dot { background: var(--accent-amber); box-shadow: 0 0 0 3px var(--accent-amber-soft); }

.step.completed     { border-left-color: var(--status-good); }
.step.completed .step-dot { background: var(--status-good); box-shadow: 0 0 0 3px var(--status-good-soft); }

.step.waiting       { font-style: italic; color: var(--muted); }
.step.waiting .step-dot { background: var(--muted); }

.step.error         { border-left-color: var(--status-bad); color: var(--status-bad); }
.step.error .step-dot { background: var(--status-bad); }

/* Intent display */

.intent-display {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 10px;
    background: var(--brand-soft);
    border: 1px solid rgba(15, 118, 110, 0.16);
}

.intent-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--brand-strong);
}

.intent-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--ink);
}

/* Tokens */

.token-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.token-cell {
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--surface-muted);
    border: 1px solid var(--line);
}

.token-cell span {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.token-cell strong {
    display: block;
    margin-top: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px;
    font-weight: 600;
    color: var(--ink);
}

.token-cell-total strong { color: var(--brand-strong); }

/* Key-value list */

.kv-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.kv-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 10px 0;
    border-bottom: 1px dashed var(--line);
    font-size: 13px;
}

.kv-row:last-child {
    border-bottom: none;
}

.kv-row dt {
    color: var(--muted);
    font-weight: 500;
    flex: 0 0 auto;
}

.kv-row dd {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
    font-weight: 600;
    text-align: right;
    word-break: break-word;
}

.kv-mono {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 500;
    color: var(--ink-soft);
}

.kv-list-tight {
    margin-top: 14px;
}

.adjust-btn,
.toggle-btn {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--muted);
    padding: 4px 6px;
    transition: color 0.15s, border-color 0.15s;
}

.adjust-btn:hover,
.toggle-btn:hover {
    color: var(--brand);
    border-color: var(--line);
}

.toggle-btn i { font-size: 16px; }

/* Pills */

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--surface-muted);
    border: 1px solid var(--line);
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-soft);
}

.pill.status-active,
.status-active {
    background: var(--status-good-soft);
    color: var(--status-good);
    border-color: rgba(22, 163, 74, 0.25);
}

.pill.status-inactive,
.status-inactive {
    background: var(--status-bad-soft);
    color: var(--status-bad);
    border-color: rgba(220, 38, 38, 0.25);
}

/* Settings actions */

.settings-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.form-hint {
    margin-top: 12px;
    font-size: 12px;
    color: var(--muted);
}

/* Database stats grid */

.db-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 6px;
}

.db-stat {
    padding: 12px;
    border-radius: 10px;
    background: var(--surface-muted);
    border: 1px solid var(--line);
}

.db-stat span {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.db-stat strong {
    display: block;
    margin-top: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
}

/* ===================== Modals ===================== */

.modal-overlay,
.modal-dialog {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 520px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-overlay .modal-content {
    max-width: 800px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 22px;
    border-bottom: 1px solid var(--line);
}

.modal-header h3,
.modal-header h4 {
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.close-modal,
.close-btn {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 22px;
    cursor: pointer;
    transition: color 0.15s;
    line-height: 1;
}

.close-modal:hover,
.close-btn:hover { color: var(--ink); }

.modal-body {
    padding: 20px 22px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 14px 22px;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: var(--surface-muted);
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-soft);
}

.form-group input,
.form-group textarea,
.form-group select,
.company-profile-modal textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 14px;
    background: var(--surface);
    color: var(--ink);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus,
.company-profile-modal textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--surface-muted);
    border: 1px solid var(--line);
}

.checkbox-row input {
    width: auto;
    margin-top: 3px;
}

.checkbox-row span {
    display: block;
    font-size: 12px;
    color: var(--muted);
}

.generated-invoice-modal .modal-content {
    max-width: 760px;
}

.action-btn {
    background: var(--brand);
    color: var(--brand-ink);
    border: none;
    padding: 9px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 600;
}

.action-btn:hover { background: var(--brand-strong); }

.cancel-btn {
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
    padding: 9px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 600;
}

.cancel-btn:hover { border-color: var(--line-strong); }

/* Company profile modal */

.company-profile-modal .modal-content {
    max-width: 720px;
}

.company-profile-modal .form-section,
.generated-invoice-modal .form-section {
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px dashed var(--line);
}

.company-profile-modal .form-section:last-child,
.generated-invoice-modal .form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.company-profile-modal .form-section h5,
.generated-invoice-modal .form-section h5 {
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--brand-strong);
}

.company-profile-modal .form-hint {
    margin-bottom: 12px;
    font-style: normal;
    color: var(--muted);
    font-size: 12px;
}

/* Step logs */

.step-logs-container {
    background: var(--surface-muted);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12.5px;
    overflow-y: auto;
    max-height: 500px;
}

.log-entry {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--line);
}
.log-entry:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }

.log-timestamp { color: var(--muted); font-size: 11px; margin-bottom: 2px; }

.log-level {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    margin-right: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.log-level.info    { background: var(--accent-blue-soft);  color: var(--accent-blue); }
.log-level.debug   { background: var(--status-good-soft);  color: var(--status-good); }
.log-level.warning { background: var(--accent-amber-soft); color: var(--accent-amber); }
.log-level.error   { background: var(--status-bad-soft);   color: var(--status-bad); }

.log-step-details {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    margin-top: 6px;
}

.log-step-input,
.log-step-output { margin-top: 5px; }

.log-step-label {
    font-weight: 700;
    color: var(--muted-strong);
    margin-right: 5px;
}

.file-storage-info {
    padding: 12px;
    background: var(--surface-muted);
    border-radius: 10px;
    margin-top: 12px;
    border: 1px solid var(--line);
}

.storage-item {
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
}

.storage-item .label {
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 3px;
    font-size: 12px;
}

.storage-item .value {
    flex: 1;
    font-family: 'JetBrains Mono', monospace;
    background: var(--surface);
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--line);
    word-break: break-all;
    font-size: 12.5px;
}

#fileStorageUrlContainer { flex: 1; }

#fileStorageUrl {
    display: inline-block;
    color: var(--brand);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12.5px;
}

#fileStorageUrl:hover { text-decoration: underline; }

/* ===================== Loading overlay ===================== */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    color: #ffffff;
}

.loading-overlay.hidden { display: none; }

.spinner {
    width: 44px;
    height: 44px;
    border: 4px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: spin 0.9s linear infinite;
    margin-bottom: 14px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 13.5px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* ===================== Responsive ===================== */

@media (max-width: 1180px) {
    .pipeline-grid,
    .quick-grid,
    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 960px) {
    :root {
        --sidebar-w: 0px;
    }

    .app-shell {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        position: fixed;
        z-index: 60;
        top: 0;
        left: 0;
        width: min(280px, 84vw);
        height: 100vh;
        height: 100dvh;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

    .app-sidebar.is-open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    body.sidebar-open .app-sidebar {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .sidebar-toggle {
        display: grid;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    body.sidebar-open::before {
        content: "";
        position: fixed;
        inset: 0;
        z-index: 55;
        background: rgba(15, 23, 42, 0.42);
        backdrop-filter: blur(1px);
    }

    .hero-card {
        grid-template-columns: 1fr;
        padding: 24px;
    }

    .hero-illustration {
        order: 2;
    }

    .inspector-grid,
    .settings-grid {
        grid-template-columns: 1fr;
    }

    .card-span-2 {
        grid-column: auto;
    }

    .db-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .generated-invoice-row,
    .history-row {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .generated-invoice-actions,
    .history-actions {
        justify-content: flex-start;
    }

    .form-grid-2 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    :root {
        --topbar-h: 112px;
    }

    .app-topbar {
        align-items: center;
        flex-wrap: wrap;
        gap: 8px;
        min-height: auto;
        padding: 10px 12px;
    }

    .topbar-title {
        flex: 1 1 calc(100% - 96px);
    }

    .topbar-actions {
        order: 3;
        width: 100%;
        min-width: 0;
        justify-content: space-between;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 2px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .topbar-actions::-webkit-scrollbar {
        display: none;
    }

    .topbar-auth {
        flex: 0 0 auto;
    }

    .topbar-user {
        flex: 1 1 0;
        min-width: 0;
        padding-left: 10px;
        padding-right: 8px;
    }

    .topbar-user-select {
        width: 100%;
        max-width: none;
        min-width: 0;
    }

    .topbar-icon-btn,
    .topbar-github-link {
        flex: 0 0 auto;
    }

    .app-content {
        padding: 14px 12px 18px;
    }

    .section {
        margin-top: 20px;
    }

    .section-head {
        margin-bottom: 10px;
    }

    .hero-card {
        gap: 18px;
        padding: 18px;
        border-radius: var(--radius-lg);
    }

    .hero-copy h2 {
        font-size: 24px;
    }

    .hero-copy p {
        font-size: 14px;
    }

    .hero-actions,
    .card-body-actions,
    .settings-actions-row {
        flex-direction: column;
    }

    .hero-actions .btn,
    .card-body-actions .btn,
    .settings-actions-row .btn,
    .settings-actions-row .action-btn {
        width: 100%;
        justify-content: center;
    }

    .hero-illustration {
        padding: 12px;
        min-height: 0;
    }

    .hero-bubble {
        max-width: 100%;
        font-size: 12.5px;
    }

    .pipeline-grid,
    .quick-grid,
    .metric-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .pipeline-card,
    .quick-card,
    .metric-card {
        padding: 14px;
    }

    .token-grid {
        grid-template-columns: 1fr;
    }

    .topbar-title h1 {
        font-size: 16px;
    }

    .topbar-title p {
        display: none;
    }

    .auth-status,
    .auth-action-btn span {
        display: none;
    }

    .auth-action-btn {
        padding: 0 10px;
        font-size: 12px;
    }

    .topbar-github-link {
        width: 38px;
        padding: 0;
        border-radius: 10px;
    }

    .topbar-github-link span {
        display: none;
    }

    .card-head,
    .card-head-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .card-head {
        padding: 14px 14px 4px;
        gap: 10px;
    }

    .card-body {
        padding: 12px 14px 14px;
    }

    .card-head-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .generated-invoice-actions,
    .history-actions {
        justify-content: stretch;
    }

    .generated-invoice-actions a,
    .history-actions a {
        flex: 1 1 120px;
        justify-content: center;
    }

    .history-actions .icon-btn {
        flex: 0 0 38px;
        width: 38px;
        height: 34px;
    }

    .connection-primary,
    .connected-number-row {
        align-items: stretch;
        flex-direction: column;
    }

    .connected-number-row .btn {
        width: 100%;
        justify-content: center;
    }

    .kv-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }

    .kv-row dd {
        width: 100%;
        text-align: left;
    }

    .view-chat {
        height: calc(100vh - var(--topbar-h) - 28px);
        height: calc(100dvh - var(--topbar-h) - 28px);
        min-height: 460px;
    }

    .chat-shell {
        border-radius: var(--radius-md);
    }

    .chat-shell-head {
        padding: 10px 12px;
    }

    .chat-shell-title {
        gap: 10px;
    }

    .chat-shell-title p {
        display: none;
    }

    .avatar-soft {
        width: 34px;
        height: 34px;
        border-radius: 10px;
    }

    .chat-quick-row {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 10px 12px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .chat-quick-row::-webkit-scrollbar {
        display: none;
    }

    .chip {
        flex: 0 0 auto;
    }

    .chat-messages {
        padding: 12px;
    }

    .message {
        max-width: 92%;
    }

    .message.system {
        max-width: 100%;
    }

    .chat-composer {
        gap: 8px;
        padding: 10px 12px;
    }

    .composer-input {
        min-width: 0;
    }

    .composer-input input {
        padding: 10px 12px;
    }

    .composer-icon-btn,
    .composer-send-btn {
        width: 38px;
        height: 38px;
        flex: 0 0 auto;
    }

    .modal-overlay,
    .modal-dialog {
        align-items: stretch;
        padding: 10px;
    }

    .modal-content,
    .modal-overlay .modal-content,
    .generated-invoice-modal .modal-content,
    .company-profile-modal .modal-content {
        max-width: none;
        max-height: calc(100vh - 20px);
        max-height: calc(100dvh - 20px);
        border-radius: var(--radius-md);
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding-left: 14px;
        padding-right: 14px;
    }

    .modal-footer {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .modal-footer .btn,
    .modal-footer .action-btn,
    .modal-footer .cancel-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ===================== Helpers ===================== */

.is-hidden { display: none !important; }
