/* ============================================================
   OpenBudget CRM — Material 3 shell
   Google-style app frame: collapsible left rail + top app bar.
   Loaded AFTER app.css/voting.css so it overrides the older
   purple theme's tokens without those files being rewritten.
   ============================================================ */

:root {
    /* Google Material 3 palette (light) */
    --m3-primary: #0b57d0;
    --m3-primary-hover: #0842a0;
    --m3-on-primary: #fff;
    --m3-primary-container: #d3e3fd;
    --m3-on-primary-container: #041e49;

    --m3-surface: #fff;
    --m3-surface-1: #f8fafd;
    --m3-surface-2: #f0f4f9;
    --m3-surface-3: #e9eef6;
    --m3-surface-variant: #e1e3e1;

    --m3-on-surface: #1f1f1f;
    --m3-on-surface-variant: #444746;
    --m3-outline: #c4c7c5;
    --m3-outline-variant: #e3e3e3;

    --m3-success: #146c2e;
    --m3-success-container: #e6f4ea;
    --m3-warning: #a05e03;
    --m3-warning-container: #fef7e0;
    --m3-error: #b3261e;
    --m3-error-container: #fce8e6;

    --m3-shadow-1: 0 1px 2px rgba(60, 64, 67, .3), 0 1px 3px 1px rgba(60, 64, 67, .15);
    --m3-shadow-2: 0 1px 2px rgba(60, 64, 67, .3), 0 2px 6px 2px rgba(60, 64, 67, .15);

    --rail-width: 264px;
    --rail-width-collapsed: 76px;
    --appbar-height: 64px;

    /* Warm accents. The blue alone read as cold and clinical, so status and
       category colours pull from a warmer set that still sits beside it. */
    --accent-amber: #b06000;
    --accent-amber-container: #ffedd4;
    --accent-teal: #00696e;
    --accent-teal-container: #cdf0f2;
    --accent-violet: #6a4bab;
    --accent-violet-container: #eae0ff;
    --accent-rose: #a3335c;
    --accent-rose-container: #ffe0eb;

    /* Remap the legacy tokens the older stylesheets are written against, so
       every existing card/button/table adopts the Google palette without
       those rules being touched. */
    --ink: var(--m3-on-surface);
    --muted: var(--m3-on-surface-variant);
    --line: var(--m3-outline-variant);
    --bg: var(--m3-surface-1);
    --card: var(--m3-surface);
    --purple: var(--m3-primary);
    --purple2: #1b6ef3;
    --purple-soft: var(--m3-primary-container);
    --blue: var(--m3-primary);
    --green: var(--m3-success);
    --red: var(--m3-error);
    --shadow: var(--m3-shadow-1);
}

body {
    font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
    background: var(--m3-surface-1);
}
/* Arial everywhere, including the places the older stylesheets hard-coded a
   display or mono face of their own. */
.mono, .overline, code, pre,
.stat-tile span, .data-table th, .badge, .rail-item, .btn {
    font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
}

.icon {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    stroke-width: 2;
}
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

/* ---------- App frame ---------- */

.app-shell {
    display: grid;
    grid-template-columns: var(--rail-width) minmax(0, 1fr);
    min-height: 100vh;
    transition: grid-template-columns .2s cubic-bezier(.2, 0, 0, 1);
}
.app-shell.rail-collapsed { grid-template-columns: var(--rail-width-collapsed) minmax(0, 1fr); }

/* ---------- Left navigation rail ---------- */

.rail {
    position: sticky;
    top: 0;
    display: flex;
    height: 100vh;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    background: var(--m3-surface-1);
    overflow: hidden;
}

.rail-head {
    display: flex;
    align-items: center;
    gap: 4px;
    height: calc(var(--appbar-height) - 12px);
    padding: 0 4px;
}
.rail-toggle {
    display: grid;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: none;
    color: var(--m3-on-surface-variant);
    cursor: pointer;
}
.rail-toggle:hover { background: var(--m3-surface-3); }

