/*
 * ESTECRM design system
 * 1. Tokens  2. Base  3. Layout shell  4. Components  5. Modules  6. Responsive
 * No build step: plain CSS, light and dark themes driven by [data-theme].
 */

/* ------------------------------------------------------------------ 1. Tokens */
:root {
    --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    --bg: #f1f5f4;
    --surface: #ffffff;
    --surface-2: #f6faf9;
    --surface-3: #ebf1ef;
    --border: #dde6e2;
    --border-strong: #cbd8d3;
    --text: #10221e;
    --text-2: #4d605b;
    --text-3: #74857f;

    --brand: #0c8f6c;
    --brand-strong: #087d5b;
    --brand-soft: #e3f6ee;
    --brand-ink: #076650;
    --focus: rgba(12, 143, 108, .26);

    /* Each tone: ink, soft background and a two-stop gradient for filled marks. */
    --green: #12805c;   --green-bg: #e3f6ee;   --green-1: #1cc48f;   --green-2: #0a8a68;
    --blue: #2563c9;    --blue-bg: #e8f0fd;    --blue-1: #5b97f8;    --blue-2: #2a63cf;
    --violet: #6a4fcf;  --violet-bg: #f0ecfc;  --violet-1: #a48af5;  --violet-2: #6a4fcf;
    --amber: #a8690a;   --amber-bg: #fdf2dc;   --amber-1: #f6bd58;   --amber-2: #d88a25;
    --red: #c23a44;     --red-bg: #fcebed;     --red-1: #f5868c;     --red-2: #d64b58;
    --teal: #0b7f8f;    --teal-bg: #e0f4f6;    --teal-1: #38cbd9;    --teal-2: #0b8797;
    --neutral: #5b6b6e; --neutral-bg: #edf2f0; --neutral-1: #9fb0ab; --neutral-2: #5f706b;

    /* Soft colour wash behind every page and the card surface that sits on it. */
    --mesh: radial-gradient(1100px 520px at 105% -8%, rgba(15, 173, 124, .12), transparent 62%), radial-gradient(820px 460px at -8% 4%, rgba(57, 120, 230, .075), transparent 58%), radial-gradient(900px 520px at 60% 118%, rgba(115, 87, 217, .06), transparent 60%);
    --card-bg: linear-gradient(180deg, #ffffff, #fbfdfc);
    --btn-ink: #176750;

    /* Petrol–emerald navigation of the original design. */
    --side-bg: radial-gradient(circle at 12% 4%, rgba(89, 242, 188, .24), transparent 24%), radial-gradient(circle at 92% 88%, rgba(31, 125, 173, .28), transparent 32%), linear-gradient(165deg, #075c54 0%, #087265 42%, #07516a 100%);
    --side-text: rgba(235, 255, 249, .8);
    --side-muted: rgba(222, 255, 246, .5);
    --side-line: rgba(255, 255, 255, .14);
    --side-hover: rgba(255, 255, 255, .09);
    --side-active: linear-gradient(90deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, .11));
    --side-accent: #baffdf;
    --brand-gradient: linear-gradient(135deg, #0fad7c, #078d77 55%, #087d91);

    /* Chart tokens: validated categorical order (blue, orange) + chart ink. */
    --series-1: #2a78d6;
    --series-2: #eb6834;
    --series-3: #1baf7a;
    --series-muted: #c9d3d3;
    --chart-grid: #e6ebeb;
    --chart-axis: #c5cfcf;
    --status-good: #0ca30c;
    --status-warning: #fab219;
    --status-critical: #d03b3b;

    --radius-sm: 10px;
    --radius: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --shadow-xs: 0 1px 2px rgba(13, 39, 33, .05);
    --shadow-sm: 0 1px 2px rgba(13, 39, 33, .03), 0 10px 28px rgba(13, 39, 33, .055);
    --shadow-md: 0 2px 6px rgba(13, 39, 33, .04), 0 18px 46px rgba(13, 39, 33, .11);
    --shadow-lg: 0 30px 80px rgba(6, 30, 26, .28);
    --ease: cubic-bezier(.22, 1, .36, 1);

    --sidebar-w: 264px;
    --topbar-h: 64px;
    --gutter: 28px;
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #0a1211;
    --surface: #111b1a;
    --surface-2: #162322;
    --surface-3: #1c2b2a;
    --border: #223432;
    --border-strong: #2e4441;
    --text: #e8f1ef;
    --text-2: #a9bbb9;
    --text-3: #7d918f;

    --brand: #22b889;
    --brand-strong: #2fcf9c;
    --brand-soft: #123329;
    --brand-ink: #7fe3bf;
    --focus: rgba(34, 184, 137, .34);

    --green: #5fd3a6;   --green-bg: #12332a;
    --blue: #8bb4f7;    --blue-bg: #17273f;
    --violet: #b3a2f5;  --violet-bg: #251f42;
    --amber: #f0bd62;   --amber-bg: #3a2c10;
    --red: #f39088;     --red-bg: #3d1c1a;
    --teal: #6fcfdc;    --teal-bg: #10333a;
    --neutral: #a9bbb9; --neutral-bg: #1f2c2d;

    --side-bg: radial-gradient(circle at 12% 4%, rgba(89, 242, 188, .12), transparent 24%), linear-gradient(165deg, #06423d 0%, #064a43 42%, #053a4c 100%);

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-muted: #344546;
    --chart-grid: #1f2d2e;
    --chart-axis: #34494a;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 12px rgba(0, 0, 0, .2);
    --shadow-md: 0 12px 32px rgba(0, 0, 0, .45);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .6);
    color-scheme: dark;

    --mesh: radial-gradient(1100px 520px at 105% -8%, rgba(34, 184, 137, .13), transparent 62%), radial-gradient(820px 460px at -8% 4%, rgba(57, 120, 230, .09), transparent 58%);
    --card-bg: linear-gradient(180deg, #131e1d, #101918);
    --btn-ink: #8fe6c6;
}

/* -------------------------------------------------------------------- 2. Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 14.5px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    overflow-wrap: break-word;
}
body::before { content: ""; position: fixed; inset: 0; z-index: -1; background: var(--mesh); pointer-events: none; }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
h1, h2, h3, h4, p, figure, dl, dd, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
h1 { font-size: 30px; line-height: 1.15; font-weight: 760; letter-spacing: -.03em; }
h2 { font-size: 17.5px; line-height: 1.3; font-weight: 730; letter-spacing: -.022em; }
h3 { font-size: 14.5px; line-height: 1.4; font-weight: 700; letter-spacing: -.01em; }
a { color: inherit; text-decoration: none; }
img, svg, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
table { border-collapse: collapse; width: 100%; }
[hidden] { display: none !important; }
::selection { background: var(--brand-soft); color: var(--brand-ink); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.icon { flex: none; }

.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 12.5px; }
.strong { font-weight: 650; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.num { font-variant-numeric: tabular-nums; }
.text-right { text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.stack { display: grid; gap: 16px; min-width: 0; }
.stack-sm { display: grid; gap: 8px; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row-wrap > .select, .row-wrap > .input { width: auto; max-width: 100%; flex: 0 1 auto; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.link { color: var(--brand); font-weight: 600; }
.link:hover { text-decoration: underline; }
.tone-green { --tone: var(--green); --tone-bg: var(--green-bg); --tone-1: var(--green-1); --tone-2: var(--green-2); }
.tone-blue { --tone: var(--blue); --tone-bg: var(--blue-bg); --tone-1: var(--blue-1); --tone-2: var(--blue-2); }
.tone-violet { --tone: var(--violet); --tone-bg: var(--violet-bg); --tone-1: var(--violet-1); --tone-2: var(--violet-2); }
.tone-amber { --tone: var(--amber); --tone-bg: var(--amber-bg); --tone-1: var(--amber-1); --tone-2: var(--amber-2); }
.tone-red { --tone: var(--red); --tone-bg: var(--red-bg); --tone-1: var(--red-1); --tone-2: var(--red-2); }
.tone-teal { --tone: var(--teal); --tone-bg: var(--teal-bg); --tone-1: var(--teal-1); --tone-2: var(--teal-2); }
.tone-neutral { --tone: var(--neutral); --tone-bg: var(--neutral-bg); --tone-1: var(--neutral-1); --tone-2: var(--neutral-2); }

/* ------------------------------------------------------------ 3. Layout shell */
.app { min-height: 100vh; min-height: 100dvh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40;
    width: var(--sidebar-w);
    display: flex; flex-direction: column;
    background: var(--side-bg);
    color: var(--side-text);
    box-shadow: 12px 0 38px rgba(7, 55, 62, .14);
    transition: width .2s ease, transform .24s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; height: var(--topbar-h); padding: 0 18px; flex: none; }
.brand-mark {
    display: grid; place-items: center; width: 34px; height: 34px; flex: none;
    border: 1px solid rgba(255, 255, 255, .5); border-radius: 11px; background: linear-gradient(145deg, #fff, #dffff3);
    color: #08705f; font-family: Georgia, serif; font-style: italic; font-weight: 800; font-size: 21px;
    box-shadow: 0 10px 24px rgba(1, 38, 39, .2);
}
.brand-word { display: grid; line-height: 1.1; min-width: 0; }
.brand-word strong { font-size: 15.5px; font-weight: 750; letter-spacing: .02em; color: #fff; }
.brand-word strong span { color: var(--side-accent); }
.brand-word small { font-size: 10.5px; letter-spacing: .14em; color: var(--side-muted); text-transform: uppercase; }
.sidebar .sidebar-close { margin-left: auto; display: none; color: var(--side-text); }

.sidebar-branch {
    display: flex; align-items: center; gap: 10px; margin: 4px 14px 10px; padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, .15); border-radius: 14px; background: rgba(255, 255, 255, .09);
    box-shadow: inset 0 1px rgba(255, 255, 255, .08);
}
.sidebar-branch .icon { color: var(--side-accent); }
.sidebar-branch span { display: grid; min-width: 0; line-height: 1.25; }
.sidebar-branch small { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--side-muted); }
.sidebar-branch strong { font-size: 13.5px; font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 12px 26px; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .16) transparent; -webkit-mask-image: linear-gradient(#000 calc(100% - 22px), transparent); mask-image: linear-gradient(#000 calc(100% - 22px), transparent); }
.nav-label { display: block; padding: 14px 10px 5px; font-size: 10.5px; font-weight: 650; letter-spacing: .12em; text-transform: uppercase; color: var(--side-muted); }
.nav-item {
    position: relative; display: flex; align-items: center; gap: 12px; min-height: 38px; padding: 0 10px;
    border-radius: var(--radius); color: var(--side-text); font-size: 14px; font-weight: 500;
    transition: background .15s ease, color .15s ease;
}
.nav-item .icon { opacity: .78; }
.nav-item > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover { background: var(--side-hover); color: #fff; }
.nav-item.is-active { background: var(--side-active); color: #fff; font-weight: 600; box-shadow: 0 7px 18px rgba(2, 47, 47, .1); }
.nav-item.is-active .icon { opacity: 1; color: var(--side-accent); }
.nav-item.is-active::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--side-accent); }
.nav-count { flex: none; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: rgba(255, 255, 255, .16); color: #fff; font-size: 11.5px; font-weight: 650; text-align: center; font-variant-numeric: tabular-nums; }
.nav-count.is-alert { background: #f0bd62; color: #2b1c02; }

.sidebar-foot { flex: none; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--side-line); display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--side-muted); }
.sidebar-foot span { display: inline-flex; align-items: center; gap: 7px; }
.sidebar-foot i { width: 7px; height: 7px; border-radius: 50%; background: var(--side-accent); box-shadow: 0 0 0 3px rgba(61, 220, 151, .18); }

.sidebar-overlay { position: fixed; inset: 0; z-index: 39; background: rgba(6, 18, 20, .5); opacity: 0; pointer-events: none; transition: opacity .2s ease; }

.workspace { margin-left: var(--sidebar-w); min-width: 0; transition: margin-left .2s ease; }
.topbar {
    position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
    display: flex; align-items: center; gap: 12px; padding: 0 var(--gutter);
    background: color-mix(in srgb, var(--surface) 70%, transparent);
    backdrop-filter: saturate(1.7) blur(18px); -webkit-backdrop-filter: saturate(1.7) blur(18px);
    border-bottom: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
}
.topbar-title { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; overflow: hidden; font-size: 13.5px; color: var(--text-3); }
.topbar-title strong { min-width: 0; color: var(--text); font-weight: 650; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-title .icon { flex: none; }
.topbar-title .org { white-space: nowrap; flex: none; }
.topbar-title .sep { display: inline-flex; flex: none; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.search-trigger {
    display: flex; align-items: center; gap: 10px; width: clamp(200px, 21vw, 300px); height: 40px; padding: 0 10px 0 13px;
    border: 1px solid var(--border); border-radius: var(--radius); background: color-mix(in srgb, var(--surface) 82%, transparent); color: var(--text-3);
    font-size: 13.5px; text-align: left; transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.search-trigger:hover { border-color: color-mix(in srgb, var(--brand) 34%, var(--border)); background: var(--surface); box-shadow: 0 6px 18px rgba(13, 39, 33, .06); }
.search-trigger span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
kbd { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); color: var(--text-3); font: 600 11px/1 var(--font); }
.profile-trigger { display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; border-radius: 14px; border: 1px solid transparent; transition: background .15s ease, border-color .15s ease; }
.profile-trigger:hover { background: var(--surface); border-color: var(--border); }
.profile-trigger span.who { display: grid; line-height: 1.2; text-align: left; white-space: nowrap; }
.profile-trigger strong { font-size: 13px; font-weight: 650; }
.profile-trigger small { font-size: 11.5px; color: var(--text-3); }
.preview-chip { display: inline-flex; flex: none; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; background: var(--amber-bg); color: var(--amber); font-size: 10.5px; font-weight: 700; letter-spacing: .08em; white-space: nowrap; }

.page { padding: 30px var(--gutter) 64px; max-width: 1600px; margin: 0 auto; display: grid; gap: 22px; min-width: 0; }
.page > * { min-width: 0; animation: rise .5s var(--ease) backwards; }
.page > *:nth-child(2) { animation-delay: .04s; }
.page > *:nth-child(3) { animation-delay: .08s; }
.page > *:nth-child(4) { animation-delay: .12s; }
.page > *:nth-child(n+5) { animation-delay: .16s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .16s; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; }
.page-head .titles { min-width: 0; display: grid; gap: 6px; }
.page-head p { color: var(--text-2); max-width: 720px; font-size: 14.5px; }
.page-head .actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.eyebrow { display: inline-flex; align-items: center; gap: 9px; font-size: 10.5px; font-weight: 850; letter-spacing: .13em; text-transform: uppercase; color: var(--brand); }
.eyebrow::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green-1); box-shadow: 0 0 0 4px color-mix(in srgb, var(--green-1) 16%, transparent); }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; font-weight: 600; }
.back-link:hover { color: var(--brand); }

/* Collapsed sidebar (desktop) */
.sidebar-collapsed { --sidebar-w: 72px; }
.sidebar-collapsed .brand-word, .sidebar-collapsed .nav-item > span, .sidebar-collapsed .nav-label,
.sidebar-collapsed .sidebar-branch span, .sidebar-collapsed .sidebar-foot b { display: none; }
.sidebar-collapsed .sidebar-brand { padding: 0; justify-content: center; }
.sidebar-collapsed .sidebar-branch { justify-content: center; padding: 10px 0; }
.sidebar-collapsed .nav-item { justify-content: center; padding: 0; }
.sidebar-collapsed .nav-count { position: absolute; top: 3px; right: 6px; min-width: 16px; padding: 0 4px; font-size: 10px; line-height: 16px; }
.sidebar-collapsed .sidebar-nav { padding-top: 8px; }
.sidebar-collapsed .sidebar-foot { justify-content: center; }

/* ---------------------------------------------------------------- 4. Components */

/* Buttons */
.btn {
    --btn-bg: linear-gradient(180deg, var(--surface), var(--surface-2)); --btn-fg: var(--btn-ink); --btn-border: color-mix(in srgb, var(--brand) 14%, var(--border));
    position: relative; overflow: hidden;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 40px; padding: 0 16px; flex: none; max-width: 100%;
    border: 1px solid var(--btn-border); border-radius: var(--radius);
    background: var(--btn-bg); color: var(--btn-fg);
    font-size: 13.5px; font-weight: 720; line-height: 1; white-space: nowrap; letter-spacing: -.005em;
    box-shadow: 0 4px 12px rgba(19, 62, 52, .05);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, filter .18s ease;
    -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(110deg, transparent 15%, rgba(255, 255, 255, .26) 45%, transparent 70%); transform: translateX(-125%); transition: transform .55s var(--ease); }
.btn:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--brand) 30%, var(--border)); box-shadow: 0 10px 22px rgba(19, 62, 52, .09); }
.btn:hover::after { transform: translateX(125%); }
.btn:active { transform: translateY(0); box-shadow: 0 2px 6px rgba(19, 62, 52, .06); }
.btn:focus-visible, .icon-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn-primary { --btn-bg: var(--brand-gradient); --btn-fg: #fff; --btn-border: transparent; box-shadow: 0 10px 24px rgba(8, 143, 111, .22); }
.btn-primary:hover { border-color: transparent; box-shadow: 0 14px 30px rgba(8, 143, 111, .32); }
.btn-soft { --btn-bg: var(--brand-soft); --btn-fg: var(--brand-ink); --btn-border: color-mix(in srgb, var(--brand) 16%, transparent); box-shadow: none; }
.btn-ghost { --btn-bg: transparent; --btn-border: transparent; --btn-fg: var(--text-2); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); border-color: transparent; box-shadow: none; transform: none; }
.btn-ghost::after { display: none; }
.btn-danger { --btn-bg: linear-gradient(135deg, var(--red-1), var(--red-2)); --btn-fg: #fff; --btn-border: transparent; box-shadow: 0 10px 24px color-mix(in srgb, var(--red-2) 26%, transparent); }
.btn-danger:hover { border-color: transparent; box-shadow: 0 14px 30px color-mix(in srgb, var(--red-2) 34%, transparent); }
.btn-danger-soft { --btn-bg: var(--red-bg); --btn-fg: var(--red); --btn-border: color-mix(in srgb, var(--red) 16%, transparent); box-shadow: none; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 12.5px; border-radius: var(--radius-sm); gap: 6px; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; border-radius: 14px; }
.btn-block { width: 100%; }
.icon-btn {
    display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; position: relative;
    border: 1px solid transparent; border-radius: var(--radius); color: var(--text-2);
    transition: background .15s ease, color .15s ease, border-color .15s ease, transform .15s ease;
}
.icon-btn:hover { background: color-mix(in srgb, var(--brand) 8%, var(--surface-3)); color: var(--brand-ink); }
.icon-btn.is-bordered { border-color: color-mix(in srgb, var(--brand) 14%, var(--border)); background: linear-gradient(180deg, var(--surface), var(--surface-2)); color: var(--btn-ink); box-shadow: 0 4px 12px rgba(19, 62, 52, .05); }
.icon-btn-sm { width: 34px; height: 34px; border-radius: var(--radius-sm); }
.icon-btn.is-danger:hover { background: var(--red-bg); color: var(--red); }
.delete-record { display: flex; align-items: flex-start; gap: 10px; padding: 13px 14px; border-radius: 14px; background: var(--surface-3); overflow-wrap: anywhere; }
.delete-record .icon { flex: none; margin-top: 2px; color: var(--red); }
.delete-record strong { min-width: 0; font-weight: 680; }
.modal-body [data-bind-text]:empty { display: none; }
.icon-btn.is-on { background: var(--brand-soft); color: var(--brand-ink); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 20%, transparent); }
.icon-btn .dot { position: absolute; top: 3px; right: 3px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: linear-gradient(135deg, var(--red-1), var(--red-2)); color: #fff; font-size: 10px; font-weight: 800; line-height: 17px; text-align: center; box-shadow: 0 0 0 2px var(--surface), 0 4px 10px color-mix(in srgb, var(--red-2) 40%, transparent); }
.btn-group { display: inline-flex; padding: 4px; border-radius: 14px; background: var(--surface-3); gap: 3px; max-width: 100%; overflow-x: auto; scrollbar-width: none; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--border) 70%, transparent); }
.btn-group::-webkit-scrollbar { display: none; }
.btn-group > a, .btn-group > button { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 13px; border-radius: 10px; font-size: 13px; font-weight: 680; color: var(--text-2); white-space: nowrap; transition: color .15s ease, background .15s ease; }
.btn-group > a:hover, .btn-group > button:hover { color: var(--text); }
.btn-group > .is-active { background: var(--surface); color: var(--brand-ink); box-shadow: 0 1px 2px rgba(13, 39, 33, .08), 0 4px 10px rgba(13, 39, 33, .05); }

