@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("../fonts/inter-latin.woff2") format("woff2"); }

:root {
    --font: "Inter", system-ui, sans-serif;
    --mono: var(--font);

    --h: 34px;
    --radius: 8px;
    --radius-lg: 12px;
    --sidebar: 240px;
    --sidebar-mini: 68px;
    --topbar: 60px;
    --ease: cubic-bezier(.2, .8, .2, 1);

    --bg: #f4f6fa;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #eef2f7;
    --border: #e3e8ef;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-2: #475569;
    --text-3: #94a3b8;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: #eaf1ff;
    --primary-ring: rgba(37, 99, 235, .18);
    --green: #059669;
    --green-soft: #e7f8f1;
    --amber: #d97706;
    --amber-soft: #fff4e2;
    --red: #dc2626;
    --red-soft: #fdecec;
    --violet: #7c3aed;
    --violet-soft: #f2ecff;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, .12), 0 2px 6px rgba(15, 23, 42, .06);
    color-scheme: light;
}

[data-theme="dark"] {
    --bg: #1c2128;
    --surface: #22272e;
    --surface-2: #1f242b;
    --surface-3: #2d333b;
    --border: #353c45;
    --border-strong: #444c56;
    --text: #d3dae3;
    --text-2: #a2adb9;
    --text-3: #768390;
    --primary: #6c9eea;
    --primary-hover: #8cb4f0;
    --primary-soft: rgba(108, 158, 234, .13);
    --primary-ring: rgba(108, 158, 234, .25);
    --green: #6bba75;
    --green-soft: rgba(107, 186, 117, .13);
    --amber: #d4a54a;
    --amber-soft: rgba(212, 165, 74, .13);
    --red: #e5726c;
    --red-soft: rgba(229, 114, 108, .13);
    --violet: #a993dc;
    --violet-soft: rgba(169, 147, 220, .14);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .18);
    --shadow: 0 1px 3px rgba(0, 0, 0, .22);
    --shadow-lg: 0 14px 34px rgba(0, 0, 0, .32);
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
body { margin: 0; font: 400 13px/1.5 var(--font); 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, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
kbd { font: 500 11px/1 var(--mono); padding: 3px 6px; border-radius: 5px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-3); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
::selection { background: var(--primary-ring); }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

.icon { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--h); padding: 0 14px; border-radius: var(--radius); font-weight: 600; font-size: 13px; border: 1px solid transparent; white-space: nowrap; transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .1s; user-select: none; }
.btn:active { transform: translateY(1px); }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-loading { opacity: .65; pointer-events: none; }
.btn.is-loading::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
.icon-btn { width: var(--h); height: var(--h); display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius); color: var(--text-2); transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* Forms */
.form-stack { display: grid; gap: 18px; }
.field { display: grid; gap: 6px; }
.field label, .field-label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.field-head { display: flex; align-items: center; justify-content: space-between; }
.link-sm { font-size: 12px; font-weight: 500; }
.input { width: 100%; height: var(--h); padding: 0 11px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); font-size: 13px; transition: border-color .15s, box-shadow .15s; }
.input::placeholder { color: var(--text-3); }
.input:hover { border-color: var(--text-3); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
textarea.input { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
.input[readonly] { background: var(--surface-2); color: var(--text-2); }
.input-group { position: relative; display: flex; }
.input-group .input { padding-right: 44px; }
.input-addon { position: absolute; right: 1px; top: 1px; bottom: 1px; width: 40px; display: flex; align-items: center; justify-content: center; color: var(--text-3); border-radius: 0 var(--radius) var(--radius) 0; transition: color .15s; }
.input-addon:hover { color: var(--text); }
.has-error .input { border-color: var(--red); }
.has-error .input:focus { box-shadow: 0 0 0 3px var(--red-soft); }
.field-error { font-size: 12px; font-weight: 500; color: var(--red); }
.field-hint { font-size: 12px; color: var(--text-3); }
.strength { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; height: 4px; }
.strength i { border-radius: 4px; background: var(--surface-3); transition: background .25s; }
.strength[data-level="1"] i:nth-child(-n+1) { background: var(--red); }
.strength[data-level="2"] i:nth-child(-n+2) { background: var(--amber); }
.strength[data-level="3"] i:nth-child(-n+3) { background: var(--primary); }
.strength[data-level="4"] i { background: var(--green); }

.alert { padding: 11px 14px; border-radius: var(--radius); font-size: 13px; font-weight: 500; border: 1px solid transparent; animation: rise .3s var(--ease); }
.alert-success { background: var(--green-soft); color: var(--green); border-color: color-mix(in srgb, var(--green) 25%, transparent); }
.alert-danger { background: var(--red-soft); color: var(--red); border-color: color-mix(in srgb, var(--red) 25%, transparent); }

/* Auth */
.auth-page { min-height: 100vh; background: var(--surface); }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, 520px) 1fr; }
.auth-card { display: flex; flex-direction: column; justify-content: center; padding: 48px clamp(28px, 6vw, 72px); gap: 0; animation: rise .45s var(--ease); }
.auth-card > .auth-title { margin-top: 40px; }
.auth-brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--primary); color: #fff; box-shadow: 0 4px 12px var(--primary-ring); flex-shrink: 0; }
.brand-mark .icon { width: 18px; height: 18px; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.auth-title { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.auth-sub { color: var(--text-2); margin: 6px 0 28px; }
.auth-card .alert { margin-bottom: 18px; }
.auth-aside { background: linear-gradient(140deg, #1e3a8a, #2563eb 55%, #3b82f6); color: #fff; display: flex; align-items: center; justify-content: center; padding: 48px; position: relative; overflow: hidden; }
.auth-aside::before, .auth-aside::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .08); animation: float 14s ease-in-out infinite; }
.auth-aside::before { width: 520px; height: 520px; top: -180px; right: -160px; }
.auth-aside::after { width: 340px; height: 340px; bottom: -140px; left: -100px; animation-delay: -6s; }
.auth-aside-inner { position: relative; max-width: 440px; z-index: 1; }
.auth-aside h2 { font-size: 28px; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; }
.auth-aside p { margin-top: 12px; color: rgba(255, 255, 255, .78); font-size: 14px; }
.auth-preview { margin-top: 36px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .18); border-radius: 16px; padding: 20px; backdrop-filter: blur(8px); }
.auth-preview-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.auth-preview-row span { height: 46px; border-radius: 10px; background: rgba(255, 255, 255, .14); }
.auth-preview-bars { display: flex; align-items: flex-end; gap: 10px; height: 120px; margin-top: 18px; }
.auth-preview-bars i { flex: 1; border-radius: 6px 6px 3px 3px; background: rgba(255, 255, 255, .55); transform-origin: bottom; animation: grow 1.1s var(--ease) both, breathe 4s ease-in-out 1.2s infinite; }
.auth-preview-bars i:nth-child(1) { height: 40%; animation-delay: .05s, 1.2s; }
.auth-preview-bars i:nth-child(2) { height: 62%; animation-delay: .12s, 1.5s; }
.auth-preview-bars i:nth-child(3) { height: 48%; animation-delay: .19s, 1.8s; }
.auth-preview-bars i:nth-child(4) { height: 80%; animation-delay: .26s, 2.1s; }
.auth-preview-bars i:nth-child(5) { height: 66%; animation-delay: .33s, 2.4s; }
.auth-preview-bars i:nth-child(6) { height: 92%; animation-delay: .4s, 2.7s; }
.auth-preview-bars i:nth-child(7) { height: 74%; animation-delay: .47s, 3s; }

/* App shell */
.app { display: flex; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; width: var(--sidebar); flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; transition: width .25s var(--ease); z-index: 40; }
.sidebar-brand { height: var(--topbar); display: flex; align-items: center; gap: 10px; padding: 0 17px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.nav-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 18px 10px 8px; white-space: nowrap; }
.nav-group { display: grid; gap: 2px; }
.nav-item { position: relative; display: flex; align-items: center; gap: 12px; height: var(--h); padding: 0 10px; border-radius: var(--radius); color: var(--text-2); font-weight: 500; white-space: nowrap; transition: background .15s, color .15s; }
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-item.is-active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }
.nav-item span { overflow: hidden; text-overflow: ellipsis; transition: opacity .2s; }
.sidebar-collapse { margin: 12px; height: var(--h); display: flex; align-items: center; justify-content: center; border-radius: var(--radius); color: var(--text-3); border: 1px solid var(--border); transition: background .15s, color .15s; }
.sidebar-collapse:hover { background: var(--surface-3); color: var(--text); }
.sidebar-collapse .icon { transition: transform .25s var(--ease); }

.app.is-collapsed .sidebar { width: var(--sidebar-mini); }
.app.is-collapsed .brand-name, .app.is-collapsed .nav-item span, .app.is-collapsed .nav-label { opacity: 0; pointer-events: none; }
.app.is-collapsed .nav-label { height: 10px; padding: 0; }
.app.is-collapsed .sidebar-collapse .icon { transform: rotate(180deg); }
.app.is-collapsed .nav-item:hover::after { content: attr(data-tip); position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%); background: var(--text); color: var(--surface); padding: 5px 10px; border-radius: 6px; font-size: 12.5px; font-weight: 600; white-space: nowrap; box-shadow: var(--shadow-lg); z-index: 60; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar); display: flex; align-items: center; gap: 16px; padding: 0 24px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar-title { font-size: 14px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.search-trigger { margin-left: auto; display: flex; align-items: center; gap: 10px; height: var(--h); width: min(340px, 40vw); padding: 0 8px 0 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); color: var(--text-3); transition: border-color .15s, background .15s; }
.search-trigger:hover { border-color: var(--border-strong); background: var(--surface); }
.search-trigger span { flex: 1; text-align: left; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 10px 0 5px; border-radius: 10px; transition: background .15s; }
.user-chip:hover, .dropdown.is-open .user-chip { background: var(--surface-3); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 12.5px; flex-shrink: 0; }
.user-meta { display: grid; text-align: left; line-height: 1.25; }
.user-meta b { font-size: 13px; font-weight: 600; white-space: nowrap; }
.user-meta small { font-size: 11.5px; color: var(--text-3); }
.user-chip > .icon { width: 16px; height: 16px; color: var(--text-3); }
.content { padding: 28px; flex: 1; }
.mobile-only { display: none; }

/* Dropdown */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 210px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); opacity: 0; visibility: hidden; transform: translateY(-6px) scale(.98); transform-origin: top right; transition: opacity .15s, transform .15s var(--ease), visibility .15s; z-index: 50; }
.dropdown.is-open .dropdown-menu { opacity: 1; visibility: visible; transform: none; }
.dropdown-item { width: 100%; display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; border-radius: 7px; color: var(--text); font-size: 13px; font-weight: 500; text-align: left; }
.dropdown-item:hover { background: var(--surface-3); color: var(--text); }
.dropdown-item .icon { width: 16px; height: 16px; color: var(--text-3); }
.dropdown-item.is-danger, .dropdown-item.is-danger .icon { color: var(--red); }
.dropdown-sep { height: 1px; margin: 6px 4px; background: var(--border); }

/* Page */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-title { font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.page-sub { color: var(--text-2); margin-top: 4px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { display: grid; gap: 4px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); transition: transform .2s var(--ease), box-shadow .2s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card:nth-child(2) { animation-delay: .05s; }
.stat-card:nth-child(3) { animation-delay: .1s; }
.stat-card:nth-child(4) { animation-delay: .15s; }
.stat-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; margin-bottom: 8px; }
.stat-label { font-size: 12px; font-weight: 500; color: var(--text-2); }
.stat-value { font-size: 20px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tone-blue .stat-icon { background: var(--primary-soft); color: var(--primary); }
.tone-green .stat-icon { background: var(--green-soft); color: var(--green); }
.tone-amber .stat-icon { background: var(--amber-soft); color: var(--amber); }
.tone-violet .stat-icon { background: var(--violet-soft); color: var(--violet); }

.skeleton-line { display: block; height: 28px; width: 60%; border-radius: 6px; background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }

.empty-state { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 56px 24px; }
.empty-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); margin-bottom: 8px; }
.empty-icon .icon { width: 26px; height: 26px; }
.empty-state h3 { font-size: 14px; font-weight: 700; }
.empty-state p { color: var(--text-2); max-width: 420px; }

/* Toasts */
.toast-stack { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 10px; z-index: 200; }
.toast { display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 380px; padding: 12px 14px; border-radius: 10px; background: var(--text); color: var(--surface); box-shadow: var(--shadow-lg); font-size: 13px; font-weight: 500; animation: toast-in .35s var(--ease); }
.toast.is-leaving { animation: toast-out .25s ease forwards; }
.toast .icon { width: 18px; height: 18px; }
.toast-success .icon { color: #34d399; }
.toast-error .icon { color: #f87171; }

/* Error page */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.error-card { text-align: center; display: grid; justify-items: center; gap: 10px; animation: rise .4s var(--ease); }
.error-code { font-size: 72px; font-weight: 800; letter-spacing: -.04em; color: var(--primary); line-height: 1; }
.error-title { font-size: 22px; font-weight: 700; }
.error-text { color: var(--text-2); margin-bottom: 14px; max-width: 380px; }

.sidebar-backdrop { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes breathe { 0%, 100% { opacity: .55; } 50% { opacity: .85; } }
@keyframes float { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(30px, 24px); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }

@media (max-width: 1100px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
    .auth-card { padding: 40px 24px; max-width: 460px; width: 100%; margin: 0 auto; }
}

@media (max-width: 768px) {
    .mobile-only { display: inline-flex; }
    .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .25s var(--ease); box-shadow: var(--shadow-lg); }
    .app.is-nav-open .sidebar { transform: none; }
    .app.is-nav-open + .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .4); z-index: 35; }
    .sidebar-collapse { display: none; }
    .topbar { padding: 0 12px; gap: 8px; }
    .search-trigger { width: var(--h); padding: 0; justify-content: center; }
    .search-trigger span, .search-trigger kbd, .user-meta, .user-chip > .icon { display: none; }
    .content { padding: 18px 16px; }
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .page-head { flex-direction: column; align-items: flex-start; }
}