.rail-brand {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 10px;
    padding-left: 4px;
    color: var(--m3-on-surface);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -.2px;
    white-space: nowrap;
}
.rail-brand-mark {
    display: grid;
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 9px;
    background: var(--m3-primary);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
}

.rail-nav {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    overflow-x: hidden;
    margin-top: 8px;
    /* Scrollbar only on hover, Gmail-style — a permanent one crowds a 76px rail. */
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}
.rail-nav:hover { scrollbar-color: var(--m3-outline) transparent; }

.rail-section {
    padding: 14px 16px 6px;
    color: var(--m3-on-surface-variant);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .8px;
    text-transform: uppercase;
    white-space: nowrap;
}

.rail-item {
    display: flex;
    align-items: center;
    gap: 14px;
    height: 44px;
    padding: 0 16px;
    border-radius: 999px;
    color: var(--m3-on-surface-variant);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}
.rail-item:hover { background: var(--m3-surface-3); color: var(--m3-on-surface); }
.rail-item.active {
    background: var(--m3-primary-container);
    color: var(--m3-on-primary-container);
    font-weight: 600;
}
.rail-item.active .icon { stroke-width: 2.2; }
.rail-item .icon { flex: 0 0 auto; }
.rail-label { overflow: hidden; text-overflow: ellipsis; }

.rail-foot {
    padding-top: 8px;
    border-top: 1px solid var(--m3-outline-variant);
}

/* Collapsed rail: labels are hidden but the DOM keeps them for screen readers
   and for the width transition to animate against. */
.rail-collapsed .rail-label,
.rail-collapsed .rail-section,
.rail-collapsed .rail-brand > span:not(.rail-brand-mark) { display: none; }
.rail-collapsed .rail-item { justify-content: center; padding: 0; }
.rail-collapsed .rail-brand { justify-content: center; padding: 0; }
.rail-collapsed .rail-head { flex-direction: column-reverse; height: auto; gap: 8px; }

/* ---------- Top app bar ---------- */

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

.appbar {
    position: sticky;
    z-index: 20;
    top: 0;
    display: flex;
    height: var(--appbar-height);
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 0 24px;
    background: var(--m3-surface-1);
}
.appbar-title { display: grid; gap: 1px; min-width: 0; }
.appbar-title b { font-size: 17px; font-weight: 600; letter-spacing: -.2px; }
.appbar-title span { color: var(--m3-on-surface-variant); font-size: 12px; }

.appbar-actions { display: flex; align-items: center; gap: 8px; }

.icon-button {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: none;
    color: var(--m3-on-surface-variant);
    cursor: pointer;
}
.icon-button:hover { background: var(--m3-surface-3); color: var(--m3-on-surface); }

.account-chip {
    display: flex;
    align-items: center;
    gap: 9px;
    height: 40px;
    padding: 0 14px 0 5px;
    border-radius: 999px;
    color: var(--m3-on-surface-variant);
    font-size: 13px;
    font-weight: 500;
}
.account-chip:hover { background: var(--m3-surface-3); color: var(--m3-on-surface); }
.account-avatar {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border-radius: 50%;
    background: var(--m3-primary);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
}

.appbar-actions form { display: flex; margin: 0; }

/* ---------- Content surface ---------- */

.app-content {
    flex: 1;
    padding: 8px 24px 40px;
}
.content-surface {
    min-height: calc(100vh - var(--appbar-height) - 48px);
    padding: 28px;
    border-radius: 16px;
    background: var(--m3-surface);
}

/* The old centred wrapper is now the full content column. */
.page-shell { width: 100%; margin: 0; padding: 0; }

/* ---------- Legacy component restyling (Material 3) ---------- */

.page-header h1 { font-size: 26px; font-weight: 600; letter-spacing: -.4px; }
.page-header p { font-size: 13px; }

.stat-tile {
    padding: 18px;
    border: 1px solid var(--m3-outline-variant);
    border-radius: 14px;
    box-shadow: none;
}
.stat-tile span { font-family: inherit; font-size: 12px; font-weight: 500; letter-spacing: 0; text-transform: none; }
.stat-tile b { font-size: 26px; font-weight: 500; letter-spacing: -.5px; }

