/* ==========================================================================
   Nonprofit CRM — design system
   ========================================================================== */

:root {
    --bg: #f3f5fa;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f4f9;
    --border: #e5e9f2;
    --border-strong: #d4dae6;
    --text: #0f172a;
    --text-soft: #334155;
    --muted: #64748b;
    --faint: #94a3b8;

    --primary: #0d9488;
    --primary-hover: #0f766e;
    --primary-soft: #ccfbf1;
    --primary-text: #0f766e;

    --success: #15803d;
    --success-soft: #dcfce7;
    --warning: #b45309;
    --warning-soft: #fef3c7;
    --danger: #b91c1c;
    --danger-soft: #fee2e2;
    --info: #0369a1;
    --info-soft: #e0f2fe;
    --purple: #7e22ce;
    --purple-soft: #f3e8ff;

    --sidebar-bg: #0b1220;
    --sidebar-bg-2: #0f1a2e;
    --sidebar-text: #94a3b8;
    --sidebar-text-strong: #f1f5f9;
    --sidebar-active: rgba(20, 184, 166, 0.16);

    --radius: 14px;
    --radius-sm: 10px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 32px -16px rgba(15, 23, 42, 0.18);
    --shadow-lg: 0 24px 70px -24px rgba(15, 23, 42, 0.35);
    --ring: 0 0 0 3px rgba(13, 148, 136, 0.16);
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
}

