/* Domainfolio — one stylesheet, design tokens first. Light theme by default, dark via prefers-color-scheme,
   or a theme picked in the profile: <html data-theme="…"> (see App\Users\ThemeCatalog). Every theme block
   defines the full colour token set, so it also works on a single element (profile preview tiles). */

/* ---------- 1. Tokens ---------- */
:root,
[data-theme="light"] {
    color-scheme: light;
    --font: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', monospace;

    --bg: #f4f6fb;
    --bg-glow: #e9ebff;
    --surface: #ffffff;
    --surface-2: #f8f9fc;
    --surface-3: #eff1f7;
    --ink: #172033;
    --ink-2: #303a52;
    --text: #4a556d;
    --muted: #697389;
    --subtle: #8e97aa;
    --line: #e5e9f1;
    --line-2: #d5dbe6;

    --primary: #5255e8;
    --primary-hover: #4144d2;
    --primary-soft: #f0f0ff;
    --primary-ink: #4a4dde;
    --on-primary: #ffffff;

    --success: #1d7f4b;
    --success-soft: #ebf8f1;
    --success-line: #c3e8d3;
    --success-solid: #2f9c63;
    --warning: #8a5a07;
    --warning-soft: #fff7e6;
    --warning-line: #f0dca8;
    --warning-solid: #d48b10;
    --danger: #b3374a;
    --danger-soft: #fff1f3;
    --danger-line: #f5d0d6;
    --danger-solid: #d14b5d;
    --info: #3a4f8f;
    --info-soft: #f0f4ff;
    --info-line: #d9e2ff;

    --radius-sm: 8px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --shadow-sm: 0 1px 2px rgba(23, 32, 51, .06);
    --shadow: 0 16px 48px rgba(34, 45, 83, .08);
    --shadow-pop: 0 14px 36px rgba(24, 33, 59, .16);
    --ring: 0 0 0 3px color-mix(in srgb, var(--primary) 28%, transparent);
    --topbar-bg: rgba(255, 255, 255, .86);
    --input-bg: #ffffff;
    --row-hover: #fafbff;
    --row-today: #fff5f6;
    --brand-a: #7375ff;
    --brand-b: #494bdd;
    --selection-bg: #172033;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        color-scheme: dark;
        --bg: #0e1220;
        --bg-glow: #1a1e3c;
        --surface: #151a2b;
        --surface-2: #1a2033;
        --surface-3: #222941;
        --ink: #e9ecf5;
        --ink-2: #d3d8e6;
        --text: #b9c1d3;
        --muted: #949db2;
        --subtle: #737d94;
        --line: #262e47;
        --line-2: #343e5c;

        --primary: #7477f6;
        --primary-hover: #8b8eff;
        --primary-soft: #23284e;
        --primary-ink: #a9abff;
        --on-primary: #ffffff;

        --success: #6fd49b;
        --success-soft: #12291f;
        --success-line: #1f4a35;
        --success-solid: #2f9c63;
        --warning: #f0c56b;
        --warning-soft: #2b2312;
        --warning-line: #54431c;
        --warning-solid: #d48b10;
        --danger: #ff8f9e;
        --danger-soft: #2f1820;
        --danger-line: #5a2a35;
        --danger-solid: #d14b5d;
        --info: #a9bbff;
        --info-soft: #1a2344;
        --info-line: #2c3a6b;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
        --shadow: 0 16px 48px rgba(0, 0, 0, .35);
        --shadow-pop: 0 18px 44px rgba(0, 0, 0, .5);
        --topbar-bg: rgba(21, 26, 43, .86);
        --input-bg: #10141f;
        --row-hover: #1a2034;
        --row-today: #2a1820;
        --brand-a: #7375ff;
        --brand-b: #494bdd;
        --selection-bg: #2a3150;
    }
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0e1220;
    --bg-glow: #1a1e3c;
    --surface: #151a2b;
    --surface-2: #1a2033;
    --surface-3: #222941;
    --ink: #e9ecf5;
    --ink-2: #d3d8e6;
    --text: #b9c1d3;
    --muted: #949db2;
    --subtle: #737d94;
    --line: #262e47;
    --line-2: #343e5c;

    --primary: #7477f6;
    --primary-hover: #8b8eff;
    --primary-soft: #23284e;
    --primary-ink: #a9abff;
    --on-primary: #ffffff;

    --success: #6fd49b;
    --success-soft: #12291f;
    --success-line: #1f4a35;
    --success-solid: #2f9c63;
    --warning: #f0c56b;
    --warning-soft: #2b2312;
    --warning-line: #54431c;
    --warning-solid: #d48b10;
    --danger: #ff8f9e;
    --danger-soft: #2f1820;
    --danger-line: #5a2a35;
    --danger-solid: #d14b5d;
    --info: #a9bbff;
    --info-soft: #1a2344;
    --info-line: #2c3a6b;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 16px 48px rgba(0, 0, 0, .35);
    --shadow-pop: 0 18px 44px rgba(0, 0, 0, .5);
    --topbar-bg: rgba(21, 26, 43, .86);
    --input-bg: #10141f;
    --row-hover: #1a2034;
    --row-today: #2a1820;
    --brand-a: #7375ff;
    --brand-b: #494bdd;
    --selection-bg: #2a3150;
}

[data-theme="tokyo-night"] {
    color-scheme: dark;
    --bg: #1a1b26; --bg-glow: #24283b; --surface: #1f2335; --surface-2: #222639; --surface-3: #292e42;
    --ink: #c0caf5; --ink-2: #a9b1d6; --text: #9aa5ce; --muted: #7f87ad; --subtle: #565f89; --line: #2a2f45; --line-2: #3b4261;
    --primary: #7aa2f7; --primary-hover: #89b4fa; --primary-soft: #283457; --primary-ink: #7dcfff; --on-primary: #16161e;
    --success: #9ece6a; --success-soft: #1f2a20; --success-line: #3a4d2a; --success-solid: #5f8f3a;
    --warning: #e0af68; --warning-soft: #2e2817; --warning-line: #574a24; --warning-solid: #b8862e;
    --danger: #f7768e; --danger-soft: #2d1b25; --danger-line: #5a2d3d; --danger-solid: #d5455f;
    --info: #7dcfff; --info-soft: #1b2a40; --info-line: #2c4566;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35); --shadow: 0 16px 48px rgba(0, 0, 0, .35); --shadow-pop: 0 18px 44px rgba(0, 0, 0, .5);
    --topbar-bg: rgba(26, 27, 38, .88); --input-bg: #16161e; --row-hover: #232639; --row-today: #2d1f2a;
    --brand-a: #7aa2f7; --brand-b: #bb9af7; --selection-bg: #292e42;
}

[data-theme="tokyo-day"] {
    color-scheme: light;
    --bg: #e1e2e7; --bg-glow: #d0d6ee; --surface: #f4f4f7; --surface-2: #ebecf0; --surface-3: #dfe1e9;
    --ink: #2b3b75; --ink-2: #3760bf; --text: #4c5a8c; --muted: #5f6a99; --subtle: #8990b3; --line: #c9ccdb; --line-2: #aeb3cc;
    --primary: #2e7de9; --primary-hover: #1f6ad0; --primary-soft: #d8e4f8; --primary-ink: #1d5fc2; --on-primary: #ffffff;
    --success: #4f6b31; --success-soft: #e2ebd7; --success-line: #bfd2a6; --success-solid: #587539;
    --warning: #7d5d22; --warning-soft: #f2e8d5; --warning-line: #dfc99c; --warning-solid: #b8862e;
    --danger: #b03a4a; --danger-soft: #f6dfe2; --danger-line: #e7b4ba; --danger-solid: #d0475b;
    --info: #006a8f; --info-soft: #d6eaf2; --info-line: #a8d0e0;
    --shadow-sm: 0 1px 2px rgba(55, 96, 191, .08); --shadow: 0 16px 48px rgba(55, 96, 191, .10); --shadow-pop: 0 14px 36px rgba(55, 96, 191, .18);
    --topbar-bg: rgba(244, 244, 247, .88); --input-bg: #fafafc; --row-hover: #e9ebf3; --row-today: #f6e3e6;
    --brand-a: #2e7de9; --brand-b: #9854f1; --selection-bg: #343b58;
}