/* Cards */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-width: 0; overflow: clip; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head > div:first-child:not(.btn-group) { min-width: 0; display: grid; gap: 3px; }
.card-head p { color: var(--text-2); font-size: 13px; }
.card-body { padding: 20px; }
.card-foot { padding: 13px 20px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--text-2); font-size: 12.5px; background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.card-kicker { font-size: 10px; font-weight: 850; letter-spacing: .13em; text-transform: uppercase; color: var(--brand); }

.grid { display: grid; gap: 18px; min-width: 0; }
.grid > * { min-width: 0; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-main { grid-template-columns: minmax(0, 1fr) 372px; align-items: start; }
.cols-auto { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }

/* Stat tiles: tinted by tone, the first one filled in the brand gradient. */
.stats { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stats.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stat {
    position: relative; isolation: isolate; overflow: hidden; display: grid; gap: 8px; min-width: 0; align-content: start;
    min-height: 148px; padding: 18px 18px 16px;
    border: 1px solid color-mix(in srgb, var(--tone, var(--brand)) 20%, var(--border)); border-radius: var(--radius-lg);
    background: linear-gradient(150deg, color-mix(in srgb, var(--tone, var(--brand)) 10%, var(--surface)) 0%, var(--surface) 62%);
    box-shadow: var(--shadow-sm);
    transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}
.stat::after { content: ""; position: absolute; z-index: -1; right: -46px; top: -58px; width: 130px; height: 130px; border: 22px solid color-mix(in srgb, var(--tone, var(--brand)) 9%, transparent); border-radius: 50%; }
.stat:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--tone, var(--brand)) 38%, var(--border)); box-shadow: 0 20px 44px color-mix(in srgb, var(--tone, var(--brand)) 16%, transparent); }
.stat-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.stat-label { padding-top: 3px; font-size: 10.5px; line-height: 1.35; color: var(--text-3); font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.stat-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; color: #fff; background: linear-gradient(145deg, var(--tone-1, var(--green-1)), var(--tone-2, var(--green-2))); box-shadow: 0 8px 18px color-mix(in srgb, var(--tone-2, var(--green-2)) 34%, transparent), inset 0 1px rgba(255, 255, 255, .32); flex: none; }
.stat-value { margin-top: 2px; font-size: 32px; font-weight: 740; letter-spacing: -.04em; line-height: 1.08; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-value small { font-size: 13px; font-weight: 500; color: var(--text-3); letter-spacing: 0; margin-left: 4px; }
.stat-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--text-3); min-height: 18px; }
.stats > .stat:first-child { color: #fff; border-color: #0d8d68; background: linear-gradient(145deg, #0da276, #087b5a); box-shadow: 0 16px 36px rgba(8, 123, 90, .26); }
.stats > .stat:first-child::after { border-color: rgba(255, 255, 255, .07); }
.stats > .stat:first-child:hover { border-color: #0d8d68; box-shadow: 0 22px 46px rgba(8, 123, 90, .34); }
.stats > .stat:first-child .stat-label { color: rgba(255, 255, 255, .7); }
.stats > .stat:first-child .stat-icon { background: rgba(255, 255, 255, .14); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18); }
.stats > .stat:first-child .stat-meta { color: rgba(255, 255, 255, .74); }
.stats > .stat:first-child .delta { color: #d7fff0; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 720; font-size: 12.5px; }
.delta.up { color: var(--green); }
.delta.down { color: var(--red); }
.delta.flat { color: var(--text-3); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; background: var(--tone-bg, var(--neutral-bg)); color: var(--tone, var(--neutral)); font-size: 11.5px; font-weight: 720; white-space: nowrap; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone, var(--neutral)) 16%, transparent); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 16%, transparent); }
.badge.plain::before { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 25px; padding: 0 10px; border-radius: 8px; background: var(--surface-3); color: var(--text-2); font-size: 12px; font-weight: 620; white-space: nowrap; max-width: 100%; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--border) 70%, transparent); }
.chip.is-alert { background: var(--red-bg); color: var(--red); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--red) 16%, transparent); }