[data-theme='dark'] {
    --bg: #080d18;
    --surface: #0f172a;
    --surface-2: #131f36;
    --surface-3: #17233c;
    --border: #1e2b45;
    --border-strong: #2b3b58;
    --text: #e8edf7;
    --text-soft: #cbd5e1;
    --muted: #8b9bb4;
    --faint: #64748b;

    --primary: #14b8a6;
    --primary-hover: #2dd4bf;
    --primary-soft: rgba(20, 184, 166, 0.15);
    --primary-text: #a5b4fc;

    --success: #4ade80;
    --success-soft: rgba(34, 197, 94, 0.14);
    --warning: #fbbf24;
    --warning-soft: rgba(245, 158, 11, 0.15);
    --danger: #f87171;
    --danger-soft: rgba(239, 68, 68, 0.15);
    --info: #38bdf8;
    --info-soft: rgba(14, 165, 233, 0.15);
    --purple: #c084fc;
    --purple-soft: rgba(168, 85, 247, 0.15);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 18px 40px -20px rgba(0, 0, 0, 0.7);
    --shadow-lg: 0 30px 80px -24px rgba(0, 0, 0, 0.85);
    --ring: 0 0 0 3px rgba(20, 184, 166, 0.3);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
button { font: inherit; }
svg { flex-shrink: 0; }

::selection { background: rgba(13, 148, 136, 0.2); }

/* --------------------------------------------------------------------------
   Layout shell
   -------------------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 262px;
    flex: 0 0 262px;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
    color: var(--sidebar-text);
    padding: 20px 14px 14px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 6px 8px 20px;
    color: var(--sidebar-text-strong);
}
.brand:hover { color: #fff; }

.brand-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 11px;
    background: linear-gradient(135deg, #14b8a6, #0ea5e9);
    color: #fff;
    box-shadow: 0 8px 20px -8px rgba(20, 184, 166, 0.8);
}
.brand-mark.lg { width: 46px; height: 46px; border-radius: 13px; }

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong {
    font-size: 14.5px;
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.brand-text small { font-size: 10.5px; color: #64748b; letter-spacing: 0.1em; text-transform: uppercase; margin-top: 2px; }

.nav { flex: 1; display: flex; flex-direction: column; gap: 20px; padding-bottom: 16px; }
.nav-section { display: flex; flex-direction: column; gap: 3px; }
.nav-section-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #526079;
    padding: 0 12px 7px;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: 9px;
    color: var(--sidebar-text);
    font-weight: 500;
    font-size: 13.5px;
    transition: background 0.15s ease, color 0.15s ease;
}
.nav-link:hover { background: rgba(148, 163, 184, 0.08); color: var(--sidebar-text-strong); }
.nav-link.active {
    background: var(--sidebar-active);
    color: #c7d2fe;
    box-shadow: inset 2px 0 0 #2dd4bf;
}
.nav-link .icon { opacity: 0.85; }
.nav-count {
    margin-left: auto;
    min-width: 21px;
    height: 20px;
    padding: 0 6px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.16);
    color: #cbd5e1;
    font-size: 11px;
    font-weight: 600;
}
.nav-link.active .nav-count { background: rgba(129, 140, 248, 0.25); color: #e0e7ff; }

.sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid rgba(148, 163, 184, 0.1); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.sidebar-user:hover { background: rgba(148, 163, 184, 0.06); }
.sidebar-user-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.sidebar-user-info strong { color: var(--sidebar-text-strong); font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-info small { color: #64748b; font-size: 11px; }
.logout-form { margin-left: auto; }

.avatar {
    display: inline-grid;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    font-weight: 600;
    letter-spacing: 0.02em;
    flex-shrink: 0;
    user-select: none;
}

.main {
    flex: 1;
    min-width: 0;
    margin-left: 262px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 16px;
    height: 66px;
    padding: 0 28px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}
.search-box {
    position: relative;
    display: flex;
    align-items: center;
    gap: 9px;
    width: min(460px, 100%);
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--muted);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.search-box:focus-within { border-color: var(--primary); box-shadow: var(--ring); background: var(--surface); }
.search-box input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 13px;
}
.search-box input::placeholder { color: var(--faint); }
.search-box kbd {
    font-family: var(--font);
    font-size: 10.5px;
    color: var(--faint);
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    border-radius: 5px;
    padding: 1px 5px;
    background: var(--surface);
}
.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.topbar-date { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.topbar-user { display: flex; align-items: center; gap: 9px; padding-left: 12px; border-left: 1px solid var(--border); }
.topbar-user-info { display: flex; flex-direction: column; line-height: 1.25; }
.topbar-user-info strong { font-size: 12.5px; font-weight: 600; }
.topbar-user-info small { font-size: 10.5px; color: var(--muted); }
.quick-add {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    border-radius: 9px;
    background: var(--primary);
    color: #fff;
    font-size: 12.5px;
    font-weight: 600;
    box-shadow: 0 6px 16px -8px rgba(13, 148, 136, 0.8);
}
.quick-add:hover { background: var(--primary-hover); color: #fff; }
.mobile-menu { display: none !important; }

.content { flex: 1; padding: 26px 28px 36px; width: 100%; max-width: 1500px; margin: 0 auto; }
.app-footer {
    display: flex;
    gap: 7px;
    align-items: center;
    padding: 16px 28px 22px;
    color: var(--faint);
    font-size: 11.5px;
}
.app-footer .dot { opacity: 0.6; }

/* --------------------------------------------------------------------------
   Page header
   -------------------------------------------------------------------------- */
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}
.page-head h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.2;
}
.page-subtitle { color: var(--muted); font-size: 13px; margin-top: 4px; }
.page-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 38px;
    padding: 0 15px;
    border-radius: 9px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px -10px rgba(13, 148, 136, 0.9); }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text-soft); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--muted); color: var(--text); }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.08); color: #fff; }