[data-theme="arasaka"] {
    color-scheme: dark;
    --bg: #070708; --bg-glow: #2a0605; --surface: #111113; --surface-2: #16161a; --surface-3: #1e1e23;
    --ink: #f4f4f5; --ink-2: #dcdce1; --text: #b6b6be; --muted: #8e8e98; --subtle: #66666f; --line: #26262c; --line-2: #3a3a42;
    --primary: #e10600; --primary-hover: #ff2a22; --primary-soft: #2a0b0a; --primary-ink: #ff5a52; --on-primary: #ffffff;
    --success: #5fd394; --success-soft: #0e2218; --success-line: #1d4430; --success-solid: #2c9c5f;
    --warning: #f2b53c; --warning-soft: #2a2010; --warning-line: #5a4519; --warning-solid: #c98b10;
    --danger: #ff6b78; --danger-soft: #2d1015; --danger-line: #5c1f29; --danger-solid: #c9283a;
    --info: #c9c9d3; --info-soft: #1b1b21; --info-line: #33333b;
    --radius-sm: 2px; --radius: 2px; --radius-lg: 3px; --radius-xl: 4px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5); --shadow: 0 16px 48px rgba(0, 0, 0, .55); --shadow-pop: 0 18px 44px rgba(0, 0, 0, .7);
    --topbar-bg: rgba(7, 7, 8, .9); --input-bg: #0c0c0e; --row-hover: #17171b; --row-today: #2a0d0d;
    --brand-a: #ff2a1f; --brand-b: #8f0400; --selection-bg: #1e1e23;
}

[data-theme="cyberpunk"] {
    color-scheme: dark;
    --font: 'Bahnschrift', 'DIN Alternate', 'Arial Narrow', ui-sans-serif, system-ui, sans-serif;
    --bg: #0a0b10; --bg-glow: #2b2a05; --surface: #11131b; --surface-2: #161824; --surface-3: #1e2130;
    --ink: #eafcff; --ink-2: #c6eef5; --text: #a6c9d1; --muted: #7d9aa4; --subtle: #586b74; --line: #1f3540; --line-2: #2c4a57;
    --primary: #fcee0a; --primary-hover: #fff563; --primary-soft: #2a2806; --primary-ink: #fcee0a; --on-primary: #000000;
    --success: #00ff9f; --success-soft: #062419; --success-line: #0d4a34; --success-solid: #00a866;
    --warning: #ff9f1c; --warning-soft: #2b1d07; --warning-line: #5a3c0e; --warning-solid: #d97f00;
    --danger: #ff4d6d; --danger-soft: #2c0712; --danger-line: #5c1024; --danger-solid: #e0003a;
    --info: #02d7f2; --info-soft: #062630; --info-line: #0b4a57;
    --radius-sm: 2px; --radius: 3px; --radius-lg: 4px; --radius-xl: 6px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5); --shadow: 0 16px 48px rgba(0, 0, 0, .55), 0 0 0 1px rgba(2, 215, 242, .06); --shadow-pop: 0 18px 44px rgba(0, 0, 0, .7);
    --topbar-bg: rgba(10, 11, 16, .9); --input-bg: #0c0d14; --row-hover: #171a26; --row-today: #2c0712;
    --brand-a: #fcee0a; --brand-b: #e2d300; --selection-bg: #1e2130;
}

[data-theme="github-light"] {
    color-scheme: light;
    --bg: #f6f8fa; --bg-glow: #f6f8fa; --surface: #ffffff; --surface-2: #f6f8fa; --surface-3: #eff2f5;
    --ink: #1f2328; --ink-2: #31363c; --text: #424a53; --muted: #59636e; --subtle: #818b98; --line: #d1d9e0; --line-2: #c3ccd5;
    --primary: #0969da; --primary-hover: #0757b8; --primary-soft: #ddf4ff; --primary-ink: #0969da; --on-primary: #ffffff;
    --success: #1a7f37; --success-soft: #dafbe1; --success-line: #aceebb; --success-solid: #1f883d;
    --warning: #9a6700; --warning-soft: #fff8c5; --warning-line: #eed888; --warning-solid: #bf8700;
    --danger: #d1242f; --danger-soft: #ffebe9; --danger-line: #ffcecb; --danger-solid: #cf222e;
    --info: #0969da; --info-soft: #ddf4ff; --info-line: #b6e3ff;
    --radius-sm: 6px; --radius: 6px; --radius-lg: 8px; --radius-xl: 12px;
    --shadow-sm: 0 1px 0 rgba(31, 35, 40, .04); --shadow: 0 1px 3px rgba(31, 35, 40, .08); --shadow-pop: 0 8px 24px rgba(66, 74, 83, .12);
    --topbar-bg: rgba(246, 248, 250, .92); --input-bg: #ffffff; --row-hover: #f6f8fa; --row-today: #fff5f4;
    --brand-a: #24292f; --brand-b: #424a53; --selection-bg: #1f2328;
}

[data-theme="github-dark"] {
    color-scheme: dark;
    --bg: #0d1117; --bg-glow: #0d1117; --surface: #151b23; --surface-2: #161b22; --surface-3: #21262d;
    --ink: #f0f6fc; --ink-2: #e6edf3; --text: #d1d7e0; --muted: #9198a1; --subtle: #6e7681; --line: #30363d; --line-2: #3d444d;
    --primary: #1f6feb; --primary-hover: #388bfd; --primary-soft: #121d2f; --primary-ink: #4493f8; --on-primary: #ffffff;
    --success: #3fb950; --success-soft: #12261e; --success-line: #1f4a2c; --success-solid: #238636;
    --warning: #d29922; --warning-soft: #272115; --warning-line: #4d3a12; --warning-solid: #9e6a03;
    --danger: #f85149; --danger-soft: #25171c; --danger-line: #5c2328; --danger-solid: #da3633;
    --info: #4493f8; --info-soft: #121d2f; --info-line: #1f3a5f;
    --radius-sm: 6px; --radius: 6px; --radius-lg: 8px; --radius-xl: 12px;
    --shadow-sm: 0 0 transparent; --shadow: 0 0 0 1px rgba(48, 54, 61, .4); --shadow-pop: 0 8px 24px rgba(1, 4, 9, .75);
    --topbar-bg: rgba(1, 4, 9, .9); --input-bg: #0d1117; --row-hover: #161b22; --row-today: #25171c;
    --brand-a: #388bfd; --brand-b: #1f6feb; --selection-bg: #21262d;
}

/* Theme accents beyond colour tokens */
[data-theme="arasaka"] h1, [data-theme="arasaka"] h2, [data-theme="arasaka"] .eyebrow { text-transform: uppercase; letter-spacing: .08em; }
[data-theme="arasaka"] .topbar { border-bottom: 1px solid var(--primary); }
[data-theme="arasaka"] .card { border-top: 2px solid var(--primary); }
[data-theme="cyberpunk"] h1, [data-theme="cyberpunk"] h2, [data-theme="cyberpunk"] .eyebrow { text-transform: uppercase; letter-spacing: .04em; }
[data-theme="cyberpunk"] h1 { color: var(--primary); text-shadow: -1px 0 rgba(255, 0, 60, .7), 1px 0 rgba(2, 215, 242, .7); }
[data-theme="cyberpunk"] .topbar { border-bottom: 1px solid var(--primary); }
[data-theme="cyberpunk"] .card { border-left: 3px solid var(--primary); }
[data-theme="cyberpunk"] main a:not(.button):not(.stat-tile) { color: var(--info); }

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: radial-gradient(ellipse at 6% 0%, var(--bg-glow) 0, transparent 36rem), var(--bg);
    font-synthesis: none;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary-ink); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; text-underline-offset: 2px; }