/* Stat tile with a leading icon chip — the icon carries the category so the
   label can drop to sentence case and stop shouting. */
.stat-tile.with-icon {
    display: flex;
    align-items: center;
    gap: 14px;
}
.stat-icon {
    display: grid;
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 10px;
    background: var(--m3-primary-container);
    color: var(--m3-on-primary-container);
}
/* The chip was sized for a 24px glyph; at 20px the icon floated in too much
   padding and the tile read as mostly empty box. */
.stat-icon .icon { width: 19px; height: 19px; }
.stat-icon.success { background: var(--m3-success-container); color: var(--m3-success); }
.stat-icon.warning { background: var(--accent-amber-container); color: var(--accent-amber); }
.stat-icon.error { background: var(--m3-error-container); color: var(--m3-error); }
.stat-icon.neutral { background: var(--m3-surface-2); color: var(--m3-on-surface-variant); }
.stat-tile.with-icon > div { display: grid; gap: 1px; min-width: 0; }
.stat-tile.with-icon > div > span {
    /* Long labels wrapped to two lines and pushed the number out of alignment
       across the row; one line with an ellipsis keeps every tile the same shape. */
    overflow: hidden;
    font-size: 12px;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.stat-tile.with-icon b { margin: 0; font-size: 22px; line-height: 1.2; }

.card {
    border: 1px solid var(--m3-outline-variant);
    border-radius: 14px;
    box-shadow: none;
}
.card h2 { font-size: 16px; font-weight: 600; }

/* Card header with icon + optional trailing action, used across pages. */
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}
.card-head > div { display: flex; align-items: center; gap: 11px; }
.card-head h2 { margin: 0; }
.card-head .stat-icon { width: 36px; height: 36px; border-radius: 10px; }

.btn {
    height: 40px;
    padding: 0 22px;
    border-radius: 999px;
    background: var(--m3-primary);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: .1px;
}
.btn:hover { background: var(--m3-primary-hover); box-shadow: var(--m3-shadow-1); transform: none; }
.btn.secondary {
    border: 1px solid var(--m3-outline);
    background: transparent;
    color: var(--m3-primary);
}
.btn.secondary:hover { background: var(--m3-primary-container); box-shadow: none; }
.btn.danger { border: 1px solid var(--m3-outline); background: transparent; color: var(--m3-error); }
.btn.danger:hover { background: var(--m3-error-container); box-shadow: none; }
.btn.small { height: 32px; padding: 0 16px; font-size: 13px; }

.data-table th {
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
    color: var(--m3-on-surface-variant);
}
.data-table td { font-size: 13px; }
.data-table tbody tr:hover { background: var(--m3-surface-1); }
.data-table a { color: var(--m3-primary); font-weight: 500; }

.badge {
    padding: 5px 10px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0;
}
.badge.active, .badge.confirmed, .badge.paid { background: var(--m3-success-container); color: var(--m3-success); }
.badge.inactive, .badge.rejected { background: var(--m3-error-container); color: var(--m3-error); }
.badge.pending { background: var(--m3-warning-container); color: var(--m3-warning); }
.badge.neutral { background: var(--m3-surface-2); color: var(--m3-on-surface-variant); }

.search-input, .form-grid input[type=text], .form-grid input[type=number],
.form-grid textarea, .form-grid select, .field-block input, .field-block textarea {
    border-radius: 8px;
    border-color: var(--m3-outline);
}
.search-input:focus, .form-grid input:focus, .form-grid textarea:focus,
.form-grid select:focus, .field-block input:focus, .field-block textarea:focus {
    border-color: var(--m3-primary);
    box-shadow: 0 0 0 1px var(--m3-primary);
}

.toast {
    border-color: var(--m3-success-container);
    border-radius: 8px;
    background: var(--m3-success-container);
    color: var(--m3-success);
    font-weight: 500;
}
.toast.error { border-color: var(--m3-error-container); background: var(--m3-error-container); color: var(--m3-error); }