.btn-sm { height: 31px; padding: 0 11px; font-size: 12px; border-radius: 8px; }
.btn-lg { height: 44px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.icon-btn.ghost-light { background: transparent; border-color: transparent; color: #94a3b8; }
.icon-btn.ghost-light:hover { background: rgba(148, 163, 184, 0.12); color: #fff; }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 8px; }
.theme-icon-dark { display: none; }
[data-theme='dark'] .theme-icon-light { display: none; }
[data-theme='dark'] .theme-icon-dark { display: inline-flex; }

/* --------------------------------------------------------------------------
   Cards & stats
   -------------------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}
.card-head.borderless { border-bottom: 0; padding-bottom: 4px; }
.card-title { font-size: 14px; font-weight: 650; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.card-subtitle { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }
.card-actions { display: flex; align-items: center; gap: 6px; }
.card-link { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.stat-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-grid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.stat-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 17px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    gap: 13px;
    align-items: flex-start;
}
.stat-icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--primary-soft);
    color: var(--primary-text);
    flex-shrink: 0;
}
.stat-icon.green { background: var(--success-soft); color: var(--success); }
.stat-icon.amber { background: var(--warning-soft); color: var(--warning); }
.stat-icon.blue { background: var(--info-soft); color: var(--info); }
.stat-icon.red { background: var(--danger-soft); color: var(--danger); }
.stat-icon.purple { background: var(--purple-soft); color: var(--purple); }
.stat-body { min-width: 0; flex: 1; }
.stat-label { font-size: 11.5px; font-weight: 550; color: var(--muted); text-transform: uppercase; letter-spacing: 0.045em; }
.stat-value { font-size: 23px; font-weight: 700; letter-spacing: -0.035em; line-height: 1.25; margin-top: 3px; font-variant-numeric: tabular-nums; }
.stat-value.sm { font-size: 19px; }
.stat-meta { display: flex; align-items: center; gap: 6px; margin-top: 5px; font-size: 11.5px; color: var(--muted); }
.trend { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-size: 11.5px; }
.trend.up { color: var(--success); }
.trend.down { color: var(--danger); }
.trend svg { width: 13px; height: 13px; }
.trend.flat { color: var(--muted); }

/* --------------------------------------------------------------------------
   Grids & panels
   -------------------------------------------------------------------------- */
.split { display: grid; gap: 18px; }
.split-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.split-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split-main { grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr); }
.split-main-wide { grid-template-columns: minmax(0, 2.2fr) minmax(300px, 1fr); }
.stack { display: flex; flex-direction: column; gap: 18px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }
.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.strong { font-weight: 600; }
.mono { font-family: var(--mono); font-size: 12px; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.money.neg { color: var(--danger); }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-wrap { width: 100%; overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
    text-align: left;
    font-size: 10.5px;
    font-weight: 650;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 11px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.data td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data .cell-main { font-weight: 550; color: var(--text); }
table.data .cell-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
table.data.compact td { padding: 9px 12px; }
table.data.compact th { padding: 9px 12px; }
.table-actions { display: inline-flex; gap: 4px; justify-content: flex-end; }
.table-actions form { display: inline; }

.table-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.filter-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }
.filter-input {
    display: flex;
    align-items: center;
    gap: 7px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--muted);
    min-width: 200px;
    flex: 1;
    max-width: 320px;
}
.filter-input input { border: 0; outline: 0; background: transparent; width: 100%; color: var(--text); font-size: 12.5px; }
.select.sm, .input.sm { height: 34px; font-size: 12.5px; border-radius: 8px; }
.toolbar-meta { font-size: 12px; color: var(--muted); margin-left: auto; white-space: nowrap; }

/* --------------------------------------------------------------------------
   Badges & status dots
   -------------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.45;
    white-space: nowrap;
    background: var(--surface-3);
    color: var(--muted);
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0.75; }
.badge-new, .badge-draft { background: var(--surface-3); color: var(--muted); }
.badge-scheduled { background: var(--primary-soft); color: var(--primary-text); }
.badge-dispatched, .badge-unpaid, .badge-maintenance { background: var(--warning-soft); color: var(--warning); }
.badge-in_progress, .badge-partial { background: var(--info-soft); color: var(--info); }
.badge-completed, .badge-paid, .badge-active { background: var(--success-soft); color: var(--success); }
.badge-cancelled, .badge-void, .badge-retired { background: var(--danger-soft); color: var(--danger); }
.badge-low { background: var(--success-soft); color: var(--success); }
.badge-normal { background: var(--info-soft); color: var(--info); }
.badge-high { background: var(--warning-soft); color: var(--warning); }
.badge-urgent { background: var(--danger-soft); color: var(--danger); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }
.badge-outline { background: transparent; border: 1px solid var(--border-strong); color: var(--muted); }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-size: 12px; font-weight: 600; color: var(--text-soft); }
.field-label .req { color: var(--danger); }
.field-hint { font-size: 11px; color: var(--muted); }

.input, .select, .textarea {
    width: 100%;
    height: 38px;
    padding: 0 11px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    outline: 0;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; line-height: 1.55; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: var(--ring); }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}
.input[type='date'], .input[type='time'], .input[type='datetime-local'] { padding-right: 8px; }
.input-group { display: flex; align-items: center; }
.input-group .input { border-radius: 8px 0 0 8px; }
.input-group .input-addon {
    display: grid;
    place-items: center;
    height: 38px;
    padding: 0 11px;
    border: 1px solid var(--border-strong);
    border-left: 0;
    border-radius: 0 8px 8px 0;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 12px;
}
.checkbox { display: flex; align-items: flex-start; gap: 8px; font-size: 12.5px; color: var(--text-soft); cursor: pointer; }
.checkbox input { width: 16px; height: 16px; margin-top: 1px; accent-color: var(--primary); }

.form-card { padding: 20px; }
.form-section { padding: 20px 0; border-top: 1px solid var(--border); }
.form-section:first-child { padding-top: 0; border-top: 0; }
.form-section-title { font-size: 13px; font-weight: 650; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: span 3; }
.form-actions {
    display: flex;
    align-items: center;
    gap: 9px;
    padding-top: 18px;
    margin-top: 20px;
    border-top: 1px solid var(--border);
}
.form-actions .right { margin-left: auto; }

/* --------------------------------------------------------------------------
   Flash / empty / pagination
   -------------------------------------------------------------------------- */
.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.flash {
    position: relative;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 11px 13px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
    animation: flash-in 0.25s ease;
}
@keyframes flash-in { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }
.flash-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 22%, transparent); }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 22%, transparent); }
.flash-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 22%, transparent); }
.flash-warning { background: var(--warning-soft); color: var(--warning); }
.flash-close { margin-left: auto; background: none; border: 0; color: currentColor; cursor: pointer; opacity: 0.7; padding: 2px; display: grid; place-items: center; }
.flash-close:hover { opacity: 1; }

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 48px 24px;
    color: var(--muted);
}
.empty-icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--primary-soft);
    color: var(--primary-text);
    margin-bottom: 14px;
}
.empty-state h3 { font-size: 14.5px; color: var(--text); margin-bottom: 4px; }
.empty-state p { font-size: 12.5px; max-width: 360px; }
.empty-state .btn { margin-top: 16px; }

