/* ==========================================================================
   Creaciones D'Doris — sistema de diseño
   Negro y dorado, sobrio: el dorado se reserva para la marca, la acción
   principal y el estado activo. Todo el texto cumple contraste AA (4.5:1).
   Dos temas: oscuro (por defecto) y claro, elegidos con data-theme en <html>
   (js/theme.js lo fija antes de pintar la página).
   ========================================================================== */

:root {
    color-scheme: dark;
    --bg: #0e0f11;
    --surface: #16181b;
    --surface-2: #1d2024;
    --surface-3: #272b30;
    --border: #2b2f35;
    --border-strong: #3d424a;
    --border-hover: #555b65;

    --text: #ecebe6;
    --text-2: #b4b3ab;
    --text-3: #8f8e87;

    --accent: #c9a24b;
    --accent-hover: #d8b462;
    --accent-soft: rgba(201, 162, 75, 0.12);
    --accent-line: rgba(201, 162, 75, 0.4);
    --on-accent: #17130a;

    --success: #4cb782;
    --success-soft: rgba(76, 183, 130, 0.12);
    --warning: #e39a4c;
    --warning-soft: rgba(227, 154, 76, 0.12);
    --on-warning: #1a1005;
    --danger: #e8706a;
    --danger-soft: rgba(232, 112, 106, 0.12);
    --danger-solid: #c8423c;
    --info: #6aa5e0;
    --info-soft: rgba(106, 165, 224, 0.12);

    --radius: 8px;
    --radius-sm: 6px;
    --shadow-pop: 0 12px 40px rgba(0, 0, 0, 0.55);

    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-brand: 'Playfair Display', Georgia, serif;

    --sidebar-w: 248px;
    --topbar-h: 56px;
    --tabbar-h: 60px;
}

/* Tema claro: marfil y dorado envejecido. El dorado se oscurece para que el
   texto y los botones dorados mantengan contraste AA sobre fondo claro. */
:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f5f3ee;
    --surface: #ffffff;
    --surface-2: #f3f1ec;
    --surface-3: #e6e3db;
    --border: #e2ded5;
    --border-strong: #c9c4b8;
    --border-hover: #a9a396;

    --text: #1c1b18;
    --text-2: #4a4842;
    --text-3: #6b6860;

    --accent: #8a6a1c;
    --accent-hover: #745815;
    --accent-soft: rgba(138, 106, 28, 0.1);
    --accent-line: rgba(138, 106, 28, 0.4);
    --on-accent: #ffffff;

    --success: #1f7a4f;
    --success-soft: rgba(31, 122, 79, 0.1);
    --warning: #a35410;
    --warning-soft: rgba(163, 84, 16, 0.1);
    --on-warning: #ffffff;
    --danger: #b42f29;
    --danger-soft: rgba(180, 47, 41, 0.08);
    --danger-solid: #b42f29;
    --info: #23639f;
    --info-soft: rgba(35, 99, 159, 0.09);

    --shadow-pop: 0 12px 32px rgba(28, 27, 24, 0.18);
}

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

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

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

h1, h2, h3, h4, p, dl, dd, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, video { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

.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;
}

.icon { font-size: 20px; line-height: 1; flex-shrink: 0; user-select: none; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 5px; border: 2px solid var(--bg); }

/* ===== App shell ===== */
.app-shell { min-height: 100dvh; }

.sidebar {
    display: none;
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border);
    z-index: 30;
}

.brand {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 20px 20px 18px;
    border-bottom: 1px solid var(--border);
    color: inherit;
}
.brand:hover { text-decoration: none; }
.brand-mark { font-family: var(--font-brand); font-size: 1.375rem; font-weight: 600; color: var(--accent); letter-spacing: 0.02em; line-height: 1.2; }
.brand-sub { font-size: 0.75rem; color: var(--text-3); }

.side-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.side-group { font-size: 0.6875rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; padding: 16px 10px 6px; }

.side-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 40px;
    padding: 8px 10px;
    margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-weight: 500;
    font-size: 0.875rem;
}
.side-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.side-link.is-active { background: var(--accent-soft); color: var(--accent); }
.side-link .count { margin-left: auto; }