.overline { font-family: inherit; font-weight: 600; letter-spacing: .8px; }
.overline.purple { color: var(--m3-primary); }
.mono { font-family: "Roboto Mono", DM Mono, monospace; }

/* ============================================================
   Richer tables
   The default was a plain grid of text. These rules give every
   row a coloured identity avatar, a warmer surface, and enough
   vertical rhythm to scan quickly.
   ============================================================ */

.card > .table-scroll,
.card > .toolbar + .table-scroll {
    margin: 0 -24px;                 /* bleed to the card edge, Gmail-style */
    padding: 0 24px;
}

.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 12px 14px;
    border-bottom: 1px solid var(--m3-outline-variant);
    background: var(--m3-surface);
    font-size: 12px;
    font-weight: 700;
    color: var(--m3-on-surface-variant);
}
.data-table td { padding: 14px; border-bottom: 1px solid var(--m3-surface-3); }
.data-table tbody tr:hover { background: var(--m3-surface-1); }

/* Identity avatar built from the row's own initial. The colour is picked per
   row in the template via .av-1 … .av-6, so the same person keeps the same
   colour across pages instead of the whole column being one flat blue. */
.row-avatar {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 50%;
    background: var(--m3-primary-container);
    color: var(--m3-on-primary-container);
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
}
.av-1 { background: var(--m3-primary-container); color: var(--m3-on-primary-container); }
.av-2 { background: var(--accent-amber-container); color: var(--accent-amber); }
.av-3 { background: var(--accent-teal-container); color: var(--accent-teal); }
.av-4 { background: var(--accent-violet-container); color: var(--accent-violet); }
.av-5 { background: var(--accent-rose-container); color: var(--accent-rose); }
.av-6 { background: var(--m3-success-container); color: var(--m3-success); }

/* Name + secondary line, the shape most rows in this panel actually want. */
.cell-identity { display: flex; align-items: center; gap: 11px; min-width: 0; }
.cell-identity > div { display: grid; gap: 1px; min-width: 0; }
.cell-identity b { font-size: 13px; font-weight: 600; }
.cell-identity small { color: var(--m3-on-surface-variant); font-size: 11px; }

/* Money reads as a figure, not as prose. */
.cell-money { font-size: 14px; font-weight: 700; white-space: nowrap; }
.cell-money.zero { color: var(--m3-on-surface-variant); font-weight: 400; }
.cell-muted { color: var(--m3-on-surface-variant); }

/* Toolbar above a table: title left, search right, with a real divider. */
.toolbar {
    margin: -4px 0 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--m3-outline-variant);
}
.toolbar h2 { font-size: 16px; font-weight: 600; }

/* Wider minimum than the original 180px: with an icon chip and a label beside
   it, a narrower tile forced the label onto two lines. */
.stat-grid { grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 14px; }

/* Stat tiles: a tinted left edge ties the number to its category colour. */
.stat-tile {
    position: relative;
    overflow: hidden;
    padding: 16px 18px;
    background: var(--m3-surface);
}
.stat-tile.with-icon::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 4px;
    background: var(--m3-primary);
}
.stat-tile.with-icon:has(.stat-icon.success)::before { background: var(--m3-success); }
.stat-tile.with-icon:has(.stat-icon.warning)::before { background: var(--accent-amber); }
.stat-tile.with-icon:has(.stat-icon.error)::before { background: var(--m3-error); }
.stat-tile.with-icon:has(.stat-icon.neutral)::before { background: var(--m3-outline); }
.stat-icon.warning { background: var(--accent-amber-container); color: var(--accent-amber); }

/* Empty states deserve more than a line of grey text. */
.empty-state {
    display: grid;
    justify-items: center;
    gap: 6px;
    padding: 56px 24px;
    color: var(--m3-on-surface-variant);
}
.empty-state .icon { width: 40px; height: 40px; color: var(--m3-outline); stroke-width: 1.5; }