.pagination { display: flex; align-items: center; gap: 4px; padding: 13px 16px; flex-wrap: wrap; }
.page {
    display: inline-grid;
    place-items: center;
    min-width: 30px;
    height: 30px;
    padding: 0 7px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}
.page:hover { border-color: var(--border-strong); color: var(--text); }
.page.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-gap { color: var(--faint); padding: 0 3px; }

/* --------------------------------------------------------------------------
   Dashboard specifics
   -------------------------------------------------------------------------- */
.chart-wrap { position: relative; height: 280px; padding: 16px 18px 10px; }
.chart-wrap.sm { height: 240px; }
.chart-wrap canvas { max-width: 100%; }

.schedule-list { display: flex; flex-direction: column; }
.schedule-item {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    align-items: flex-start;
}
.schedule-item:last-child { border-bottom: 0; }
.schedule-time {
    flex: 0 0 62px;
    font-size: 11.5px;
    font-weight: 650;
    color: var(--text-soft);
    padding-top: 1px;
    font-variant-numeric: tabular-nums;
}
.schedule-time small { display: block; font-size: 10px; color: var(--faint); font-weight: 500; }
.schedule-body { flex: 1; min-width: 0; }
.schedule-body strong { display: block; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.schedule-body span { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.schedule-item .badge { margin-top: 2px; }

.activity-list { display: flex; flex-direction: column; }
.activity-item { display: flex; gap: 11px; padding: 11px 16px; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: 0; }
.activity-dot {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 8px;
    background: var(--surface-3);
    color: var(--muted);
}
.activity-body { min-width: 0; font-size: 12px; color: var(--text-soft); }
.activity-body strong { font-weight: 600; color: var(--text); }
.activity-time { font-size: 10.5px; color: var(--faint); margin-top: 1px; }

.mini-list { display: flex; flex-direction: column; }
.mini-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.mini-item:last-child { border-bottom: 0; }
.mini-item .grow { flex: 1; min-width: 0; }
.mini-item .name { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-item .sub { font-size: 11px; color: var(--muted); }

/* --------------------------------------------------------------------------
   Detail pages
   -------------------------------------------------------------------------- */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
.detail-hero {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
    flex-wrap: wrap;
}
.detail-hero .hero-icon {
    display: grid;
    place-items: center;
    width: 50px;
    height: 50px;
    border-radius: 13px;
    background: var(--primary-soft);
    color: var(--primary-text);
    flex-shrink: 0;
}
.detail-hero h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }

.info-list { display: flex; flex-direction: column; }
.info-row { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--border); font-size: 12.5px; }
.info-row:last-child { border-bottom: 0; }
.info-row dt { flex: 0 0 122px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.info-row dd { margin: 0; flex: 1; color: var(--text-soft); word-break: break-word; }

.panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 650; }
.panel-body { padding: 16px; }

.desc-block { font-size: 13px; color: var(--text-soft); line-height: 1.65; white-space: pre-wrap; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 14px; overflow-x: auto; }
.tab {
    padding: 11px 12px;
    font-size: 12.5px;
    font-weight: 550;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary-text); border-bottom-color: var(--primary); }