/* Avatars: gradient tiles in the person's colour. */
.avatar { display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 12px; color: #fff; font-size: 11px; font-style: normal; font-weight: 800; letter-spacing: .04em; background: linear-gradient(145deg, color-mix(in srgb, var(--avatar, var(--brand)) 70%, white), var(--avatar, var(--brand))); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18), 0 6px 14px color-mix(in srgb, var(--avatar, var(--brand)) 24%, transparent); }
.avatar-sm { width: 30px; height: 30px; border-radius: 10px; font-size: 9.5px; }
.avatar-lg { width: 62px; height: 62px; border-radius: 19px; font-size: 20px; }
.person { display: flex; align-items: center; gap: 11px; min-width: 0; }
.person > span:last-child { display: grid; min-width: 0; line-height: 1.3; }
.person strong { font-weight: 680; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person small { color: var(--text-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.person:hover strong { color: var(--brand); }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field-label { font-size: 12.5px; font-weight: 720; color: var(--text); letter-spacing: -.003em; }
.field-label i { color: var(--red); font-style: normal; margin-left: 2px; }
.input, .select, .textarea {
    width: 100%; min-width: 0; height: 42px; padding: 0 13px;
    border: 1px solid var(--border-strong); border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface-2) 55%, var(--surface)); color: var(--text); font-size: 14px;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
    -webkit-appearance: none; appearance: none;
}
.textarea { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.select {
    padding-right: 34px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236f8185' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: color-mix(in srgb, var(--border-strong) 60%, var(--text-3)); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 4px var(--focus); }
.input[type="file"] { padding: 7px 8px; height: auto; font-size: 13px; }
.input[type="file"]::file-selector-button { margin-right: 10px; height: 26px; padding: 0 10px; border: 0; border-radius: 7px; background: var(--brand-soft); color: var(--brand-ink); font: 600 12.5px var(--font); cursor: pointer; }
.field-hint { font-size: 12.5px; color: var(--text-3); }
.field-error { font-size: 12.5px; color: var(--red); font-weight: 550; }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--red); }
.input-group { position: relative; display: flex; align-items: center; }
.input-group > .icon { position: absolute; left: 12px; color: var(--text-3); pointer-events: none; }
.input-group > .input { padding-left: 38px; }
.input-group > .input-action { position: absolute; right: 4px; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; min-height: 32px; }
.check input { width: 18px; height: 18px; flex: none; accent-color: var(--brand); cursor: pointer; margin: 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.form-section { display: grid; gap: 16px; }
.form-section-title { display: flex; align-items: center; gap: 12px; }
.form-section-title b { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--brand-gradient); color: #fff; font-size: 13px; font-weight: 800; flex: none; box-shadow: 0 8px 18px rgba(8, 143, 111, .24); }
.form-section-title p { color: var(--text-2); font-size: 13px; }

/* Toolbars and filters */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .search { position: relative; flex: 1 1 200px; max-width: 380px; min-width: 0; }
.toolbar .search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.toolbar .search .input { padding-left: 38px; }
.toolbar .select { width: auto; max-width: 100%; flex: 0 1 auto; }
.toolbar .spacer { flex: 1; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table th { padding: 12px 16px; text-align: left; font-size: 10.5px; font-weight: 820; letter-spacing: .07em; text-transform: uppercase; color: var(--text-3); background: color-mix(in srgb, var(--surface-2) 80%, transparent); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 14px 16px; border-bottom: 1px solid color-mix(in srgb, var(--border) 76%, transparent); vertical-align: middle; font-size: 14px; }
.table tbody tr { transition: background .15s ease; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--brand) 4.5%, var(--surface)); }
.table .cell-main { font-weight: 680; }
.table td .person { min-width: 160px; }
.table.compact th, .table.compact td { padding-left: 11px; padding-right: 11px; }
.table.compact th:first-child, .table.compact td:first-child { padding-left: 18px; }
.table td .badge, .table td .chip { vertical-align: middle; }
.table .break-any { display: block; min-width: 200px; overflow-wrap: anywhere; }
.table .cell-sub { display: block; color: var(--text-3); font-size: 12.5px; font-weight: 400; }
.table .cell-actions { text-align: right; white-space: nowrap; width: 1%; }
.table .cell-actions > * { vertical-align: middle; }
.table .amount { font-weight: 720; font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: -.01em; }
.table .amount.negative { color: var(--red); }

/* Empty states */
.empty { display: grid; justify-items: center; gap: 8px; padding: 48px 20px; text-align: center; color: var(--text-2); }
.empty .empty-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 18px; background: linear-gradient(145deg, var(--brand-soft), var(--surface)); color: var(--brand); margin-bottom: 6px; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 14%, transparent), 0 10px 24px rgba(8, 143, 111, .1); }
.empty strong { color: var(--text); font-size: 15.5px; letter-spacing: -.01em; }
.empty p { max-width: 380px; font-size: 13.5px; }
.empty .btn { margin-top: 8px; }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pagination a, .pagination span { display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 10px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.pagination a:hover { background: var(--surface-3); color: var(--text); }
.pagination .is-active { background: var(--brand-gradient); color: #fff; box-shadow: 0 6px 14px rgba(8, 143, 111, .24); }
.pagination .is-disabled { opacity: .4; pointer-events: none; }

/* Tabs: a segmented pill bar. */
.tabs { display: flex; gap: 4px; width: fit-content; max-width: 100%; padding: 5px; border-radius: 16px; background: var(--surface-3); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--border) 70%, transparent); overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.card > .tabs { margin: 0 16px 16px; max-width: calc(100% - 32px); }
.tabs.can-scroll-end { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 44px), transparent); }
.tabs.can-scroll-start { -webkit-mask-image: linear-gradient(270deg, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(270deg, #000 calc(100% - 44px), transparent); }
.tabs.can-scroll-start.can-scroll-end { -webkit-mask-image: linear-gradient(90deg, transparent, #000 44px, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(90deg, transparent, #000 44px, #000 calc(100% - 44px), transparent); }
.tab { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 13px; flex: none; border-radius: 11px; color: var(--text-2); font-size: 13.5px; font-weight: 680; white-space: nowrap; transition: color .15s ease, background .15s ease; }
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--surface); color: var(--brand-ink); box-shadow: 0 1px 2px rgba(13, 39, 33, .08), 0 6px 14px rgba(13, 39, 33, .06); }
.tab.is-active .icon { color: var(--brand); }
.tab b { min-width: 20px; padding: 0 6px; border-radius: 999px; background: color-mix(in srgb, var(--text-3) 14%, transparent); color: var(--text-2); font-size: 11px; line-height: 20px; text-align: center; font-weight: 760; }
.tab.is-active b { background: var(--brand-soft); color: var(--brand-ink); }

/* Dialogs: modal, drawer, palette */
dialog { padding: 0; border: 0; color: inherit; background: transparent; max-width: none; max-height: none; }
dialog::backdrop { background: rgba(6, 26, 23, .5); backdrop-filter: blur(7px) saturate(1.2); -webkit-backdrop-filter: blur(7px) saturate(1.2); }
body:has(dialog[open]) { overflow: hidden; }
.modal { width: min(560px, calc(100vw - 32px)); margin: auto; }
.modal.modal-lg { width: min(760px, calc(100vw - 32px)); }
.modal.modal-sm { width: min(420px, calc(100vw - 32px)); }
.code-details > div { padding-left: 0; padding-right: 0; }
.modal[open] { animation: pop .18s ease; }
.modal-card { display: flex; flex-direction: column; max-height: calc(100dvh - 48px); background: var(--card-bg); border: 1px solid color-mix(in srgb, var(--brand) 10%, var(--border)); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 22px 14px; flex: none; background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 6%, transparent), transparent); }
.modal-head h2 { font-size: 19.5px; }
.modal-head p { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.modal-body { padding: 6px 22px 22px; overflow-y: auto; display: grid; gap: 14px; overscroll-behavior: contain; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 15px 22px; border-top: 1px solid var(--border); background: var(--surface-2); flex: none; flex-wrap: wrap; }
.drawer { width: min(440px, 100vw); height: 100dvh; margin: 0 0 0 auto; }
.drawer[open] { animation: slide-in .22s ease; }
.drawer .modal-card { height: 100%; max-height: none; border-radius: 0; border-width: 0 0 0 1px; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes slide-in { from { transform: translateX(32px); opacity: 0; } }
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } }

.theme-sun, :root[data-theme="dark"] .theme-moon { display: none; }
:root[data-theme="dark"] .theme-sun { display: block; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.palette { width: min(620px, calc(100vw - 24px)); margin: 10vh auto auto; }
.palette-input { display: flex; align-items: center; gap: 12px; padding: 0 16px; height: 56px; border-bottom: 1px solid var(--border); color: var(--text-3); }
.palette-input input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font-size: 16px; color: var(--text); }
.palette-results { max-height: min(56vh, 460px); overflow-y: auto; padding: 8px; }
.palette-group { padding: 10px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--text-3); }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--radius); min-width: 0; }
.palette-item .ico { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; font-size: 11px; font-weight: 800; background: var(--surface-3); color: var(--text-2); flex: none; }
.palette-item span.txt { display: grid; min-width: 0; flex: 1; line-height: 1.3; }
.palette-item strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item small { color: var(--text-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item.is-selected, .palette-item:hover { background: var(--surface-3); }
.palette-item.is-selected .ico { background: var(--brand-gradient); color: #fff; }
.palette-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--border); background: var(--surface-2); color: var(--text-3); font-size: 12px; }
.palette-foot span { display: inline-flex; align-items: center; gap: 6px; }

/* Menus */
.menu-wrap { position: relative; display: inline-block; }
.menu { position: fixed; z-index: 60; min-width: 210px; max-width: min(300px, calc(100vw - 16px)); padding: 7px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(18px) saturate(1.5); -webkit-backdrop-filter: blur(18px) saturate(1.5); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-md); animation: pop .14s ease; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 6px 11px; border-radius: 10px; font-size: 13.5px; font-weight: 500; color: var(--text); text-align: left; }
.menu-item:hover { background: color-mix(in srgb, var(--brand) 8%, var(--surface-3)); }
.menu-item:hover .icon { color: var(--brand); }
.menu-item .icon { color: var(--text-3); }
.menu-item.is-danger, .menu-item.is-danger .icon { color: var(--red); }
.menu-sep { height: 1px; margin: 6px 4px; background: var(--border); }
.menu-label { padding: 6px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.menu form { display: contents; }
.menu-profile { display: flex; align-items: center; gap: 12px; padding: 8px 10px 10px; }
.menu-profile span { display: grid; min-width: 0; line-height: 1.3; }
.menu-profile small { color: var(--text-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }

/* Toasts and alerts */
.toast-stack { position: fixed; top: calc(var(--topbar-h) + 12px); right: 20px; z-index: 80; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 13px 12px 13px 15px; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid color-mix(in srgb, var(--tone, var(--brand)) 26%, var(--border)); border-left: 4px solid var(--tone, var(--brand)); border-radius: 16px; box-shadow: var(--shadow-md); animation: pop .2s ease; transition: opacity .25s ease, transform .25s ease; }
.toast > .icon { color: var(--tone, var(--brand)); margin-top: 1px; }
.toast p { flex: 1; font-size: 13.5px; font-weight: 550; min-width: 0; }
.toast.is-leaving { opacity: 0; transform: translateX(12px); }
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 13px 15px; border-radius: 14px; background: var(--tone-bg, var(--blue-bg)); color: var(--tone, var(--blue)); font-size: 13.5px; font-weight: 520; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone, var(--blue)) 16%, transparent); }
.alert > .icon { margin-top: 1px; }
.alert > div { flex: 1; min-width: 0; }
.alert strong { font-weight: 650; }
.alert .btn { margin-left: auto; }