.count {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--warning);
    color: var(--on-warning);
    font-size: 0.6875rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.side-user { border-top: 1px solid var(--border); padding: 12px; display: flex; align-items: center; gap: 10px; }
.side-user-info { flex: 1; min-width: 0; color: inherit; }
.side-user-info:hover { text-decoration: none; }
.side-user-name { font-size: 0.875rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-role { font-size: 0.75rem; color: var(--text-3); }

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    color: var(--accent);
    font-size: 0.8125rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.avatar.lg { width: 48px; height: 48px; font-size: 1rem; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.topbar .brand { flex-direction: row; align-items: baseline; gap: 10px; padding: 0; border: 0; }
.topbar .brand-mark { font-size: 1.1875rem; }
.topbar-end { display: flex; align-items: center; gap: 4px; }
.topbar-user { display: flex; align-items: center; gap: 10px; color: inherit; }
.topbar-user:hover { text-decoration: none; }
.topbar-user .side-user-role { display: none; }

.content {
    padding: 20px 16px calc(var(--tabbar-h) + 32px);
    max-width: 1200px;
    margin: 0 auto;
    outline: none;
}
.content.narrow { max-width: 760px; }

.tabbar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 25;
    display: flex;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
}
.tab-link {
    flex: 1;
    min-height: var(--tabbar-h);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-3);
    font-size: 0.6875rem;
    font-weight: 500;
    position: relative;
}
.tab-link:hover { text-decoration: none; color: var(--text); }
.tab-link.is-active { color: var(--accent); }
.tab-link .icon { font-size: 22px; }
.tab-link .count { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; font-size: 0.625rem; }

@media (min-width: 960px) {
    .sidebar { display: flex; }
    .topbar, .tabbar { display: none; }
    .app-main { margin-left: var(--sidebar-w); }
    .content { padding: 32px 32px 48px; }
}

/* ===== Page header ===== */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head-main { min-width: 0; }
.page-title { font-size: 1.375rem; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; }
.page-sub { color: var(--text-2); font-size: 0.875rem; margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-size: 0.8125rem; font-weight: 500; margin-bottom: 8px; min-height: 32px; }
.back-link:hover { color: var(--text); text-decoration: none; }
.back-link .icon { font-size: 18px; }