.timeline { position: relative; display: flex; flex-direction: column; gap: 0; }
.timeline-item { position: relative; padding: 0 0 18px 24px; }
.timeline-item::before { content: ''; position: absolute; left: 5px; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.timeline-item::after { content: ''; position: absolute; left: 8.5px; top: 16px; bottom: 0; width: 1px; background: var(--border); }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item:last-child::after { display: none; }
.timeline-title { font-size: 12.5px; font-weight: 600; }
.timeline-meta { font-size: 11px; color: var(--faint); }

/* --------------------------------------------------------------------------
   Calendar
   -------------------------------------------------------------------------- */
.calendar-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.calendar-toolbar h2 { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; min-width: 170px; }
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}
.calendar-dow {
    padding: 9px 10px;
    font-size: 10px;
    font-weight: 650;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}
.calendar-cell {
    min-height: 112px;
    padding: 6px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    position: relative;
}
.calendar-cell:nth-child(7n) { border-right: 0; }
.calendar-cell.out { background: var(--surface-2); opacity: 0.65; }
.calendar-cell.today { background: color-mix(in srgb, var(--primary-soft) 55%, var(--surface)); }
.calendar-date { display: inline-grid; place-items: center; min-width: 21px; height: 21px; border-radius: 6px; font-size: 11px; font-weight: 650; color: var(--muted); margin-bottom: 3px; }
.calendar-cell.today .calendar-date { background: var(--primary); color: #fff; }
.calendar-event {
    display: block;
    font-size: 10.5px;
    line-height: 1.35;
    padding: 3px 5px;
    margin-bottom: 3px;
    border-radius: 5px;
    border-left: 3px solid var(--primary);
    background: var(--primary-soft);
    color: var(--primary-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 550;
}
.calendar-event:hover { filter: brightness(0.97); }
.calendar-event.completed { background: var(--success-soft); color: var(--success); border-left-color: var(--success); }
.calendar-event.cancelled { background: var(--danger-soft); color: var(--danger); border-left-color: var(--danger); text-decoration: line-through; }
.calendar-event.dispatched, .calendar-event.in_progress { background: var(--warning-soft); color: var(--warning); border-left-color: var(--warning); }
.calendar-more { font-size: 10px; color: var(--muted); font-weight: 600; padding-left: 5px; }
.calendar-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 14px; font-size: 11px; color: var(--muted); }
.legend-dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 5px; }

/* --------------------------------------------------------------------------
   Invoice document
   -------------------------------------------------------------------------- */