/* Lists and timelines */
.list > * { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); min-width: 0; }
.list > *:last-child { border-bottom: 0; }
.list > * { transition: background .15s ease; }
.list a:hover, a.list-row:hover { background: color-mix(in srgb, var(--brand) 4.5%, var(--surface)); }
.list .list-main { flex: 1; min-width: 0; display: grid; line-height: 1.35; }
.list .list-main strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .list-main small { color: var(--text-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .list-end { flex: none; display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 12.5px; }
.ico-box { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--tone-bg, var(--surface-3)); color: var(--tone, var(--text-2)); flex: none; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone, var(--text-3)) 14%, transparent); }
.timeline { display: grid; padding: 6px 18px 18px; }
.timeline-item { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; padding-top: 14px; }
.timeline-item::before { content: ""; position: absolute; left: 13.5px; top: 0; bottom: -14px; width: 1px; background: var(--border); }
.timeline-item:last-child::before { bottom: auto; height: 20px; }
.timeline-dot { position: relative; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 10px; background: linear-gradient(145deg, var(--tone-1, var(--neutral-1)), var(--tone-2, var(--neutral-2))); color: #fff; box-shadow: 0 0 0 4px var(--surface), 0 6px 14px color-mix(in srgb, var(--tone-2, var(--neutral-2)) 26%, transparent); }
.timeline-item small { color: var(--text-3); font-size: 12px; }
.timeline-item p { color: var(--text-2); font-size: 13.5px; }
.definition { display: grid; }
.definition > div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 18px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.definition > div:last-child { border-bottom: 0; }
.definition dt { color: var(--text-3); flex: none; }
.definition dd { font-weight: 550; text-align: right; min-width: 0; overflow-wrap: anywhere; }

/* Progress and meters */
.meter { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--green-1), var(--green-2)); min-width: 2px; }
.meter.is-warning > i { background: linear-gradient(90deg, var(--amber-1), var(--amber-2)); }
.meter.is-critical > i { background: linear-gradient(90deg, var(--red-1), var(--red-2)); }
.bar-list { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 160px) minmax(0, 1fr) auto; align-items: center; gap: 12px; font-size: 13.5px; }
.bar-row > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.bar-row .track { height: 14px; border-radius: 4px; background: transparent; }
.bar-row .track i { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--series-1); min-width: 2px; }
.bar-row strong { font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }

/* Charts */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font); font-size: 11px; fill: var(--text-3); font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--chart-axis); stroke-width: 1; }
.chart .crosshair { stroke: var(--chart-axis); stroke-width: 1; }
.chart-tip { position: absolute; z-index: 5; pointer-events: none; min-width: 120px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-md); font-size: 12.5px; transform: translate(-50%, calc(-100% - 12px)); white-space: nowrap; }
.chart-tip b { display: block; font-size: 11.5px; font-weight: 600; color: var(--text-3); margin-bottom: 4px; }
.chart-tip div { display: flex; align-items: center; gap: 8px; }
.chart-tip i { width: 12px; height: 2px; border-radius: 2px; flex: none; }
.chart-tip strong { font-weight: 700; color: var(--text); }
.chart-tip span { color: var(--text-2); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.chart-table { margin-top: 10px; font-size: 12.5px; }
.chart-table summary { cursor: pointer; color: var(--text-3); font-weight: 600; width: fit-content; }
.chart-table table { margin-top: 8px; }
.chart-table th, .chart-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: right; font-variant-numeric: tabular-nums; }
.chart-table th:first-child, .chart-table td:first-child { text-align: left; }
.chart-table th { color: var(--text-3); font-weight: 600; }

/* Kanban */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(248px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 10px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; align-items: start; }
.kanban-col { display: grid; gap: 10px; padding: 12px; border-radius: var(--radius-lg); scroll-snap-align: start; min-width: 0; align-content: start; background: linear-gradient(180deg, color-mix(in srgb, var(--tone, var(--neutral)) 11%, var(--surface-3)), var(--surface-3) 150px); border: 1px solid color-mix(in srgb, var(--tone, var(--neutral)) 14%, transparent); transition: border-color .15s ease, box-shadow .15s ease; }
.kanban-col.is-over { border-color: var(--tone, var(--brand)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--tone, var(--brand)) 14%, transparent); }
.kanban-head { display: flex; align-items: center; gap: 9px; padding: 4px 4px 6px; font-size: 13px; font-weight: 760; letter-spacing: -.005em; }
.kanban-head i { width: 9px; height: 9px; border-radius: 50%; background: linear-gradient(145deg, var(--tone-1, var(--neutral-1)), var(--tone-2, var(--neutral-2))); box-shadow: 0 0 0 4px color-mix(in srgb, var(--tone, var(--neutral)) 16%, transparent); flex: none; }
.kanban-head b { margin-left: auto; min-width: 24px; padding: 0 8px; border-radius: 999px; background: var(--surface); color: var(--tone, var(--text-2)); font-size: 11.5px; line-height: 22px; text-align: center; font-weight: 800; box-shadow: var(--shadow-xs); }
.kanban-head small { color: var(--text-3); font-weight: 600; font-size: 12px; }
.kanban-cards { display: grid; gap: 9px; min-height: 40px; align-content: start; }
.kanban-card { display: grid; gap: 9px; padding: 13px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-xs); min-width: 0; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.kanban-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--tone, var(--brand)) 34%, var(--border)); box-shadow: 0 14px 30px color-mix(in srgb, var(--tone, var(--brand)) 13%, transparent); }
.kanban-card[draggable="true"] { cursor: grab; }
.kanban-card.is-dragging { opacity: .45; transform: rotate(1.2deg); }
.kanban-card .kc-top { display: flex; align-items: flex-start; gap: 8px; }
.kanban-card .kc-top strong { flex: 1; min-width: 0; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; letter-spacing: -.008em; }
.kanban-card .kc-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.kanban-card .kc-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--text-3); font-size: 12.5px; }
.kanban-card.is-done strong { text-decoration: line-through; color: var(--text-3); }
.kanban-empty { padding: 18px 8px; text-align: center; color: var(--text-3); font-size: 12.5px; border: 1px dashed color-mix(in srgb, var(--tone, var(--neutral)) 30%, var(--border-strong)); border-radius: 12px; }