/* ============================================================
   Motion & depth
   Material's standard easing throughout: fast, decisive, and
   never bouncy. Every effect here is decorative, so the whole
   block is disabled under prefers-reduced-motion at the end of
   this file.
   ============================================================ */

:root {
    --ease-standard: cubic-bezier(.2, 0, 0, 1);
    --ease-emphasized: cubic-bezier(.05, .7, .1, 1);
    --dur-fast: .15s;
    --dur-base: .25s;
}

/* Page entry: content fades up once per navigation. Kept short — anything
   slower reads as lag rather than polish, which is the opposite of the goal. */
@keyframes page-enter {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}
.content-surface { animation: page-enter var(--dur-base) var(--ease-emphasized) both; }

/* Stat tiles arrive in a short stagger, so a dashboard resolves as a sweep
   instead of a single block appearing. Only the first eight are staggered;
   past that the delay would outlast the page load itself. */
@keyframes tile-enter {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}
.stat-grid > .stat-tile {
    animation: tile-enter .3s var(--ease-emphasized) both;
}
.stat-grid > .stat-tile:nth-child(1) { animation-delay: .02s; }
.stat-grid > .stat-tile:nth-child(2) { animation-delay: .05s; }
.stat-grid > .stat-tile:nth-child(3) { animation-delay: .08s; }
.stat-grid > .stat-tile:nth-child(4) { animation-delay: .11s; }
.stat-grid > .stat-tile:nth-child(5) { animation-delay: .14s; }
.stat-grid > .stat-tile:nth-child(6) { animation-delay: .17s; }
.stat-grid > .stat-tile:nth-child(7) { animation-delay: .20s; }
.stat-grid > .stat-tile:nth-child(8) { animation-delay: .23s; }

/* Hover depth. Cards lift a hair and gain Material's level-2 shadow; the
   border lightening to the primary tone is what makes it read as focus
   rather than as a graphic effect. */
.stat-tile, .card, .kind-card, .template-choice {
    transition: box-shadow var(--dur-base) var(--ease-standard),
                border-color var(--dur-base) var(--ease-standard),
                transform var(--dur-base) var(--ease-standard);
}
.stat-tile:hover {
    border-color: var(--m3-outline);
    box-shadow: var(--m3-shadow-1);
    transform: translateY(-2px);
}
.card:hover { box-shadow: var(--m3-shadow-1); }
.kind-card:hover, .template-choice:hover { transform: translateY(-2px); box-shadow: var(--m3-shadow-1); }

/* Buttons: Material's press response is a quick settle, not a bounce. */
.btn, .primary-button, .icon-button, .rail-item, .filter-tab, .account-chip {
    transition: background-color var(--dur-fast) var(--ease-standard),
                box-shadow var(--dur-fast) var(--ease-standard),
                color var(--dur-fast) var(--ease-standard),
                transform var(--dur-fast) var(--ease-standard);
}
.btn:active, .primary-button:active { transform: scale(.97); }
.icon-button:active, .rail-toggle:active { transform: scale(.92); }

/* Rail items slide their icon a touch on hover — a small, cheap cue that the
   row is interactive, matching how Gmail's own rail behaves. */
.rail-item .icon { transition: transform var(--dur-fast) var(--ease-standard); }
.rail-item:hover .icon { transform: translateX(2px); }
.rail-collapsed .rail-item:hover .icon { transform: scale(1.12); }

/* Table rows: a tinted sweep on hover instead of a hard background flip. */
.data-table tbody tr { transition: background-color var(--dur-fast) var(--ease-standard); }

/* Inputs: the focus ring grows rather than snapping in. */
.search-input, .form-grid input, .form-grid textarea, .form-grid select,
.field-block input, .field-block textarea, .login-card input, .filter-panel input {
    transition: border-color var(--dur-fast) var(--ease-standard),
                box-shadow var(--dur-fast) var(--ease-standard);
}

/* Toasts drop in from the top so a save confirmation is noticed. */
@keyframes toast-enter {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: none; }
}
.toast { animation: toast-enter var(--dur-base) var(--ease-emphasized) both; }