.invoice-doc {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow-sm);
}
.invoice-top { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; padding-bottom: 24px; border-bottom: 2px solid var(--border); }
.invoice-brand { display: flex; gap: 13px; align-items: flex-start; }
.invoice-brand h2 { font-size: 20px; font-weight: 750; letter-spacing: -0.03em; }
.invoice-brand p { font-size: 12px; color: var(--muted); margin-top: 2px; }
.invoice-meta { text-align: right; }
.invoice-meta h1 { font-size: 22px; letter-spacing: 0.04em; color: var(--muted); font-weight: 700; }
.invoice-meta .inv-number { font-size: 15px; font-weight: 650; color: var(--text); margin-top: 2px; font-family: var(--mono); }
.invoice-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 24px 0; }
.invoice-parties h4 { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 7px; }
.invoice-parties p { font-size: 12.5px; color: var(--text-soft); line-height: 1.55; }
.invoice-totals { width: min(330px, 100%); margin-left: auto; display: flex; flex-direction: column; gap: 7px; padding-top: 8px; }
.invoice-totals .line { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.invoice-totals .line.total { border-top: 2px solid var(--border); margin-top: 5px; padding-top: 10px; font-size: 16px; font-weight: 700; color: var(--text); }
.invoice-totals .line.paid { color: var(--success); font-weight: 600; }
.invoice-totals .line.due { font-size: 14px; font-weight: 700; }
.invoice-note { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--muted); }
.invoice-status-stamp {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border: 2px solid currentColor;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    transform: rotate(-4deg);
    margin-top: 10px;
}
.stamp-paid { color: var(--success); }
.stamp-unpaid { color: var(--warning); }
.stamp-void { color: var(--danger); }

/* Sale builder */
.sale-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
.line-table { width: 100%; border-collapse: collapse; }
.line-table th { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--border); }
.line-table td { padding: 7px 8px; vertical-align: middle; border-bottom: 1px solid var(--border); }
.line-table td:first-child, .line-table th:first-child { padding-left: 0; }
.line-table td:last-child, .line-table th:last-child { padding-right: 0; }
.line-table .input, .line-table .select { height: 34px; font-size: 12.5px; }
.line-table .line-total { font-size: 13px; font-weight: 600; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.line-table .remove-line { color: var(--faint); }
.line-table .remove-line:hover { color: var(--danger); }
.sale-summary { position: sticky; top: 90px; }
.summary-line { display: flex; justify-content: space-between; padding: 6px 0; font-size: 12.5px; color: var(--muted); }
.summary-line.total { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 12px; font-size: 17px; font-weight: 700; color: var(--text); }
.stock-hint { font-size: 10.5px; color: var(--faint); margin-top: 2px; }

/* --------------------------------------------------------------------------
   Reports
   -------------------------------------------------------------------------- */
.report-bars { display: flex; flex-direction: column; gap: 15px; padding: 18px; }
.report-bar-row { display: flex; flex-direction: column; gap: 6px; }
.report-bar-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 12.5px; color: var(--text-soft); }
.report-bar-head .tiny { margin-left: 4px; }
.report-bar-track { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.report-bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), #0ea5e9); min-width: 2px; }

/* --------------------------------------------------------------------------
   Auth page
   -------------------------------------------------------------------------- */