a.button:hover, .dropdown-menu a:hover, .nav-link:hover, .brand:hover, .stat-tile:hover, .tabs a:hover { text-decoration: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
h1, h2, h3 { color: var(--ink); letter-spacing: -.02em; font-weight: 750; }
h1 { font-size: clamp(24px, 2.6vw, 30px); line-height: 1.2; margin: 0 0 6px; }
h2 { font-size: 17px; line-height: 1.3; margin: 0 0 4px; }
h3 { font-size: 15px; margin: 0 0 4px; }
p { margin: 0 0 12px; }
code, pre { font-family: var(--mono); }
code { font-size: .92em; }
hr { border: 0; height: 1px; background: var(--line); }
.muted { color: var(--muted); font-size: 13px; line-height: 1.55; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.bi-icon { display: block; width: 16px; height: 16px; flex: none; }

/* ---------- 3. Layout ---------- */
.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 28px;
    height: 68px; padding: 0 clamp(16px, 4vw, 56px);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 800; font-size: 18px; letter-spacing: -.03em; white-space: nowrap; }
.brand:hover { color: var(--ink); }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: linear-gradient(145deg, var(--brand-a), var(--brand-b)); color: var(--on-primary); font-size: 16px; box-shadow: 0 6px 14px color-mix(in srgb, var(--brand-b) 30%, transparent); }
.brand-muted { color: var(--primary); }
.primary-nav { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; }
.nav-link {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 12px; border: 0; border-radius: var(--radius);
    background: transparent; color: var(--muted);
    font: 600 14px var(--font); white-space: nowrap; cursor: pointer;
}
.nav-link:hover, .nav-link.is-active, .hover-dropdown.is-open > .nav-link { color: var(--primary-ink); background: var(--primary-soft); }
.page-main { max-width: 1320px; margin: 0 auto; padding: 36px clamp(16px, 4vw, 56px) 96px; }
.page-main.is-narrow { max-width: 960px; }
.auth-main { max-width: 460px; padding-top: 9vh; }

/* Dropdown menus (navigation, account) */
.hover-dropdown { position: relative; display: flex; align-items: center; }
.dropdown-chevron { width: 14px; height: 14px; color: var(--subtle); transition: transform .16s ease; }
.hover-dropdown.is-open .dropdown-chevron { transform: rotate(180deg); }
.dropdown-menu {
    position: absolute; z-index: 40; top: 100%; left: 0;
    display: none; gap: 2px; min-width: 200px; padding: 6px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-pop);
}
.hover-dropdown.is-open > .dropdown-menu { display: grid; }
@media (hover: hover) {
    .hover-dropdown:hover:not(.is-dismissed) > .dropdown-menu { display: grid; }
    .hover-dropdown:hover:not(.is-dismissed) .dropdown-chevron { transform: rotate(180deg); }
}
.dropdown-menu-end { left: auto; right: 0; }
.dropdown-menu a, .dropdown-item {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 9px 11px; border: 0; border-radius: var(--radius-sm);
    background: transparent; color: var(--text); font: 600 13px var(--font); text-align: left; white-space: nowrap; cursor: pointer;
}
.dropdown-menu a:hover, .dropdown-menu a:focus-visible, .dropdown-item:hover, .dropdown-item:focus-visible { color: var(--primary-ink); background: var(--primary-soft); outline: none; }
.dropdown-menu a[aria-current="page"] { color: var(--primary-ink); }
.dropdown-menu hr { width: 100%; margin: 4px 0; }
.dropdown-menu form { margin: 0; }
.dropdown-label { padding: 8px 11px 4px; color: var(--subtle); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.account-dropdown { margin-left: auto; flex: none; }
.account-menu { display: flex; align-items: center; gap: 9px; padding: 4px 8px 4px 4px; border: 0; border-radius: 999px; background: transparent; color: var(--ink-2); font: 600 14px var(--font); cursor: pointer; }
.account-menu:hover, .hover-dropdown.is-open > .account-menu { background: var(--surface-3); }
.avatar { display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-ink); font-weight: 750; font-size: 13px; }
.avatar-small { width: 28px; height: 28px; font-size: 12px; }