.section { margin-bottom: 24px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-title { font-size: 0.9375rem; font-weight: 600; }

.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { text-decoration: none; }
.btn .icon { font-size: 18px; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface-2); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-3); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { border-color: color-mix(in srgb, var(--danger) 50%, transparent); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-danger-solid { background: var(--danger-solid); color: #fff; }
.btn-danger-solid:hover { background: #d6504a; }
.btn-success { background: #2f8f62; color: #fff; }
.btn-success:hover { background: #379f6e; }
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: 0.8125rem; }
.btn-lg { min-height: 48px; padding: 12px 24px; font-size: 0.9375rem; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
@media (min-width: 720px) {
    .btn-compact { width: 32px; padding: 0; justify-content: center; }
    .btn-compact .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@media (max-width: 719px) {
    .table.stack-sm .cell-actions { flex-wrap: wrap; }
}
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; }

/* ===== Cards ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 0.9375rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-title .icon { color: var(--text-3); font-size: 19px; }
.card-body { padding: 20px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border); }
.cell-progress { display: grid; gap: 4px; min-width: 160px; }
.cell-badges { display: inline-flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

/* ===== KPIs ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
@media (min-width: 720px) { .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; } }
.kpi { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; color: inherit; }
a.kpi:hover { border-color: var(--border-strong); text-decoration: none; }
.kpi-label { font-size: 0.8125rem; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.kpi-label .icon { font-size: 17px; color: var(--text-3); }
.kpi-value { font-size: 1.625rem; font-weight: 600; line-height: 1.2; margin-top: 8px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.kpi-hint { font-size: 0.75rem; color: var(--text-3); margin-top: 4px; }
.kpi.is-alert { border-color: color-mix(in srgb, var(--warning) 45%, transparent); }
.kpi.is-alert .kpi-value { color: var(--warning); }

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
    background: var(--surface-3);
    color: var(--text-2);
}
.badge .icon { font-size: 14px; }
.badge.tone-accent { background: var(--accent-soft); color: var(--accent); }
.badge.tone-success { background: var(--success-soft); color: var(--success); }
.badge.tone-warning { background: var(--warning-soft); color: var(--warning); }
.badge.tone-danger { background: var(--danger-soft); color: var(--danger); }
.badge.tone-info { background: var(--info-soft); color: var(--info); }

/* ===== Alerts ===== */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); font-size: 0.875rem; color: var(--text-2); }
.alert .icon { font-size: 19px; margin-top: 1px; }
.alert strong { color: var(--text); font-weight: 600; }
.alert.tone-info { border-color: color-mix(in srgb, var(--info) 35%, transparent); background: var(--info-soft); }
.alert.tone-info .icon { color: var(--info); }
.alert.tone-warning { border-color: color-mix(in srgb, var(--warning) 40%, transparent); background: var(--warning-soft); }
.alert.tone-warning .icon { color: var(--warning); }
.alert.tone-danger { border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: var(--danger-soft); }
.alert.tone-danger .icon { color: var(--danger); }
.alert.tone-success { border-color: color-mix(in srgb, var(--success) 40%, transparent); background: var(--success-soft); }
.alert.tone-success .icon { color: var(--success); }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-3);
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    background: var(--surface);
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .ta-right { text-align: right; }
.table tr[data-href] { cursor: pointer; }
.table tr[data-href]:hover td { background: var(--surface-2); }
.cell-main { font-weight: 600; color: var(--text); }
.cell-main a { color: inherit; }
.cell-sub { font-size: 0.8125rem; color: var(--text-3); }
.cell-actions { display: flex; gap: 4px; justify-content: flex-end; }

@media (max-width: 719px) {
    .table.stack-sm thead { display: none; }
    .table.stack-sm, .table.stack-sm tbody, .table.stack-sm tr, .table.stack-sm td { display: block; width: 100%; }
    .table.stack-sm tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
    .table.stack-sm tbody tr:last-child { border-bottom: 0; }
    .table.stack-sm td { padding: 3px 0; border: 0; display: flex; justify-content: space-between; align-items: center; gap: 16px; text-align: right; }
    .table.stack-sm td::before { content: attr(data-label); color: var(--text-3); font-size: 0.8125rem; text-align: left; flex-shrink: 0; }
    .table.stack-sm td.cell-lead { display: block; text-align: left; padding-bottom: 6px; }
    .table.stack-sm td.cell-lead::before { display: none; }
    .table.stack-sm td:empty { display: none; }
    .table.stack-sm tr[data-href]:hover td { background: transparent; }
    .table.stack-sm .cell-actions { justify-content: flex-end; flex: 1; }
}

/* ===== Progress ===== */
.progress { display: flex; height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.progress-seg.is-credited { background: var(--accent); }
.progress-seg.is-review {
    background: repeating-linear-gradient(135deg, rgba(201, 162, 75, 0.55) 0 4px, rgba(201, 162, 75, 0.2) 4px 8px);
}
.progress.sm { height: 6px; }

.balance { display: grid; gap: 12px; }
.balance-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.balance-amount { font-size: 1.75rem; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; line-height: 1.2; }
.balance-of { color: var(--text-2); font-size: 0.875rem; }
.balance-meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 0.8125rem; color: var(--text-2); }

.legend { display: grid; gap: 6px; font-size: 0.8125rem; }
.legend-row { display: flex; justify-content: space-between; gap: 12px; color: var(--text-2); }
.legend-row .num { color: var(--text); font-weight: 500; }
.legend-row.is-total { padding-top: 8px; margin-top: 2px; border-top: 1px solid var(--border); font-weight: 600; color: var(--text); }
.legend-key { display: inline-flex; align-items: center; gap: 8px; }
.swatch { width: 10px; height: 10px; border-radius: 2px; background: var(--surface-3); flex-shrink: 0; }
.swatch.is-credited { background: var(--accent); }
.swatch.is-review { background: repeating-linear-gradient(135deg, rgba(201, 162, 75, 0.7) 0 2px, rgba(201, 162, 75, 0.25) 2px 4px); }

/* ===== Definition lists ===== */
.dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; }
@media (min-width: 720px) { .dl.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.dl dt { font-size: 0.75rem; color: var(--text-3); margin-bottom: 2px; }
.dl dd { font-size: 0.9375rem; overflow-wrap: anywhere; }
.dl .span-all { grid-column: 1 / -1; }
.dl .dd-sub { display: block; font-size: 0.8125rem; color: var(--text-3); margin-top: 2px; }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.9375rem; color: var(--text); }

/* ===== Forms ===== */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 0.8125rem; font-weight: 500; color: var(--text-2); }
.field-label .req { color: var(--danger); margin-left: 2px; }
.field-label .opt { color: var(--text-3); font-weight: 400; }
.field-hint { font-size: 0.75rem; color: var(--text-3); }
.field-error { font-size: 0.8125rem; color: var(--danger); display: flex; align-items: center; gap: 4px; }
.field-error .icon { font-size: 16px; }