/* ------------------------------------------------------------------ 5. Modules */


/* Patient profile */
.profile-hero { display: flex; align-items: center; gap: 20px; padding: 24px 22px 20px; flex-wrap: wrap; background: radial-gradient(520px 200px at 0% 0%, color-mix(in srgb, var(--brand) 10%, transparent), transparent 70%); }
.profile-hero .who { flex: 1; min-width: 220px; display: grid; gap: 6px; }
.profile-hero .who h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.profile-hero .contact { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--text-2); font-size: 13.5px; }
.profile-hero .contact span, .profile-hero .contact a { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.profile-hero .contact a:hover { color: var(--brand); }
.profile-hero .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.balance { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
.balance > div { padding: 18px 20px; border-right: 1px solid var(--border); display: grid; gap: 4px; min-width: 0; background: linear-gradient(180deg, color-mix(in srgb, var(--blue) 6%, transparent), transparent 70%); }
.balance > .is-clear { background: linear-gradient(180deg, color-mix(in srgb, var(--green) 8%, transparent), transparent 70%); }
.balance > .is-due { background: linear-gradient(180deg, color-mix(in srgb, var(--amber) 10%, transparent), transparent 70%); }
.balance > div:last-child { border-right: 0; }
.balance span { font-size: 10.5px; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); }
.balance strong { font-size: 26px; font-weight: 740; letter-spacing: -.035em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.balance .is-due strong { color: var(--amber); }
.balance .is-clear strong { color: var(--green); }
.package-row { display: grid; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.package-row:last-child { border-bottom: 0; }
.package-row .top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.package-row .figures { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 13px; color: var(--text-2); }
.package-row .figures b { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }

/* Photo gallery */
.gallery-group { display: grid; gap: 12px; padding: 18px; border-bottom: 1px solid var(--border); }
.gallery-group:last-child { border-bottom: 0; }
.gallery-group > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.photo { position: relative; border-radius: 16px; overflow: hidden; background: var(--surface-3); border: 1px solid var(--border); aspect-ratio: 4 / 3; box-shadow: var(--shadow-xs); transition: transform .22s ease, box-shadow .22s ease; }
.photo:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.photo button.open { display: block; width: 100%; height: 100%; }
.photo img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s ease; }
.photo:hover img { transform: scale(1.04); }
.photo figcaption { position: absolute; inset: auto 0 0 0; padding: 22px 10px 8px; background: linear-gradient(transparent, rgba(4, 16, 18, .78)); color: #fff; font-size: 12px; line-height: 1.3; pointer-events: none; }
.photo figcaption b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo .icon-btn.photo-delete { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; background: rgba(4, 16, 18, .6); color: #fff; border-radius: 8px; }
.photo .icon-btn.photo-delete:hover { background: var(--red); color: #fff; }
.compare { position: relative; border-radius: 18px; overflow: hidden; background: #0b1213; aspect-ratio: 4 / 3; max-height: 520px; margin: 0 auto; width: 100%; --pos: 50%; user-select: none; }
.compare img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.compare img.top { clip-path: inset(0 calc(100% - var(--pos)) 0 0); }
.compare .divider { position: absolute; top: 0; bottom: 0; left: var(--pos); width: 2px; background: #fff; transform: translateX(-1px); pointer-events: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, .15); }
.compare .divider::after { content: ""; position: absolute; top: 50%; left: 50%; width: 34px; height: 34px; border-radius: 50%; background: #fff; transform: translate(-50%, -50%); box-shadow: 0 2px 8px rgba(0, 0, 0, .35); }
.compare input[type="range"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: ew-resize; margin: 0; }
.compare .tag { position: absolute; top: 12px; padding: 4px 10px; border-radius: 999px; background: rgba(4, 16, 18, .66); color: #fff; font-size: 11.5px; font-weight: 650; letter-spacing: .04em; pointer-events: none; }
.compare .tag.left { left: 12px; }
.compare .tag.right { right: 12px; }
.lightbox { width: 100vw; height: 100dvh; margin: 0; }
.lightbox::backdrop { background: rgba(4, 12, 14, .92); }
.lightbox-inner { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; color: #fff; }
.lightbox-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.lightbox-bar .icon-btn { color: #fff; }
.lightbox-bar .icon-btn:hover { background: rgba(255, 255, 255, .14); }
.lightbox-stage { display: grid; place-items: center; min-height: 0; padding: 0 12px; position: relative; }
.lightbox-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; background: rgba(255, 255, 255, .14); color: #fff; display: grid; place-items: center; }
.lightbox-nav:hover { background: rgba(255, 255, 255, .26); }
.lightbox-nav.prev { left: 12px; }
.lightbox-nav.next { right: 12px; }
.lightbox-caption { padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); text-align: center; font-size: 13.5px; color: rgba(255, 255, 255, .84); }

/* Scheduler */
.scheduler-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.scheduler-bar .date-nav { display: flex; align-items: center; gap: 6px; min-width: 0; flex-wrap: wrap; }
.scheduler-bar .date-nav h2 { margin-left: 6px; }
.scheduler-bar .date-nav small { color: var(--text-3); font-weight: 500; font-size: 13px; }
.day-strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(64px, 1fr); gap: 6px; padding: 12px 18px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.day-strip::-webkit-scrollbar { display: none; }
.day-strip a { display: grid; justify-items: center; gap: 1px; padding: 9px 4px; border-radius: 14px; border: 1px solid transparent; color: var(--text-2); transition: background .15s ease, transform .15s ease; }
.day-strip a:hover { background: var(--surface-3); }
.day-strip a small { font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.day-strip a strong { font-size: 17px; font-weight: 700; color: var(--text); }
.day-strip a em { font-style: normal; font-size: 11px; color: var(--text-3); }
.day-strip a.is-today strong { color: var(--brand); }
.day-strip a.is-active { background: var(--brand-gradient); border-color: transparent; box-shadow: 0 10px 22px rgba(8, 143, 111, .26); }
.day-strip a.is-active small, .day-strip a.is-active strong, .day-strip a.is-active em { color: #fff; }
.day-grid { display: grid; grid-template-columns: 56px repeat(var(--cols, 3), minmax(160px, 1fr)); overflow-x: auto; }
.day-grid .head { position: sticky; top: 0; z-index: 2; padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; min-width: 0; }
.day-grid .head:first-child { border-left: 0; }
.day-grid .head span.txt { display: grid; min-width: 0; line-height: 1.25; }
.day-grid .head small { color: var(--text-3); font-weight: 500; font-size: 12px; }
.day-grid .hour { padding: 8px 8px 0 0; text-align: right; font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; border-bottom: 1px solid var(--border); min-height: 64px; }
.day-grid .slot { border-left: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 4px; display: grid; gap: 4px; align-content: start; min-height: 64px; min-width: 0; }
.event { display: grid; gap: 2px; padding: 9px 11px; border-radius: 12px; background: linear-gradient(135deg, var(--tone-bg), color-mix(in srgb, var(--tone-bg) 55%, var(--surface))); border-left: 3px solid var(--tone); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 10%, transparent); transition: transform .15s ease, box-shadow .15s ease; text-align: left; width: 100%; min-width: 0; font-size: 12.5px; line-height: 1.3; }
.event:hover { transform: translateY(-1px); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 22%, transparent), 0 8px 18px color-mix(in srgb, var(--tone) 14%, transparent); }
.event .top { display: flex; align-items: center; justify-content: space-between; gap: 2px 6px; flex-wrap: wrap; color: var(--tone); font-weight: 700; font-size: 11.5px; white-space: nowrap; }
.event strong { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.event small { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(112px, 1fr)); overflow-x: auto; }
.cols-main:has(.week-grid) { grid-template-columns: minmax(0, 1fr); }
.week-grid > section { border-left: 1px solid var(--border); min-width: 0; }
.week-grid > section:first-child { border-left: 0; }
.week-grid header { padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); display: flex; align-items: baseline; gap: 8px; }
.week-grid header small { font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.week-grid header strong { font-size: 15px; }
.week-grid header.is-today strong { color: var(--brand); }
.week-grid .events { display: grid; gap: 6px; padding: 8px; align-content: start; min-height: 180px; }
.week-grid .free { color: var(--text-3); font-size: 12.5px; text-align: center; padding: 16px 0; }
.agenda-day { padding: 10px 18px 6px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.agenda-row { display: grid; grid-template-columns: 64px minmax(0, 1.3fr) minmax(0, 1.2fr) minmax(0, 1fr) auto auto; gap: 14px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.agenda-row:hover { background: var(--surface-2); }
.agenda-row time { font-weight: 700; font-variant-numeric: tabular-nums; }
.agenda-row .cell { display: grid; min-width: 0; line-height: 1.3; }
.agenda-row .cell strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda-row .cell small { color: var(--text-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.slot-add { display: grid; place-items: center; height: 100%; min-height: 54px; border-radius: 8px; color: var(--text-3); opacity: 0; transition: opacity .15s ease, background .15s ease; }
.slot:hover .slot-add, .slot-add:focus-visible { opacity: 1; background: var(--surface-3); }
button.agenda-row { width: 100%; text-align: left; }
.only-phone { display: none; }

/* Procedures */
.checklist { display: grid; }
.checklist label { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 14px; }
.checklist label:last-of-type { border-bottom: 0; }
.checklist label:hover { background: var(--surface-2); }
.checklist input { width: 18px; height: 18px; accent-color: var(--brand); flex: none; margin: 0; }
.checklist input:checked + span { color: var(--text-3); text-decoration: line-through; }
.steps { display: flex; gap: 6px; flex-wrap: wrap; }
.step { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border-radius: 999px; background: var(--surface-3); color: var(--text-3); font-size: 12.5px; font-weight: 600; }
.step.is-done { background: var(--green-bg); color: var(--green); }
.step.is-current { background: var(--brand-gradient); color: #fff; box-shadow: 0 8px 18px rgba(8, 143, 111, .24); }
.ring { --value: 0; display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; background: conic-gradient(var(--green-1) 0, var(--green-2) calc(var(--value) * 1%), var(--surface-3) 0); flex: none; box-shadow: 0 6px 14px rgba(8, 143, 111, .12); }
.ring span { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--surface); font-size: 12px; font-weight: 700; }

/* Package cards */
.package-card { position: relative; display: grid; gap: 13px; padding: 20px; align-content: start; transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease; }
.package-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--brand-gradient); }
.package-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--brand) 30%, var(--border)); box-shadow: 0 20px 44px rgba(8, 143, 111, .13); }
.package-card .price { width: fit-content; font-size: 28px; font-weight: 760; letter-spacing: -.04em; line-height: 1.1; background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.package-card ul { display: grid; gap: 6px; font-size: 13px; color: var(--text-2); }
.package-card li { display: flex; gap: 8px; align-items: flex-start; }
.package-card li .icon { color: var(--brand); margin-top: 2px; }
.package-card footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-3); margin-top: auto; }

/* Settings */
.settings-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; align-items: start; }
.settings-nav { display: grid; gap: 2px; padding: 8px; position: sticky; top: calc(var(--topbar-h) + 16px); }
.settings-nav a { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 12px; border-radius: var(--radius); color: var(--text-2); font-weight: 600; font-size: 13.5px; }
.settings-nav a:hover { background: var(--surface-3); color: var(--text); }
.settings-nav a.is-active { background: var(--brand-gradient); color: #fff; box-shadow: 0 8px 18px rgba(8, 143, 111, .22); }
.matrix th, .matrix td { text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.matrix .yes { color: var(--green); }
.matrix .no { color: var(--border-strong); }
.matrix .group-row td { background: var(--surface-2); font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); padding: 8px 16px; }

/* Auth, installer and error pages */
.auth { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--surface); }
.auth-aside { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; padding: 40px 48px; color: #fff; background: var(--side-bg); }
.auth-aside::after { content: ""; position: absolute; right: -180px; bottom: -180px; width: 520px; height: 520px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .08); box-shadow: 0 0 0 80px rgba(255, 255, 255, .025), 0 0 0 160px rgba(255, 255, 255, .02); pointer-events: none; }
.auth-aside .brand { display: flex; align-items: center; gap: 12px; }
.auth-aside h1 { font-size: clamp(28px, 3.2vw, 42px); line-height: 1.12; letter-spacing: -.03em; max-width: 520px; }
.auth-aside h1 em { font-style: normal; color: var(--side-accent); }
.auth-aside p { color: rgba(255, 255, 255, .72); max-width: 460px; margin-top: 14px; font-size: 15.5px; }
.auth-points { display: grid; gap: 12px; margin-top: 28px; position: relative; z-index: 1; }
.auth-points li { display: flex; align-items: center; gap: 12px; color: rgba(255, 255, 255, .86); font-size: 14px; }
.auth-points .icon { color: var(--side-accent); }
.auth-aside footer { position: relative; z-index: 1; font-size: 12.5px; color: rgba(255, 255, 255, .5); }
.auth-main { display: grid; place-items: center; padding: 32px 24px; }
.auth-card { width: min(400px, 100%); display: grid; gap: 22px; }
.auth-card h2 { font-size: 24px; letter-spacing: -.02em; }
.auth-card .brand { display: none; align-items: center; gap: 10px; }
.auth-card .brand strong { font-size: 16px; font-weight: 750; letter-spacing: .02em; }
.auth-card .brand strong span { color: var(--brand); }
.auth-form { display: grid; gap: 16px; }
.auth-note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); color: var(--text-2); font-size: 12.5px; }
.auth-note .icon { color: var(--brand); margin-top: 1px; }
.demo-box { display: grid; gap: 4px; padding: 12px 14px; border: 1px dashed var(--border-strong); border-radius: 12px; font-size: 13px; color: var(--text-2); }
.demo-box code { font: 600 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text); }
.center-page { min-height: 100dvh; display: grid; place-items: center; padding: 32px 20px; }
.center-card { width: min(520px, 100%); display: grid; gap: 14px; justify-items: center; text-align: center; }
.error-code { width: fit-content; padding: .06em .08em .06em 0; font-size: 96px; font-weight: 820; letter-spacing: -.04em; line-height: 1.1; background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.installer { width: min(760px, 100%); margin: 0 auto; padding: 40px 20px 64px; display: grid; gap: 20px; }
.requirements { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.requirement { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--green-bg); color: var(--green); font-size: 13px; font-weight: 600; }
.requirement.failed { background: var(--red-bg); color: var(--red); }

/* ---------------------------------------------------------------- 6. Responsive */
.show-mobile { display: none !important; }

@media (max-width: 1500px) {
    .stats.six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .cols-2.stack-lg { grid-template-columns: minmax(0, 1fr); }
    /* Settings: the section list becomes a bar above the content, which gets the full width. */
    .settings-layout { grid-template-columns: minmax(0, 1fr); }
    .settings-nav { position: static; grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; scrollbar-width: none; }
    .settings-nav::-webkit-scrollbar { display: none; }
}

@media (max-width: 1400px) {
    .preview-chip { display: none; }
    .card > .tabs .tab > .icon { display: none; }
    .cols-main { grid-template-columns: minmax(0, 1fr) 320px; }
    .table th, .table td { padding-left: 13px; padding-right: 13px; }
}

@media (max-width: 1320px) {
    .cols-main { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1240px) {
    :root { --gutter: 20px; }
    .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .search-trigger { width: 200px; }
    .topbar-title .org, .topbar-title .sep { display: none; }
    .table th, .table td { padding-left: 11px; padding-right: 11px; }
}

/* Between the phone layout (stacked cards) and a wide screen, a table drops its least
   important columns instead of scrolling sideways: drop-N at 1240px, drop2-N at 1100px. */
@media (min-width: 641px) and (max-width: 1240px) {
    .table.drop-3 :is(th, td):nth-child(3), .table.drop-4 :is(th, td):nth-child(4), .table.drop-5 :is(th, td):nth-child(5), .table.drop-6 :is(th, td):nth-child(6), .table.drop-7 :is(th, td):nth-child(7) { display: none; }
}
@media (min-width: 641px) and (max-width: 1100px) {
    /* Two text buttons side by side do not fit a small laptop: they stack. */
    .table td.cell-actions.stack-narrow { white-space: normal; }
    .table td.cell-actions.stack-narrow > * { margin: 2px 0; }
    .table.drop2-2 :is(th, td):nth-child(2), .table.drop2-3 :is(th, td):nth-child(3), .table.drop2-4 :is(th, td):nth-child(4), .table.drop2-5 :is(th, td):nth-child(5), .table.drop2-6 :is(th, td):nth-child(6), .table.drop2-7 :is(th, td):nth-child(7) { display: none; }
}

@media (max-width: 1100px) {
    .week-grid { grid-template-columns: minmax(0, 1fr); overflow-x: visible; }
    .week-grid > section { border-left: 0; border-top: 1px solid var(--border); }
    .week-grid > section:first-child { border-top: 0; }
    .week-grid .events { min-height: 0; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
    .week-grid .free { text-align: left; padding: 6px 4px; }
    .profile-trigger span.who { display: none; }
    .table td .person { min-width: 148px; }
    .profile-trigger { padding: 4px; }
    .search-trigger { width: 170px; }
}

@media (max-width: 960px) {
    .sidebar { transform: translateX(-100%); width: min(288px, 86vw); box-shadow: var(--shadow-lg); }
    .sidebar-collapsed { --sidebar-w: 264px; }
    .sidebar-collapsed .brand-word, .sidebar-collapsed .sidebar-branch span { display: grid; }
    .sidebar-collapsed .nav-item > span, .sidebar-collapsed .nav-label, .sidebar-collapsed .sidebar-foot b { display: revert; }
    .sidebar-collapsed .nav-item > span { flex: 1; }
    .sidebar-collapsed .sidebar-brand { padding: 0 18px; justify-content: flex-start; }
    .sidebar-collapsed .sidebar-branch { justify-content: flex-start; padding: 10px 12px; }
    .sidebar-collapsed .nav-item { justify-content: flex-start; padding: 0 10px; }
    .sidebar-collapsed .nav-count { position: static; min-width: 22px; padding: 1px 7px; font-size: 11.5px; line-height: inherit; }
    .sidebar-collapsed .sidebar-foot { justify-content: space-between; }
    .sidebar-open .sidebar { transform: none; }
    .sidebar-open .sidebar-overlay { opacity: 1; pointer-events: auto; }
    .sidebar .sidebar-close { display: inline-grid; }
    .workspace { margin-left: 0; }
    .hide-mobile { display: none !important; }
    .show-mobile { display: inline-grid !important; }
    .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .auth { grid-template-columns: minmax(0, 1fr); }
    .auth-aside { display: none; }
    .auth-card .brand { display: flex; }
    .agenda-row { grid-template-columns: 56px minmax(0, 1fr) auto; }
    .agenda-row .cell.optional { display: none; }
}

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

@media (max-width: 640px) {
    :root { --gutter: 14px; --topbar-h: 56px; }
    body { font-size: 14px; }
    h1 { font-size: 25px; }
    .page { padding-top: 18px; gap: 16px; padding-bottom: calc(44px + env(safe-area-inset-bottom)); }
    .topbar { gap: 6px; }
    .topbar-actions { gap: 4px; }
    .topbar-title strong { font-size: 14px; }
    .topbar-title .org, .topbar-title .sep { display: none; }
    .profile-trigger { padding: 2px; }
    .page-head { align-items: stretch; }
    .page-head .actions { width: 100%; }
    .page-head .actions > .btn { flex: 1 1 auto; }
    .cols-2, .cols-3, .cols-4 { grid-template-columns: minmax(0, 1fr); }
    .stats, .stats.six { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .stat { min-height: 124px; padding: 14px; gap: 6px; }
    .stat-value { font-size: 24px; }
    .stat-icon { width: 30px; height: 30px; border-radius: 10px; }
    .stat-label { font-size: 9.5px; letter-spacing: .08em; }
    .card > .tabs { margin: 0 12px 12px; max-width: calc(100% - 24px); }
    .tabs { width: auto; }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .input, .select, .textarea { font-size: 16px; height: 46px; }
    .textarea { height: auto; }
    .btn { height: 44px; }
    .btn-sm { height: 36px; }
    .card-head, .card-body { padding: 14px; }
    .card-foot { padding: 12px 14px; }
    .balance { grid-template-columns: minmax(0, 1fr); }
    .balance > div { border-right: 0; border-bottom: 1px solid var(--border); padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
    .balance > div:last-child { border-bottom: 0; }
    .balance strong { font-size: 20px; }
    .toolbar .search { flex-basis: 100%; max-width: none; }
    .toolbar .select { flex: 1 1 140px; }
    .list > *, .timeline, .definition > div, .package-row, .gallery-group, .scheduler-bar, .day-strip, .agenda-row, .agenda-day, .checklist label { padding-left: 14px; padding-right: 14px; }
    .profile-hero { padding: 16px 14px; gap: 14px; }
    .profile-hero .actions { width: 100%; }
    .profile-hero .actions .btn { flex: 1 1 auto; }
    .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .kanban { grid-auto-columns: 84vw; margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter); scroll-snap-type: x mandatory; }
    .toast-stack { right: 16px; left: 16px; width: auto; }
    .bar-row { grid-template-columns: minmax(70px, 110px) minmax(0, 1fr) auto; gap: 8px; }

    .hide-phone { display: none !important; }
    .only-phone { display: block; }

    /* Dialogs become bottom sheets. */
    .modal, .modal.modal-lg, .modal.modal-sm { width: 100vw; margin: auto 0 0 0; }
    .modal[open] { animation: sheet .22s ease; }
    .modal-card { max-height: 92dvh; border-radius: 20px 20px 0 0; border-width: 1px 0 0 0; }
    .modal-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
    .modal-foot .btn { flex: 1 1 auto; }
    .palette { margin: 0; width: 100vw; height: 100dvh; }
    .palette .modal-card { height: 100%; max-height: none; border-radius: 0; border: 0; }
    .palette-results { max-height: none; flex: 1; }
    .palette-foot { display: none; }

    .table.compact th, .table.compact td, .matrix th, .matrix td { padding-left: 6px; padding-right: 6px; font-size: 13px; }
    .table.compact th, .matrix th { font-size: 9.5px; letter-spacing: .02em; }
    .matrix th, .matrix td { padding-left: 4px; padding-right: 4px; }
    .matrix th { letter-spacing: 0; }
    .matrix th:first-child, .matrix td:first-child { padding-left: 12px; }
    .table.compact th:first-child, .table.compact td:first-child, .matrix th:first-child, .matrix td:first-child { padding-left: 14px; }
    .table.compact td .person { min-width: 0; }
    .table.compact td .person .avatar, .matrix th .cell-sub { display: none; }
    .table.compact td .person strong { white-space: normal; }
    .matrix .group-row td { padding: 8px 14px; }

    /* Tables turn into stacked cards so nothing scrolls sideways. */
    .table.responsive thead { display: none; }
    .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
    .table.responsive tr { padding: 12px 14px; border-bottom: 1px solid var(--border); position: relative; }
    .table.responsive tbody tr:last-child { border-bottom: 0; }
    .table.responsive td { padding: 3px 0; border: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; text-align: right; min-width: 0; }
    .table.responsive td::before { content: attr(data-label); color: var(--text-3); font-size: 12.5px; font-weight: 500; text-align: left; flex: none; }
    .table.responsive td.cell-primary { display: block; text-align: left; padding: 0 44px 6px 0; }
    .table.responsive td.cell-primary::before { display: none; }
    .table.responsive td.cell-actions { position: absolute; top: 8px; right: 8px; width: auto; padding: 0; }
    .table.responsive td.cell-primary:has(~ td.cell-actions > :nth-child(2)) { padding-right: 82px; }
    /* Text buttons (Yanıtla, Onayla, Düzenle…) do not fit beside the title: they get the last line. */
    .table.responsive td.cell-actions:has(.btn) { position: static; display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 8px; padding: 8px 0 2px; text-align: left; }
    .table.responsive td.cell-primary:has(~ td.cell-actions .btn) { padding-right: 0; }
    .table.responsive td.cell-actions::before { display: none; }
    .table.responsive td:empty { display: none; }
    .table.responsive td.cell-full { display: block; text-align: left; }
    .table.responsive td.cell-full::before { display: block; margin-bottom: 2px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

@media print {
    .sidebar, .topbar, .toast-stack, .page-head .actions, .toolbar, .cell-actions { display: none !important; }
    .workspace { margin: 0; }
    .card { box-shadow: none; }
    body { background: #fff; }
}