/* ---------- 4. Cards & page headings ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-xl); padding: clamp(20px, 3vw, 32px); box-shadow: var(--shadow); }
.card + .card { margin-top: 24px; }
.card-narrow { max-width: 900px; margin-left: auto; margin-right: auto; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-header p { margin: 0; }
.page-header .muted { max-width: 70ch; }
.eyebrow { margin: 0 0 6px; color: var(--primary-ink); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.section-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: none; }
.section { padding-top: 24px; margin-top: 24px; border-top: 1px solid var(--line); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-title h2 { margin: 0; }
.section-title p { margin: 4px 0 0; }
.meta-list { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 18px; padding: 0; list-style: none; color: var(--muted); font-size: 13px; }
.meta-list strong { color: var(--ink-2); font-weight: 650; }
.empty-state { display: grid; justify-items: center; gap: 6px; padding: 40px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line-2); border-radius: var(--radius-lg); }
.empty-state strong { color: var(--ink-2); font-size: 15px; }
.empty-state p { margin: 0; max-width: 52ch; }
.empty-state .button { margin-top: 10px; }
.status-card { max-width: 520px; margin: 6vh auto 0; text-align: center; }
.status-card .form-actions { justify-content: center; }
.status-code { display: block; margin-bottom: 4px; color: var(--primary-ink); font-size: 13px; font-weight: 800; letter-spacing: .1em; }

/* ---------- 5. Messages ---------- */
.alert {
    display: flex; align-items: flex-start; gap: 10px;
    margin: 0 0 20px; padding: 13px 16px;
    border: 1px solid; border-radius: 12px; font-size: 14px; line-height: 1.5;
}
.alert::before { flex: none; display: grid; place-items: center; width: 20px; height: 20px; margin-top: 1px; border-radius: 50%; font-size: 12px; font-weight: 800; color: #fff; }
.alert > .alert-body { flex: 1; min-width: 0; }
.alert p { margin: 0; }
.alert a { font-weight: 700; color: inherit; text-decoration: underline; }
.alert-error { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-line); }
.alert-error::before { content: '!'; background: var(--danger-solid); }
.alert-success { color: var(--success); background: var(--success-soft); border-color: var(--success-line); }
.alert-success::before { content: '✓'; background: var(--success-solid); }
.alert-info { color: var(--info); background: var(--info-soft); border-color: var(--info-line); }
.alert-info::before { content: 'i'; background: var(--primary); font-family: Georgia, serif; }
.alert-warning { color: var(--warning); background: var(--warning-soft); border-color: var(--warning-line); }
.alert-warning::before { content: '!'; background: var(--warning-solid); }
.alert-close { flex: none; margin: -4px -6px -4px 0; width: 28px; height: 28px; padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: inherit; font-size: 18px; line-height: 1; opacity: .7; cursor: pointer; }
.alert-close:hover { opacity: 1; background: rgba(127, 127, 127, .12); }
.alert .diagnostic-details { margin-top: 8px; }
.diagnostic-details summary { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; list-style: none; font-size: 12px; font-weight: 700; }
.diagnostic-details summary::-webkit-details-marker { display: none; }
.details-chevron { width: 14px; height: 14px; transition: transform .15s ease; }
.diagnostic-details[open] .details-chevron { transform: rotate(90deg); }
.diagnostic-details pre, .code-block {
    max-height: 360px; overflow: auto; margin: 8px 0 0; padding: 12px;
    white-space: pre-wrap; overflow-wrap: anywhere;
    background: var(--surface); color: var(--ink-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
    font: 12px/1.55 var(--mono);
}
.secret-box { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 20px; padding: 16px 18px; border: 1px solid var(--success-line); border-radius: 12px; background: var(--success-soft); color: var(--success); }
.secret-box p { margin: 4px 0 10px; font-size: 13px; }
.secret-box code { display: inline-block; padding: 7px 10px; border: 1px solid var(--success-line); border-radius: 7px; background: var(--surface); color: var(--ink); font-size: 14px; user-select: all; overflow-wrap: anywhere; }

/* Toasts */
.toast-region { position: fixed; z-index: 100; right: 20px; bottom: 20px; display: grid; gap: 10px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast {
    display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
    background: var(--surface); color: var(--ink-2); border: 1px solid var(--line); border-left: 4px solid var(--primary);
    border-radius: 12px; box-shadow: var(--shadow-pop); font-size: 13px; line-height: 1.45;
    pointer-events: auto; animation: toast-in .2s ease both;
}
.toast-body { flex: 1; min-width: 0; }
.toast-body strong { display: block; color: var(--ink); }
.toast-success { border-left-color: var(--success-solid); }
.toast-error { border-left-color: var(--danger-solid); }
.toast-warning { border-left-color: var(--warning-solid); }
.toast .alert-close { color: var(--muted); }
.toast.is-leaving { animation: toast-out .18s ease both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* Confirmation dialog */
.dialog { width: min(440px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop); }
.dialog::backdrop { background: rgba(10, 14, 28, .45); backdrop-filter: blur(2px); }
.dialog form { margin: 0; padding: 22px 22px 18px; }
.dialog h2 { margin: 0 0 8px; font-size: 18px; }
.dialog p { margin: 0 0 20px; line-height: 1.55; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
/* Alert popup (ui.js, 1.0.1): SweetAlert-style message in the middle of the screen */
.popup { --popup-color: var(--primary); width: min(420px, calc(100vw - 32px)); padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop); text-align: center; animation: popup-in .32s cubic-bezier(.2, 1.4, .4, 1) both; }
.popup::backdrop { background: rgba(10, 14, 28, .45); backdrop-filter: blur(2px); animation: popup-fade .2s ease both; }
.popup.is-leaving { animation: popup-out .16s ease both; }
.popup-success { --popup-color: var(--success-solid); }
.popup-error { --popup-color: var(--danger-solid); }
.popup-warning { --popup-color: var(--warning-solid); }
.popup form { margin: 0; padding: 28px 24px 22px; }
.popup-icon { width: 76px; height: 76px; margin: 0 auto 14px; }
.popup-icon svg { width: 100%; height: 100%; fill: none; stroke: var(--popup-color); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.popup-ring { stroke-dasharray: 145; stroke-dashoffset: 145; opacity: .9; transform: rotate(-90deg); transform-box: fill-box; transform-origin: center; animation: popup-draw .5s ease-out .08s forwards; }
.popup-mark { stroke-width: 3.6; stroke-dasharray: 48; stroke-dashoffset: 48; animation: popup-draw .34s ease-out .45s forwards; }
.popup-dot { fill: var(--popup-color); stroke: none; opacity: 0; animation: popup-fade .2s ease .6s forwards; }
.popup-error .popup-icon { animation: popup-shake .4s ease .55s both; }
.popup-title { margin: 0 0 8px; font-size: 21px; color: var(--ink); }
.popup-text { margin: 0 0 22px; color: var(--ink-2); line-height: 1.55; overflow-wrap: anywhere; }
.popup-actions { display: flex; justify-content: center; }
.popup .popup-ok { min-width: 120px; background: var(--popup-color); border-color: var(--popup-color); color: #fff; box-shadow: 0 4px 14px color-mix(in srgb, var(--popup-color) 30%, transparent); }
.popup .popup-ok:hover { background: color-mix(in srgb, var(--popup-color) 86%, #000); border-color: color-mix(in srgb, var(--popup-color) 86%, #000); color: #fff; }
.popup-timer { height: 4px; background: var(--popup-color); opacity: .55; transform-origin: left; animation: popup-timer linear forwards; }
.popup:hover .popup-timer { animation-play-state: paused; }
@keyframes popup-in { from { opacity: 0; transform: scale(.72); } to { opacity: 1; transform: scale(1); } }
@keyframes popup-out { to { opacity: 0; transform: scale(.94); } }
@keyframes popup-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes popup-draw { to { stroke-dashoffset: 0; } }
@keyframes popup-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes popup-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }

/* ---------- 6. Forms ---------- */
form { margin: 0; }
.form { display: grid; gap: 18px; }
.field { display: grid; gap: 6px; align-content: start; min-width: 0; }
label, .label { display: block; margin: 0; color: var(--ink-2); font-size: 13px; font-weight: 650; }
.label-optional { color: var(--subtle); font-weight: 500; }
input, select, textarea {
    display: block; width: 100%; margin: 0;
    padding: 10px 12px; min-height: 42px;
    font: inherit; font-size: 14px; color: var(--ink);
    background-color: var(--input-bg);
    border: 1px solid var(--line-2); border-radius: var(--radius);
    transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover, textarea:hover { border-color: var(--subtle); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: var(--subtle); }
input[readonly], textarea[readonly] { background: var(--surface-2); }
input[type="checkbox"], input[type="radio"] { display: inline-block; width: 16px; height: 16px; min-height: 0; padding: 0; accent-color: var(--primary); vertical-align: middle; cursor: pointer; }
input[type="checkbox"]:focus { box-shadow: none; }
textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%238e97aa' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
.hint { display: block; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.hint-error { color: var(--danger); }
.hint-success { color: var(--success); }
.checkbox-label { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 550; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-wide { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.form-actions-split { justify-content: space-between; }
.form-actions .spacer { flex: 1; }
.form-section { display: grid; gap: 14px; margin: 0; padding: 0; border: 0; min-width: 0; }
.form-section + .form-section { padding-top: 22px; border-top: 1px solid var(--line); }
/* A floated legend is laid out as a normal grid item instead of sitting on the fieldset border. */
.form-section > legend { float: left; width: 100%; padding: 0; margin: 0 0 -4px; color: var(--ink); font-size: 16px; font-weight: 750; }
.form-section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.form-section-head p { margin: 2px 0 0; }
.form-section-head .button { flex: none; }
.form-section > .muted, .form-section-head .muted { margin: 0; }
.input-code { font-family: var(--mono); font-size: 18px; line-height: 21px; letter-spacing: .14em; text-align: center; }

/* Password field: show/hide toggle + strength meter */
.password-field { position: relative; display: block; }
.password-field input { padding-right: 46px; }
.password-toggle { position: absolute; top: 50%; right: 5px; transform: translateY(-50%); display: grid; place-items: center; width: 34px; height: 32px; padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--subtle); cursor: pointer; }
.password-toggle:hover { color: var(--primary-ink); background: var(--primary-soft); }
.password-toggle[aria-pressed="true"] { color: var(--primary-ink); }
.password-toggle[aria-pressed="true"] .bi-icon { opacity: .55; }
.strength { display: grid; gap: 5px; }
.strength-track { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; height: 4px; }
.strength-track span { border-radius: 999px; background: var(--surface-3); transition: background .2s; }
.strength[data-level="1"] .strength-track span:nth-child(-n+1) { background: var(--danger-solid); }
.strength[data-level="2"] .strength-track span:nth-child(-n+2) { background: var(--warning-solid); }
.strength[data-level="3"] .strength-track span:nth-child(-n+3) { background: var(--success-solid); }
.strength[data-level="4"] .strength-track span { background: var(--success-solid); }

/* ---------- 7. Buttons ---------- */
button { font: inherit; }
.button {
    appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    min-height: 40px; padding: 9px 16px;
    border: 1px solid var(--primary); border-radius: var(--radius);
    background: var(--primary); color: var(--on-primary);
    font: 650 13px/1.2 var(--font); white-space: nowrap; text-decoration: none; cursor: pointer;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 18%, transparent);
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .15s;
}
.button:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); transform: translateY(-1px); }
.button:active { transform: none; }
.button-secondary { background: var(--surface); color: var(--ink-2); border-color: var(--line-2); box-shadow: var(--shadow-sm); }
.button-secondary:hover { background: var(--surface-2); color: var(--ink); border-color: var(--subtle); }
.button-quiet { background: transparent; color: var(--muted); border-color: transparent; box-shadow: none; }
.button-quiet:hover { background: var(--surface-3); color: var(--ink); border-color: transparent; }
.button-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); box-shadow: none; }
.button-danger:hover { background: var(--danger-solid); color: #fff; border-color: var(--danger-solid); }
.button-danger-solid { background: var(--danger-solid); border-color: var(--danger-solid); color: #fff; box-shadow: none; }
.button-danger-solid:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.button-small { min-height: 32px; padding: 6px 11px; font-size: 12px; border-radius: var(--radius-sm); }
.button-block { width: 100%; }
.icon-button { width: 34px; min-height: 32px; height: 32px; padding: 0; }
.icon-button .bi-icon { width: 16px; height: 16px; }
.button:disabled, .button[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.button.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.button.is-loading .bi-icon { visibility: hidden; }
.button.is-loading::after { content: ''; position: absolute; inset: 0; margin: auto; width: 14px; height: 14px; border: 2px solid var(--primary-soft); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
.button-secondary.is-loading::after { border-color: var(--line-2); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 8. Badges ---------- */
.badge, .role-badge, .status-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: 999px;
    font-size: 12px; font-weight: 650; line-height: 1.5; white-space: nowrap;
    background: var(--surface-3); color: var(--text);
}
a.badge:hover { text-decoration: none; filter: brightness(.97); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-success, .status-active { background: var(--success-soft); color: var(--success); }
.badge-info, .role-badge { background: var(--primary-soft); color: var(--primary-ink); }
.badge-muted, .status-inactive { background: var(--surface-3); color: var(--muted); }
.badge-dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-action { border: 1px dashed var(--line-2); background: transparent; color: var(--primary-ink); }
.count-pill { display: inline-grid; place-items: center; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 11px; font-weight: 700; }

/* ---------- 9. Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
thead { background: var(--surface-2); }
th { padding: 11px 14px; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; border-bottom: 1px solid var(--line); vertical-align: middle; }
td { padding: 12px 14px; color: var(--text); border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--row-hover); }
tbody tr.is-today { background: var(--row-today); }
tbody tr.is-today td:first-child { box-shadow: inset 3px 0 0 var(--danger-solid); }
tbody tr.is-selected { background: var(--primary-soft); }
tbody tr.is-updated { animation: row-flash 1.6s ease; }
@keyframes row-flash { 0%, 30% { background: var(--success-soft); } 100% { background: transparent; } }
td strong { color: var(--ink-2); font-size: 14px; font-weight: 650; }
.cell-wrap { max-width: 320px; overflow-wrap: anywhere; }
td.cell-primary { min-width: 11rem; }
.domain-name { display: block; color: var(--ink-2); font-weight: 650; font-size: 14px; }
.punycode { display: block; color: var(--muted); font-size: 11px; font-weight: 400; overflow-wrap: anywhere; }
.date-time { display: block; color: var(--subtle); font-size: 11px; }
.cell-select { width: 44px; padding-right: 6px; text-align: center; }
th.cell-select { padding-right: 6px; }
td.actions-cell, th.actions-cell { width: 1%; text-align: right; white-space: nowrap; }
.actions-cell .row-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; }
.inline-form { display: inline-flex; margin: 0; }
.user-name { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-weight: 650; }
.audit-details summary { cursor: pointer; color: var(--primary-ink); font-size: 12px; font-weight: 650; }
.audit-details pre { max-width: 420px; }
.audit-action { display: block; color: var(--ink-2); font-weight: 600; }
.audit-code { display: block; color: var(--subtle); font-size: 11px; font-family: var(--mono); }

/* Datatable toolbar */
.datatable-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 0 0 12px; }
.datatable-search { position: relative; flex: 1 1 260px; max-width: 380px; }
.datatable-search .bi-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--subtle); pointer-events: none; }
.datatable-filter { padding-left: 36px; }
.datatable-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.datatable-popover { position: relative; }
.datatable-popover > summary { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 8px 12px; list-style: none; cursor: pointer; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface); color: var(--ink-2); font-size: 13px; font-weight: 650; white-space: nowrap; }
.datatable-popover > summary::-webkit-details-marker { display: none; }
.datatable-popover > summary:hover, .datatable-popover[open] > summary { border-color: var(--subtle); background: var(--surface-2); }
.datatable-popover > summary .count-pill { background: var(--primary); color: var(--on-primary); }
.datatable-popover-panel { position: absolute; z-index: 25; top: calc(100% + 6px); right: 0; display: grid; gap: 12px; width: max-content; min-width: 220px; max-width: min(340px, calc(100vw - 32px)); max-height: 70vh; overflow: auto; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-pop); }
.datatable-popover-panel .checkbox-label { font-size: 13px; }
.datatable-popover-panel .panel-intro { margin: 0; font-size: 12px; }
.datatable-popover-panel .field label { font-size: 12px; color: var(--muted); }
.datatable-popover-panel input:not([type="checkbox"]), .datatable-popover-panel select { min-height: 36px; padding-top: 7px; padding-bottom: 7px; font-size: 13px; }
.datatable-popover-footer { display: flex; justify-content: space-between; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.datatable-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: -2px 0 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 11px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-ink); font-size: 12px; font-weight: 650; }
.chip button, .chip a { display: grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: inherit; font-size: 15px; line-height: 1; cursor: pointer; }
.chip button:hover, .chip a:hover { background: color-mix(in srgb, var(--primary) 15%, transparent); text-decoration: none; }
.datatable-sort { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; white-space: nowrap; cursor: pointer; }
.datatable-sort:hover { color: var(--primary-ink); }
.datatable-sort::after { content: '↕'; font-size: 12px; color: var(--line-2); }
.datatable-sort:hover::after { color: var(--subtle); }
th[aria-sort="ascending"] .datatable-sort, th[aria-sort="descending"] .datatable-sort { color: var(--primary-ink); }
th[aria-sort="ascending"] .datatable-sort::after { content: '↑'; color: var(--primary-ink); }
th[aria-sort="descending"] .datatable-sort::after { content: '↓'; color: var(--primary-ink); }
.datatable-mobile-sort { display: none; }
.datatable-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding-top: 14px; color: var(--muted); font-size: 13px; }
.datatable-size-label { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 500; }
.datatable-size { width: auto; min-height: 34px; padding: 5px 30px 5px 10px; font-size: 13px; }
.datatable-pager { display: inline-flex; align-items: center; gap: 10px; }
.datatable-page-buttons { display: inline-flex; gap: 6px; }
.datatable-page-buttons .button { width: 34px; padding: 0; font-size: 17px; }
.datatable-empty { margin: 0; padding: 28px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line-2); border-top: 0; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.table-wrap.is-empty { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }

/* Selection bar (bulk actions) */
.selection-bar {
    position: sticky; bottom: 16px; z-index: 20;
    display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px;
    margin: 14px 0 0; padding: 10px 12px 10px 16px;
    background: var(--selection-bg); color: #fff; border-radius: 14px; box-shadow: var(--shadow-pop);
}
.selection-bar[data-state="idle"] { position: static; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); box-shadow: none; }
.selection-count { font-weight: 700; font-size: 13px; }
.selection-bar .selection-hint { color: inherit; opacity: .75; font-size: 12px; }
.selection-bar .spacer { flex: 1; }
.selection-bar .button-secondary { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .22); box-shadow: none; }
.selection-bar .button-secondary:hover { background: rgba(255, 255, 255, .18); }
.selection-bar[data-state="idle"] .button-secondary { background: var(--surface); color: var(--ink-2); border-color: var(--line-2); }
.selection-bar select { width: auto; min-height: 32px; padding: 5px 30px 5px 10px; font-size: 12px; }
.selection-bar .inline-group { display: inline-flex; align-items: center; gap: 6px; }
.selection-bar .link-button { padding: 0; border: 0; background: none; color: inherit; font-size: 12px; font-weight: 650; text-decoration: underline; cursor: pointer; opacity: .85; }