.input, .select, .textarea {
    width: 100%;
    min-height: 40px;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 1rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}
@media (min-width: 960px) { .input, .select, .textarea { font-size: 0.9375rem; } }
.input::placeholder, .textarea::placeholder { color: var(--text-3); opacity: 1; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-hover); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input[readonly] { color: var(--text-2); background: var(--surface-2); }
.input:disabled, .select:disabled { opacity: 0.6; cursor: not-allowed; }
.input.is-invalid, .select.is-invalid { border-color: var(--danger); }
.input.amount { font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; min-height: 48px; }
.textarea { min-height: 96px; resize: vertical; }
.select {
    appearance: none;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23b4b3ab' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}


.input-group { position: relative; display: flex; }
.input-group .input { padding-left: 40px; }
.input-group .prefix { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-weight: 600; pointer-events: none; }
.input-group .suffix-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.input-group.has-suffix .input { padding-left: 12px; padding-right: 44px; }

.form-grid { display: grid; gap: 16px; }
@media (min-width: 600px) {
    .form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .form-grid .span-all { grid-column: 1 / -1; }
}

.form-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.form-actions.sticky {
    position: sticky;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    margin: 24px -16px 0;
    padding: 12px 16px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 10;
}
@media (min-width: 960px) {
    .form-actions.sticky { bottom: 0; margin: 24px 0 0; border: 1px solid var(--border); border-radius: var(--radius); }
}

/* Radio cards */
.choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.choice { position: relative; display: block; }
.choice input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.choice-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 72px;
    padding: 10px 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text-2);
    font-size: 0.875rem;
    font-weight: 500;
    text-align: center;
}
.choice-body .icon { font-size: 22px; }
.choice input:hover + .choice-body { border-color: var(--border-hover); }
.choice input:checked + .choice-body { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.choice input:focus-visible + .choice-body { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Segmented control */
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--bg); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.segmented span { display: block; padding: 6px 12px; font-size: 0.8125rem; font-weight: 500; color: var(--text-2); border-right: 1px solid var(--border-strong); min-height: 32px; }
.segmented label:last-child span { border-right: 0; }
.segmented input:checked + span { background: var(--accent-soft); color: var(--accent); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

.option-list { display: grid; gap: 0; }
.option-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.option-row:last-child { border-bottom: 0; }
@media (min-width: 720px) {
    .option-list { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }
    .option-row:nth-last-child(2):nth-child(odd) { border-bottom: 0; }
}

.check { display: flex; gap: 10px; align-items: flex-start; font-size: 0.875rem; color: var(--text); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex-shrink: 0; }

/* File drop */
.dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 24px 16px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--bg);
    text-align: center;
    color: var(--text-2);
    font-size: 0.875rem;
    cursor: pointer;
}
.dropzone:hover { border-color: var(--accent-line); background: var(--surface-2); }
.dropzone input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.dropzone .icon { font-size: 28px; color: var(--accent); margin-bottom: 4px; }
.dropzone strong { color: var(--text); font-weight: 600; }
.dropzone.is-required { border-color: var(--accent-line); padding: 36px 16px; }
.dropzone.is-invalid { border-color: var(--danger); }

.photo-preview { position: relative; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg); }
.photo-preview img { width: 100%; max-height: 320px; object-fit: contain; }
.photo-preview-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--border); font-size: 0.8125rem; color: var(--text-2); background: var(--surface); }