/* Badges and progress bars get a soft pulse only while something is running,
   so motion on the page always means work is actually in flight. */
.sync-progress-bar > i { transition: width .4s var(--ease-standard); }

/* Navigation progress bar. It only appears once a rail link has been clicked,
   and it animates toward — never reaching — 90%, because the real completion
   is the next document replacing this one. A bar that pretended to finish
   would be lying about a page that had not arrived yet. */
@keyframes nav-progress {
    from { width: 0; }
    to   { width: 90%; }
}
body.navigating::before {
    content: "";
    position: fixed;
    z-index: 100;
    top: 0;
    left: 0;
    height: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--m3-primary);
    animation: nav-progress 2.4s var(--ease-emphasized) forwards;
}

/* Marks a secret field that already has a stored value, without ever
   printing the value itself back into the page. */
.field-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--m3-success-container);
    color: var(--m3-success);
    font-size: 10px;
    font-weight: 700;
    vertical-align: middle;
}
.field-status-badge .icon { width: 12px; height: 12px; }

/* ---------- Legacy accent surfaces flattened to Material ---------- */

/* These all shipped as purple gradients; Material uses flat tonal fills. */
.bot-logo, .bot-avatar, .user-avatar, .profile-identity > span {
    background: var(--m3-primary);
    box-shadow: none;
}
.bot-control-card, .template-kind-section { background: var(--m3-surface); }
.step-number, .settings-heading > span, .visual-label b, .point-cards > div > span,
.kind-icon, .template-type-icon, .profile-card-heading > span, .user-cell > span {
    background: var(--m3-primary-container);
    color: var(--m3-on-primary-container);
    font-family: inherit;
    font-weight: 600;
}
/* These chips now hold an inline SVG rather than a text glyph. */
.kind-icon .icon, .template-type-icon .icon, .upload-symbol .icon { width: 20px; height: 20px; }
.upload-symbol { color: var(--m3-primary); }
.bot-logo .icon { width: 26px; height: 26px; }
.sync-progress-bar > i { background: var(--m3-primary); }
.sync-dot.running { background: var(--m3-primary); box-shadow: 0 0 0 4px var(--m3-primary-container); }
.sync-dot.done { background: var(--m3-success); box-shadow: 0 0 0 4px var(--m3-success-container); }
.sync-dot.failed { background: var(--m3-error); box-shadow: 0 0 0 4px var(--m3-error-container); }
.sync-dot.awaiting_captcha, .sync-dot.stopping { background: var(--m3-warning); box-shadow: 0 0 0 4px var(--m3-warning-container); }

.filter-tab { border-radius: 999px; font-family: inherit; font-size: 13px; font-weight: 500; }
.filter-tab.active { background: var(--m3-primary-container); color: var(--m3-on-primary-container); }
.filter-panel, .optional-panel, .sync-meta > div, .password-rules { border-radius: 12px; background: var(--m3-surface-1); }
.kind-card, .template-choice { border-radius: 12px; border-color: var(--m3-outline-variant); }
.kind-card:hover, .template-choice:hover { border-color: var(--m3-primary); transform: none; box-shadow: none; }
.kind-card.selected, .template-choice.selected {
    border-color: var(--m3-primary);
    background: var(--m3-surface-1);
    box-shadow: inset 0 0 0 1px var(--m3-primary);
}
.setting-toggle { border-radius: 12px; background: var(--m3-surface-1); }
.setting-toggle input:checked + i { background: var(--m3-primary); }
.settings-savebar {
    border-color: var(--m3-outline-variant);
    border-radius: 14px;
    background: var(--m3-surface);
    box-shadow: var(--m3-shadow-2);
}
.sync-captcha { border-color: var(--m3-outline-variant); border-radius: 12px; background: var(--m3-warning-container); }
.sync-captcha button { border-radius: 999px; background: var(--m3-primary); }
.token-callout { border-color: var(--m3-outline-variant); border-radius: 12px; background: var(--m3-warning-container); }
.profile-security-note { border-color: var(--m3-outline-variant); border-radius: 12px; background: var(--m3-primary-container); }
.profile-security-note > span { background: var(--m3-surface); color: var(--m3-primary); }
.profile-security-note b, .profile-security-note p { color: var(--m3-on-primary-container); }

