:root {
    --bg: #f3f6fa;
    --surface: #ffffff;
    --surface-muted: #eaf0f6;
    --surface-strong: #dfe8f1;
    --text: #17202c;
    --muted: #657284;
    --border: #d7e0e9;
    --accent: #1769aa;
    --accent-strong: #0e548e;
    --accent-soft: #e3f1fb;
    --green: #19734b;
    --green-soft: #ddf3e8;
    --amber: #8a5b00;
    --amber-soft: #fff1c9;
    --red: #a1323e;
    --red-soft: #fde6e8;
    --violet: #6951a3;
    --violet-soft: #eee8fb;
    --shadow: 0 12px 28px rgba(28, 49, 71, 0.08);
    --sidebar: #e9eef4;
}

/* Obsidian: layered volcanic glass — deep facets, a vein of amethyst, and a soft sheen where light catches an edge. */
:root[data-control-theme="dark"] {
    --bg: #0a0910;
    --surface: #18151f;
    --surface-muted: #211c2b;
    --surface-strong: #2f2740;
    --text: #f4f1fa;
    --muted: #a79fb5;
    --border: #3c3350;
    --accent: #b79ae0;
    --accent-strong: #e7d9fb;
    --accent-soft: #2c2140;
    --accent-glow: rgba(183, 154, 224, 0.45);
    --green: #8bd3ab;
    --green-soft: #1a3127;
    --amber: #ebc785;
    --amber-soft: #382c1a;
    --red: #f39ca7;
    --red-soft: #382127;
    --violet: #c9adee;
    --violet-soft: #342841;
    --shadow: 0 24px 48px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(231, 217, 251, 0.05);
    --sidebar: #0e0c15;
}

/* Depth comes from a faint glow bleeding in from one corner, like light meeting glass. */
html[data-control-theme="dark"] body {
    background:
        radial-gradient(120% 140% at 12% -12%, rgba(140, 108, 196, 0.12), transparent 55%),
        radial-gradient(90% 120% at 100% 110%, rgba(84, 66, 128, 0.10), transparent 60%),
        var(--bg);
}

/* A light accent must use dark ink, not white, on solid fills. */
:root[data-control-theme="dark"] .brand-mark,
:root[data-control-theme="dark"] .account-avatar,
:root[data-control-theme="dark"] .step-number,
:root[data-control-theme="dark"] .button.primary {
    color: #19131f !important;
}
:root[data-control-theme="dark"] .brand-mark {
    background: linear-gradient(150deg, #f2e7fc 0%, #b79ae0 55%, #6d5590 100%);
    box-shadow: 0 4px 18px rgba(150, 120, 190, 0.28);
}
:root[data-control-theme="dark"] .sidebar {
    background: linear-gradient(185deg, #1a1524 0%, var(--sidebar) 65%);
}
:root[data-control-theme="dark"] .primary-nav a[aria-current="page"] {
    box-shadow: inset 3px 0 0 var(--accent), inset 40px 0 32px -28px var(--accent-glow);
}
:root[data-control-theme="dark"] .primary-nav a:hover,
:root[data-control-theme="dark"] .sidebar-footer a:hover {
    color: var(--text);
}
:root[data-control-theme="dark"] .topbar {
    background: color-mix(in srgb, var(--bg) 90%, transparent);
}
:root[data-control-theme="dark"] .theme-button:hover,
:root[data-control-theme="dark"] .icon-button:hover,
:root[data-control-theme="dark"] .logout-button:hover {
    border-color: #6a5b85;
    background: var(--surface-muted);
}
:root[data-control-theme="dark"] .button.primary {
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 10px 24px -8px var(--accent-glow);
}
:root[data-control-theme="dark"] .button.primary:hover {
    background: var(--accent-strong);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 12px 28px -6px rgba(231, 217, 251, 0.55);
}
:root[data-control-theme="dark"] .stat,
:root[data-control-theme="dark"] .panel,
:root[data-control-theme="dark"] .record,
:root[data-control-theme="dark"] .management-card,
:root[data-control-theme="dark"] .editor-panel,
:root[data-control-theme="dark"] .team-member,
:root[data-control-theme="dark"] .role-reference {
    box-shadow: var(--shadow);
}
:root[data-control-theme="dark"] .management-card:hover {
    border-color: var(--accent);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5), 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent), inset 0 1px 0 rgba(231, 217, 251, 0.07);
}
:root[data-control-theme="dark"] .stat:hover,
:root[data-control-theme="dark"] .record:hover {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}
:root[data-control-theme="dark"] :is(a, button, input, select, textarea):focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
:root[data-control-theme="dark"] ::selection {
    color: #fff;
    background: #6c4f96;
}
:root[data-control-theme="dark"] * {
    scrollbar-color: #4d4266 var(--surface);
}