/* Thumbnails */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); background: var(--bg); }
.thumb-open { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }
.thumb-tag { position: absolute; left: 4px; bottom: 4px; display: inline-flex; align-items: center; gap: 2px; padding: 2px 6px; border-radius: 4px; background: rgba(0, 0, 0, 0.75); color: #fff; font-size: 0.6875rem; pointer-events: none; }
.thumb-tag .icon { font-size: 14px; }
.thumb-remove { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.75); color: #fff; display: flex; align-items: center; justify-content: center; }
.thumb-remove:hover { background: var(--danger-solid); }
.thumb-remove .icon { font-size: 16px; }

/* ===== Toolbar, search, chips ===== */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.search { position: relative; flex: 1; min-width: 220px; max-width: 420px; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 40px; background: var(--surface); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { min-height: 32px; padding: 4px 12px; border-radius: 16px; border: 1px solid var(--border-strong); background: transparent; color: var(--text-2); font-size: 0.8125rem; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { background: var(--surface-2); color: var(--text); }
.chip.is-active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.chip .n { color: inherit; opacity: 0.8; font-variant-numeric: tabular-nums; }

/* ===== Lists (payments, tasks) ===== */
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
a.list-row { color: inherit; }
a.list-row:hover { background: var(--surface-2); text-decoration: none; }
.list-icon { width: 36px; height: 36px; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--text-2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.list-main { flex: 1; min-width: 0; }
.list-title { font-weight: 600; font-size: 0.875rem; }
.list-title a { color: inherit; }
.list-title a:hover { color: var(--accent); }
.list-meta { font-size: 0.8125rem; color: var(--text-3); overflow-wrap: anywhere; }
.list-end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.list-amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.list-note { font-size: 0.8125rem; color: var(--text-2); margin-top: 4px; }
.list-note.is-danger { color: var(--danger); }

/* Validation cards */
.task { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.task:last-child { border-bottom: 0; }
.task-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.task-amount { font-size: 1.125rem; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.task-step { font-size: 0.75rem; color: var(--text-3); margin-top: 8px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.task-proofs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.task-proofs .thumb { width: 72px; }
.task-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }

/* Timeline */
.timeline { padding: 4px 20px 8px; }
.timeline-item { position: relative; padding: 12px 0 12px 20px; border-left: 1px solid var(--border-strong); margin-left: 4px; }
.timeline-item::before { content: ''; position: absolute; left: -4px; top: 18px; width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.timeline-item:first-child::before { background: var(--accent); }
.timeline-action { font-size: 0.875rem; font-weight: 600; }
.timeline-detail { font-size: 0.8125rem; color: var(--text-2); overflow-wrap: anywhere; }
.timeline-meta { font-size: 0.75rem; color: var(--text-3); margin-top: 2px; }

/* Empty state */
.empty { padding: 40px 20px; text-align: center; color: var(--text-2); }
.empty > .icon { font-size: 36px; color: var(--text-3); margin-bottom: 8px; }
.empty-title { font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty-text { font-size: 0.875rem; max-width: 420px; margin: 0 auto; }
.empty .btn { margin-top: 16px; }

/* Copy field */
.copy-field { display: flex; gap: 8px; }
.copy-field .input { font-size: 0.8125rem; min-width: 0; }

/* ===== Layouts ===== */
.detail-layout { display: grid; gap: 16px; align-items: start; }
.detail-layout > * { min-width: 0; }
@media (min-width: 1040px) {
    .detail-layout { grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; }
    .detail-main { grid-column: 1; grid-row: 1; }
    .detail-aside { grid-column: 2; grid-row: 1; position: sticky; top: 24px; }
}
.split { display: grid; gap: 16px; align-items: start; }
.split > * { min-width: 0; }
@media (min-width: 1040px) { .split { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; } }

.person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.person-name { font-weight: 600; }
.person-meta { font-size: 0.8125rem; color: var(--text-3); }

/* ===== Dialogs ===== */
dialog.dialog {
    width: min(520px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px);
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-pop);
    overflow: hidden;
}
dialog.dialog[open] { display: flex; flex-direction: column; }
dialog.dialog.wide { width: min(640px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, 0.7); }
.dialog-form { display: flex; flex-direction: column; min-height: 0; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.dialog-title { font-size: 1.0625rem; font-weight: 600; }
.dialog-body { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.dialog-body p { color: var(--text-2); font-size: 0.9375rem; }
.dialog-body p strong { color: var(--text); }
.dialog-body ul { margin: -8px 0 0; padding-left: 20px; color: var(--text-2); font-size: 0.9375rem; display: grid; gap: 2px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; }

dialog.lightbox { max-width: 100vw; max-height: 100dvh; width: 100vw; height: 100dvh; margin: 0; padding: 16px; border: 0; background: rgba(0, 0, 0, 0.92); }
dialog.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lightbox img, .lightbox video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; }
.lightbox-close { position: absolute; top: 12px; right: 12px; background: rgba(0, 0, 0, 0.6); color: #fff; border-color: rgba(255, 255, 255, 0.3); }

/* ===== Toasts ===== */
.toast-region { position: fixed; z-index: 1000; left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + 16px); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
@media (min-width: 960px) { .toast-region { left: auto; right: 24px; bottom: 24px; align-items: flex-end; } }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 420px; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--surface-3); border: 1px solid var(--border-strong); border-left-width: 3px; color: var(--text); font-size: 0.875rem; box-shadow: var(--shadow-pop); animation: toast-in 0.2s ease-out; }
.toast.success { border-left-color: var(--success); }
.toast.success .icon { color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.error .icon { color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.warning .icon { color: var(--warning); }
.toast.info { border-left-color: var(--info); }
.toast.info .icon { color: var(--info); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== Login ===== */
.auth { position: relative; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 56px 16px 24px; }
.auth-tools { position: absolute; top: 12px; right: 12px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand .brand-mark { font-size: 2rem; display: block; }
.auth-brand .brand-sub { font-size: 0.8125rem; color: var(--text-2); }
.auth-brand::after { content: ''; display: block; width: 40px; height: 1px; background: var(--accent); margin: 16px auto 0; }
.auth-title { font-size: 1.0625rem; font-weight: 600; margin-bottom: 4px; }
.auth-foot { text-align: center; font-size: 0.8125rem; color: var(--text-3); margin-top: 16px; }
.demo-box { margin-top: 16px; }
.demo-box .card-body { padding: 12px; display: grid; gap: 6px; }
.demo-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); text-align: left; }
.demo-btn:hover { border-color: var(--border-strong); background: var(--surface-2); }
.demo-btn .icon { color: var(--text-3); }
.demo-btn-name { font-size: 0.875rem; font-weight: 600; }
.demo-btn-role { font-size: 0.75rem; color: var(--text-3); }

/* ===== Public client page ===== */
.public-head { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); }
.public-head-inner { max-width: 640px; margin: 0 auto; height: var(--topbar-h); padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.public-head .brand-mark { font-size: 1.25rem; }
.public-head-end { display: flex; align-items: center; gap: 8px; }
.public-main { max-width: 640px; margin: 0 auto; padding: 20px 16px 40px; outline: none; }
.public-foot { text-align: center; font-size: 0.8125rem; color: var(--text-3); padding: 8px 16px 0; line-height: 1.7; }
.public-foot strong { color: var(--text-2); font-weight: 600; }

/* ===== Misc ===== */
.steps { display: grid; gap: 0; counter-reset: step; }
.step { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); counter-increment: step; }
.step:last-child { border-bottom: 0; }
.step::before { content: counter(step); width: 24px; height: 24px; border-radius: 50%; background: var(--surface-3); color: var(--text-2); font-size: 0.75rem; font-weight: 600; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; }
.step-title { font-weight: 600; font-size: 0.875rem; }
.step-text { font-size: 0.8125rem; color: var(--text-2); }

.menu-list a.list-row .icon.end { color: var(--text-3); }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.danger-zone .card-title { color: var(--danger); }
.danger-zone .card-title .icon { color: var(--danger); }
.loading { padding: 64px 16px; text-align: center; color: var(--text-3); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
    .sidebar, .topbar, .tabbar, .toast-region, .page-actions { display: none !important; }
    .app-main { margin: 0; }
}