/* Custom controls */
.native-hidden { position: absolute !important; width: 1px !important; height: 1px !important; margin: -1px !important; padding: 0 !important; overflow: hidden !important; clip: rect(0 0 0 0) !important; border: 0 !important; opacity: 0 !important; pointer-events: none !important; }
.select-trigger, .date-trigger { display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; cursor: pointer; }
.select-trigger .icon, .date-trigger .icon { width: 16px; height: 16px; color: var(--text-3); transition: transform .2s var(--ease), color .15s; }
.select-trigger.is-active, .date-trigger.is-active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.select-trigger.is-active .icon { transform: rotate(180deg); color: var(--primary); }
.date-trigger.is-active .icon { color: var(--primary); }
.select-value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.is-placeholder .select-value { color: var(--text-3); }
.select-trigger:disabled { opacity: .6; cursor: not-allowed; }

.popover { position: fixed; z-index: 300; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); opacity: 0; visibility: hidden; transform: translateY(-4px); transition: opacity .14s, transform .14s var(--ease), visibility .14s; }
.popover.is-open { opacity: 1; visibility: visible; transform: none; }
.popover-search { margin-bottom: 6px; height: 34px; }
.popover-list { max-height: 260px; overflow-y: auto; }
.popover-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 32px; padding: 0 10px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.popover-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.popover-item.is-active { background: var(--surface-3); }
.popover-item.is-selected { color: var(--primary); font-weight: 600; }
.popover-item .icon { width: 16px; height: 16px; }
.popover-item.is-disabled { opacity: .45; cursor: not-allowed; }
.popover-empty { padding: 10px; text-align: center; color: var(--text-3); font-size: 13px; }
.is-hidden { display: none !important; }

.cal-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px 8px; }
.cal-head .icon-btn { width: 32px; height: 32px; }
.cal-title { font-weight: 700; font-size: 13px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow { text-align: center; font-size: 11.5px; font-weight: 600; color: var(--text-3); padding: 4px 0; }
.cal-day { height: 32px; border-radius: 8px; font-size: 13px; font-variant-numeric: tabular-nums; transition: background .12s, color .12s; }
.cal-day:hover:not(:disabled) { background: var(--surface-3); }
.cal-day.is-out { color: var(--text-3); }
.cal-day.is-today { box-shadow: inset 0 0 0 1px var(--border-strong); font-weight: 700; }
.cal-day.is-selected { background: var(--primary); color: #fff; font-weight: 600; box-shadow: none; }
.cal-day:disabled { color: var(--border-strong); cursor: not-allowed; text-decoration: line-through; }
.cal-foot { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.is-primary { color: var(--primary); }

.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: 13px; }
.check input { appearance: none; width: 18px; height: 18px; margin: 0; border: 1.5px solid var(--border-strong); border-radius: 5px; background: var(--surface); display: grid; place-items: center; transition: background .15s, border-color .15s; cursor: pointer; flex-shrink: 0; }
.check input[type="radio"] { border-radius: 50%; }
.check input:checked { background: var(--primary); border-color: var(--primary); }
.check input[type="checkbox"]:checked::after { content: ""; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.check input[type="radio"]:checked::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #fff; }
.check input:focus-visible { box-shadow: 0 0 0 3px var(--primary-ring); outline: none; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { appearance: none; width: 38px; height: 22px; margin: 0; border-radius: 22px; background: var(--border-strong); transition: background .2s; cursor: pointer; position: relative; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s var(--ease); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(16px); }

/* Page transition + skeletons */
.content.is-entering { animation: fade .18s ease-out; }
.skeleton { display: block; border-radius: 8px; background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.sk-head { display: grid; gap: 10px; margin-bottom: 24px; }
.sk-title { height: 26px; width: 240px; }
.sk-sub { height: 14px; width: 320px; max-width: 70%; }
.sk-card { height: 112px; border-radius: var(--radius-lg); }
.sk-table { padding: 8px 20px; }
.sk-row { display: flex; gap: 24px; align-items: center; height: 52px; border-bottom: 1px solid var(--border); }
.sk-row:last-child { border-bottom: 0; }
.sk-cell { height: 12px; }
.w-30 { width: 30%; } .w-20 { width: 20%; } .w-15 { width: 15%; } .w-10 { width: 10%; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 400; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .45); backdrop-filter: blur(3px); animation: fade .18s ease; }
.modal-box { position: relative; width: 100%; max-width: 560px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 24px; animation: pop .22s var(--ease); }
.modal-sm { max-width: 400px; }
.modal-title { font-size: 15px; font-weight: 700; }
.modal-text { color: var(--text-2); margin-top: 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.modal.is-closing .modal-box, .modal.is-closing .modal-backdrop { opacity: 0; transition: opacity .18s; }

/* Settings-style pages */
.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: start; }
.subnav { position: sticky; top: calc(var(--topbar) + 20px); display: grid; gap: 2px; }
.subnav a { display: flex; align-items: center; gap: 10px; height: var(--h); padding: 0 12px; border-radius: var(--radius); color: var(--text-2); font-weight: 500; border: 1px solid transparent; }
.subnav a:hover { background: var(--surface-3); color: var(--text); }
.subnav a.is-active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); border-color: var(--border); }
.section-card { padding: 24px; margin-bottom: 20px; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.section-title { font-size: 14px; font-weight: 700; }
.section-sub { color: var(--text-2); font-size: 12.5px; margin-top: 2px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 24px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-gray { background: var(--surface-3); color: var(--text-2); }
.badge-blue { background: var(--primary-soft); color: var(--primary); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 180px)); gap: 12px; }
.theme-choice { position: relative; display: grid; gap: 10px; padding: 10px; border: 1.5px solid var(--border); border-radius: var(--radius-lg); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.theme-choice:hover { border-color: var(--border-strong); }
.theme-choice:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.theme-choice input { position: absolute; opacity: 0; }
.theme-preview { height: 72px; border-radius: 8px; display: grid; grid-template-columns: 26% 1fr; overflow: hidden; border: 1px solid var(--border); }
.theme-preview.light { background: #f4f6fa; }
.theme-preview.light i { background: #fff; }
.theme-preview.dark { background: #0b1120; }
.theme-preview.dark i { background: #111827; }
.theme-choice span { font-weight: 600; font-size: 13px; }
.recovery-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 16px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); font: 600 13px/1.4 var(--mono); }
.steps { display: grid; gap: 18px; counter-reset: step; }
.step { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 12px; }
.step::before { counter-increment: step; content: counter(step); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 12px; }
.step > div { display: grid; gap: 8px; }
.list-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.list-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex-shrink: 0; }
.list-main { flex: 1; min-width: 0; }
.list-main b { display: block; font-weight: 600; }
.list-main small { color: var(--text-3); font-size: 12px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); padding: 0 16px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.row-actions .icon-btn { width: 32px; height: 32px; }
.text-muted { color: var(--text-3); }

.stat-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-value-sm { font-size: 15px; padding-top: 6px; }
.file-drop { display: flex; align-items: center; gap: 10px; height: var(--h); padding: 0 12px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius); color: var(--text-2); cursor: pointer; transition: border-color .15s, background .15s, color .15s; overflow: hidden; }
.file-drop:hover, .file-drop.is-dragging { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.file-drop.has-file { border-style: solid; color: var(--text); }
.file-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-drop span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.modal-field { margin-top: 18px; }
.row-actions form { display: contents; }

.twofa-setup { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 28px; align-items: start; }
.qr-frame { padding: 10px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); animation: rise .4s var(--ease); }
.qr { display: block; width: 100%; height: auto; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.input-row { display: flex; gap: 8px; max-width: 420px; }
.input-row .input { flex: 1; min-width: 0; }
.input-row.has-error .input { border-color: var(--red); }
.step b { font-weight: 600; }
.step .input-group { max-width: 420px; }
.list-row .btn { flex-shrink: 0; }

.brand-mark.is-light { background: rgba(255, 255, 255, .18); box-shadow: none; border: 1px solid rgba(255, 255, 255, .28); }
.auth-hero-brand { display: none; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } }

@media (max-width: 900px) {
    .settings-layout { grid-template-columns: 1fr; gap: 16px; }
    .subnav { position: static; display: flex; overflow-x: auto; gap: 6px; padding-bottom: 2px; }
    .subnav a { flex-shrink: 0; height: 36px; }

    .auth-page { background: var(--bg); }
    .auth-shell { display: flex; flex-direction: column; min-height: 100svh; }
    .auth-aside { display: flex; order: -1; padding: 40px 24px 76px; align-items: flex-start; justify-content: flex-start; }
    .auth-aside::before { width: 300px; height: 300px; top: -120px; right: -90px; }
    .auth-aside::after { width: 200px; height: 200px; bottom: -90px; left: -60px; }
    .auth-aside h2 { font-size: 20px; margin-top: 24px; }
    .auth-aside p { font-size: 13px; margin-top: 6px; }
    .auth-preview { display: none; }
    .auth-hero-brand { display: flex; align-items: center; gap: 10px; }
    .auth-hero-brand .brand-name { color: #fff; }
    .auth-card { position: relative; z-index: 2; flex: 1; margin: -44px 0 0; max-width: none; width: auto; padding: 32px 24px 40px; background: var(--surface); border-radius: 24px 24px 0 0; box-shadow: 0 -10px 30px rgba(15, 23, 42, .12); justify-content: flex-start; animation: sheet .5s var(--ease); }
    .auth-card > .auth-brand { display: none; }
    .auth-card > .auth-title { margin-top: 0; font-size: 20px; }
    .auth-card .input, .auth-card .btn { height: 42px; font-size: 14px; }
    .auth-card .input-addon { width: 42px; }
}

@media (max-width: 768px) {
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
    .section-card { padding: 18px; }
    .choice-grid { grid-template-columns: 1fr 1fr; }
    .modal { align-items: end; padding: 0; }
    .modal-box { border-radius: 20px 20px 0 0; max-width: none; animation: sheet .3s var(--ease); }
    .toast-stack { left: 16px; right: 16px; bottom: 16px; }
    .toast { min-width: 0; max-width: none; }
    .sk-row .w-10, .sk-row .w-15 { display: none; }
    .stat-grid-3 { grid-template-columns: 1fr; }
    .twofa-setup { grid-template-columns: 1fr; justify-items: start; gap: 20px; }
    .qr-frame { width: 184px; }
    .list-row { flex-wrap: wrap; }
    .section-head { flex-wrap: wrap; margin-bottom: 16px; }
    .section-head > form, .section-head > .btn { width: 100%; }
    .section-head > form .btn { width: 100%; }
    .form-actions .btn { flex: 1; }

    .topbar-title { font-size: 15px; }
    .stat-grid, .stat-grid-3 { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
    .stat-grid-3 > :first-child { grid-column: 1 / -1; }
    .stat-card { grid-template-columns: 32px minmax(0, 1fr); column-gap: 10px; row-gap: 0; padding: 12px; align-items: center; }
    .stat-icon { grid-row: span 2; width: 32px; height: 32px; margin: 0; border-radius: 9px; }
    .stat-icon .icon { width: 16px; height: 16px; }
    .stat-label { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .stat-value, .stat-value-sm { font-size: 15px; padding: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

    .table-cards thead { display: none; }
    .table-cards, .table-cards tbody { display: block; }
    .table-cards tr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; column-gap: 10px; row-gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--border); }
    .table-cards tr:last-child { border-bottom: 0; }
    .table-cards tbody tr:hover { background: none; }
    .table-cards td { padding: 0; border: 0; text-align: left; }
    .table-cards td:nth-child(1) { grid-column: 1 / 3; }
    .table-cards td:nth-child(2) { grid-column: 1; grid-row: 2; }
    .table-cards td:nth-child(3) { grid-column: 2; grid-row: 2; color: var(--text-3); }
    .table-cards td:last-child { grid-column: 3; grid-row: 1 / 3; }
    .table-wrap:has(.table-cards) { overflow: visible; }
}

@supports (-webkit-touch-callout: none) {
    @media (max-width: 768px) {
        .input, .popover-search { font-size: 16px; }
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
.nowrap { white-space: nowrap; }
.settings-layout > *, .content > *, .card, .field { min-width: 0; }
.section-card.is-highlight { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); box-shadow: 0 0 0 3px var(--primary-ring); animation: rise .35s var(--ease); }
.inline-actions { display: flex; gap: 6px; margin-top: 12px; margin-left: -10px; }

/* Tooltips */
[data-tip]:not(.nav-item) { position: relative; }
[data-tip]:not(.nav-item):hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: 4px 9px; border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; box-shadow: var(--shadow-lg); pointer-events: none; z-index: 60; animation: fade .15s; }

/* Shared page bits */
.text-danger { color: var(--red) !important; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--text-2); margin-bottom: 8px; }
.back-link .icon { width: 14px; height: 14px; }
.back-link:hover { color: var(--primary); }
.page-sub .badge { height: 22px; font-size: 11.5px; vertical-align: middle; }
.head-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn-lg { border: 1px solid var(--border-strong); background: var(--surface); }
.icon-btn-lg:hover { color: var(--red); border-color: var(--red); background: var(--red-soft); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot-green { background: var(--green); }
.dot-amber { background: var(--amber); }
.row-title { display: block; font-weight: 600; color: var(--text); }
.row-title:hover { color: var(--primary); }
.row-sub { display: block; font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
tr[data-href] { cursor: pointer; }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.toolbar > .select-trigger { width: 160px; }
.toolbar-search { position: relative; flex: 1; min-width: 220px; max-width: 340px; }
.toolbar-search > .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.toolbar-search .input { padding-left: 34px; }
.toolbar-search .input::-webkit-search-cancel-button { -webkit-appearance: none; }
.segmented { display: inline-flex; margin-left: auto; padding: 3px; gap: 2px; height: var(--h); background: var(--surface-3); border-radius: var(--radius); }
.segmented a { display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; border-radius: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.segmented a .icon { width: 15px; height: 15px; }
.segmented a.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented a[data-tip]:hover::after { display: none; }

/* Progress */
.progress { display: block; height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.progress-bar { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 60%, var(--violet))); transition: width .9s var(--ease); }
.progress-bar.is-done { background: var(--green); }
.progress-inline { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.progress-inline .progress { flex: 1; }
.progress-inline small { width: 32px; font-size: 11.5px; color: var(--text-2); text-align: right; font-variant-numeric: tabular-nums; }
.progress-lg { height: 8px; }
.progress-block { margin-top: 20px; }
.progress-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.progress-label b { color: var(--text); }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 12.5px; }
.pager { display: flex; align-items: center; gap: 4px; }
.pager .icon-btn { width: 30px; height: 30px; }
.pager-num { min-width: 30px; height: 30px; padding: 0 6px; display: grid; place-items: center; border-radius: 7px; font-weight: 600; color: var(--text-2); }
.pager-num:hover { background: var(--surface-3); color: var(--text); }
.pager-num.is-active { background: var(--primary); color: #fff; }

/* Projects table */
.table-projects th:first-child, .table-projects td:first-child { padding-left: 20px; }
.table-projects thead th { padding-top: 14px; }
.table-projects td { padding-top: 11px; padding-bottom: 11px; }
.table-projects .cell-project { min-width: 190px; max-width: 230px; }
.table-projects .cell-project .row-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table-projects .cell-start { color: var(--text-2); }
.table-projects .cell-client { color: var(--text-2); }

/* Board */
.board { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 14px; align-items: start; overflow-x: auto; padding-bottom: 6px; }
.board-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 10px; min-height: 160px; transition: background .15s, border-color .15s; }
.board-col.is-over { background: var(--primary-soft); border-color: var(--primary); }
.board-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 10px; }
.board-count { min-width: 24px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--surface-3); color: var(--text-2); font-size: 11.5px; font-weight: 700; display: grid; place-items: center; }
.board-list { display: grid; gap: 8px; min-height: 60px; }
.board-card { display: grid; gap: 6px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-sm); color: var(--text); cursor: grab; transition: box-shadow .15s, transform .15s var(--ease), border-color .15s; }
.board-card:hover { color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.board-card.is-dragging { opacity: .45; }
.board-code { font-size: 11px; color: var(--text-3); }
.board-title { font-size: 13px; font-weight: 600; line-height: 1.35; }
.board-client { font-size: 12px; color: var(--text-2); margin-top: -3px; }
.board-meta { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; color: var(--text-2); }
.board-meta > span:first-child { display: inline-flex; align-items: center; gap: 4px; }
.board-meta .icon { width: 13px; height: 13px; }
.board-meta .badge { height: 20px; padding: 0 8px; font-size: 11px; }
.board-empty { display: none; padding: 18px 0; text-align: center; font-size: 12px; color: var(--text-3); }
.board-list:not(:has(.board-card)) .board-empty { display: block; }

/* Detail page */
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.detail-side { position: sticky; top: calc(var(--topbar) + 20px); }
.kv-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 0; }
.kv-grid dt { font-size: 11.5px; font-weight: 500; color: var(--text-3); margin-bottom: 3px; }
.kv-grid dd { margin: 0; font-weight: 600; }
.kv-grid dd small { display: block; font-size: 12px; font-weight: 400; color: var(--text-2); }
.link-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.link-chip { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); font-size: 12.5px; font-weight: 600; color: var(--text); }
.link-chip .icon { width: 15px; height: 15px; color: var(--primary); }
.link-chip:hover { border-color: var(--primary); color: var(--primary); }
.prose { color: var(--text-2); line-height: 1.65; overflow-wrap: anywhere; }
.section-head-gap { margin-top: 22px; }
.payment-form { display: grid; grid-template-columns: 150px 170px minmax(0, 1fr) auto; gap: 10px; align-items: end; margin-bottom: 6px; }
.table-ledger { margin-top: 14px; }
.ledger-empty { margin-top: 14px; padding: 14px; border: 1px dashed var(--border-strong); border-radius: var(--radius); text-align: center; color: var(--text-3); font-size: 12.5px; }
.meta-note { margin-top: 12px; font-size: 11.5px; color: var(--text-3); }

.money-card { display: grid; }
.money-label { font-size: 12px; color: var(--text-2); }
.money-value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.money-sub { font-size: 12px; color: var(--text-3); }
.ring-row { display: flex; align-items: center; gap: 18px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
@property --p { syntax: "<number>"; inherits: false; initial-value: 0; }
.ring { --p: 0; width: 82px; height: 82px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--green) calc(var(--p) * 1%), var(--amber-soft) 0); transition: --p 1s var(--ease); }
.ring span { width: 62px; height: 62px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.money-list { display: grid; gap: 8px; margin: 0; flex: 1; min-width: 0; }
.money-list > div { display: flex; justify-content: space-between; gap: 10px; }
.money-list dt { display: inline-flex; align-items: center; gap: 7px; color: var(--text-2); }
.money-list dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.money-list-split { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.money-list .is-total { padding: 9px 10px; margin: 2px -10px 0; border-radius: 8px; background: var(--green-soft); }
.money-list .is-total dt, .money-list .is-total dd { color: var(--green); font-weight: 700; }

/* Form page */
.form-page { max-width: none; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-footer { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 8px; padding: 14px 0; margin-top: -4px; background: linear-gradient(transparent, var(--bg) 30%); z-index: 5; }
.range-field { display: flex; align-items: center; gap: 12px; height: var(--h); }
.range-field output { width: 42px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.range-field input[type="range"] { --v: 0%; flex: 1; height: 6px; margin: 0; border-radius: 6px; appearance: none; -webkit-appearance: none; background: linear-gradient(var(--primary), var(--primary)) 0 / var(--v) 100% no-repeat, var(--surface-3); cursor: pointer; }
.range-field input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 2px solid var(--primary); box-shadow: var(--shadow); transition: transform .15s; }
.range-field input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 2px solid var(--primary); box-shadow: var(--shadow); }
.range-field input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.15); }
.range-field input[type="range"]:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-ring); }