.auth-body { background: var(--bg); min-height: 100vh; }
.auth-shell { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100vh; }
.auth-art {
    position: relative;
    overflow: hidden;
    background: radial-gradient(1200px 600px at 10% 10%, #1e1b4b 0%, #0b1220 55%, #070b14 100%);
    color: #e2e8f0;
    padding: 54px 56px;
    display: flex;
    align-items: center;
}
.auth-art-inner { position: relative; z-index: 2; max-width: 470px; }
.auth-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 52px; }
.auth-brand strong { display: block; color: #fff; font-size: 15px; }
.auth-brand small { color: #64748b; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.1em; }
.auth-art h1 { font-size: 34px; line-height: 1.16; letter-spacing: -0.035em; font-weight: 750; color: #fff; margin-bottom: 16px; }
.auth-lede { color: #94a3b8; font-size: 14px; line-height: 1.7; margin-bottom: 28px; }
.auth-features { list-style: none; margin: 0 0 34px; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.auth-features li { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #cbd5e1; }
.auth-features li span { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: rgba(20, 184, 166, 0.18); color: #a5b4fc; flex-shrink: 0; }
.auth-quote { border-left: 2px solid #0f766e; padding-left: 16px; color: #64748b; font-size: 12.5px; font-style: italic; }
.auth-glow { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.35; }
.auth-glow-1 { width: 420px; height: 420px; background: #0d9488; top: -140px; right: -100px; }
.auth-glow-2 { width: 320px; height: 320px; background: #7c3aed; bottom: -120px; left: -60px; }
.auth-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; background: var(--bg); }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow-lg); }
.auth-card-head { margin-bottom: 22px; }
.auth-card-head h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.025em; }
.auth-card-head p { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.auth-form { display: flex; flex-direction: column; gap: 15px; }
.auth-demo { margin-top: 22px; padding: 13px 14px; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--border-strong); font-size: 11.5px; }
.auth-demo-title { display: flex; align-items: center; gap: 6px; font-weight: 650; color: var(--text-soft); margin-bottom: 7px; }
.auth-demo div { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); padding: 2px 0; }
.auth-demo code { font-family: var(--mono); font-size: 11px; color: var(--text-soft); }
.auth-foot { margin-top: 22px; color: var(--faint); font-size: 11px; }
.auth-form .btn { margin-top: 4px; }

/* --------------------------------------------------------------------------
   Dialogs
   -------------------------------------------------------------------------- */
dialog.dialog {
    width: min(520px, calc(100vw - 32px));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
}
dialog.dialog::backdrop { background: rgba(2, 6, 23, 0.55); backdrop-filter: blur(2px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.dialog-head h3 { font-size: 15px; font-weight: 650; }
.dialog-body { padding: 20px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.hr-space { height: 18px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.scroll-y { max-height: 360px; overflow-y: auto; }
.muted-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 11px 13px; font-size: 12px; color: var(--muted); }
.sidebar-scrim { display: none; }
.print-only { display: none; }

/* Responsive */
@media (max-width: 1200px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat-grid.cols-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .split-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.22s ease; }
    .sidebar.open { transform: none; box-shadow: 20px 0 60px rgba(0, 0, 0, 0.35); }
    .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(2, 6, 23, 0.5); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
    .sidebar-scrim.show { opacity: 1; pointer-events: auto; }
    .main { margin-left: 0; }
    .mobile-menu { display: inline-grid !important; }
    .content { padding: 20px 20px 30px; }
    .topbar { padding: 0 20px; }
    .split-main, .split-main-wide, .detail-grid, .sale-grid { grid-template-columns: minmax(0, 1fr); }
    .sale-summary { position: static; }
    .auth-shell { grid-template-columns: 1fr; }
    .auth-art { display: none; }
}
@media (max-width: 760px) {
    .topbar-date, .topbar-user-info, .search-box kbd { display: none; }
    .search-box { max-width: none; }
    .quick-add span { display: none; }
    .quick-add { width: 36px; padding: 0; justify-content: center; }
    .stat-grid, .stat-grid.cols-3, .stat-grid.cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .stat-card { padding: 13px; gap: 10px; }
    .stat-icon { width: 32px; height: 32px; }
    .stat-value { font-size: 19px; }
    .form-grid, .form-grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
    .form-grid .span-2, .form-grid .span-3 { grid-column: span 1; }
    .split-2, .split-3 { grid-template-columns: minmax(0, 1fr); }
    .page-head h1 { font-size: 21px; }
    .content { padding: 16px 14px 24px; }
    .topbar { padding: 0 14px; gap: 10px; }
    .invoice-doc { padding: 20px; }
    .invoice-parties { grid-template-columns: 1fr; gap: 16px; }
    .calendar-cell { min-height: 78px; }
    .calendar-event { font-size: 9.5px; }
    .calendar-dow { font-size: 9px; padding: 7px 4px; }
    .topbar-user { padding-left: 0; border-left: 0; }
    .app-footer { display: none; }
}
@media (max-width: 480px) {
    .stat-grid, .stat-grid.cols-3, .stat-grid.cols-5 { grid-template-columns: minmax(0, 1fr); }
}

/* Print */
@media print {
    .sidebar, .topbar, .app-footer, .page-actions, .flash-stack, .print-hide, .sidebar-scrim { display: none !important; }
    .main { margin-left: 0 !important; }
    .content { padding: 0 !important; max-width: none !important; }
    body { background: #fff; color: #000; }
    .invoice-doc { border: 0; box-shadow: none; padding: 0; }
    .print-only { display: block; }
    a { color: #000; }
    .card { box-shadow: none; }
}

/* ==========================================================================
   Nonprofit CRM additions
   ========================================================================== */
.grow { flex: 1; min-width: 0; }
.upper { text-transform: uppercase; letter-spacing: .04em; }
.info-row > span:first-child { flex: 0 0 130px; color: var(--muted); }
.info-row > strong { font-weight: 600; word-break: break-word; }
.info-row.span-2 { grid-column: span 2; }
.detail-grid .info-row.span-2 { grid-column: 1 / -1; }
.kanban { display: grid; grid-template-columns: repeat(8, minmax(210px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: start; }
.kanban-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); min-height: 260px; }
.kanban-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); }
.kanban-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.kanban-card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 11px; box-shadow: var(--shadow-sm); transition: border-color .15s, transform .15s; }
.kanban-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.kanban-empty { font-size: 11.5px; color: var(--faint); text-align: center; padding: 22px 6px; }
.calendar-event { border-left: 3px solid var(--primary); }
details.card > summary { cursor: pointer; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary:hover { background: var(--surface-2); }
details > summary.card-link { cursor: pointer; list-style: none; }
details > summary.card-link::-webkit-details-marker { display: none; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.table th {
    text-align: left;
    font-size: 10.5px;
    font-weight: 650;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 11px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.table tbody tr:last-child td { border-bottom: 0; }
table.table tbody tr:hover { background: var(--surface-2); }
table.table td.num, table.table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.table td.actions { text-align: right; white-space: nowrap; }
table.table .cell-main { font-weight: 550; color: var(--text); }
table.table .cell-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
table.table.compact td { padding: 9px 12px; }
table.table.compact th { padding: 9px 12px; }

/* --------------------------------------------------------------------------
   Writing Studio editor
   -------------------------------------------------------------------------- */
.editor-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
    padding: 8px 14px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.editor-btn {
    min-width: 30px; height: 30px; padding: 0 8px; border-radius: 7px;
    border: 1px solid transparent; background: transparent; color: var(--text-soft);
    font-size: 12px; font-weight: 600; cursor: pointer; display: inline-flex;
    align-items: center; justify-content: center;
}
.editor-btn:hover { background: var(--surface); border-color: var(--border); color: var(--primary-text); }
.editor-sep { width: 1px; height: 20px; background: var(--border-strong); margin: 0 4px; }
.editor {
    min-height: 460px; padding: 26px 30px; outline: none; font-size: 14px;
    line-height: 1.75; color: var(--text); background: var(--surface);
}
.editor:focus { box-shadow: inset 0 0 0 2px var(--primary-soft); }
.editor h2 { font-size: 19px; margin: 18px 0 10px; letter-spacing: -0.02em; }
.editor h3 { font-size: 16px; margin: 16px 0 8px; }
.editor p { margin: 0 0 12px; }
.editor ul, .editor ol { margin: 0 0 14px; padding-left: 24px; }
.editor li { margin-bottom: 4px; }
.editor a { color: var(--primary-text); text-decoration: underline; }
.editor-footer {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 14px; border-top: 1px solid var(--border); background: var(--surface-2);
    border-radius: 0 0 var(--radius) var(--radius);
}
.doc-paper {
    max-width: 760px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 46px 54px; box-shadow: var(--shadow); font-size: 14px; line-height: 1.75;
}
.doc-paper h2 { font-size: 22px; margin: 0 0 18px; }
.doc-paper h3 { font-size: 16px; margin: 20px 0 8px; }
.doc-paper p { margin: 0 0 12px; }
.doc-paper ul, .doc-paper ol { padding-left: 24px; margin: 0 0 14px; }
@media (max-width: 760px) {
    .editor { min-height: 360px; padding: 18px; }
    .doc-paper { padding: 24px 20px; }
}