:root[data-control-theme="ri-chu"] {
    --bg: #fff8fc;
    --surface: #ffffff;
    --surface-muted: #fff1f7;
    --surface-strong: #f9dce9;
    --text: #432735;
    --muted: #7f6371;
    --border: #eccbd9;
    --accent: #d93675;
    --accent-strong: #aa2057;
    --accent-soft: #ffe1ed;
    --green: #167d72;
    --green-soft: #dcf5ef;
    --amber: #875800;
    --amber-soft: #fff0c7;
    --red: #a92e49;
    --red-soft: #ffe2e9;
    --violet: #7151a0;
    --violet-soft: #eee5fa;
    --shadow: 0 12px 30px rgba(143, 48, 86, 0.10);
    --sidebar: #fff2f7;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); color-scheme: light; }
html[data-control-theme="dark"] { color-scheme: dark; }
html[data-control-theme="ri-chu"] { color-scheme: light; }
html[data-ri-chu-welcome="visible"] body,
html[data-ri-chu-welcome="closing"] body { overflow: hidden; }
body { min-height: 100vh; margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: 0; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
.skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; transform: translateY(-150%); background: var(--surface); padding: 10px 14px; border: 1px solid var(--border); }
.skip-link:focus { transform: none; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 20px 14px; display: flex; flex-direction: column; background: var(--sidebar); border-right: 1px solid var(--border); }
.brand { min-height: 48px; display: flex; align-items: center; gap: 11px; padding: 0 10px 16px; border-bottom: 1px solid var(--border); }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; background: var(--accent); color: #fff; border-radius: 7px; font-size: 12px; font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { color: var(--muted); font-size: 11px; }
.primary-nav { min-height: 0; display: grid; gap: 3px; padding: 18px 0; overflow-y: auto; scrollbar-width: none; }
.primary-nav::-webkit-scrollbar { display: none; }
.primary-nav a, .sidebar-footer a { min-height: 40px; display: flex; align-items: center; padding: 0 12px; border-radius: 6px; color: var(--muted); font-weight: 650; }
.primary-nav a:hover, .sidebar-footer a:hover { color: var(--text); background: var(--surface-muted); }
.primary-nav a[aria-current="page"] { color: var(--accent-strong); background: var(--accent-soft); }
.sidebar-footer { margin-top: auto; display: grid; gap: 8px; padding-top: 14px; border-top: 1px solid var(--border); }
.account-link { gap: 10px; height: auto; padding: 8px !important; }
.account-link img, .account-avatar { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.account-avatar { display: grid; place-items: center; color: #fff !important; background: var(--accent); font-size: 13px !important; font-weight: 800; }
.account-link > span:last-child { min-width: 0; padding: 0; }
.account-link strong, .account-link small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-link strong { color: var(--text); font-size: 12px; }
.account-link small { color: var(--muted); font-size: 10px; }
.sidebar-footer form { margin: 0; }
.logout-button { width: 100%; min-height: 38px; padding: 0 12px; color: var(--muted); background: transparent; border: 1px solid var(--border); border-radius: 6px; text-align: left; cursor: pointer; }
.logout-button:hover { color: var(--text); background: var(--surface-muted); }
.workspace { min-width: 0; }
.topbar { position: sticky; z-index: 20; top: 0; height: 64px; display: flex; align-items: center; gap: 14px; padding: 0 clamp(16px, 3vw, 36px); background: color-mix(in srgb, var(--bg) 88%, transparent); border-bottom: 1px solid var(--border); backdrop-filter: blur(12px); }
.topbar-title { font-weight: 750; }
.theme-button, .icon-button { min-height: 36px; padding: 0 12px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
.theme-button { margin-left: auto; }
.menu-button { display: none; }
.content { width: min(1440px, 100%); margin: 0 auto; padding: 28px clamp(16px, 3vw, 40px) 56px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-heading h1 { margin: 2px 0 5px; font-size: clamp(25px, 3vw, 36px); line-height: 1.15; }
.page-heading p:not(.eyebrow) { margin: 0; color: var(--muted); }
.eyebrow { margin: 0; color: var(--accent); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; padding: 0 14px; border: 1px solid transparent; border-radius: 6px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.button.primary { background: var(--accent); color: #fff; }
.button.primary:hover { background: var(--accent-strong); }
.button.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.button.quiet { background: transparent; color: var(--muted); border-color: var(--border); }
.button:hover { filter: brightness(0.98); }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { min-height: 112px; display: flex; flex-direction: column; justify-content: space-between; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
.stat span { color: var(--muted); font-weight: 650; }
.stat strong { font-size: 30px; line-height: 1; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 16px; }
.panel { min-width: 0; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-heading h2 { margin: 2px 0 0; font-size: 18px; }
.section-heading > a { color: var(--accent); font-weight: 700; }
.warning-list, .activity-list { display: grid; gap: 8px; }
.warning-list a { display: grid; gap: 2px; padding: 12px; background: var(--amber-soft); border-left: 3px solid var(--amber); border-radius: 5px; }
.warning-list span, .activity-list small { color: var(--muted); }
.activity-list > div { display: grid; grid-template-columns: 10px minmax(0, 1fr); gap: 10px; align-items: start; padding: 8px 0; border-bottom: 1px solid var(--border); }
.activity-list > div:last-child { border-bottom: 0; }
.activity-list p, .activity-list strong, .activity-list small { display: block; margin: 0; }
.activity-dot { width: 8px; height: 8px; margin-top: 7px; border-radius: 50%; background: var(--muted); }
.activity-dot.success { background: var(--green); }
.quick-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.quick-grid a { display: grid; gap: 4px; min-height: 88px; padding: 16px; background: var(--surface-muted); border: 1px solid var(--border); border-radius: 8px; }
.quick-grid span { color: var(--muted); font-size: 12px; }
.filters { display: grid; grid-template-columns: minmax(220px, 1fr) 190px 190px auto; gap: 10px; align-items: end; margin-bottom: 18px; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.filters label { display: grid; gap: 5px; min-width: 0; color: var(--muted); font-size: 11px; font-weight: 750; }
.filters input, .filters select { width: 100%; min-height: 40px; padding: 0 11px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 5px; }
.record-list { display: grid; gap: 10px; }
.record { display: grid; grid-template-columns: minmax(260px, 1.25fr) minmax(300px, 1fr) auto; gap: 18px; align-items: center; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.record-main { min-width: 0; display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 13px; align-items: center; }
.record-image { width: 58px; height: 58px; object-fit: cover; background: var(--surface-muted); border: 1px solid var(--border); border-radius: 6px; }
.record-image.placeholder { display: grid; place-items: center; color: var(--accent); font-size: 20px; font-weight: 800; }
.record-copy { min-width: 0; }
.record-copy h2 { margin: 0 0 3px; font-size: 16px; overflow-wrap: anywhere; }
.record-copy p { margin: 0 0 8px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.badges { display: flex; flex-wrap: wrap; gap: 5px; }
.badge { display: inline-flex; align-items: center; min-height: 23px; padding: 0 8px; background: var(--surface-muted); color: var(--muted); border-radius: 999px; font-size: 11px; font-weight: 750; }
.badge.success { color: var(--green); background: var(--green-soft); }
.badge.warning { color: var(--amber); background: var(--amber-soft); }
.badge.danger { color: var(--red); background: var(--red-soft); }
.badge.violet { color: var(--violet); background: var(--violet-soft); }
.badge.ri-chu { color: #a91f57; background: #ffe0ed; }

/* Ri Chu is intentionally a complete visual mode, not only a color swap. */
:root[data-control-theme="ri-chu"] body { font-family: Inter, "Segoe UI", system-ui, sans-serif; }
:root[data-control-theme="ri-chu"] .sidebar { border-right-color: #e9bfd1; box-shadow: 8px 0 28px rgba(153, 57, 96, 0.05); }
:root[data-control-theme="ri-chu"] .brand { position: relative; padding-bottom: 22px; }
:root[data-control-theme="ri-chu"] .brand::after { content: "для Ри Чу"; position: absolute; left: 55px; bottom: 7px; color: var(--accent); font: 600 10px/1.2 Georgia, "Times New Roman", serif; }
:root[data-control-theme="ri-chu"] .brand-mark { background: #d93675; box-shadow: 0 6px 16px rgba(191, 42, 99, 0.2); }
:root[data-control-theme="ri-chu"] .page-heading h1,
:root[data-control-theme="ri-chu"] .section-heading h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 700; }
:root[data-control-theme="ri-chu"] .eyebrow { color: #c12b66; }
:root[data-control-theme="ri-chu"] .topbar { background: color-mix(in srgb, #fff8fc 91%, transparent); }
:root[data-control-theme="ri-chu"] .theme-button { color: #98204f; background: #fff; border-color: #e7b8cc; box-shadow: 0 5px 15px rgba(143, 48, 86, 0.08); }
:root[data-control-theme="ri-chu"] .button.primary { background: #d93675; box-shadow: 0 7px 17px rgba(191, 42, 99, 0.16); }
:root[data-control-theme="ri-chu"] .button.primary:hover { background: #b9255d; }
:root[data-control-theme="ri-chu"] .stat,
:root[data-control-theme="ri-chu"] .panel,
:root[data-control-theme="ri-chu"] .record,
:root[data-control-theme="ri-chu"] .management-card,
:root[data-control-theme="ri-chu"] .editor-panel,
:root[data-control-theme="ri-chu"] .team-member,
:root[data-control-theme="ri-chu"] .role-reference { border-color: #ebc6d6; box-shadow: 0 10px 24px rgba(143, 48, 86, 0.06); }
:root[data-control-theme="ri-chu"] .editor-panel > header { border-bottom-color: #eccbd9; }
:root[data-control-theme="ri-chu"] input:focus,
:root[data-control-theme="ri-chu"] select:focus,
:root[data-control-theme="ri-chu"] textarea:focus { outline-color: rgba(217, 54, 117, 0.24); }
:root[data-control-theme="ri-chu"] ::selection { color: #432735; background: #ffd5e6; }
:root[data-control-theme="ri-chu"] * { scrollbar-color: #dfa7bf #fff1f7; }

.ri-chu-welcome { display: none; position: fixed; z-index: 200; inset: 0; min-height: 100dvh; place-items: center; overflow: hidden; padding: 28px; color: #482534; background: #fff5fa; }
:root[data-ri-chu-welcome="visible"] .ri-chu-welcome { display: grid; animation: ri-chu-curtain-in 520ms ease both; }
:root[data-ri-chu-welcome="closing"] .ri-chu-welcome { display: grid; pointer-events: none; animation: ri-chu-curtain-out 360ms ease both; }
.ri-chu-welcome::before,
.ri-chu-welcome::after { content: ""; position: absolute; width: min(28vw, 320px); height: min(28vw, 320px); border: 1px solid #eab6cc; transform: rotate(45deg); opacity: .42; }
.ri-chu-welcome::before { top: -170px; left: -120px; }
.ri-chu-welcome::after { right: -120px; bottom: -170px; }
.ri-chu-welcome-content { position: relative; z-index: 2; width: min(700px, 100%); text-align: center; }
.ri-chu-monogram { width: 70px; height: 70px; display: grid; place-items: center; margin: 0 auto 28px; color: #fff; background: #d93675; border: 8px solid #ffe1ed; border-radius: 50%; box-shadow: 0 12px 30px rgba(168, 33, 84, 0.18); font: 700 18px/1 Georgia, "Times New Roman", serif; animation: ri-chu-monogram-in 700ms 120ms ease both; }
.ri-chu-kicker { margin: 0 0 12px; color: #bd2a62; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.ri-chu-welcome h1 { margin: 0; font: 700 clamp(36px, 7vw, 72px)/1.05 Georgia, "Times New Roman", serif; letter-spacing: 0; text-wrap: balance; animation: ri-chu-copy-in 700ms 180ms ease both; }
.ri-chu-wish { max-width: 540px; margin: 24px auto 0; color: #785665; font-size: clamp(15px, 2vw, 18px); line-height: 1.7; text-wrap: balance; animation: ri-chu-copy-in 700ms 260ms ease both; }
.ri-chu-dedication { margin: 28px 0 34px; color: #a82457; font: italic 600 18px/1.4 Georgia, "Times New Roman", serif; animation: ri-chu-copy-in 700ms 340ms ease both; }
.ri-chu-dismiss-choice { width: max-content; max-width: 100%; display: flex; align-items: center; justify-content: center; gap: 9px; margin: 0 auto 15px; color: #80606e; font-size: 13px; cursor: pointer; }
.ri-chu-dismiss-choice input { width: 17px; height: 17px; accent-color: #d93675; }
.ri-chu-enter { min-width: 210px; min-height: 46px; padding: 0 22px; color: #fff; background: #d93675; border: 1px solid #d93675; border-radius: 7px; box-shadow: 0 10px 24px rgba(168, 33, 84, 0.18); font-weight: 750; cursor: pointer; }
.ri-chu-enter:hover { background: #b9255d; }
.ri-chu-enter:focus-visible { outline: 3px solid rgba(217, 54, 117, 0.28); outline-offset: 4px; }
.ri-chu-petals { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.ri-chu-petals span { position: absolute; color: #dd7ca2; font: 400 28px/1 Georgia, "Times New Roman", serif; opacity: .28; animation: ri-chu-float 6s ease-in-out infinite; }
.ri-chu-petals span:nth-child(1) { left: 12%; top: 18%; }
.ri-chu-petals span:nth-child(2) { right: 14%; top: 13%; animation-delay: -1.3s; }
.ri-chu-petals span:nth-child(3) { left: 18%; bottom: 16%; animation-delay: -2.6s; }
.ri-chu-petals span:nth-child(4) { right: 20%; bottom: 20%; animation-delay: -3.7s; }
.ri-chu-petals span:nth-child(5) { left: 50%; top: 8%; animation-delay: -4.4s; }

.profile-panel > header > div { display: grid; grid-template-columns: 64px minmax(0, 1fr); column-gap: 14px; align-items: center; }
.profile-panel > header h2, .profile-panel > header p { grid-column: 2; margin: 0; }
.profile-avatar-preview { grid-column: 1; grid-row: 1 / span 2; width: 64px; height: 64px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
.profile-avatar-preview.placeholder { display: grid; place-items: center; color: #fff; background: var(--accent); font-size: 22px; font-weight: 800; }

.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.login-shell { width: min(880px, 100%); display: grid; grid-template-columns: minmax(0, .9fr) minmax(340px, 1.1fr); overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
.login-brand { display: flex; flex-direction: column; justify-content: flex-end; min-height: 500px; padding: 42px; color: #fff; background: #1769aa; }
:root[data-control-theme="dark"] .login-brand { background: #111318; border-right: 1px solid var(--border); }
.login-brand .brand-mark { margin-bottom: auto; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.28); }
.login-brand .eyebrow { color: rgba(255,255,255,.72); }
.login-brand h1 { margin: 5px 0 8px; font-size: 42px; }
.login-brand p:last-child { margin: 0; color: rgba(255,255,255,.78); }
.login-card { display: flex; flex-direction: column; justify-content: center; gap: 24px; padding: 42px; }
.login-card h2 { margin: 4px 0; font-size: 28px; }
.login-card p { margin: 0; color: var(--muted); }
.login-card form { display: grid; gap: 8px; }
.login-card label { margin-top: 8px; color: var(--muted); font-size: 12px; font-weight: 750; }
.login-card input { width: 100%; min-height: 44px; padding: 0 12px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
.login-card .button { margin-top: 14px; }

@keyframes ri-chu-curtain-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes ri-chu-curtain-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes ri-chu-monogram-in { from { opacity: 0; transform: translateY(14px) scale(.9); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes ri-chu-copy-in { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes ri-chu-float { 0%, 100% { transform: translateY(0) rotate(-5deg); } 50% { transform: translateY(-18px) rotate(7deg); } }

@media (max-width: 560px) {
    .ri-chu-welcome { padding: 22px; }
    .ri-chu-monogram { width: 60px; height: 60px; margin-bottom: 22px; border-width: 7px; }
    .ri-chu-welcome h1 { font-size: clamp(34px, 12vw, 48px); }
    .ri-chu-wish { margin-top: 18px; line-height: 1.55; }
    .ri-chu-dedication { margin: 22px 0 28px; }
    .ri-chu-enter { width: 100%; }
    .login-page { padding: 0; }
    .login-shell { min-height: 100dvh; grid-template-columns: 1fr; border: 0; border-radius: 0; }
    .login-brand { min-height: 180px; padding: 24px; }
    .login-brand .brand-mark { margin-bottom: 30px; }
    .login-brand h1 { font-size: 32px; }
    .login-card { padding: 28px 24px; }
}
.record-facts { min-width: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; margin: 0; }
.record-facts div { min-width: 0; }
.record-facts dt { color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; }
.record-facts dd { margin: 1px 0 0; overflow-wrap: anywhere; }
.record-actions { display: flex; gap: 7px; justify-content: flex-end; }
.record-actions form { margin: 0; }
.empty-state { display: grid; gap: 4px; place-items: center; min-height: 150px; padding: 20px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--text); }
.empty-state.large { min-height: 320px; background: var(--surface); border: 1px dashed var(--border); border-radius: 8px; }
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; margin-top: 20px; }
.pagination a { color: var(--accent); font-weight: 750; }
.pagination-disabled { color: var(--muted); opacity: .55; }
.pagination-jump { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 7px; margin: 0; }
.pagination-jump input { width: 5.5rem; min-height: 34px; padding: 5px 7px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 5px; }
.pagination-jump button { min-height: 34px; padding: 5px 10px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 5px; cursor: pointer; }
.messages { display: grid; gap: 8px; margin-bottom: 16px; }
.message { padding: 11px 14px; background: var(--accent-soft); border: 1px solid var(--border); border-radius: 6px; }
.message.error { background: var(--red-soft); color: var(--red); }
.message.success { background: var(--green-soft); color: var(--green); }
.sidebar-scrim { display: none; }
.heading-actions, .form-actions, .segmented { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.global-search { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; margin-bottom: 20px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.global-search label, .editor-form label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.global-search input, .editor-form input:not([type="checkbox"]), .editor-form textarea, .editor-form select { width: 100%; min-height: 40px; padding: 8px 11px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 5px; }
.search-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.result-links { display: grid; }
.result-links a { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.result-links a:last-child { border-bottom: 0; }
.result-links span { color: var(--muted); text-align: right; }
.diagnostic-list, .audit-list, .backup-list { display: grid; gap: 9px; }
.diagnostic-row { display: grid; grid-template-columns: 10px minmax(0, 1fr); gap: 11px; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 7px; }
.diagnostic-row .status-dot { width: 9px; height: 9px; margin-top: 5px; background: var(--amber); border-radius: 50%; }
.diagnostic-row.danger .status-dot { background: var(--red); }
.diagnostic-row strong, .diagnostic-row small { display: block; }
.diagnostic-row small { margin-top: 2px; color: var(--muted); }
.segmented { padding: 4px; background: var(--surface-muted); border: 1px solid var(--border); border-radius: 7px; }
.segmented a { min-height: 32px; display: inline-flex; align-items: center; padding: 0 10px; color: var(--muted); border-radius: 4px; font-weight: 700; }
.segmented a[aria-current="true"] { color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
.analytics-grid { grid-template-columns: minmax(0, 1.3fr) repeat(2, minmax(220px, 0.7fr)); }
.bar-chart { display: grid; gap: 8px; }
.bar-chart > div { display: grid; grid-template-columns: 42px minmax(0, 1fr) 36px; gap: 9px; align-items: center; }
.bar-chart time, .bar-chart strong { font-size: 12px; }
.bar-chart span { height: 9px; overflow: hidden; background: var(--surface-muted); border-radius: 4px; }
.bar-chart i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.rank-list { margin: 0; padding-left: 22px; }
.rank-list li { padding: 8px 0 8px 4px; border-bottom: 1px solid var(--border); }
.rank-list li span { display: inline-block; width: calc(100% - 45px); }
.rank-list li strong { float: right; }
.audit-list article, .backup-list article { padding: 15px; background: var(--surface); border: 1px solid var(--border); border-radius: 7px; }
.audit-list article > div, .backup-list article > div { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.audit-list p { margin: 8px 0; }
.audit-list small { color: var(--muted); }
.backup-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.backup-list dl, .preview-summary dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.backup-list dt, .preview-summary dt { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.backup-list dd, .preview-summary dd { margin: 2px 0 0; }
.notice { display: grid; gap: 4px; margin-bottom: 18px; padding: 14px; border-left: 3px solid var(--amber); background: var(--amber-soft); border-radius: 5px; }
.notice span { color: var(--muted); }
.editor-form { display: grid; gap: 15px; }
.editor-form fieldset { min-width: 0; margin: 0; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.editor-form legend { padding: 0 8px; color: var(--text); font-weight: 800; }
.editor-form legend span { display: inline-grid; place-items: center; width: 24px; height: 24px; margin-right: 6px; color: #fff; background: var(--accent); border-radius: 50%; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.field-help { margin: 0 0 14px; color: var(--muted); }
.choice-grid > div, .choice-grid > ul { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin: 0; padding: 0; list-style: none; }
.choice-grid label { min-height: 40px; display: flex; align-items: center; gap: 8px; padding: 8px 10px; color: var(--text); background: var(--surface-muted); border: 1px solid var(--border); border-radius: 5px; }
.choice-grid input { flex: 0 0 auto; }
.form-actions { position: sticky; z-index: 10; bottom: 0; justify-content: flex-end; padding: 12px; background: color-mix(in srgb, var(--surface) 94%, transparent); border: 1px solid var(--border); border-radius: 7px; backdrop-filter: blur(10px); }
.errorlist { margin: 3px 0 0; padding: 0; color: var(--red); list-style: none; font-size: 12px; }
.confirmation-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.confirmation-list > span { display: grid; gap: 2px; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 5px; }
.confirmation-list small { color: var(--muted); }
.telegram-preview { width: min(460px, 100%); overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
.telegram-preview img { width: 100%; max-height: 520px; display: block; object-fit: contain; background: #111; }
.media-placeholder { min-height: 220px; display: grid; place-items: center; padding: 20px; color: var(--muted); background: var(--surface-muted); text-align: center; }
.telegram-preview > div { padding: 15px; }
.telegram-preview p { margin: 7px 0; white-space: pre-wrap; }
.telegram-preview small { color: var(--muted); }
.preview-summary { max-width: 800px; }
.chance-list { display: grid; gap: 7px; margin-top: 16px; }
.chance-list div { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); }

@media (max-width: 1080px) {
    .stat-grid, .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .record { grid-template-columns: minmax(240px, 1fr) minmax(260px, 1fr); }
    .record-actions { grid-column: 1 / -1; padding-top: 10px; border-top: 1px solid var(--border); }
    .analytics-grid { grid-template-columns: 1fr 1fr; }
    .analytics-grid .panel:first-child { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
    .app-shell { display: block; }
    .sidebar { position: fixed; z-index: 50; left: 0; top: 0; width: min(300px, 86vw); transform: translateX(-102%); transition: transform 180ms ease; box-shadow: var(--shadow); }
    .sidebar-open .sidebar { transform: none; }
    .sidebar-scrim { position: fixed; z-index: 45; inset: 0; width: 100%; height: 100%; padding: 0; background: rgba(0, 0, 0, 0.48); border: 0; }
    .sidebar-open .sidebar-scrim { display: block; }
    .menu-button { display: inline-flex; align-items: center; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .filters { grid-template-columns: 1fr 1fr; }
    .search-field { grid-column: 1 / -1; }
    .record { grid-template-columns: 1fr; }
    .record-actions { grid-column: auto; justify-content: flex-start; }
    .search-groups, .backup-list, .form-grid { grid-template-columns: 1fr; }
    .choice-grid > div, .choice-grid > ul, .confirmation-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
    .topbar { height: 58px; }
    .content { padding-top: 20px; }
    .page-heading { align-items: stretch; flex-direction: column; gap: 14px; }
    .page-heading .button { width: 100%; }
    .stat-grid, .quick-grid, .filters { grid-template-columns: 1fr; }
    .search-field { grid-column: auto; }
    .stat { min-height: 96px; }
    .record { gap: 14px; padding: 12px; }
    .record-main { grid-template-columns: 50px minmax(0, 1fr); }
    .record-image { width: 50px; height: 50px; }
    .record-facts { grid-template-columns: 1fr 1fr; }
    .record-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .record-actions .button, .record-actions form, .record-actions form button { width: 100%; }
    .heading-actions, .global-search, .analytics-grid { display: grid; grid-template-columns: 1fr; }
    .heading-actions .button, .global-search .button { width: 100%; }
    .choice-grid > div, .choice-grid > ul, .confirmation-list { grid-template-columns: 1fr; }
    .form-actions { position: static; display: grid; grid-template-columns: 1fr; }
    .form-actions .button { width: 100%; }
}

.control-editor { display: grid; gap: 18px; padding-bottom: 88px; }
.editor-section-nav { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: thin; }
.editor-section-nav a { flex: 0 0 auto; padding: 9px 13px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 700; text-decoration: none; }
.editor-section-nav a:hover { color: var(--accent); border-color: var(--accent); }
.editor-panel { scroll-margin-top: 76px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); overflow: hidden; }
.editor-panel > header { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); background: var(--surface-muted); }
.editor-panel > header h2 { margin: 0; font-size: 17px; }
.editor-panel > header p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.step-number { display: grid; place-items: center; width: 25px; height: 25px; flex: 0 0 25px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; font-weight: 800; }
.editor-field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px 20px; padding: 20px; }
.editor-field-grid.compact { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); padding: 0; }
.editor-field { min-width: 0; }
.editor-field[hidden] { display: none !important; }
.smart-select-recipients { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.smart-select-recipient { max-width: 100%; overflow-wrap: anywhere; border: 1px solid var(--border); border-radius: 6px; padding: 6px 9px; background: var(--surface-muted); color: var(--text); cursor: pointer; }
.editor-field:has(textarea), .editor-field:has(select[multiple]) { grid-column: 1 / -1; }
.editor-field > label:not(.check-label) { display: block; margin-bottom: 7px; color: var(--text); font-size: 13px; font-weight: 750; }
.editor-field input:not([type="checkbox"]), .editor-field textarea, .editor-field select { width: 100%; min-height: 42px; box-sizing: border-box; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-muted); color: var(--text); padding: 9px 11px; font: inherit; }
.editor-field textarea { min-height: 104px; resize: vertical; }
.editor-field select[multiple] { min-height: 150px; }
.editor-field input:focus, .editor-field textarea:focus, .editor-field select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 28%, transparent); border-color: var(--accent); }
.file-picker { position: relative; min-height: 42px; display: flex; align-items: center; gap: 10px; padding: 5px; overflow: hidden; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-muted); }
.file-picker:focus-within { outline: 2px solid color-mix(in srgb, var(--accent) 28%, transparent); border-color: var(--accent); }
.editor-field .file-picker input[type="file"] { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; min-height: 0; padding: 0; opacity: 0; cursor: pointer; }
.file-picker-button { flex: 0 0 auto; padding: 7px 10px; border-radius: 4px; background: var(--surface-strong); color: var(--text); font-size: 13px; font-weight: 750; }
.file-picker-name { min-width: 0; overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.editor-field small { display: block; margin-top: 6px; color: var(--muted); line-height: 1.45; }
.check-label { display: flex; align-items: center; gap: 10px; min-height: 42px; font-weight: 700; }
.check-label input, .remove-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.errorlist { margin: 7px 0 0; padding: 0; list-style: none; color: var(--red); font-size: 13px; font-weight: 650; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--red); }
.form-errors { padding: 13px 15px; border-left: 3px solid var(--red); border-radius: 6px; background: var(--red-soft); }
.inline-editor-list { display: grid; gap: 0; }
.inline-editor-row { padding: 18px 20px; border-bottom: 1px solid var(--border); }
.inline-editor-row:last-child { border-bottom: 0; }
.inline-editor-add { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-muted); }
.remove-row { display: flex; align-items: center; gap: 8px; width: max-content; margin-top: 12px; color: var(--red); font-size: 13px; font-weight: 700; }
.editor-actions { position: sticky; z-index: 10; bottom: 12px; display: flex; justify-content: flex-end; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: color-mix(in srgb, var(--surface) 94%, transparent); box-shadow: 0 10px 28px rgba(15, 23, 42, .12); backdrop-filter: blur(12px); }

@media (max-width: 720px) {
    .editor-field-grid, .editor-field-grid.compact { grid-template-columns: 1fr; padding: 16px; }
    .editor-field:has(textarea), .editor-field:has(select[multiple]) { grid-column: auto; }
    .editor-panel > header, .inline-editor-row { padding: 16px; }
    .editor-actions { position: static; display: grid; grid-template-columns: 1fr; }
    .editor-actions .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
.management-sections { display: grid; gap: 24px; }
.management-section { border-top: 1px solid var(--border); padding-top: 18px; }
.management-section > header { margin-bottom: 12px; }
.management-section h2 { margin: 0; font-size: 1.05rem; }
.management-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 10px; }
.management-card { position: relative; display: grid; gap: 7px; min-height: 118px; padding: 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); text-decoration: none; }
.management-card:hover { border-color: var(--accent); box-shadow: 0 8px 24px rgb(15 23 42 / 8%); }
.management-card strong { padding-right: 42px; }
.management-card small { color: var(--muted); line-height: 1.45; }
.management-card-count { position: absolute; top: 13px; right: 13px; min-width: 30px; padding: 4px 7px; border-radius: 999px; background: var(--surface-strong); color: var(--muted); text-align: center; font-size: .78rem; }
.operation-panel { margin-top: 18px; }
.operation-actions { justify-content: flex-start; }
.button.danger { background: var(--danger, #b42318); color: #fff; border-color: transparent; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 1px; margin: 0; background: var(--border); }
.detail-grid > div { min-width: 0; padding: 14px; background: var(--surface); }
.detail-grid dt { margin-bottom: 6px; color: var(--muted); font-size: .78rem; }
.detail-grid dd { margin: 0; overflow-wrap: anywhere; }
.detail-grid pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; }
.related-panel, .operation-summary { margin-top: 18px; }
.related-links { display: flex; flex-wrap: wrap; gap: 9px; padding: 16px 20px; }
.team-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .7fr); gap: 18px; align-items: start; }
.team-members { display: grid; gap: 10px; }
.team-member { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.team-avatar { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 7px; background: var(--accent-soft); color: var(--accent-strong); font-size: 17px; font-weight: 850; }
.team-member-copy { min-width: 0; }
.team-member-copy h2 { margin: 0; font-size: 16px; }
.team-member-copy p { margin: 2px 0 8px; color: var(--muted); overflow-wrap: anywhere; }
.owner-lock { color: var(--muted); font-size: 12px; }
.role-reference { padding: 18px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.role-reference-list { display: grid; gap: 0; }
.role-reference-list > div { padding: 12px 0; border-bottom: 1px solid var(--border); }
.role-reference-list > div:last-child { border-bottom: 0; }
.role-reference-list p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.role-choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 20px; }
.role-choice { min-width: 0; display: flex; align-items: flex-start; gap: 11px; padding: 14px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-muted); cursor: pointer; }
.role-choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.role-choice input { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 2px; accent-color: var(--accent); }
.role-choice strong, .role-choice small { display: block; }
.role-choice small { margin-top: 4px; color: var(--muted); font-weight: 500; line-height: 1.4; }
@media (max-width: 720px) {
    .related-links { display: grid; grid-template-columns: 1fr; padding: 16px; }
    .related-links .button { width: 100%; }
    .team-layout, .role-choice-grid { grid-template-columns: 1fr; }
    .team-member { grid-template-columns: 40px minmax(0, 1fr); }
    .team-member .record-actions { grid-column: 1 / -1; }
    .team-member .record-actions .button { width: 100%; }
}

/* Lightweight in-panel navigation: keep the shell/avatar mounted and only refresh content. */
body.control-navigation-pending::before {
    content: "";
    position: fixed;
    z-index: 250;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent);
    opacity: .82;
    animation: control-navigation-progress 900ms ease-in-out infinite alternate;
    pointer-events: none;
}
body.control-navigation-pending #main-content {
    opacity: .72;
    transition: opacity 120ms ease;
}
@keyframes control-navigation-progress {
    from { transform: scaleX(.18); transform-origin: left; }
    to { transform: scaleX(.92); transform-origin: left; }
}
@media (prefers-reduced-motion: reduce) {
    body.control-navigation-pending::before { animation: none; transform: none; }
    body.control-navigation-pending #main-content { transition: none; }
}

/* Searchable relation selectors and compact filter UX. */
.smart-select-native { position: absolute !important; width: 1px !important; height: 1px !important; opacity: 0 !important; pointer-events: none !important; }
.smart-select { position: relative; width: 100%; }
.smart-select-input { width: 100%; min-height: 42px; padding: 0 12px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 7px; }
.smart-select-input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 28%, transparent); border-color: var(--accent); }
.smart-select-input.is-invalid { border-color: var(--red); outline: 2px solid color-mix(in srgb, var(--red) 18%, transparent); }
.smart-select-menu { position: absolute; z-index: 90; top: calc(100% + 5px); left: 0; right: 0; max-height: 280px; overflow-y: auto; padding: 5px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
.editor-panel .smart-select-menu { position: relative; top: auto; margin-top: 5px; }
.smart-select-option { overflow-wrap: anywhere; }
.smart-select-option { display: block; width: 100%; padding: 9px 10px; color: var(--text); background: transparent; border: 0; border-radius: 6px; text-align: left; cursor: pointer; }
.smart-select-option:hover, .smart-select-option:focus { background: var(--accent-soft); color: var(--accent-strong); outline: 0; }
.smart-select-empty { padding: 14px 10px; color: var(--muted); text-align: center; }
.filters { align-items: end; }
.filter-actions { display: flex; gap: 7px; align-items: center; }
.filter-summary { margin: -6px 0 14px; color: var(--muted); font-size: 12px; }
.filter-summary strong { color: var(--text); }

.backup-import-panel { margin-bottom: 18px; }
.backup-upload-form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.backup-upload-form label { flex: 1 1 360px; display: grid; gap: 6px; }
.form-hint { margin: 10px 0 0; color: var(--muted); font-size: 12px; }
.backup-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 430px), 1fr)); gap: 14px; }
.backup-card { padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; box-shadow: var(--shadow); }
.backup-card.ready { border-color: color-mix(in srgb, var(--accent) 42%, var(--border)); }
.backup-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.backup-card-head strong, .backup-card-head small { display: block; }
.backup-card-head small { margin-top: 3px; color: var(--muted); }
.backup-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0; }
.backup-summary div { padding: 9px; background: var(--surface-muted); border-radius: 7px; }
.backup-summary dt { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.backup-summary dd { margin: 2px 0 0; font-weight: 750; }
.backup-note { margin-bottom: 12px; padding: 9px 10px; color: var(--muted); background: var(--surface-muted); border-radius: 6px; }
.backup-note.danger { color: var(--red); background: var(--red-soft); }
.backup-restore-form { display: grid; gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.danger-check { color: var(--red); }
@media (max-width: 620px) { .backup-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } .filter-actions { width: 100%; } }

/* Player workspace, collection coverage and safer destructive actions. */
.heading-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.player-tabs { display: flex; gap: 6px; margin: 0 0 18px; padding: 6px; overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; }
.player-tabs a { flex: 0 0 auto; min-height: 36px; display: inline-flex; align-items: center; padding: 0 13px; color: var(--muted); border-radius: 6px; font-weight: 750; }
.player-tabs a:hover { color: var(--text); background: var(--surface-muted); }
.player-tabs a.active { color: var(--accent-strong); background: var(--accent-soft); }
.player-dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.player-recent-panel { margin-top: 14px; }
.compact-detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.compact-card-list { display: grid; }
.compact-card-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.compact-card-list > div:last-child { border-bottom: 0; }
.compact-card-list span, .muted-copy { color: var(--muted); }
.inventory-grant-panel { margin-bottom: 14px; }
.inventory-grant-form { display: grid; grid-template-columns: minmax(260px, 1fr) 150px auto; gap: 10px; align-items: end; }
.inventory-grant-form label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 750; }
.inventory-grant-form input, .inventory-grant-form select { min-height: 40px; padding: 0 11px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
.bulk-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.bulk-toolbar label { margin-right: auto; }
.bulk-toolbar select { min-height: 38px; padding: 0 10px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
.inventory-grid { display: grid; gap: 9px; }
.inventory-card { position: relative; display: grid; grid-template-columns: 26px 58px minmax(170px, 1fr) 80px minmax(280px, auto); gap: 12px; align-items: center; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.inventory-card.readonly { grid-template-columns: 58px minmax(170px, 1fr) 80px; }
.inventory-select { display: grid; place-items: center; }
.inventory-card-media, .collection-card-media { display: grid; place-items: center; overflow: hidden; background: var(--surface-muted); border: 1px solid var(--border); border-radius: 7px; color: var(--accent); font-weight: 800; }
.inventory-card-media { width: 58px; height: 58px; }
.inventory-card-media img, .collection-card-media img { width: 100%; height: 100%; object-fit: cover; }
.inventory-card-copy { min-width: 0; }
.inventory-card-copy strong, .inventory-card-copy small, .collection-card strong, .collection-card small { display: block; }
.inventory-card-copy small, .collection-card small { margin: 2px 0 7px; color: var(--muted); }
.inventory-quantity { font-size: 18px; font-weight: 800; text-align: center; }
.inventory-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.inventory-actions form { display: flex; gap: 5px; margin: 0; }
.inventory-actions input[type="number"] { width: 76px; min-height: 38px; padding: 0 8px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
.collection-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.collection-card { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; align-items: center; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.collection-card.missing { opacity: .72; }
.collection-card-media { width: 64px; height: 64px; }
.collection-card .button { grid-column: 1 / -1; width: 100%; min-height: 34px; }
.history-list { display: grid; gap: 8px; }
.history-list article, .ownership-list article { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 13px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.history-list strong, .history-list small, .ownership-list strong, .ownership-list small { display: block; }
.history-list small, .history-list time, .ownership-list small { margin-top: 3px; color: var(--muted); }
.ownership-list { display: grid; gap: 8px; }
.ownership-list article { grid-template-columns: minmax(0, 1fr) auto auto; }
.delete-panel { overflow: hidden; }
.delete-blockers { margin: 16px; padding: 14px; color: var(--red); background: var(--red-soft); border-radius: 7px; }
.delete-blockers ul { margin: 8px 0 0; padding-left: 20px; }
.delete-confirm-form { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; padding: 18px; border-top: 1px solid var(--border); }
@media (max-width: 900px) {
    .player-dashboard-grid { grid-template-columns: 1fr; }
    .inventory-card { grid-template-columns: 24px 50px minmax(0, 1fr) auto; }
    .inventory-card.readonly { grid-template-columns: 50px minmax(0, 1fr) auto; }
    .inventory-card-media { width: 50px; height: 50px; }
    .inventory-actions { grid-column: 1 / -1; justify-content: flex-start; padding-top: 8px; border-top: 1px solid var(--border); }
}
@media (max-width: 620px) {
    .player-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .inventory-grant-form { grid-template-columns: 1fr; }
    .inventory-card { grid-template-columns: 24px 44px minmax(0, 1fr); }
    .inventory-card.readonly { grid-template-columns: 44px minmax(0, 1fr); }
    .inventory-card-media { width: 44px; height: 44px; }
    .inventory-quantity { grid-column: 2; text-align: left; }
    .inventory-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr; }
    .inventory-actions form, .inventory-actions .button { width: 100%; }
    .inventory-actions input[type="number"] { flex: 1; width: auto; }
    .ownership-list article { grid-template-columns: 1fr auto; }
    .ownership-list article .button { grid-column: 1 / -1; width: 100%; }
    .delete-confirm-form { display: grid; grid-template-columns: 1fr; }
}


/* Catalog records: prevent overflow without changing team or player actions. */
.workspace, .content, .record-list { min-width: 0; }
.record-list .record { min-width: 0; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); }
.record-list .record-actions {
    min-width: 0;
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.record-list .record-actions > *,
.record-list .record-actions .button { max-width: 100%; }
.record-list .record-actions .button { white-space: normal; text-align: center; overflow-wrap: anywhere; }
.record-list .record-actions form { min-width: 0; }
@media (max-width: 1350px) {
    .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filters > * { min-width: 0; }
    .filters .search-field { grid-column: 1 / -1; }
    .filter-actions { flex-wrap: wrap; }
}
@media (max-width: 1080px) {
    .record-list .record { grid-template-columns: minmax(0, 1fr); }
    .record-list .record-actions { grid-column: 1; }
}
@media (max-width: 560px) {
    .filters { grid-template-columns: minmax(0, 1fr); }
    .filters .search-field { grid-column: auto; }
    .record-list .record-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .record-list .record-actions > *, .record-list .record-actions form,
    .record-list .record-actions .button, .record-list .record-actions form button { width: 100%; }
}

/* Shared paginated catalogue filters. No per-keystroke requests. */
.admin-filter-panel { padding: 16px; margin-bottom: 12px; }
.admin-filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 12px; }
.admin-filter-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.admin-filter-field input, .admin-filter-field select { width: 100%; min-width: 0; box-sizing: border-box; }
.admin-filter-search { grid-column: span 2; }
.admin-filter-advanced { margin: 14px 0; }
.admin-filter-advanced summary { cursor: pointer; margin-bottom: 12px; font-weight: 600; }
.admin-filter-panel .filter-actions { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.admin-filter-panel .muted { color: var(--muted); margin-bottom: 0; font-size: .85rem; }
.admin-filter-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; overflow-wrap: anywhere; }
@media (max-width: 600px) { .admin-filter-search { grid-column: auto; } .admin-filter-grid { grid-template-columns: 1fr; } }

.admin-filter-field { color: var(--muted); font-size: 11px; font-weight: 750; }
.admin-filter-field input, .admin-filter-field select { min-height: 40px; padding: 0 11px; font: inherit; font-size: 13px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 5px; }
.admin-filter-field input:focus-visible, .admin-filter-field select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