/* Tabs */
.tabs { display: flex; align-items: center; gap: 4px; margin: 0 0 18px; border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px; color: var(--muted); font-size: 13px; font-weight: 650; white-space: nowrap; }
.tabs a:hover { color: var(--ink-2); }
.tabs a.is-active { color: var(--primary-ink); box-shadow: inset 0 -2px 0 var(--primary); }
.tabs a.is-active .count-pill { background: var(--primary-soft); color: var(--primary-ink); }

/* ---------- 10. Dashboard ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-tile { display: grid; gap: 4px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); color: var(--text); transition: border-color .15s, transform .15s; }
.stat-tile:hover { border-color: var(--primary); transform: translateY(-1px); color: var(--text); }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 650; }
.stat-value { color: var(--ink); font-size: 28px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.stat-tile-danger .stat-value { color: var(--danger); }
.stat-tile-warning .stat-value { color: var(--warning); }
.stat-tile-muted .stat-value { color: var(--muted); }
.stat-tile.is-zero .stat-value { color: var(--subtle); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.dashboard-grid .card + .card { margin-top: 0; }
.deadline-list { margin: 0; padding: 0; list-style: none; }
.deadline-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.deadline-list li:last-child { border-bottom: 0; }
.deadline-list .domain-name { font-size: 14px; }
.deadline-list a:hover { text-decoration: none; }
.deadline-list a:hover .domain-name { color: var(--primary-ink); }
.deadline-date { color: var(--muted); font-size: 13px; white-space: nowrap; }
.status-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 14px; }
.status-list li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: start; }
.status-dot { width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; background: var(--subtle); }
.status-dot.is-ok { background: var(--success-solid); }
.status-dot.is-warning { background: var(--warning-solid); }
.status-dot.is-error { background: var(--danger-solid); }
.status-list strong { display: block; color: var(--ink-2); font-size: 13px; }
.status-list .muted { margin: 0; font-size: 12px; }

/* ---------- 11. Bulk import ---------- */
.bulk-textarea { min-height: 220px; font-family: var(--mono); font-size: 13px; line-height: 1.8; }
.bulk-preview { margin: 0; }
.bulk-progress { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.bulk-progress-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.bulk-progress-heading h2 { margin: 0 0 4px; }
.bulk-progress-heading p { margin: 0; }
.bulk-count { padding: 6px 12px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-ink); font-size: 13px; font-weight: 750; white-space: nowrap; }
.progress-track { height: 8px; margin: 18px 0; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand-a), var(--brand-b)); transition: width .28s ease; }
.bulk-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.bulk-results { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.bulk-result { display: grid; grid-template-columns: 20px minmax(120px, 1fr) minmax(120px, 2fr); align-items: center; gap: 10px; min-height: 44px; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.bulk-result-name { font-size: 13px; font-weight: 650; color: var(--ink-2); overflow-wrap: anywhere; }
.bulk-result-status { justify-self: end; color: var(--muted); font-size: 12px; text-align: right; }
.bulk-result-marker { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--surface-3); color: var(--muted); font-size: 11px; font-weight: 800; }
.is-pending .bulk-result-marker::before { content: '·'; font-size: 18px; line-height: 10px; }
.bulk-result.is-processing { border-color: var(--primary); background: var(--primary-soft); }
.is-processing .bulk-result-marker { border: 2px solid var(--line-2); border-top-color: var(--primary); background: transparent; animation: spin .7s linear infinite; }
.is-processing .bulk-result-status { color: var(--primary-ink); }
.bulk-result.is-success { border-color: var(--success-line); }
.is-success .bulk-result-marker { background: var(--success-solid); color: #fff; }
.is-success .bulk-result-marker::before { content: '✓'; }
.is-success .bulk-result-status { color: var(--success); }
.bulk-result.is-warning { border-color: var(--warning-line); }
.is-warning .bulk-result-marker { background: var(--warning-solid); color: #fff; }
.is-warning .bulk-result-marker::before { content: '!'; }
.is-warning .bulk-result-status { color: var(--warning); }
.bulk-result.is-error { border-color: var(--danger-line); background: var(--danger-soft); }
.is-error .bulk-result-marker { background: var(--danger-solid); color: #fff; }
.is-error .bulk-result-marker::before { content: '!'; }
.is-error .bulk-result-status { color: var(--danger); }
.bulk-result.is-skipped { opacity: .7; }
.is-skipped .bulk-result-marker::before { content: '–'; }
.bulk-result-details { grid-column: 2 / -1; font-size: 12px; color: var(--muted); }
.bulk-result-details summary { cursor: pointer; font-weight: 650; }
.bulk-result-details pre { max-height: 240px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; padding: 10px; border-radius: 7px; background: var(--surface-2); font-size: 11px; }
.bulk-complete { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding-top: 18px; }

/* ---------- 12. Potential domains ---------- */
.potential-filters { display: grid; gap: 10px; }
.potential-filters .field { gap: 4px; }
.info-panel { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin: 0 0 24px; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface-2); }
.info-panel h2 { margin: 0 0 10px; font-size: 15px; }
.info-panel dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; font-size: 13px; }
.info-panel dt { color: var(--muted); }
.info-panel dd { margin: 0; color: var(--ink-2); font-weight: 600; overflow-wrap: anywhere; }
.info-panel .hint { margin-top: 10px; }
.info-panel form { flex: none; }
/* Registrar actions (1.0.1, stage 2): renew, automatic renewal, permissions, sniper */
html { scroll-padding-top: 76px; } /* anchors (#permissions, #sniper…) land below the sticky header */
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.subsection-title { margin: 22px 0 10px; font-size: 14px; }
.confirm-field label { display: inline-flex; align-items: center; gap: 6px; }
.registrar-auto { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface-2); }
.registrar-auto p { margin: 6px 0 0; }
.registrar-confirm-form { display: flex; align-items: flex-end; gap: 10px; flex: none; max-width: 420px; }
.registrar-confirm-form .confirm-field { flex: 1 1 220px; margin: 0; }
.registrar-operations-table td, .registrar-renew-table td { vertical-align: top; }
.form-inline-action { margin-top: 14px; }
.registrar-ns { margin-top: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.registrar-ns summary { cursor: pointer; font-size: 14px; overflow-wrap: anywhere; }
.registrar-ns-toggle { margin-left: 6px; color: var(--primary-ink); font-size: 13px; font-weight: 600; }
.registrar-ns[open] .registrar-ns-toggle { display: none; }
.registrar-ns form { margin-top: 12px; }
.registrar-ns-static { margin: 14px 0 0; font-size: 14px; overflow-wrap: anywhere; }
/* Domain search (1.0.1, stage 3) */
.domain-search-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 14px 16px; }
.domain-search-row .field-grow { flex: 1 1 320px; }
.domain-search-row .field-submit { align-self: flex-start; padding-top: 26px; }
.domain-search-row textarea { min-height: 46px; resize: vertical; }
.zone-picker { margin: 0; padding: 0; border: 0; min-width: 0; }
.zone-picker legend { margin-bottom: 8px; padding: 0; color: var(--muted); font-size: 13px; font-weight: 600; }
.zone-options { display: flex; flex-wrap: wrap; gap: 6px; }
.zone-option { position: relative; display: inline-flex; cursor: pointer; }
.zone-option input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.zone-option span { padding: 4px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-2); font-size: 13px; font-weight: 600; transition: background .15s, border-color .15s, color .15s; }
.zone-option:hover span { border-color: var(--primary); }
.zone-option input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-ink); }
.zone-option input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.zone-more { margin-top: 10px; }
.zone-more summary { margin-bottom: 8px; color: var(--muted); font-size: 13px; cursor: pointer; }
.domain-search-table .price-gross { display: block; color: var(--muted); font-size: 12px; }
.domain-search-table tr.search-available .cell-primary { font-weight: 650; }
.domain-search-table tr.search-taken .cell-primary { color: var(--muted); }
/* Domain name with its icons (auto-renew, sniper) on one line; the punycode line stays under the name. */
.name-line { display: inline-flex; align-items: flex-start; gap: 6px; max-width: 100%; }
.name-line > a { min-width: 0; }
.name-line .list-flag { flex: none; margin: 0; }
.list-flag { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; margin-left: 4px; border-radius: 999px; vertical-align: -4px; color: var(--muted); background: var(--surface-2); text-decoration: none; }
.list-flag .bi-icon { width: 12px; height: 12px; }
.list-flag-auto { color: var(--success); background: var(--success-soft); }
.list-flag-snipe-armed, .list-flag-snipe-registering { color: var(--primary); }
.list-flag-snipe-lost { color: var(--warning); background: var(--warning-soft); }
.list-flag-snipe-failed { color: var(--danger); background: var(--danger-soft); }
#sniper h2 { display: inline-flex; align-items: center; gap: 8px; }
.sniper-status { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0 0 16px; font-size: 13px; }
.sniper-status dt { color: var(--muted); }
.sniper-status dd { margin: 0; color: var(--ink-2); font-weight: 600; overflow-wrap: anywhere; }
@media (max-width: 700px) {
    .registrar-auto, .registrar-confirm-form { flex-direction: column; align-items: stretch; max-width: none; }
}
.link-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }

/* F13: renewal costs and budget */
.cost-stats { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin-top: 18px; }
.cost-tile:hover { transform: none; border-color: var(--line); }
.cost-tile .stat-value { font-size: 24px; }
.cost-tile .muted, .cost-over { font-size: 12px; }
.cost-over { color: var(--danger); font-weight: 650; }
.cost-tile meter { width: 100%; height: 8px; }
.cost-note { margin: -8px 0 8px; font-size: 13px; }
.cost-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cost-table th, .cost-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.cost-table thead th { color: var(--muted); font-size: 12px; font-weight: 700; }
.cost-table tfoot th { color: var(--ink); border-bottom: 0; }
.cost-table .cell-number { text-align: right; font-variant-numeric: tabular-nums; }
.cost-table .is-muted-row td { color: var(--subtle); }
.cost-bar-cell { min-width: 140px; }
/* Cost tables are not datatables (no card layout on phones), so they keep their own horizontal scroll. */
.table-wrap:has(> .cost-table) { overflow-x: auto; }
@media (max-width: 640px) { .cost-bar-cell { min-width: 96px; } .cost-table th, .cost-table td { padding: 8px; } }
.cost-bar-cell .cost-bar { display: block; width: 100%; height: 6px; margin-top: 4px; }
.cost-breakdowns { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0 24px; }
.cost-budget-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.cost-budget-list { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 8px 24px; }
.cost-paid-totals { margin-top: 8px; }
.payment-form { margin-top: 16px; }
.payment-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.payment-grid .payment-note { grid-column: 1 / -1; }
meter { accent-color: var(--primary); }
meter::-webkit-meter-bar { background: var(--surface-3); border: 0; border-radius: 99px; }
meter::-webkit-meter-optimum-value { background: var(--primary); border-radius: 99px; }
meter::-webkit-meter-suboptimum-value { background: var(--warning-solid); border-radius: 99px; }
meter::-webkit-meter-even-less-good-value { background: var(--danger-solid); border-radius: 99px; }
meter::-moz-meter-bar { background: var(--primary); border-radius: 99px; }