@media (max-width: 1100px) {
    .detail-layout { grid-template-columns: 1fr; }
    .detail-side { position: static; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
    .detail-side .section-card { margin-bottom: 0; }
    .kv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .board { grid-template-columns: repeat(4, 260px); }
}

@media (max-width: 768px) {
    .toolbar-search { flex-basis: 100%; max-width: none; min-width: 0; }
    .toolbar > .select-trigger { width: auto; flex: 1 1 calc(50% - 4px); min-width: 0; }
    .toolbar > .btn-ghost { flex: 1 1 100%; justify-content: center; }
    .segmented { margin-left: 0; flex: 1 1 100%; }
    .segmented a { flex: 1; justify-content: center; }
    .page-head > .btn { width: 100%; }
    .head-actions { width: 100%; }
    .head-actions > .btn { flex: 1; }
    .detail-side { grid-template-columns: 1fr; }
    .form-grid-3 { grid-template-columns: 1fr; }
    .payment-form { grid-template-columns: 1fr 1fr; }
    .payment-form .field:nth-of-type(3) { grid-column: 1 / -1; }
    .payment-form .btn { grid-column: 1 / -1; }
    .form-footer .btn { flex: 1; }
    .board { grid-template-columns: repeat(4, 82vw); scroll-snap-type: x mandatory; margin: 0 -16px; padding: 0 16px 6px; }
    .board-col { scroll-snap-align: center; }

    .table-projects thead { display: none; }
    .table-projects, .table-projects tbody { display: block; }
    .table-projects tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
    .table-projects tr:last-child { border-bottom: 0; }
    .table-projects td, .table-projects td:first-child { padding: 0; border: 0; }
    .table-projects .cell-project { grid-column: 1; grid-row: 1; min-width: 0; }
    .table-projects .cell-status { grid-column: 2; grid-row: 1; justify-self: end; align-self: start; }
    .table-projects .cell-client { grid-column: 1; grid-row: 2; font-size: 12px; }
    .table-projects .cell-payment { grid-column: 2; grid-row: 2; justify-self: end; }
    .table-projects .cell-progress { grid-column: 1 / -1; grid-row: 3; }
    .table-projects .cell-deadline { grid-column: 1; grid-row: 4; font-size: 12px; color: var(--text-2); }
    .table-projects .cell-start { grid-column: 1; grid-row: 5; font-size: 12px; }
    .table-projects .cell-start::before { content: "Start: "; color: var(--text-3); }
    .table-projects .cell-deadline::before { content: "Deadline: "; color: var(--text-3); }
    .table-projects .cell-budget { grid-column: 2; grid-row: 4; font-weight: 600; }
    .table-projects .cell-budget .row-sub, .table-projects .cell-due { display: none; }
    .table-wrap:has(.table-projects) { overflow: visible; }
    .pagination { flex-direction: column; }
}
.table th.num { text-align: right; }
.board-more { display: flex; align-items: center; justify-content: center; gap: 4px; height: 32px; margin-top: 8px; border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.board-more:hover { background: var(--surface-3); color: var(--primary); }
.board-more .icon { width: 14px; height: 14px; }
@media (max-width: 1100px) { .detail-side { order: -1; } .detail-layout { display: flex; flex-direction: column; } .detail-layout > * { width: 100%; } }
@media (max-width: 768px) { .table-ledger td:nth-child(3) { color: var(--text); } }
[data-results] { transition: opacity .15s; }
[data-results].is-loading { opacity: .55; pointer-events: none; }
.form-page { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.form-col { display: grid; gap: 20px; min-width: 0; }
.form-col .section-card { margin-bottom: 0; }
.form-page .form-footer { grid-column: 1 / -1; }
@media (max-width: 1100px) { .form-page { grid-template-columns: 1fr; } }

/* Avatars */
.avatar { overflow: hidden; user-select: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-xs { width: 20px; height: 20px; font-size: 10px; }
.avatar-sm { width: 28px; height: 28px; font-size: 12px; }
.avatar-xl { width: 72px; height: 72px; font-size: 26px; }
.av-0 { background: #e0ecff; color: #1d4ed8; }
.av-1 { background: #dcf5ea; color: #047857; }
.av-2 { background: #fdf0d9; color: #b45309; }
.av-3 { background: #ece7fe; color: #6d28d9; }
.av-4 { background: #fde4ea; color: #be123c; }
.av-5 { background: #e2f3f8; color: #0e7490; }
[data-theme="dark"] .av-0 { background: rgba(108,158,234,.16); color: #9dbdf0; }
[data-theme="dark"] .av-1 { background: rgba(107,186,117,.15); color: #93cf9b; }
[data-theme="dark"] .av-2 { background: rgba(212,165,74,.15); color: #dcbc7c; }
[data-theme="dark"] .av-3 { background: rgba(169,147,220,.16); color: #bfaee6; }
[data-theme="dark"] .av-4 { background: rgba(229,114,108,.15); color: #eb9f9a; }
[data-theme="dark"] .av-5 { background: rgba(86,178,196,.15); color: #8ccad6; }
.avatar-editor { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; }
.avatar-editor .field-hint { flex-basis: 100%; margin-top: -2px; }
.person { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.person-text { display: grid; min-width: 0; }
.person-text b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-text small { font-size: 12px; color: var(--text-2); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-lg .section-sub { margin-top: 2px; }
.contractor-tag { display: inline-flex !important; align-items: center; gap: 4px; margin-top: 2px; color: var(--violet) !important; font-weight: 500 !important; }
.contractor-tag .icon { width: 12px; height: 12px; }
.board-client { display: flex; align-items: center; gap: 6px; }

/* Custom select with people */
.select-trigger.has-person { padding-left: 6px; }
.select-value { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.select-trigger.has-person .option-person small { display: none; }
.option-person { display: grid; min-width: 0; line-height: 1.3; text-align: left; }
.option-person b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.option-person small { font-size: 11.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; }
.popover-item:has(.option-person) { gap: 10px; justify-content: flex-start; min-height: 44px; }
.popover-item:has(.option-person) > .icon { margin-left: auto; }
.select-trigger.has-person .avatar-sm { width: 24px; height: 24px; font-size: 11px; }

/* Stat cards as filters */
.stat-grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
a.stat-card { color: var(--text); }
a.stat-card:hover { color: var(--text); }
.stat-card.is-current { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.tone-gray .stat-icon { background: var(--surface-3); color: var(--text-2); }
.tone-red .stat-icon { background: var(--red-soft); color: var(--red); }

/* Amounts */
.amount { display: block; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.amount-due { color: var(--amber); }
.pill { display: inline-block; margin-top: 3px; padding: 1px 8px; border-radius: 20px; background: var(--surface-3); color: var(--text-2); font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Buttons */
.icon-btn-danger:hover { background: var(--red-soft); color: var(--red); }
.btn-ghost-danger { color: var(--red); }
.btn-ghost-danger:hover { background: var(--red-soft); color: var(--red); }
.btn-danger-soft { background: var(--red-soft); color: var(--red); border: 1px solid transparent; }
.btn-danger-soft:hover { background: var(--red); color: #fff; }
.row-actions .btn-sm .icon { width: 14px; height: 14px; }

/* Bulk selection */
.cell-check { width: 44px; padding-right: 0 !important; }
.table-projects tbody tr.is-selected { background: var(--primary-soft); }
.bulk-bar { display: flex; align-items: center; gap: 10px; padding: 0 16px 0 20px; height: 0; overflow: hidden; background: var(--primary-soft); border-bottom: 1px solid transparent; border-radius: var(--radius-lg) var(--radius-lg) 0 0; font-size: 13px; transition: height .2s var(--ease); }
.bulk-bar.is-visible { height: 48px; border-bottom-color: var(--border); }
.bulk-bar .btn-danger { margin-left: auto; }
.cell-actions { width: 120px; }
.cell-actions .row-actions { justify-content: flex-end; }
.row-actions { display: flex; align-items: center; gap: 2px; }
.row-actions form { display: contents; }

/* Inputs */
.input-combo { display: flex; }
.input-combo > .select-trigger { width: 96px; flex-shrink: 0; border-radius: var(--radius) 0 0 var(--radius); border-right: 0; }
.input-combo > .input:last-child { border-radius: 0 var(--radius) var(--radius) 0; min-width: 0; }
.payment-form-client { grid-template-columns: 140px 210px 160px minmax(0, 1fr) auto; }
.modal-grid { margin: 16px 0 4px; }
.table-ledger .amount { display: inline; }
.table-ledger .pill { margin: 0 0 0 6px; }

@media (max-width: 1280px) {
    .stat-grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .payment-form-client { grid-template-columns: 1fr 1fr; }
    .payment-form-client .btn { grid-column: 1 / -1; }
}

@media (max-width: 768px) {
    .stat-grid-5 { grid-template-columns: 1fr 1fr; }
    .stat-grid-5 > :first-child { grid-column: 1 / -1; }
    .head-actions > .btn, .head-actions > form { flex: 1; }
    .head-actions > form .btn { width: 100%; }
    .table-projects tr { grid-template-columns: auto minmax(0, 1fr) auto; }
    .table-projects .cell-check { grid-column: 1; grid-row: 1; width: auto; }
    .table-projects .cell-project { grid-column: 2; }
    .table-projects .cell-status { grid-column: 3; }
    .table-projects .cell-client { grid-column: 1 / 3; }
    .table-projects .cell-payment { grid-column: 3; }
    .table-projects .cell-progress { grid-column: 1 / -1; }
    .table-projects .cell-deadline { grid-column: 1 / 3; }
    .table-projects .cell-budget { grid-column: 3; }
    .table-projects .cell-actions { grid-column: 1 / -1; grid-row: 6; width: auto; }
    .table-projects .cell-actions .row-actions { justify-content: flex-start; gap: 6px; }
    .table-projects .cell-budget .pill { display: inline-block; }
    .table-ledger td:last-child .row-actions { flex-direction: column; align-items: flex-end; }
    .payment-form-client .field:nth-of-type(n) { grid-column: auto; }
    .payment-form-client .field:nth-of-type(2), .payment-form-client .field:nth-of-type(4) { grid-column: 1 / -1; }
}
.amount-none { font-weight: 500; font-size: 12px; color: var(--text-3); }
.table-projects .cell-client { min-width: 170px; max-width: 220px; }
.table-projects .cell-project { min-width: 200px; }
.table-projects .cell-progress .progress-inline { min-width: 96px; }
.payment-form-client { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.payment-form-client .field:nth-of-type(4) { grid-column: span 2; }
.range-field input[type="range"] { min-width: 0; }
.range-field { min-width: 0; }
.range-field output { flex-shrink: 0; }
@media (max-width: 768px) {
    .payment-form-client { grid-template-columns: 1fr 1fr; }
    .payment-form-client .field:nth-of-type(2), .payment-form-client .field:nth-of-type(4) { grid-column: 1 / -1; }
    .payment-form-client .btn { grid-column: 1 / -1; }
}
.cell-payment .amount-due { font-size: 12px; margin-top: 3px; white-space: nowrap; }
.table-projects .cell-progress .progress-inline { min-width: 80px; }
.table-projects .cell-client { min-width: 150px; max-width: 190px; }
.table-projects th, .table-projects td { padding-left: 10px; padding-right: 10px; }
.table-projects .cell-actions { width: 110px; padding-right: 14px; }
.form-subhead { display: flex; flex-direction: column; gap: 2px; margin: 22px 0 14px; padding-top: 18px; border-top: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--text); }
.form-subhead span { font-weight: 400; color: var(--text-3); }

.editor { border: 1px solid var(--border-strong, var(--border)); border-radius: var(--radius); background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.editor:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.editor-bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px; border-bottom: 1px solid var(--border); background: var(--surface-2, var(--surface)); border-radius: var(--radius) var(--radius) 0 0; }
.editor-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; min-width: 0; }
.editor-tools.is-disabled { opacity: .4; pointer-events: none; }
.editor-tools > .select-trigger { width: 132px; height: 30px; font-size: 13px; }
.editor-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 7px; background: none; color: var(--text-2); cursor: pointer; transition: background .15s, color .15s; }
.editor-btn .icon { width: 16px; height: 16px; }
.editor-btn:hover { background: var(--surface-3); color: var(--text); }
.editor-btn.is-on { background: var(--primary-soft, var(--primary-ring)); color: var(--primary); }
.editor-sep { width: 1px; height: 18px; margin: 0 4px; background: var(--border); }
.editor-tabs { display: flex; flex-shrink: 0; padding: 2px; border-radius: 8px; background: var(--surface-3); }
.editor-tab { height: 26px; padding: 0 12px; border: 0; border-radius: 6px; background: none; color: var(--text-2); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.editor-tab.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,.08)); }
.editor-view { position: relative; min-height: 220px; max-height: 520px; overflow-y: auto; padding: 14px 16px; color: var(--text); outline: none; }
.editor-view.is-empty::before { content: attr(data-placeholder); position: absolute; color: var(--text-3); pointer-events: none; }
.editor-code.input { display: block; width: 100%; min-height: 220px; border: 0; border-radius: 0 0 var(--radius) var(--radius); box-shadow: none; font-size: 13px; line-height: 1.6; resize: vertical; }
.editor-code.input:focus { box-shadow: none; }
.editor-view.is-hidden, .editor-code.is-hidden { display: none; }
.editor-link { display: flex; gap: 8px; padding: 8px; border-bottom: 1px solid var(--border); }
.editor-link .input { flex: 1; height: 32px; }
.editor.is-full { position: fixed; inset: 16px; z-index: 400; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.editor.is-full .editor-view, .editor.is-full .editor-code { flex: 1; max-height: none; }

.rich h2 { margin: 18px 0 8px; font-size: 20px; color: var(--text); }
.rich h3 { margin: 16px 0 6px; font-size: 17px; color: var(--text); }
.rich h4 { margin: 14px 0 6px; font-size: 15px; color: var(--text); }
.rich p { margin: 0 0 10px; }
.rich ul, .rich ol { margin: 0 0 10px; padding-left: 22px; }
.rich li { margin: 2px 0; }
.rich blockquote { margin: 0 0 10px; padding: 6px 14px; border-left: 3px solid var(--primary); background: var(--surface-3); border-radius: 0 6px 6px 0; }
.rich pre { margin: 0 0 10px; padding: 10px 12px; border-radius: 8px; background: var(--surface-3); overflow-x: auto; font-size: 13px; white-space: pre-wrap; }
.rich hr { margin: 14px 0; border: 0; border-top: 1px solid var(--border); }
.rich a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
.rich > :first-child { margin-top: 0; }
.rich > :last-child { margin-bottom: 0; }
@media (max-width: 768px) {
    .editor-bar { flex-direction: column-reverse; align-items: stretch; }
    .editor-tabs { align-self: flex-end; }
    .editor.is-full { inset: 0; border-radius: 0; }
}

/* Clients & contractors */
.stat-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.text-link { color: var(--primary); }
.text-link:hover { text-decoration: underline; text-underline-offset: 2px; }
.avatar-lg { width: 48px; height: 48px; font-size: 18px; }
.person-head { display: flex; align-items: center; gap: 14px; margin-top: 6px; min-width: 0; }
.person-head .page-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kv-grid .span-all { grid-column: 1 / -1; }
.kv-grid dd a { word-break: break-word; }
.section-flush { padding-left: 0; padding-right: 0; padding-bottom: 8px; }
.section-flush > .section-head { padding: 0 24px; }
.section-flush .pagination { padding: 12px 24px 4px; }
.empty-state-sm { padding: 20px 24px 28px; }
.empty-state-sm p { color: var(--text-2); }
.icon-btn.is-disabled, .btn.is-disabled { opacity: .4; cursor: not-allowed; }
.icon-btn.is-disabled:hover { background: none; color: inherit; }
.btn-danger-soft.is-disabled:hover { background: var(--red-soft); color: var(--red); }
.cell-label { display: none; }
.contact-line { display: block; max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.table-people th:first-child, .table-people td:first-child { padding-left: 20px; }
.table-people thead th { padding-top: 14px; }
.table-people td { padding-top: 11px; padding-bottom: 11px; }
.table-people tbody tr.is-selected { background: var(--primary-soft); }
.table-people .cell-person { min-width: 230px; max-width: 280px; }
.table-people .person-text .row-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-people .cell-count { white-space: nowrap; }
.table-people .cell-count .badge { margin-left: 6px; }
.table-people .cell-actions { width: 120px; padding-right: 16px; }
.table-contractors .cell-actions { width: 90px; }
.table-client-projects th:first-child, .table-client-projects td:first-child { padding-left: 24px; }
.table-client-projects th:last-child, .table-client-projects td:last-child { padding-right: 24px; }
.table-client-projects .row-title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.table-client-projects tbody tr:last-child td { border-bottom: 0; }
.table-client-projects .cell-payment .amount-due { display: block; }

@media (max-width: 1280px) {
    .stat-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
    .stat-grid-4 { grid-template-columns: 1fr 1fr; }
    .kv-grid-3 { grid-template-columns: 1fr 1fr; }
    .person-head .avatar-lg { width: 40px; height: 40px; font-size: 16px; }
    .section-flush > .section-head { padding: 0 18px; }
    .cell-label { display: block; font-size: 11px; color: var(--text-3); font-weight: 500; }

    .table-people thead { display: none; }
    .table-people, .table-people tbody { display: block; }
    .table-people tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
    .table-people tr:last-child { border-bottom: 0; }
    .table-people td, .table-people td:first-child { padding: 0; border: 0; text-align: left; }
    .table-people .cell-check { grid-column: 1 / -1; grid-row: 1; display: none; }
    .table-people .cell-person { grid-column: 1 / 3; grid-row: 1; min-width: 0; max-width: none; }
    .table-people .cell-count { grid-column: 3; grid-row: 1; justify-self: end; text-align: right; white-space: normal; }
    .table-people .cell-count .badge { display: table; margin: 3px 0 0 auto; }
    .table-people .cell-contact { grid-column: 1 / -1; grid-row: 2; }
    .table-people .cell-billed { grid-column: 1; grid-row: 3; }
    .table-people .cell-received { grid-column: 2; grid-row: 3; }
    .table-people .cell-due { grid-column: 3; grid-row: 3; }
    .table-people .cell-actions { grid-column: 1 / -1; grid-row: 4; width: auto; padding: 0; }
    .table-people .cell-actions .row-actions { justify-content: flex-start; gap: 6px; }
    .table-wrap:has(.table-people) { overflow: visible; }

    .table-client-projects thead { display: none; }
    .table-client-projects, .table-client-projects tbody { display: block; }
    .table-client-projects tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
    .table-client-projects tr:last-child { border-bottom: 0; }
    .table-client-projects td, .table-client-projects td:first-child, .table-client-projects td:last-child { padding: 0; border: 0; text-align: left; }
    .table-client-projects .cell-project { grid-column: 1 / 3; min-width: 0; }
    .table-client-projects .row-title { max-width: none; }
    .table-client-projects .cell-status { grid-column: 3; justify-self: end; }
    .table-client-projects .cell-deadline { grid-column: 1; font-size: 12px; color: var(--text-2); }
    .table-client-projects .cell-deadline::before { content: "Deadline"; display: block; font-size: 11px; color: var(--text-3); }
    .table-wrap:has(.table-client-projects) { overflow: visible; }
}
@media (max-width: 1100px) {
    .detail-side.has-photo { display: contents; }
    .detail-side.has-photo > .money-card { order: -1; }
    .detail-side.has-photo > .photo-card { order: 9; }
}
.row-actions > :last-child[data-tip]::after, .row-actions > form:last-child [data-tip]::after { left: auto; right: 0; transform: none; }
@media (min-width: 769px) {
    .table-people th, .table-people td { padding-left: 12px; padding-right: 12px; }
    .table-people .cell-person { min-width: 200px; max-width: 250px; }
    .table-people .contact-line { max-width: 210px; }
    .table-people .cell-count .badge { display: table; margin: 4px 0 0; }
    .table-people .cell-actions { width: 112px; }
}
@media (min-width: 769px) and (max-width: 1440px) {
    .table-people .cell-billed { display: none; }
}
@media (min-width: 769px) and (max-width: 1100px) {
    .table-people .cell-contact { display: none; }
}

/* Dashboard */
.finance-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.finance-card { display: grid; align-content: start; gap: 2px; padding: 18px 20px; }
.finance-card.is-primary { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.finance-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.finance-label { font-size: 13px; font-weight: 600; color: var(--text); }
.finance-sub { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.finance-net { font-size: 24px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; color: var(--text); }
.finance-caption { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); }
.trend { padding: 1px 7px; border-radius: 20px; font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.trend.is-up { background: var(--green-soft); color: var(--green); }
.trend.is-down { background: var(--red-soft); color: var(--red); }
.finance-split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--border); }
.finance-split dt { font-size: 11.5px; color: var(--text-3); }
.finance-split dd { margin: 2px 0 0; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

.dash-row { display: grid; gap: 20px; margin-bottom: 20px; }
.dash-row > .section-card { margin-bottom: 0; min-width: 0; }
.dash-row-chart { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.dash-row-lists { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.section-link { display: inline-flex; align-items: center; gap: 2px; font-size: 12.5px; font-weight: 600; color: var(--primary); }
.section-link .icon { width: 14px; height: 14px; }

.chart-legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.chart-legend span, .chart-tip span { display: inline-flex; align-items: center; gap: 6px; }
.legend-bar { width: 10px; height: 10px; border-radius: 3px; background: var(--primary); }
.legend-line { width: 14px; height: 3px; border-radius: 2px; background: var(--green); }
.bar-chart { position: relative; min-height: 220px; }
.chart-svg { display: block; overflow: visible; }
.chart-grid { stroke: var(--border); stroke-dasharray: 3 4; }
.chart-axis { stroke: var(--border-strong, var(--border)); }
.chart-label { fill: var(--text-3); font-size: 11px; font-family: inherit; }
.chart-bar { fill: var(--primary); opacity: .85; transform-box: fill-box; transform-origin: bottom; transition: transform .7s var(--ease), opacity .15s; }
.chart-line { fill: none; stroke: var(--green); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart-line.is-drawing { transition: stroke-dashoffset 1.2s var(--ease) .3s; }
.chart-dot { fill: var(--green); stroke: var(--surface); stroke-width: 1.5; transition: r .15s; }
.chart-area { pointer-events: none; animation: chart-area-in .9s var(--ease) .4s both; }
.chart-area-top { stop-color: var(--green); stop-opacity: .22; }
.chart-area-bottom { stop-color: var(--green); stop-opacity: 0; }
@keyframes chart-area-in { from { opacity: 0; } }
.chart-dot.is-on { r: 5; }
.chart-hover { fill: var(--surface-3); opacity: 0; transition: opacity .15s, x .15s; }
.chart-hover.is-on { opacity: 1; }
.chart-hit { fill: transparent; cursor: pointer; }
.chart-tip { position: absolute; left: 0; top: 0; display: grid; gap: 4px; min-width: 190px; padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 12px; color: var(--text-2); opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s var(--ease); z-index: 5; }
.chart-tip.is-visible { opacity: 1; }
.chart-tip b { color: var(--text); font-size: 12.5px; margin-bottom: 2px; }
.chart-tip em { margin-left: auto; padding-left: 14px; font-style: normal; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

.donut-wrap { display: grid; justify-items: center; gap: 18px; }
.donut { position: relative; width: 190px; height: 190px; }
.donut-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut-track { fill: none; stroke: var(--surface-3); stroke-width: 11; }
.donut-seg { fill: none; stroke-width: 11; cursor: pointer; transition: stroke-dasharray 1s var(--ease), opacity .15s, stroke-width .15s; }
.donut-seg:hover { stroke-width: 13; }
.donut-seg.is-dim { opacity: .25; }
.status-pending { stroke: #94a3b8; background: #94a3b8; }
.status-running { stroke: var(--primary); background: var(--primary); }
.status-completed { stroke: var(--green); background: var(--green); }
.status-cancelled { stroke: var(--red); background: var(--red); }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut-center b { font-size: 30px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.donut-center small { font-size: 12px; color: var(--text-2); }
.donut-legend { list-style: none; margin: 0; padding: 0; width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.donut-legend a { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; font-size: 13px; color: var(--text-2); transition: background .15s; }
.donut-legend a:hover, .donut-legend a.is-on { background: var(--surface-3); color: var(--text); }
.donut-legend b { margin-left: auto; color: var(--text); font-variant-numeric: tabular-nums; }
.donut-legend .dot { width: 9px; height: 9px; border-radius: 50%; }

.list-link { margin: 0 -10px; padding: 10px; border-radius: 10px; color: var(--text); transition: background .15s; }
.list-link:hover { background: var(--surface-2); color: var(--text); }
.list-link .list-main { min-width: 0; flex: 1; }
.list-link .list-main b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.when { display: grid; justify-items: end; flex-shrink: 0; font-size: 12px; color: var(--text-2); }
.when b { font-size: 12.5px; color: var(--text); }
.when.is-soon b { color: var(--amber); }
.when.is-late b { color: var(--red); }
.when small { color: var(--text-3); }
.list-link .amount { display: inline; flex-shrink: 0; font-size: 13px; }
.amount-in { color: var(--green); }
.amount-out { color: var(--text-2); }

@media (max-width: 1280px) {
    .finance-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dash-row-chart { grid-template-columns: 1fr; }
    .dash-row-lists { grid-template-columns: 1fr 1fr; }
    .dash-row-lists > :last-child { grid-column: 1 / -1; }
    .donut-wrap { grid-template-columns: 190px minmax(0, 1fr); align-items: center; }
}
@media (max-width: 768px) {
    .finance-grid { grid-template-columns: 1fr; gap: 12px; }
    .finance-card { padding: 16px; }
    .finance-net { font-size: 22px; }
    .dash-row { gap: 16px; margin-bottom: 16px; }
    .dash-row-lists { grid-template-columns: 1fr; }
    .donut-wrap { grid-template-columns: 1fr; }
    .donut { width: 170px; height: 170px; }
    .dash-row-chart .section-head { flex-direction: column; gap: 8px; }
}
.table-people .cell-count .count-line { display: block; }
.active-pill { display: inline-flex; align-items: center; gap: 6px; margin-top: 5px; padding: 2px 9px 2px 7px; border-radius: 20px; background: var(--primary-soft); color: var(--primary); font-size: 11.5px; font-weight: 600; line-height: 18px; white-space: nowrap; }
.pulse-dot { position: relative; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }
.pulse-dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--primary); animation: pulse-ring 1.8s ease-out infinite; }
@keyframes pulse-ring { 0% { transform: scale(1); opacity: .5; } 100% { transform: scale(2.6); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pulse-dot::after { animation: none; } }
@media (max-width: 768px) { .table-people .cell-count .active-pill { margin-left: auto; } .table-people .cell-count { display: grid; justify-items: end; } }

/* Settings */
.field-gap { margin-top: 18px; }
.check-row { display: flex; flex-wrap: wrap; gap: 10px; }
.check-card { padding: 0 14px; height: var(--h); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); transition: border-color .15s, background .15s; }
.check-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.field-hint-check { margin-top: 8px; font-size: 12.5px; color: var(--text-2); }
.choice-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice-card { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s; }
.choice-card:hover { border-color: var(--border-strong); }
.choice-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px var(--primary-ring); }
.choice-card input { appearance: none; width: 18px; height: 18px; margin: 2px 0 0; flex-shrink: 0; border: 1.5px solid var(--border-strong); border-radius: 50%; background: var(--surface); display: grid; place-items: center; cursor: pointer; }
.choice-card input:checked { border-color: var(--primary); background: var(--primary); }
.choice-card input:checked::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #fff; }
.choice-card span { display: grid; gap: 3px; }
.choice-card b { font-size: 13.5px; }
.choice-card small { font-size: 12.5px; color: var(--text-2); line-height: 1.45; }
.mail-error { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 20px; }
.mail-error .icon { flex-shrink: 0; margin-top: 1px; }
.mail-error div { display: grid; gap: 2px; }
.mail-error span { font-weight: 400; word-break: break-word; }
.section-card.is-hidden { display: none; }
.settings-layout form > .form-actions { display: flex; justify-content: flex-end; }
@media (max-width: 768px) {
    .choice-cards { grid-template-columns: 1fr; }
    .settings-layout form > .form-actions .btn { width: 100%; }
    .settings-layout .input-row { flex-wrap: wrap; }
    .settings-layout .input-row .btn { width: 100%; }
}

/* Portal login */
.form-wide { grid-column: 1 / -1; }
.form-wide .section-card { margin-bottom: 0; }
.portal-card .section-head { align-items: center; }
.portal-card .section-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.switch-label { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; }
.label-note { font-weight: 400; color: var(--text-3); font-size: 12px; }
.password-tools { display: flex; gap: 8px; max-width: 640px; }
.password-tools .input-group { flex: 1; min-width: 0; }
.portal-fields.is-hidden { display: none; }
.field-hint .icon { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; color: var(--green); }
.form-grid > .field-hint.span-2 { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.form-grid > .field-hint.span-2 .icon { color: var(--primary); }
@media (max-width: 768px) {
    .portal-card .section-head { align-items: flex-start; }
    .password-tools { flex-wrap: wrap; }
    .password-tools .input-group { flex-basis: 100%; }
    .password-tools .btn { flex: 1; }
}

/* Team & Access */
.badge-violet { background: var(--violet-soft); color: var(--violet); }
.you-tag { display: inline-block; margin-left: 6px; padding: 0 7px; border-radius: 20px; background: var(--surface-3); color: var(--text-2); font-size: 11px; font-weight: 600; vertical-align: 1px; }
.tfa { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-3); }
.tfa .icon { width: 14px; height: 14px; }
.tfa.is-on { color: var(--green); font-weight: 600; }
.table-users th:first-child, .table-users td:first-child { padding-left: 20px; }
.table-users thead th { padding-top: 14px; }
.table-users td { padding-top: 11px; padding-bottom: 11px; }
.table-users .cell-person { min-width: 240px; }
.table-users .cell-login small { display: block; font-size: 11.5px; color: var(--text-3); }
.table-users .cell-actions { width: 150px; padding-right: 16px; }
.toolbar .segmented + .toolbar-search { flex: 1; max-width: 360px; margin-left: auto; }
.role-guide { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.role-guide > div { padding: 14px 16px; border: 1px dashed var(--border-strong, var(--border)); border-radius: var(--radius-lg); }
.role-guide p { margin: 8px 0 0; font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
.choice-cards-stack { grid-template-columns: 1fr; }
.choice-card:has(input:disabled) { opacity: .7; cursor: not-allowed; }
.security-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 13px; }
.security-row > span:first-child { display: inline-flex; align-items: center; gap: 6px; }
.security-row .icon { width: 15px; height: 15px; color: var(--primary); }
.switch input:disabled { opacity: .6; cursor: not-allowed; }
@media (max-width: 1100px) {
    .table-users .cell-tfa, .table-users th:nth-child(4) { display: none; }
}
@media (max-width: 768px) {
    .role-guide { grid-template-columns: 1fr; }
    .toolbar .segmented + .toolbar-search { max-width: none; flex-basis: 100%; }
    .table-users thead { display: none; }
    .table-users, .table-users tbody { display: block; }
    .table-users tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
    .table-users tr:last-child { border-bottom: 0; }
    .table-users td, .table-users td:first-child { padding: 0; border: 0; }
    .table-users .cell-person { grid-column: 1 / -1; min-width: 0; }
    .table-users .cell-role { grid-column: 1; }
    .table-users .cell-state { grid-column: 2; justify-self: end; }
    .table-users .cell-tfa { display: block; grid-column: 1; }
    .table-users .cell-tfa::before { content: "Two-step: "; font-size: 12px; color: var(--text-3); }
    .table-users .cell-login { grid-column: 2; justify-self: end; text-align: right; font-size: 12px; }
    .table-users .cell-actions { grid-column: 1 / -1; width: auto; padding: 0; }
    .table-users .cell-actions .row-actions { justify-content: flex-start; gap: 6px; }
    .table-wrap:has(.table-users) { overflow: visible; }
}
.dash-row.is-contents { display: contents; }
.dash-row-half { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
@media (max-width: 1100px) { .dash-row-half { grid-template-columns: 1fr; } }

/* Activity log */
.toolbar .input-date { width: 150px; flex: 0 0 auto; }
.toolbar .input-date + .select-trigger, .toolbar .date-trigger { width: 150px; }
.timeline { padding: 6px 20px 8px; }
.timeline-day { position: sticky; top: var(--topbar); z-index: 2; margin: 0 -20px; padding: 12px 20px 8px; background: var(--surface); font-size: 12px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--text-3); }
.timeline-day:first-child { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.timeline-item { position: relative; display: flex; gap: 14px; padding: 10px 0 14px; }
.timeline-item::before { content: ""; position: absolute; left: 15px; top: 42px; bottom: -4px; width: 2px; background: var(--border); }
.timeline-item:has(+ .timeline-day)::before, .timeline-item:last-child::before { display: none; }
.timeline-item.has-check::before { left: 47px; }
.timeline-check { align-self: flex-start; margin-top: 7px; }
.timeline-item.is-selected .timeline-body { opacity: .7; }
.timeline-selectall { display: flex; align-items: center; gap: 10px; padding: 14px 20px 0; font-size: 13px; font-weight: 500; color: var(--text-2); cursor: pointer; }
.timeline-icon { position: relative; z-index: 1; width: 32px; height: 32px; flex-shrink: 0; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.timeline-icon .icon { width: 16px; height: 16px; }
.timeline-icon.tone-blue { background: var(--primary-soft); color: var(--primary); }
.timeline-icon.tone-green { background: var(--green-soft); color: var(--green); }
.timeline-icon.tone-violet { background: var(--violet-soft); color: var(--violet); }
.timeline-icon.tone-amber { background: var(--amber-soft); color: var(--amber); }
.timeline-icon.tone-red, .timeline-item.is-warning .timeline-icon { background: var(--red-soft); color: var(--red); }
.timeline-body { flex: 1; min-width: 0; padding-top: 5px; }
.timeline-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 13.5px; line-height: 1.45; }
.timeline-actor { display: inline-flex; align-items: center; gap: 6px; }
.timeline-actor b { font-weight: 600; }
.timeline-text { color: var(--text-2); min-width: 0; word-break: break-word; }
.timeline-text a { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong, var(--border)); text-underline-offset: 3px; }
.timeline-text a:hover { color: var(--primary); text-decoration-color: currentColor; }
.timeline-item.is-warning .timeline-text { color: var(--red); }
.timeline-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: 3px; font-size: 12px; color: var(--text-3); }
.timeline-toggle { display: inline-flex; align-items: center; gap: 3px; padding: 0; border: 0; background: none; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; }
.timeline-toggle .icon { width: 14px; height: 14px; transition: transform .25s var(--ease); }
.is-open .timeline-toggle .icon { transform: rotate(180deg); }
.timeline-changes { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .3s var(--ease); }
.timeline-changes > div { overflow: hidden; }
.is-open .timeline-changes { grid-template-rows: 1fr; }
.changes-box { display: grid; gap: 6px; margin-top: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2, var(--surface-3)); font-size: 12.5px; }
.change-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.change-row .icon { width: 13px; height: 13px; color: var(--text-3); }
.change-key { min-width: 110px; font-weight: 600; color: var(--text-2); }
.change-from { color: var(--text-3); text-decoration: line-through; word-break: break-word; }
.change-to { color: var(--text); word-break: break-word; }
.timeline + .pagination { border-top: 1px solid var(--border); }
@media (max-width: 768px) {
    .timeline { padding: 4px 16px 6px; }
    .timeline-day { margin: 0 -16px; padding: 12px 16px 8px; }
    .toolbar .input-date, .toolbar .date-trigger { width: calc(50% - 5px); }
    .change-key { min-width: 0; flex-basis: 100%; }
}
/* Command palette */
.command { align-items: start; padding-top: min(14vh, 120px); }
.command-box { position: relative; width: 100%; max-width: 620px; display: flex; flex-direction: column; max-height: min(560px, 76vh); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .2s var(--ease); }
.command.is-closing .command-box, .command.is-closing .modal-backdrop { opacity: 0; transition: opacity .16s; }
.command-head { display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 56px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.command-head > .icon { width: 18px; height: 18px; color: var(--text-3); flex-shrink: 0; }
.command-box.is-loading .command-head > .icon { animation: pulse-icon .8s ease-in-out infinite alternate; }
@keyframes pulse-icon { to { opacity: .35; } }
.command-input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; color: var(--text); font: inherit; font-size: 15px; }
.command-input::-webkit-search-cancel-button { display: none; }
.command-head kbd, .command-foot kbd { padding: 1px 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; background: var(--surface-2, var(--surface-3)); color: var(--text-2); font: 600 11px/1.5 inherit; cursor: pointer; }
.command-list { flex: 1; overflow-y: auto; padding: 6px 8px 8px; overscroll-behavior: contain; }
.command-group { padding: 10px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.command-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 10px; color: var(--text); scroll-margin: 8px; }
.command-item:hover { color: var(--text); }
.command-item.is-active { background: var(--primary-soft); }
.command-item > .icon { width: 15px; height: 15px; margin-left: auto; color: var(--text-3); opacity: 0; flex-shrink: 0; }
.command-item.is-active > .icon { opacity: 1; color: var(--primary); }
.command-icon { width: 30px; height: 30px; flex-shrink: 0; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.command-icon .icon { width: 15px; height: 15px; }
.command-item.is-active .command-icon { background: var(--surface); color: var(--primary); }
.command-avatar { display: grid; place-items: center; width: 30px; flex-shrink: 0; }
.command-text { display: grid; min-width: 0; }
.command-text b { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.command-text small { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.command-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-left: auto; }
.command-dot + .icon { margin-left: 4px; }
.command-empty { display: grid; gap: 4px; justify-items: center; padding: 36px 16px; text-align: center; color: var(--text-2); font-size: 13px; }
.command-empty b { color: var(--text); }
.command-foot { display: flex; gap: 16px; padding: 9px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); flex-shrink: 0; }
.command-foot span { display: inline-flex; align-items: center; gap: 4px; }
@media (max-width: 768px) {
    .command { padding: 10px; align-items: start; }
    .command-box { max-height: calc(100dvh - 20px); border-radius: 14px; }
    .command-input { font-size: 16px; }
    .command-foot { display: none; }
}
/* ===== Round 2 ===== */
.icon.is-flipped { transform: rotate(180deg); }
.badge .icon { width: 12px; height: 12px; margin-right: 3px; vertical-align: -2px; }

/* Team & Access list card with tabs */
.list-card { overflow: hidden; }
.list-card-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 0 16px 0 8px; border-bottom: 1px solid var(--border); }
.tabs { display: flex; gap: 4px; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 50px; padding: 0 14px; color: var(--text-2); font-weight: 600; font-size: 13px; }
.tab .icon { width: 16px; height: 16px; }
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--primary); }
.tab.is-active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--primary); }
.tab-count { min-width: 22px; padding: 1px 7px; border-radius: 20px; background: var(--surface-3); color: var(--text-2); font-size: 11.5px; text-align: center; }
.tab.is-active .tab-count { background: var(--primary-soft); color: var(--primary); }
.list-card-search { width: 320px; margin: 8px 0; }
.list-card .table-wrap { border-radius: 0; }
.role-guide { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Manager permissions */
.role-fixed { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.perm-panel { margin-top: 18px; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.perm-panel.is-hidden { display: none; }
.perm-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-weight: 700; font-size: 13px; }
.perm-tools { display: flex; gap: 4px; }
.perm-group-title { padding: 12px 14px 4px; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.perm-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 9px 14px; cursor: pointer; transition: background .15s; }
.perm-row:hover { background: var(--surface-2); }
.perm-row > span:first-child { display: grid; gap: 1px; min-width: 0; }
.perm-row b { font-size: 13px; font-weight: 600; }
.perm-row small { font-size: 12px; color: var(--text-2); }
.perm-group + .perm-group { border-top: 1px solid var(--border); }

/* Settings lists */
.list-rows { display: grid; gap: 8px; }
.list-edit-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) 84px 108px; align-items: center; gap: 10px; animation: rise .2s var(--ease); }
.list-edit-row.is-leaving { opacity: 0; transform: translateX(8px); transition: opacity .16s, transform .16s; }
.currency-row, .currency-head { grid-template-columns: 28px 100px 80px minmax(0, 1fr) 110px 112px; }
.currency-head { display: grid; gap: 10px; padding: 0 0 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }
[data-list-editor] { container-type: inline-size; }
@container (max-width: 400px) {
    .list-edit-row:not(.currency-row) { grid-template-columns: 28px minmax(0, 1fr) 108px; }
    .list-edit-row:not(.currency-row) .row-usage { display: none; }
}
.currency-row .row-tools .badge { margin-right: 4px; }
@container (max-width: 640px) {
    .currency-head { display: none; }
    .currency-row { grid-template-columns: 90px 64px minmax(0, 1fr); row-gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; }
    .currency-row .row-order { display: none; }
    .currency-row .row-usage { display: block; grid-column: 1 / 3; }
    .currency-row .row-tools { grid-column: 3; }
}
.row-order { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: var(--surface-3); color: var(--text-2); font-size: 12px; font-weight: 700; }
.row-usage { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.row-tools { display: flex; align-items: center; justify-content: flex-end; gap: 2px; }
.input-code { text-transform: uppercase; font-weight: 600; letter-spacing: .04em; }
.list-edit-row.is-fixed .input { background: var(--surface-2); color: var(--text-2); }
.lists-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.lists-grid > .section-card { margin-bottom: 0; }
.settings-layout form > .section-card { margin-bottom: 20px; }

/* Client billing by currency */
.table-currency th:first-child, .table-currency td:first-child { padding-left: 24px; }
.table-currency th:last-child, .table-currency td:last-child { padding-right: 24px; }
.table-currency .cell-cur { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; }
.table-currency .cell-cur small { flex-basis: 100%; padding-left: 42px; font-size: 11.5px; color: var(--text-3); }
.cur-chip { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.table-currency tr.is-total td { background: var(--surface-2); }
.table-currency tr.is-total .cur-chip { background: var(--green-soft); color: var(--green); }
.table-currency .cell-paid .progress-inline { min-width: 120px; }
.table-currency .amount-in { color: var(--green); font-weight: 600; }
.table-currency .amount-due { color: var(--amber); }
.table-note { padding: 10px 24px 6px; font-size: 12px; color: var(--text-3); }

/* Dashboard income card */
.income-head { align-items: center; flex-wrap: wrap; }
.range-form { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.range-form > .select-trigger { width: 170px; }
.range-custom { display: inline-flex; align-items: center; gap: 6px; }
.range-custom.is-hidden { display: none; }
.range-custom .date-trigger { width: 150px; }
.range-dash { color: var(--text-3); }
.range-totals { display: grid; grid-template-columns: 1.3fr 1fr 1fr auto; align-items: stretch; gap: 12px; margin-bottom: 18px; }
.range-total { display: grid; align-content: start; gap: 2px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-2); }
.range-total > span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.range-total b { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.range-total small { font-size: 11.5px; color: var(--text-3); }
.range-total.is-net { background: linear-gradient(135deg, var(--green-soft), var(--surface)); border-color: color-mix(in srgb, var(--green) 35%, var(--border)); }
.range-total.is-net > span { color: var(--green); font-weight: 700; }
.range-total.is-net b { font-size: 24px; color: var(--text); }
.range-totals .chart-legend { align-self: end; flex-direction: column; gap: 6px; }
.legend-out { width: 10px; height: 10px; border-radius: 3px; background: var(--red); opacity: .7; }
.income-report-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 12.5px; font-weight: 600; }
.income-report-link .icon { width: 15px; height: 15px; }
.income-card [data-results].is-loading { opacity: .55; transition: opacity .15s; }

/* Bottom tab bar (phones) */
.tabbar { display: none; }

@media (max-width: 1280px) {
    .range-totals { grid-template-columns: 1fr 1fr 1fr; }
    .range-totals .chart-legend { grid-column: 1 / -1; flex-direction: row; }
    .role-guide { grid-template-columns: 1fr 1fr; }
    .lists-grid { grid-template-columns: 1fr; }
}

/* ===== Phones: app-like ===== */
@media (max-width: 768px) {
    body.app-page { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
    .tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 150; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; height: calc(60px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--border); }
    .tab-item { display: grid; place-items: center; align-content: center; gap: 3px; padding: 0; border: 0; background: none; color: var(--text-3); font: 600 10.5px/1 var(--font); cursor: pointer; -webkit-tap-highlight-color: transparent; }
    .tab-item .icon { width: 22px; height: 22px; transition: transform .2s var(--ease); }
    .tab-item.is-active { color: var(--primary); }
    .tab-item.is-active .icon { transform: translateY(-1px) scale(1.06); }
    .tab-item:active .icon { transform: scale(.9); }
    .topbar .search-trigger { display: none; }

    .content { padding: 14px 12px 20px; }
    .page-head { gap: 12px; margin-bottom: 14px; }
    .page-title { font-size: 20px; }
    .page-sub { font-size: 12.5px; }

    .stat-grid, .stat-grid-3, .stat-grid-4, .stat-grid-5 { display: flex; gap: 10px; overflow-x: auto; margin: 0 -12px 14px; padding: 2px 12px 6px; scroll-snap-type: x mandatory; scrollbar-width: none; }
    .stat-grid::-webkit-scrollbar { display: none; }
    .stat-grid > .stat-card { flex: 0 0 auto; min-width: 132px; padding: 12px 14px; scroll-snap-align: start; grid-column: auto !important; }
    .stat-grid > .stat-card .stat-icon { width: 30px; height: 30px; margin-bottom: 4px; }
    .stat-grid > .stat-card .stat-value { font-size: 20px; }

    .toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .toolbar > .toolbar-search { grid-column: 1 / -1; }
    .toolbar > .segmented { grid-column: 1 / -1; }
    .toolbar > .btn-ghost[data-filter-clear] { grid-column: 1 / -1; }
    .toolbar > .input-date, .toolbar > .date-trigger, .toolbar .input-date + .select-trigger { width: 100%; min-width: 0; }

    [data-results] > .card:has(.table-projects), [data-results] > .card:has(.table-people) { background: transparent; border: 0; box-shadow: none; }
    .table-projects tbody, .table-people tbody { display: grid; gap: 10px; }
    .table-projects tr, .table-people tr { border: 1px solid var(--border) !important; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-sm); padding: 14px !important; }

    .table-projects tr { grid-template-columns: minmax(0, 1fr) auto !important; gap: 8px 12px !important; }
    .table-projects .cell-check { display: none !important; }
    .table-projects .cell-project { grid-column: 1 !important; grid-row: 1 !important; }
    .table-projects .cell-project .row-title { white-space: normal; font-size: 14.5px; line-height: 1.3; }
    .table-projects .cell-status { grid-column: 2 !important; grid-row: 1 !important; justify-self: end; align-self: start; }
    .table-projects .cell-client { grid-column: 1 !important; grid-row: 2 !important; max-width: none !important; min-width: 0 !important; }
    .table-projects .cell-payment { grid-column: 2 !important; grid-row: 2 !important; justify-self: end; text-align: right; }
    .table-projects .cell-progress { grid-column: 1 / -1 !important; grid-row: 3 !important; }
    .table-projects .cell-progress .progress-inline { display: flex; align-items: center; gap: 8px; min-width: 0; }
    .table-projects .cell-progress .progress { flex: 1; }
    .table-projects .cell-start { grid-column: 1 !important; grid-row: 4 !important; font-size: 12px; color: var(--text) !important; }
    .table-projects .cell-deadline { grid-column: 2 !important; grid-row: 4 !important; font-size: 12px; justify-self: end; }
    .table-projects .cell-budget { grid-column: 1 !important; grid-row: 5 !important; justify-self: start; text-align: left; display: flex; align-items: center; gap: 8px; }
    .table-projects .cell-budget .pill { margin: 0; }
    .table-projects .cell-actions { grid-column: 2 !important; grid-row: 5 !important; justify-self: end; width: auto !important; padding: 0 !important; }
    .table-projects .cell-actions .row-actions { gap: 2px; }

    .table-people .cell-actions { border-top: 1px solid var(--border) !important; padding-top: 10px !important; }
    .table-people .cell-actions .row-actions { justify-content: flex-end; }

    .list-card-head { flex-direction: column; align-items: stretch; gap: 0; padding: 0 12px; }
    .list-card-search { width: auto; margin: 0 0 12px; }
    .tabs { overflow-x: auto; }
    .tab { height: 46px; flex: 1; justify-content: center; }
    .role-guide { grid-template-columns: 1fr; }

    .list-edit-row { grid-template-columns: 28px minmax(0, 1fr) auto; }
    .list-edit-row .row-usage { display: none; }
    .currency-head { display: none; }
    .currency-row { grid-template-columns: 76px 60px minmax(0, 1fr); row-gap: 6px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; }
    .currency-row .row-order { display: none; }
    .currency-row .row-usage { display: block; grid-column: 1 / 3; }
    .currency-row .row-tools { grid-column: 3; }

    .table-currency thead { display: none; }
    .table-currency, .table-currency tbody { display: block; }
    .table-currency tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
    .table-currency td, .table-currency td:first-child, .table-currency td:last-child { padding: 0; border: 0; text-align: left; }
    .table-currency .cell-cur { grid-column: 1 / -1; }
    .table-currency td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--text-3); font-weight: 500; }
    .table-currency .cell-paid { grid-column: 1 / -1; }
    .table-wrap:has(.table-currency) { overflow: visible; }

    .income-head { gap: 10px; }
    .range-form { width: 100%; }
    .range-form > .select-trigger { width: 100%; }
    .range-custom { width: 100%; }
    .range-custom .date-trigger { flex: 1; width: auto; }
    .range-totals { grid-template-columns: 1fr 1fr; }
    .range-total.is-net { grid-column: 1 / -1; }
    .range-total b { font-size: 16px; }
    .range-total.is-net b { font-size: 22px; }

    .perm-row { padding: 10px 12px; }
    .form-footer { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 5; margin: 0 -12px; padding: 10px 12px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--border); }
    .toast-stack { bottom: calc(72px + env(safe-area-inset-bottom)); }
}
.list-edit-row .input { width: 100%; min-width: 0; }
.table-currency .est { display: block; font-size: 11px; color: var(--text-3); font-weight: 500; }
@media (max-width: 768px) { .topbar-actions { margin-left: auto; } }
@media (max-width: 768px) { .income-head { align-items: stretch; } }
@media (max-width: 768px) { .table-currency tr.is-total { background: var(--surface-2); } .table-currency tr.is-total td { background: none; } }
.tab { white-space: nowrap; }
.tabs { scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
@media (max-width: 768px) { .tab { padding: 0 8px; gap: 6px; font-size: 12.5px; } }

/* System health */
.health-hero { display: flex; align-items: center; gap: 20px; padding: 20px 24px; margin-bottom: 20px; }
.health-ring { width: 74px; height: 74px; }
.health-ring span { width: 56px; height: 56px; font-size: 18px; }
.health-hero.is-warn .health-ring { background: conic-gradient(var(--amber) calc(var(--p) * 1%), var(--surface-3) 0); }
.health-hero.is-fail .health-ring { background: conic-gradient(var(--red) calc(var(--p) * 1%), var(--surface-3) 0); }
.health-hero.is-ok .health-ring { background: conic-gradient(var(--green) calc(var(--p) * 1%), var(--surface-3) 0); }
.health-hero-text { flex: 1; min-width: 0; }
.health-hero-text h3 { font-size: 17px; font-weight: 700; }
.health-hero-text p { margin-top: 3px; color: var(--text-2); font-size: 13px; }
.health-pills { display: flex; gap: 8px; }
.health-pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 20px; font-weight: 700; font-size: 13px; }
.health-pill .icon { width: 14px; height: 14px; }
.health-pill.is-ok { background: var(--green-soft); color: var(--green); }
.health-pill.is-warn { background: var(--amber-soft); color: var(--amber); }
.health-pill.is-fail { background: var(--red-soft); color: var(--red); }
.health-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; align-items: start; }
.health-grid > .section-card { margin-bottom: 0; }
.health-card .section-head { align-items: center; margin-bottom: 12px; }
.health-card .section-title { display: flex; align-items: center; gap: 10px; }
.health-group-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.health-group-icon .icon { width: 15px; height: 15px; }
.health-row { display: flex; align-items: flex-start; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); }
.health-dot { width: 22px; height: 22px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; background: var(--green-soft); color: var(--green); }
.health-dot .icon { width: 12px; height: 12px; stroke-width: 3; }
.is-warn > .health-dot, .health-dot.is-warn { background: var(--amber-soft); color: var(--amber); }
.is-fail > .health-dot, .health-dot.is-fail { background: var(--red-soft); color: var(--red); }
.health-text { display: grid; gap: 1px; min-width: 0; font-size: 13px; }
.health-text b { font-weight: 600; }
.health-text span { color: var(--text-2); word-break: break-word; }
.health-text small { margin-top: 2px; font-size: 12px; color: var(--amber); }
.health-row.is-fail .health-text small { color: var(--red); }
.health-actions { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 10px; border-top: 1px solid var(--border); }
.health-actions form { display: contents; }
.data-checks { border-top: 1px solid var(--border); }
.data-check + .data-check { border-top: 1px solid var(--border); }
.data-check-head { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 24px; border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; transition: background .15s; }
.data-check-head:hover:not(:disabled) { background: var(--surface-2); }
.data-check-head:disabled { cursor: default; }
.data-check-text { display: grid; flex: 1; min-width: 0; }
.data-check-text b { font-weight: 600; font-size: 13.5px; }
.data-check-text small { font-size: 12px; color: var(--text-2); }
.data-check.is-clear .data-check-text b { color: var(--text-2); }
.data-check-count { min-width: 34px; padding: 2px 9px; border-radius: 20px; background: var(--surface-3); font-weight: 700; font-size: 12px; text-align: center; color: var(--text-2); }
.data-check:not(.is-clear) .data-check-count { background: var(--red-soft); color: var(--red); }
.data-check-chevron { width: 16px; height: 16px; color: var(--text-3); transition: transform .25s var(--ease); }
.data-check.is-open .data-check-chevron { transform: rotate(180deg); }
.data-check-list { display: grid; padding: 0 24px 12px 58px; }
.data-check-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.data-check-item:hover { background: var(--surface-2); color: var(--text); }
.data-check-item > span:first-child { display: grid; min-width: 0; }
.data-check-item b { font-weight: 600; font-size: 13px; }
.data-check-item small { font-size: 12px; color: var(--text-3); }
.data-check-item .num { font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.error-list { display: grid; border-top: 1px solid var(--border); max-height: 420px; overflow-y: auto; }
.error-row { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 12px; padding: 9px 24px; border-bottom: 1px solid var(--border); font-size: 12px; }
.error-row.is-recent { background: var(--red-soft); }
.error-time { color: var(--text-3); white-space: nowrap; }
.error-row code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11.5px; color: var(--text-2); word-break: break-word; }
@media (max-width: 1100px) { .health-grid { grid-template-columns: 1fr; } }
@media (max-width: 768px) {
    .health-hero { flex-wrap: wrap; padding: 16px; gap: 14px; }
    .health-hero-text { flex-basis: calc(100% - 90px); }
    .health-pills { flex-basis: 100%; }
    .data-check-head { padding: 12px 16px; }
    .data-check-list { padding: 0 12px 10px; }
    .error-row { grid-template-columns: 1fr; gap: 2px; padding: 9px 16px; }
}

/* Client & contractor portal */
.pp-hero { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 28px 30px; margin-bottom: 20px; border-radius: 16px; color: #fff; background: radial-gradient(120% 140% at 100% 0%, #4f7cf0 0%, transparent 55%), linear-gradient(135deg, #1e3a8a 0%, #2563eb 60%, #3b82f6 100%); box-shadow: 0 18px 40px -18px rgba(37, 99, 235, .55); animation: pp-rise .5s var(--ease) both; }
.pp-hero::after { content: ""; position: absolute; right: -60px; bottom: -90px; width: 260px; height: 260px; border-radius: 50%; border: 40px solid rgba(255, 255, 255, .07); pointer-events: none; }
[data-theme="dark"] .pp-hero { background: radial-gradient(120% 140% at 100% 0%, #3b5fae 0%, transparent 55%), linear-gradient(135deg, #1f2d4d 0%, #2b4377 60%, #345394 100%); box-shadow: none; }
.pp-hero-main { position: relative; z-index: 1; display: flex; align-items: center; gap: 18px; min-width: 0; }
.pp-hero-avatar { width: 64px; height: 64px; font-size: 24px; flex-shrink: 0; box-shadow: 0 0 0 4px rgba(255, 255, 255, .22); }
.pp-hero-kicker { font-size: 12px; font-weight: 500; opacity: .8; margin-bottom: 4px; }
.pp-hero-title { font-size: 24px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.pp-hero-sub { margin-top: 6px; font-size: 14px; opacity: .88; max-width: 520px; }
.pp-hero-btn { position: relative; z-index: 1; flex-shrink: 0; background: #fff; color: #1e3a8a; border-color: transparent; font-weight: 600; }
.pp-hero-btn:hover { background: #eef3ff; color: #1e3a8a; }
[data-theme="dark"] .pp-hero-btn { background: rgba(255, 255, 255, .92); }

.pp-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.pp-section-head { margin-bottom: 14px; }
.pp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.pp-grid-wide { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.pp-main .pp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pp-side .pp-money-grid { grid-template-columns: 1fr; gap: 0; }
.pp-side .pp-money-grid > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); }
.pp-side .pp-money-grid dt { margin: 0; font-size: 13px; color: var(--text-2); }
.pp-side .pp-money-grid dd { font-size: 16px; text-align: right; }

.pp-card { will-change: transform; display: flex; flex-direction: column; gap: 10px; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); color: inherit; text-decoration: none; transition: transform .35s cubic-bezier(.22, .61, .36, 1), box-shadow .35s ease, border-color .35s ease; animation: pp-fade .45s var(--ease) backwards; }
.pp-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.pp-card:nth-child(2) { animation-delay: .05s; } .pp-card:nth-child(3) { animation-delay: .1s; } .pp-card:nth-child(4) { animation-delay: .15s; }
.pp-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pp-code { font-size: 12px; font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; }
.pp-card-title { font-size: 16px; font-weight: 700; letter-spacing: -.01em; line-height: 1.35; }
.pp-card-type { margin-top: -6px; font-size: 13px; color: var(--text-2); }
.pp-card .progress-block { margin: 4px 0 0; }
.pp-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.pp-when { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--text-2); }
.pp-when svg { width: 14px; height: 14px; }
.pp-when.is-late { color: var(--red); }

.pp-money { display: grid; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-2); }
.pp-money + .pp-money { margin-top: 12px; }
.pp-money-flat { padding: 0; border: 0; background: none; }
.pp-money-empty { display: flex; align-items: center; gap: 12px; color: var(--text-2); }
.pp-money-empty .stat-icon { margin: 0; background: var(--surface-3); color: var(--text-3); }
.pp-money-head { display: flex; align-items: center; justify-content: space-between; }
.pp-currency { font-size: 12px; font-weight: 700; letter-spacing: .06em; color: var(--text-2); }
.pp-pct { font-size: 12px; font-weight: 600; color: var(--green); }
.pp-money-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.pp-money-grid dt { font-size: 11px; font-weight: 500; color: var(--text-3); margin-bottom: 2px; }
.pp-money-grid dd { margin: 0; text-align: left; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; overflow-wrap: anywhere; }
.pp-in { color: var(--green); }
.pp-due { color: var(--amber); }
.pp-money-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 420px)); gap: 16px; margin-bottom: 20px; }
.pp-money-row .pp-money { margin: 0; background: var(--surface); box-shadow: var(--shadow); }

.pp-pay-icon { width: 36px; height: 36px; flex-shrink: 0; display: grid; place-items: center; border-radius: 10px; background: var(--green-soft); color: var(--green); }
.pp-pay-icon svg { width: 16px; height: 16px; }
.pp-help { display: flex; gap: 12px; align-items: flex-start; color: var(--text-2); font-size: 13px; }
.pp-help .stat-icon { margin: 0; flex-shrink: 0; background: var(--primary-soft); color: var(--primary); }

.pp-tabs { display: flex; gap: 6px; margin-bottom: 20px; padding: 4px; width: max-content; max-width: 100%; overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-sm); scrollbar-width: none; }
.pp-tabs::-webkit-scrollbar { display: none; }
.pp-tab { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--text-2); text-decoration: none; white-space: nowrap; transition: background .15s, color .15s; }
.pp-tab b { min-width: 22px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 10px; font-size: 11px; background: var(--surface-3); color: var(--text-2); }
.pp-tab:hover { color: var(--text); background: var(--surface-2); }
.pp-tab.is-active { background: var(--primary); color: #fff; }
.pp-tab.is-active b { background: rgba(255, 255, 255, .22); color: #fff; }

@keyframes pp-rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes pp-fade { from { opacity: 0; } }
.pp-card-money { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 2px 0 0; padding: 10px 12px; border-radius: var(--radius); background: var(--surface-2); }
.pp-card-money dt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11px; font-weight: 500; color: var(--text-3); margin-bottom: 2px; }
.pp-card-money dd { margin: 0; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

@media (max-width: 1100px) {
    .pp-layout { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .pp-hero { flex-direction: column; align-items: stretch; padding: 22px 20px; border-radius: 14px; }
    .pp-hero-avatar { width: 52px; height: 52px; font-size: 20px; }
    .pp-hero-title { font-size: 20px; }
    .pp-hero-btn { justify-content: center; }
    .pp-grid, .pp-grid-wide, .pp-money-row, .pp-main .pp-grid { grid-template-columns: 1fr; gap: 12px; }
    .pp-card { padding: 16px; }
    .pp-tabs { width: auto; }
    .detail-side .pp-help { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .pp-hero, .pp-card { animation: none; }
}

/* Admin viewing as another account */
.imp-bar { position: fixed; left: 50%; bottom: 20px; z-index: 400; transform: translateX(-50%); display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px); padding: 8px 8px 8px 14px; border-radius: 999px; background: #1e293b; color: #fff; box-shadow: 0 14px 34px rgba(15, 23, 42, .35); font-size: 13px; animation: pp-rise .3s var(--ease) both; }
.imp-who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.imp-who > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.imp-who small { margin-left: 4px; padding: 1px 7px; border-radius: 10px; background: rgba(255, 255, 255, .14); font-size: 11px; }
.imp-back { flex-shrink: 0; border-radius: 999px; background: #f59e0b; color: #1e293b; border-color: transparent; font-weight: 700; }
.imp-back:hover { background: #fbbf24; color: #1e293b; }
[data-theme="dark"] .imp-bar { background: #0f141a; border: 1px solid #353c45; }
body:has(.imp-bar) .toast-stack { bottom: 80px; }
@media (max-width: 768px) {
    .imp-bar { bottom: calc(72px + env(safe-area-inset-bottom)); }
    .imp-who small { display: none; }
    body:has(.imp-bar) .toast-stack { bottom: calc(132px + env(safe-area-inset-bottom)); }
}
@media print { .imp-bar { display: none; } }

/* Payment cell: badge, small meter, small amount left */
.cell-payment .pay-meter { display: flex; align-items: center; gap: 6px; width: 96px; margin-top: 6px; }
.cell-payment .pay-meter .progress { flex: 1; height: 4px; }
.cell-payment .pay-meter .progress-bar { background: var(--amber); }
.cell-payment .pay-meter small { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.cell-payment .pay-due { display: block; margin-top: 2px; font-size: 11.5px; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 768px) {
    .cell-payment { text-align: right; }
    .cell-payment .pay-meter { margin-left: auto; }
}

/* Range slider */
.range { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; cursor: pointer; }
.range::-webkit-slider-runnable-track { height: 6px; border-radius: 6px; background: var(--surface-3); }
.range::-moz-range-track { height: 6px; border-radius: 6px; background: var(--surface-3); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%; background: var(--surface); border: 2px solid var(--primary); box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 2px solid var(--primary); }
.range:focus-visible { outline: none; }
.range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(37, 99, 235, .2); }
.field label output { float: right; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* Invoice settings */
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sign-setup { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; align-items: start; }
.sign-preview { display: grid; padding: 22px 22px 16px; border: 1px solid var(--border); border-radius: 12px; background: #fff; color: #111; text-align: right; }
.sign-preview svg { width: 100%; height: auto; overflow: visible; }
.sign-preview-line { border-top: 1px dashed #9ca3af; margin-top: 2px; }
.sign-preview-label { margin-top: 4px; font-size: 14px; }
.check-inline { margin-top: 8px; }
@media (max-width: 900px) {
    .sign-setup { grid-template-columns: 1fr; }
    .form-grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
    .form-grid-3 { grid-template-columns: 1fr; }
}

/* Invoice builder */
.invoice-builder { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.ib-main { display: grid; gap: 20px; min-width: 0; }
.ib-side { position: sticky; top: 84px; }
.span-3-1 { grid-column: 1 / -1; }
.section-card.is-locked { opacity: .5; pointer-events: none; }
.ib-empty { margin: 0; color: var(--text-3); font-size: 13px; }
.ib-bank { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; transition: opacity .2s; }
.ib-bank.is-loading { opacity: .5; }
.ib-project { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); transition: border-color .15s, background .15s; }
.ib-project:hover { border-color: var(--border-strong); }
.ib-project.is-added { background: var(--surface-2); }
.ib-project-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.ib-project-text b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ib-project-text small { font-size: 12px; color: var(--text-3); }
.ib-custom { display: grid; grid-template-columns: minmax(0, 2.2fr) 90px 110px 140px auto; gap: 12px; align-items: end; }
.ib-lines { display: grid; gap: 8px; }
.ib-line { display: grid; grid-template-columns: minmax(0, 1fr) 80px 96px 130px 120px 34px; gap: 10px; align-items: center; }
.ib-line-head { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.ib-line-head span:nth-child(5) { text-align: right; }
.ib-cell-name { display: grid; gap: 3px; min-width: 0; }
.ib-tag { font-size: 11px; color: var(--primary); }
.ib-amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ib-summary { display: grid; gap: 18px; }
.ib-totals { margin: 0; display: grid; gap: 10px; }
.ib-totals > div { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.ib-totals dt { color: var(--text-2); padding-top: 2px; }
.ib-totals dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.ib-discount dd { display: grid; gap: 4px; justify-items: end; }
.ib-discount .input-row { max-width: 210px; }
.ib-discount .input-row > .input:first-child { width: 90px; flex: none; }
.ib-discount small { color: var(--red); font-size: 12px; }
.ib-grand { padding-top: 12px; border-top: 1px solid var(--border); }
.ib-grand dt, .ib-grand dd { font-size: 18px; font-weight: 700; color: var(--text); }
.ib-actions { display: grid; gap: 8px; }
.stamp-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stamp-option { position: relative; cursor: pointer; }
.stamp-option input { position: absolute; opacity: 0; }
.stamp-option span { display: flex; align-items: center; justify-content: center; height: 38px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; font-weight: 600; color: var(--text-2); transition: border-color .15s, background .15s, color .15s; }
.stamp-option input:focus-visible + span { box-shadow: 0 0 0 3px rgba(37, 99, 235, .25); }
.stamp-paid input:checked + span { border-color: var(--green); color: var(--green); background: color-mix(in srgb, var(--green) 10%, transparent); }
.stamp-partial input:checked + span { border-color: var(--amber); color: var(--amber); background: color-mix(in srgb, var(--amber) 10%, transparent); }
.stamp-unpaid input:checked + span { border-color: var(--red); color: var(--red); background: color-mix(in srgb, var(--red) 10%, transparent); }
.stamp-none input:checked + span { border-color: var(--border-strong); background: var(--surface-2); color: var(--text); }
@media (max-width: 1100px) {
    .invoice-builder { grid-template-columns: 1fr; }
    .ib-side { position: static; }
}
@media (max-width: 768px) {
    .ib-custom { grid-template-columns: 1fr 1fr; }
    .ib-custom .field:first-child, .ib-custom .btn { grid-column: 1 / -1; }
    .ib-line-head { display: none; }
    .ib-line { grid-template-columns: 1fr 1fr 1fr; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); }
    .ib-cell-name { grid-column: 1 / -1; }
    .ib-amount { grid-column: 1 / 3; text-align: left; }
    .ib-line .icon-btn { justify-self: end; }
}

/* Invoices list */
.table-invoices .cell-items { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
@media (max-width: 1280px) { .table-invoices .cell-items, .table-invoices th:nth-child(4) { display: none; } }
@media (max-width: 768px) {
    .table-invoices thead { display: none; }
    .table-invoices, .table-invoices tbody { display: block; }
    .table-invoices tr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
    .table-invoices td, .table-invoices td:first-child { padding: 0; border: 0; }
    .table-invoices .cell-check { grid-row: 1 / 3; align-self: center; }
    .table-invoices .cell-invoice { grid-column: 2; }
    .table-invoices .cell-total { grid-column: 3; grid-row: 1; }
    .table-invoices .cell-client { grid-column: 2; grid-row: 2; font-size: 12px; }
    .table-invoices .cell-payment { grid-column: 3; grid-row: 2; }
    .table-invoices .cell-date { grid-column: 2; grid-row: 3; font-size: 12px; color: var(--text-3); }
    .table-invoices .cell-actions { grid-column: 3; grid-row: 3; justify-self: end; }
}
.table-invoices thead th { padding-top: 14px; }
.table-invoices th:first-child, .table-invoices td:first-child { padding-left: 20px; }

/* Portal project search */
.pp-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 20px; }
.pp-filter .pp-tabs { margin-bottom: 0; }
.pp-search { position: relative; flex: 1 1 260px; max-width: 360px; }
.pp-search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.pp-search .input { width: 100%; height: 44px; padding-left: 36px; border-radius: 12px; }
.pp-card.is-hidden { display: none; }
@media (max-width: 768px) { .pp-search { max-width: none; flex-basis: 100%; } }

/* Portal projects: grid / list switch */
.segmented button { display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; font: 600 12.5px var(--font, inherit); color: var(--text-2); cursor: pointer; }
.segmented button .icon { width: 15px; height: 15px; }
.segmented button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.pp-views { height: 44px; border-radius: 12px; }
.pp-views button { border-radius: 9px; padding: 0 14px; }
.table-portal tbody tr { cursor: pointer; }
.table-portal th:first-child, .table-portal td:first-child { padding-left: 20px; }
.table-portal thead th { padding-top: 14px; }
.table-portal .cell-project { min-width: 200px; }
@media (max-width: 1100px) { .table-portal th:nth-child(3), .table-portal td:nth-child(3) { display: none; } }
@media (max-width: 768px) {
    .pp-views { margin-left: 0; }
    .table-portal thead { display: none; }
    .table-portal, .table-portal tbody { display: block; }
    .table-portal tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
    .table-portal tr:last-child { border-bottom: 0; }
    .table-portal td, .table-portal td:first-child { padding: 0; border: 0; text-align: left; }
    .table-portal .cell-project { grid-column: 1 / 3; min-width: 0; }
    .table-portal .cell-status { grid-column: 3; justify-self: end; }
    .table-portal td:nth-child(3) { display: block; grid-column: 1 / -1; }
    .table-portal .cell-deadline { grid-column: 1 / -1; font-size: 12px; color: var(--text-2); }
    .table-portal .cell-deadline::before { content: "Deadline: "; color: var(--text-3); }
    .table-portal td[data-label] { display: grid; gap: 2px; }
    .table-portal td[data-label]::before { content: attr(data-label); font-size: 11px; color: var(--text-3); }
    .table-portal .cell-payment { grid-column: 1 / 3; align-self: center; }
    .table-portal .cell-actions { grid-column: 3; justify-self: end; }
}
.pp-sort { width: 190px; }
.pp-filter .select-trigger { flex: 0 0 190px; width: 190px; height: 44px; border-radius: 12px; }
@media (max-width: 768px) { .pp-filter .select-trigger { flex: 1 1 100%; width: 100%; } }