/* ---------- Login page ---------- */

.login-page { background: var(--m3-surface); }
.login-visual {
    background:
        radial-gradient(circle at 78% 18%, rgba(168, 199, 250, .30), transparent 34%),
        linear-gradient(150deg, #041e49, #0842a0 58%, #0b57d0);
}
.login-copy .overline { color: #a8c7fa; }
.login-copy h1 { font-weight: 600; letter-spacing: -2.4px; }
.login-copy p { color: #c2d7f7; }
.brand-symbol { border-radius: 9px; background: var(--m3-primary); box-shadow: none; }
.login-card h2 { font-size: 28px; font-weight: 600; letter-spacing: -.6px; }
.login-card input { border-radius: 8px; border-color: var(--m3-outline); }
.login-card input:focus { border-color: var(--m3-primary); box-shadow: 0 0 0 1px var(--m3-primary); }
.login-card label { font-size: 12px; font-weight: 500; color: var(--m3-on-surface-variant); }
.primary-button {
    height: 44px;
    border-radius: 999px;
    background: var(--m3-primary);
    font-size: 14px;
    font-weight: 500;
    box-shadow: none;
}
.primary-button:hover { background: var(--m3-primary-hover); box-shadow: var(--m3-shadow-1); transform: none; }
.form-alert { border-radius: 8px; border-color: var(--m3-error-container); background: var(--m3-error-container); color: var(--m3-error); }

/* ---------- Mobile: rail becomes an overlay drawer ---------- */

.rail-scrim {
    position: fixed;
    z-index: 29;
    inset: 0;
    display: none;
    background: rgba(32, 33, 36, .5);
}

@media (max-width: 900px) {
    .app-shell, .app-shell.rail-collapsed { grid-template-columns: minmax(0, 1fr); }
    .rail {
        position: fixed;
        z-index: 30;
        top: 0;
        left: 0;
        width: var(--rail-width);
        border-right: 1px solid var(--m3-outline-variant);
        background: var(--m3-surface);
        transform: translateX(-100%);
        transition: transform .2s cubic-bezier(.2, 0, 0, 1);
    }
    /* On mobile the rail is never the collapsed-width variant — it is either
       off-canvas or fully open, so the collapsed rules are undone here. */
    .rail-collapsed .rail-label, .rail-collapsed .rail-section,
    .rail-collapsed .rail-brand > span:not(.rail-brand-mark) { display: revert; }
    .rail-collapsed .rail-item { justify-content: flex-start; padding: 0 16px; }
    .rail-collapsed .rail-brand { justify-content: flex-start; padding-left: 4px; }
    .rail-collapsed .rail-head { flex-direction: row; height: calc(var(--appbar-height) - 12px); gap: 4px; }

    .rail-open .rail { transform: translateX(0); box-shadow: var(--m3-shadow-2); }
    .rail-open .rail-scrim { display: block; }
    .app-content { padding: 8px 12px 32px; }
    .content-surface { padding: 18px; border-radius: 12px; }
    .appbar { padding: 0 8px 0 4px; }
}

@media (min-width: 901px) {
    /* The hamburger is the mobile affordance; on desktop the rail's own
       toggle handles collapsing. */
    .appbar-menu { display: none; }
}

@media (max-width: 600px) {
    .appbar-title span { display: none; }
    .account-chip > span:last-child { display: none; }
    .account-chip { padding: 0 5px; }
}

@media (prefers-reduced-motion: reduce) {
    /* Every effect above is decoration, so all of it goes — including the
       entry animations, which must still leave the element visible. */
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-delay: 0ms !important;
        transition-duration: .001ms !important;
    }
    .stat-tile:hover, .kind-card:hover, .template-choice:hover,
    .btn:active, .primary-button:active, .icon-button:active,
    .rail-toggle:active, .rail-item:hover .icon { transform: none !important; }
}