/* ---------- 13. Settings, profile, 2FA ---------- */
.reminder-days-list { display: grid; gap: 8px; margin-bottom: 12px; }
.reminder-day-row { display: flex; align-items: center; gap: 8px; max-width: 360px; }
.reminder-day-row input { max-width: 160px; }
.reminder-day-row .unit { color: var(--muted); font-size: 13px; }
.reminder-day-row .icon-button { margin-left: auto; font-size: 18px; }
.totp-setup { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 24px 32px; align-items: start; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface-2); }
.totp-qr-frame { margin: 0; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: #fff; line-height: 0; }
.totp-qr { display: block; width: 184px; height: 184px; }
.totp-steps { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; min-width: 0; }
.totp-step { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 14px; min-width: 0; }
.totp-step + .totp-step { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.step-num { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-size: 13px; font-weight: 750; }
.totp-step-body { min-width: 0; }
.totp-step-body h3 { margin: 3px 0 4px; }
.totp-step-body > .muted { margin: 0; font-size: 13px; }
.totp-key-label { margin: 14px 0 6px; color: var(--muted); font-size: 12px; font-weight: 650; }
.totp-key { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.totp-secret { flex: 0 1 auto; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font-family: var(--mono); font-size: 14px; letter-spacing: .06em; user-select: all; overflow-wrap: anywhere; }
.totp-form { margin-top: 14px; gap: 16px; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 8px 0 12px; padding: 0; list-style: none; }
.recovery-codes code { display: block; padding: 7px 9px; border: 1px solid var(--success-line); border-radius: 7px; background: var(--surface); color: var(--ink); font-size: 14px; text-align: center; user-select: all; }
.inline-status { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.inline-status p { margin: 0; }
.danger-zone { padding: 16px 18px; border: 1px solid var(--danger-line); border-radius: var(--radius-lg); background: var(--danger-soft); }
.danger-zone h3 { color: var(--danger); }
.danger-zone .muted { color: var(--text); }

/* Theme picker: each tile carries its own data-theme, so it is drawn with that theme's tokens */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 0; padding: 0; border: 0; min-width: 0; }
.theme-option { position: relative; display: grid; gap: 2px; padding: 10px; border: 1px solid var(--line-2); border-radius: var(--radius-lg); background: var(--bg); color: var(--text); font-family: var(--font); cursor: pointer; transition: border-color .15s ease, box-shadow .15s ease; }
.theme-option:hover { border-color: var(--primary); }
.theme-option:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.theme-option:has(input:focus-visible) { box-shadow: var(--ring); }
.theme-option input { position: absolute; top: 12px; right: 12px; margin: 0; }
.theme-swatch { display: grid; grid-template-rows: 10px 1fr; gap: 6px; height: 74px; margin-bottom: 6px; padding: 6px; border-radius: var(--radius); background: var(--bg); border: 1px solid var(--line); overflow: hidden; }
.theme-swatch-bar { border-radius: 3px; background: var(--surface); border-bottom: 2px solid var(--primary); }
.theme-swatch-card { display: grid; align-content: start; gap: 5px; padding: 6px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); }
.theme-swatch-card span { height: 5px; border-radius: 3px; background: var(--ink); width: 70%; }
.theme-swatch-card span + span { width: 45%; background: var(--muted); }
.theme-swatch-card .theme-swatch-button { width: 34%; height: 8px; background: var(--primary); }
.theme-option:not([data-theme]) .theme-swatch { background: linear-gradient(135deg, #f4f6fb 50%, #0e1220 50%); }
.theme-option:not([data-theme]) .theme-swatch-bar, .theme-option:not([data-theme]) .theme-swatch-card { background: color-mix(in srgb, var(--surface) 70%, transparent); }
.theme-name { color: var(--ink); font-size: 13px; font-weight: 700; }
.theme-hint { color: var(--muted); font-size: 12px; line-height: 1.35; }

/* ---------- 14. Auth pages ---------- */
.auth-main .card { padding: 32px; }
.auth-brand { display: flex; justify-content: center; margin-bottom: 22px; }
.auth-main h1 { text-align: center; }
.auth-main .card > .muted { text-align: center; }
.auth-main .form { margin-top: 22px; }
.auth-footer { margin: 18px 0 0; text-align: center; }

/* ---------- 14b. Registrars and wallet (1.0.1) ---------- */
.topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; flex: none; }
.topbar-actions .account-dropdown { margin-left: 0; }
.wallet-menu { position: relative; display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; }
.wallet-menu .bi-icon { width: 19px; height: 19px; }
.wallet-menu:hover, .hover-dropdown.is-open > .wallet-menu { background: var(--surface-3); color: var(--primary-ink); }
.wallet-alert-dot { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--warning-solid); box-shadow: 0 0 0 2px var(--surface); }
.wallet-panel { min-width: 300px; max-width: min(360px, calc(100vw - 32px)); }
.dropdown-menu a.wallet-item { display: grid; gap: 2px; white-space: normal; }
.wallet-item-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.wallet-item-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wallet-item-balance { flex: none; font-variant-numeric: tabular-nums; font-weight: 750; color: var(--ink); }
.wallet-item-balance.is-low { color: var(--warning); }
.wallet-item-meta, .wallet-item-note { color: var(--muted); font-size: 12px; font-weight: 500; }
.wallet-item-note.is-warning { color: var(--warning); font-weight: 650; }
.wallet-item-note.is-error { color: var(--danger); font-weight: 650; }
.wallet-total { display: flex; justify-content: space-between; gap: 12px; padding: 8px 11px 4px; border-top: 1px dashed var(--line); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.wallet-empty { margin: 0; padding: 6px 11px 8px; color: var(--muted); font-size: 13px; }
.registrar-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 0; }
.registrar-stats .stat-value { font-size: 22px; }
.registrar-stats .stat-tile:hover { transform: none; border-color: var(--line); }
.registrar-price-table td code, .registrar-table code { font-size: 12px; }
.registrar-price-details { margin-top: 12px; }
.registrar-price-details > summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 650; }
.registrar-price-details[open] .details-chevron { transform: rotate(90deg); }
.registrar-delete { margin-top: 12px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---------- 15. Responsive ---------- */
@media (max-width: 1100px) {
    .stat-grid { gap: 10px; }
    .stat-tile { padding: 14px; }
    .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat-tile:first-child { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
    .topbar { height: auto; min-height: 60px; padding: 10px 16px; gap: 6px 12px; flex-wrap: wrap; }
    .primary-nav { order: 3; flex-basis: 100%; margin: 0 -6px; overflow-x: auto; }
    .account-name { display: none; }
    .page-main { padding-top: 24px; }
    .page-header { flex-direction: column; align-items: stretch; }
    .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
    .info-panel { flex-direction: column; align-items: stretch; }
}
@media (max-width: 640px) {
    body { font-size: 14px; }
    .card { border-radius: 14px; padding: 18px 16px; }
    .page-main { padding: 18px 12px 96px; }
    .stat-tile { padding: 12px 14px; }
    .stat-value { font-size: 24px; }
    .section-actions { width: 100%; }
    .section-actions > .button, .section-actions > form { flex: 1; }
    .section-actions > form .button { width: 100%; }
    .form-actions { flex-direction: column-reverse; align-items: stretch; }
    .form-actions .button { width: 100%; }
    .form-actions .spacer { display: none; }
    .form-section-head { flex-direction: column; }
    .form-section-head .button { width: 100%; }
    .secret-box { flex-direction: column; align-items: stretch; }
    .recovery-codes { grid-template-columns: 1fr 1fr; }
    .totp-setup { grid-template-columns: 1fr; padding: 16px; }
    .totp-qr-frame { justify-self: center; }
    .totp-qr { width: 160px; height: 160px; }
    .bulk-result { grid-template-columns: 20px minmax(0, 1fr); }
    .bulk-result-status { grid-column: 2; justify-self: start; text-align: left; }
    .deadline-list li { grid-template-columns: minmax(0, 1fr) auto; }
    .deadline-list .deadline-date { grid-column: 1; grid-row: 2; }
    .toast-region { right: 16px; bottom: 16px; }
    .datatable-search { max-width: none; flex-basis: 100%; }
    .datatable-tools { flex-wrap: wrap; margin-left: 0; width: 100%; }
    .datatable-tools > * { flex: 1; }
    .datatable-tools > .datatable-mobile-sort { flex: 1 1 100%; order: -1; }
    .datatable-popover > summary { width: 100%; justify-content: center; }
    .datatable-popover-panel { left: 0; right: auto; }
    .datatable-tools > .datatable-popover:last-child .datatable-popover-panel { left: auto; right: 0; }
    .datatable-mobile-sort { display: block; }
    .datatable-mobile-sort select { min-height: 40px; font-size: 13px; }
    .datatable-footer { flex-direction: column-reverse; align-items: stretch; }
    .datatable-pager { justify-content: space-between; }
    .selection-bar { bottom: 10px; }
    .selection-bar .spacer { display: none; }

    /* Tables become cards on phones. */
    .table-wrap { overflow: visible; border: 0; background: transparent; }
    table.is-cards, table.is-cards tbody, table.is-cards tr, table.is-cards td { display: block; }
    table.is-cards thead { display: none; }
    table.is-cards tbody tr { position: relative; margin: 0 0 10px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-sm); }
    table.is-cards tbody tr:hover { background: var(--surface); }
    table.is-cards tbody tr.is-selected { background: var(--primary-soft); border-color: var(--primary); }
    table.is-cards tbody tr.is-today { background: var(--row-today); border-color: var(--danger-line); }
    table.is-cards tbody tr.is-today td:first-child { box-shadow: none; }
    table.is-cards td { display: grid; grid-template-columns: minmax(96px, 38%) minmax(0, 1fr); align-items: baseline; gap: 12px; padding: 6px 0; border: 0; text-align: right; max-width: none; }
    table.is-cards td::before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    table.is-cards td.cell-primary { display: block; padding: 2px 34px 6px 0; text-align: left; }
    table.is-cards td.cell-primary::before { content: none; }
    table.is-cards td.cell-select { position: absolute; top: 12px; right: 12px; display: block; width: auto; padding: 0; }
    table.is-cards td > * { justify-self: end; }
    table.is-cards td.cell-select::before { content: none; }
    table.is-cards td.cell-primary + td.cell-select, table.is-cards td.cell-select ~ td.cell-primary { padding-right: 34px; }
    table.is-cards td.actions-cell { display: flex; justify-content: flex-end; width: auto; margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
    table.is-cards td.actions-cell::before { content: none; }
    table.is-cards .cell-wrap { max-width: none; }
    .datatable-empty { border-top: 1px dashed var(--line-2); border-radius: var(--radius-lg); }
}
@media (max-width: 340px) {
    .brand-text { display: none; }
    .recovery-codes { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Action menus (export/import, bulk edit) — <details class="action-menu"> */
.action-menu { position: relative; }
.action-menu > summary { list-style: none; cursor: pointer; }
.action-menu > summary::-webkit-details-marker { display: none; }
.action-menu[open] > summary .dropdown-chevron { transform: rotate(180deg); }
.action-menu-panel { position: absolute; z-index: 30; top: calc(100% + 6px); right: 0; display: grid; gap: 4px; width: max-content; min-width: 230px; max-width: min(340px, calc(100vw - 32px)); padding: 8px; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-pop); }
.action-menu-panel > .muted { margin: 2px 6px 6px; font-size: 12px; }
.action-menu-panel .dropdown-item { white-space: normal; }
.action-menu-panel .dropdown-item .muted { font-weight: 500; }
.action-menu-up .action-menu-panel { top: auto; bottom: calc(100% + 8px); right: auto; left: 0; }
.bulk-edit .action-menu-panel { gap: 12px; padding: 14px; min-width: 260px; }
.bulk-edit .field label { font-size: 12px; color: var(--muted); }
.bulk-edit select, .bulk-edit input { width: 100%; min-height: 36px; font-size: 13px; }
.selection-bar .bulk-edit .action-menu-panel .button-secondary { color: var(--ink-2); }

/* Tags */
.tag-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 11px; font-weight: 650; line-height: 1.6; }

/* Undo after delete */
.undo-bar { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin: -6px 0 14px; font-size: 13px; color: var(--muted); }

/* Monitoring and history on the domain page */
.check-list { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 18px; margin: 0 0 12px; font-size: 13px; }
.check-list dt { color: var(--muted); }
.check-list dd { margin: 0; color: var(--ink-2); overflow-wrap: anywhere; }
.history-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.history-list > li { padding-left: 14px; border-left: 2px solid var(--line); }
.history-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 13px; }
.history-head strong { color: var(--ink-2); }
.history-head .muted { font-size: 12px; }
.history-details { margin: 4px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
section.danger-zone, form.danger-zone { margin-top: 24px; }

/* Per-domain reminder thresholds: the custom field only matters for "Własne progi" */
.reminder-fields:has(#reminder_mode option[value="custom"]:not(:checked)) .reminder-custom { display: none; }

.secret-link { word-break: break-all; }
.auth-footer { margin: 16px 0 0; text-align: center; font-size: 13px; }

@media (max-width: 640px) {
    .check-list { grid-template-columns: 1fr; gap: 2px; }
    .check-list dd { margin-bottom: 8px; }
    .action-menu-panel { right: auto; left: 0; }
}
