:root {
    color-scheme: light;
    --page: #f4f7f6;
    --surface: #ffffff;
    --subtle: #eef3f0;
    --field: #ffffff;
    --disabled: #e9efec;
    --text: #17251e;
    --label: #34473d;
    --muted: #52655b;
    --border: #d6e0da;
    --accent: #33574c;
    --primary: #2d4b3e;
    --primary-hover: #203c30;
    --on-primary: #ffffff;
    --focus: #3d6c5d;
    --success-bg: #e3f2e9;
    --success-text: #245b3e;
    --danger-bg: #ffebee;
    --danger: #a52739;
    --warning-bg: #fff4d6;
    --warning-text: #79500d;
    --shadow: 0 12px 40px -18px rgb(32 60 48 / 18%);
    font-family: Segoe UI, Arial, sans-serif;
    color: var(--text);
    background: var(--page);
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --page: #0b0f19;
    --surface: #111827;
    --subtle: #1a2537;
    --field: #1e293b;
    --disabled: #192335;
    --text: #f1f5f9;
    --label: #e2e8f0;
    --muted: #a6b4c8;
    --border: #354155;
    --accent: #bbb8ff;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --focus: #aaa5ff;
    --success-bg: #14372b;
    --success-text: #9de0b7;
    --danger-bg: #3f2029;
    --danger: #fda4af;
    --warning-bg: #3d3018;
    --warning-text: #f6d58a;
    --shadow: 0 12px 40px -18px rgb(0 0 0 / 60%);
}

* { box-sizing: border-box; }
.form-fields { border: 0; margin: 0; padding: 0; min-width: 0; }
.settings-json { font-family: Consolas, monospace; tab-size: 2; }
.json-actions { display: flex; gap: 8px; flex-wrap: wrap; }
form[aria-busy="true"] button[type="submit"] { cursor: progress; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--page);
}

.container { max-width: 1280px; margin: auto; padding: 0 20px; }
.topbar { background: var(--accent); color: var(--on-primary); }
.topbar-inner { min-height: 62px; padding-top: 10px; padding-bottom: 10px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.brand { color: var(--on-primary); text-decoration: none; font-size: 20px; font-weight: 700; }
.userbox { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; min-width: 0; max-width: 100%; }
.userbox span { min-width: 0; overflow-wrap: anywhere; }
.userbox form { flex-shrink: 0; }
.authenticated { font-size: 14px; line-height: 1.45; }
.authenticated h1 { font-size: 24px; overflow-wrap: anywhere; }
.authenticated .brand { font-size: 18px; }
.page { padding-top: 24px; padding-bottom: 40px; }
.workspace-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.workspace-tabs a { padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border); text-decoration: none; color: var(--accent); background: var(--surface); font-weight: 600; overflow-wrap: anywhere; }
.workspace-tabs a.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.code-reference { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.code-reference-item { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding: 10px 12px; font-size: 13px; }
.code-reference-item strong { color: var(--accent); }
.code-reference-item span { overflow-wrap: anywhere; }
.code-reference-item label { font-weight: 600; }
.password-field { display: flex; gap: 6px; min-width: 0; }
.password-field input { flex: 1 1 0; min-width: 0; width: 0; }
.password-toggle { min-width: 54px; }
input[readonly] { background: var(--disabled); color: var(--muted); }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.toolbar > div { min-width: 0; }
.toolbar h1, .login-card h1 { margin: 0 0 4px; }
.muted { color: var(--muted); margin: 0; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 14px;
    text-decoration: none;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    flex-shrink: 0;
    white-space: nowrap;
    background: var(--surface);
    color: var(--text);
}

.btn-primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-light { background: var(--surface); }
.btn-small { padding: 6px 10px; }
.full { width: 100%; }

.searchbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.searchbar input { flex: 1 1 220px; min-width: 0; }
.table-wrap { max-width: 100%; }
.col-width-7 { width: 7%; }
.col-width-8 { width: 8%; }
.col-width-9 { width: 9%; }
.col-width-10 { width: 10%; }
.col-width-11 { width: 11%; }
.col-width-12 { width: 12%; }
.col-width-17 { width: 17%; }
.col-width-18 { width: 18%; }
.col-width-22 { width: 22%; }
.col-width-30 { width: 30%; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 6px 7px; border-bottom: 1px solid var(--border); text-align: left; white-space: normal; overflow-wrap: anywhere; }
th { background: var(--subtle); font-size: 13px; }
.partners-table { table-layout: fixed; background: var(--surface); font-size: 13px; }
.partner-actions { text-align: center; }
.partner-actions .btn { padding: 7px 10px; }
.partners-table td > span { min-width: 0; }

.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; }
.pagination-summary { color: var(--muted); font-size: 13px; }
.pagination-pages { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.pagination-pages a, .pagination-pages span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    padding: 5px 9px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}
.pagination-pages .active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.pagination-pages .disabled { color: var(--muted); background: var(--disabled); }
.pagination-pages .ellipsis { min-width: auto; padding-inline: 3px; border-color: transparent; background: transparent; }

.badge { padding: 4px 8px; border-radius: 999px; font-size: 12px; }
.badge.ok { background: var(--success-bg); color: var(--success-text); }
.badge.off { background: var(--danger-bg); color: var(--danger); }

.section { padding: 18px; margin-bottom: 16px; }
.section h3 { margin-top: 0; color: var(--accent); }
.section h3.section-title-danger { color: var(--danger); }
.grid-2, .grid-3, .grid-4 { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.field label { font-size: 13px; font-weight: 700; color: var(--label); }

input, textarea, select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 11px;
    background: var(--field);
    color: var(--text);
    font: inherit;
}

input:focus, textarea:focus, select:focus {
    outline: 2px solid var(--focus);
    outline-offset: 1px;
}

input:disabled, select:disabled, textarea:disabled, textarea[readonly] {
    background: var(--disabled);
    color: var(--muted);
}

.uppercase { text-transform: uppercase; }
.checks { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 16px; }
.checks label { display: flex; align-items: center; gap: 7px; }
.checks input { width: auto; }
.option-note { margin-bottom: 14px; }
.form-grid .section { padding: 12px 14px; margin-bottom: 10px; }
.form-grid .section h3 { margin: 0 0 8px; }
.form-grid .grid-2, .form-grid .grid-3, .form-grid .grid-4 { row-gap: 8px; }
.form-grid .field { gap: 2px; }
.form-grid .field .validation:empty { display: none; }
.form-grid .option-note { margin-bottom: 8px; }
.form-grid .checks { row-gap: 8px; margin-bottom: 8px; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.validation { color: var(--danger); font-size: 13px; }
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; }
.alert.success { background: var(--success-bg); color: var(--success-text); }

.login-card { width: min(440px, 100%); padding: 12px 0; border: 0; background: transparent; box-shadow: none; }
.login-card form { margin-top: 28px; }
.login-card .field { margin-bottom: 18px; }
.captcha-row { display: flex; gap: 8px; align-items: center; }
.captcha-row img { border: 1px solid var(--border); border-radius: 12px; height: 62px; width: 100%; object-fit: contain; background: #f3f4f6; }

html { min-height: 100%; scroll-padding-top: 100px; }
body { line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { letter-spacing: -.025em; }
a { color: var(--accent); }
button, input, select, textarea { accent-color: var(--primary); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:disabled, textarea:disabled, select:disabled { opacity: 1; -webkit-text-fill-color: var(--muted); }
input:-webkit-autofill { -webkit-text-fill-color: var(--text); box-shadow: 0 0 0 1000px var(--field) inset; caret-color: var(--text); }
input[type="checkbox"] { flex: 0 0 auto; }
textarea { resize: vertical; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.skip-link { position: fixed; top: 8px; left: 12px; z-index: 100; padding: 10px 16px; background: var(--surface); border: 2px solid var(--focus); border-radius: 8px; transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); color: var(--text); border-bottom: 1px solid var(--border); }
.topbar-inner { min-height: 78px; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); font-size: 18px; min-width: 0; }
.brand-mark { display: grid; place-items: center; flex: 0 0 42px; height: 42px; border-radius: 12px; color: var(--on-primary); background: var(--primary); }
.brand-mark svg { width: 25px; height: 25px; }
.brand-copy { display: flex; flex-direction: column; min-width: 0; }
.brand-copy > span { overflow-wrap: anywhere; }
.brand-copy strong { color: var(--accent); margin-left: 5px; }
.brand-copy small { color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; margin-top: 2px; }
.header-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.userbox { font-size: 13px; color: var(--muted); }
.theme-toggle { min-height: 42px; gap: 8px; border-radius: 999px; background: var(--subtle); font-size: 12px; }
.theme-toggle svg { width: 18px; height: 18px; flex-shrink: 0; }
.theme-toggle .theme-sun { display: none; }
[data-theme="dark"] .theme-toggle .theme-sun { display: block; color: #fcd34d; }
[data-theme="dark"] .theme-toggle .theme-moon { display: none; }
.btn { transition: border-color .15s, box-shadow .15s; border-radius: 10px; }
.btn:not(.btn-primary):hover { background: var(--subtle); border-color: var(--accent); }
.btn:disabled { cursor: default; }
.page { padding-top: 28px; }
.toolbar { margin-bottom: 22px; }
.toolbar h1 { font-size: clamp(23px, 3vw, 30px); font-weight: 800; }
.workspace-tabs { padding: 5px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; gap: 5px; }
.workspace-tabs a { border-color: transparent; background: transparent; border-radius: 9px; font-size: 13px; }
.workspace-tabs a:not(.active):hover { background: var(--subtle); }
.card { border-radius: 16px; }
.partner-list { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--surface); }
.partners-table th { padding-top: 13px; padding-bottom: 13px; font-weight: 700; }
.partners-table td { padding-top: 11px; padding-bottom: 11px; }
.partners-table tbody tr:hover { background: var(--subtle); }
.section h3 { font-size: 15px; }
.alert { background: var(--warning-bg); color: var(--warning-text); }
.login-page-content { width: 100%; }
.auth-shell { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); min-height: calc(100svh - 79px); }
.auth-showcase { position: relative; isolation: isolate; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; gap: 36px; padding: clamp(40px, 5vw, 80px); color: #ffffff; background: radial-gradient(circle at 0 0, #355f4a 0, transparent 55%), linear-gradient(145deg, #15241e, #2d4b3e 65%, #1e382b); }
.auth-showcase::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; background-image: radial-gradient(rgb(255 255 255 / 18%) 1px, transparent 1px); background-size: 24px 24px; opacity: .45; }
[data-theme="dark"] .auth-showcase { background: radial-gradient(circle at 0 0, #232654 0, transparent 55%), linear-gradient(145deg, #090d16, #0f172a 65%, #1e1b4b); }
.auth-eyebrow { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border: 1px solid rgb(255 255 255 / 20%); border-radius: 999px; background: rgb(255 255 255 / 6%); font-size: 11px; font-weight: 600; color: #d3efe0; }
.auth-eyebrow > span { width: 6px; height: 6px; border-radius: 50%; background: #a7f3d0; flex-shrink: 0; }
.showcase-brand { margin: 30px 0 12px; font-size: 13px; font-weight: 800; letter-spacing: .16em; color: #b5e5ca; overflow-wrap: anywhere; }
.auth-showcase h2 { font-size: clamp(30px, 3.2vw, 48px); font-weight: 800; line-height: 1.2; margin: 0 0 22px; }
.showcase-description { font-size: 15px; color: #d4e5dc; line-height: 1.8; margin: 0; max-width: 480px; }
.showcase-features { display: grid; gap: 14px; }
.showcase-feature { display: flex; gap: 14px; padding: 18px; border: 1px solid rgb(255 255 255 / 14%); border-radius: 14px; background: rgb(255 255 255 / 5%); }
.feature-icon { display: grid; place-items: center; flex: 0 0 40px; height: 40px; border-radius: 10px; color: #b5e5ca; background: rgb(167 243 208 / 10%); }
.feature-icon svg { width: 22px; height: 22px; }
.showcase-feature h3 { margin: 0 0 5px; font-size: 14px; font-weight: 700; }
.showcase-feature p { margin: 0; font-size: 12px; color: #d4e5dc; line-height: 1.7; }
.showcase-footer { display: flex; justify-content: space-between; gap: 16px; border-top: 1px solid rgb(255 255 255 / 16%); padding-top: 22px; font-size: 11px; color: #d4e5dc; }
[data-theme="dark"] .auth-eyebrow, [data-theme="dark"] .showcase-description, [data-theme="dark"] .showcase-feature p, [data-theme="dark"] .showcase-footer { color: #cbd5e1; }
[data-theme="dark"] .showcase-brand, [data-theme="dark"] .feature-icon { color: #c7d2fe; }
.auth-form-panel { min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 42px clamp(28px, 5vw, 70px) 24px; background: var(--surface); }
.login-kicker { display: block; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .1em; overflow-wrap: anywhere; }
.login-heading h1 { font-size: clamp(26px, 2.6vw, 34px); font-weight: 800; line-height: 1.25; margin: 12px 0 10px; }
.login-heading p { font-size: 14px; }
.login-heading strong { color: var(--accent); }
.login-card .field label { font-size: 13px; font-weight: 700; }
.login-card input { min-height: 48px; border-radius: 11px; }
.login-card .password-field { gap: 8px; }
.login-card .captcha-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; gap: 10px; }
.login-card .captcha-row .btn { font-size: 12px; }
[data-theme="dark"] .captcha-row img { filter: invert(.9) hue-rotate(180deg); }
.login-submit { min-height: 50px; gap: 12px; margin-top: 4px; font-size: 15px; }
.login-submit span { font-size: 20px; }
.auth-footer { color: var(--muted); font-size: 11px; text-align: center; margin-top: 26px; overflow-wrap: anywhere; }

@media (max-width: 1000px) {
    .partner-list { background: transparent; border: 0; border-radius: 0; overflow: visible; }
    .partners-table td { padding-top: 5px; padding-bottom: 5px; }
}
@media (max-width: 960px) {
    .auth-shell { display: block; }
    .auth-showcase { display: none; }
    .auth-form-panel { min-height: calc(100svh - 79px); padding: 32px 20px; background: transparent; }
    .login-card { padding: 30px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); border-radius: 20px; }
}
@media (max-width: 560px) {
    .topbar-inner { flex-wrap: nowrap; gap: 8px; min-height: 72px; }
    .brand { font-size: 14px; gap: 8px; }
    .authenticated .brand { font-size: 14px; }
    .brand-mark { flex-basis: 34px; height: 34px; border-radius: 10px; }
    .brand-mark svg { width: 21px; height: 21px; }
    .brand-copy small { font-size: 8px; letter-spacing: .03em; }
    .header-actions { justify-content: flex-end; gap: 6px; flex-shrink: 0; }
    .header-actions .userbox { gap: 6px; }
    .userbox > span { display: none; }
    .userbox .btn { font-size: 11px; padding: 6px 8px; }
    .theme-toggle { padding: 9px; min-width: 44px; }
    .theme-toggle [data-theme-caption] { display: none; }
    .workspace-tabs a { padding: 9px 10px; font-size: 12px; }
    .auth-form-panel { padding: 24px 16px; min-height: calc(100svh - 73px); }
    .login-card { padding: 24px 20px; }
    .login-heading h1 { font-size: 26px; }
    .login-kicker { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}

@media (max-width: 1000px) {
    .partners-table, .partners-table tbody { display: block; }
    .partners-table { background: transparent; }
    .partners-table colgroup { display: none; }
    .partners-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        clip-path: inset(50%);
    }
    .partners-table tbody { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .partners-table tr {
        display: flex;
        flex-direction: column;
        min-width: 0;
        padding: 9px 12px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 12px;
    }
    .partners-table td {
        display: grid;
        grid-template-columns: 100px minmax(0, 1fr);
        gap: 6px;
        align-items: start;
        padding: 3px 0;
    }
    .partners-table td[data-label]::before { content: attr(data-label); font-weight: 600; color: var(--label); }
    .partners-table td .badge { justify-self: start; }
    .partners-table .partner-actions { display: block; border: 0; padding-bottom: 0; margin-top: auto; }
    .partner-actions .btn { width: 100%; min-height: 44px; }
}

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

@media (max-width: 700px) {
    .partners-table tbody { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
    .code-reference { grid-template-columns: minmax(0, 1fr); }
    .container { padding-left: 12px; padding-right: 12px; }
    .section { padding: 14px; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
    .span-2 { grid-column: span 1; }
    .toolbar { align-items: flex-start; gap: 12px; }
    .searchbar input { flex-basis: 100%; }
    .searchbar .btn, .form-actions .btn { flex: 1 1 auto; min-height: 44px; }
    .btn { min-height: 44px; }
    .pagination { align-items: stretch; }
    .pagination-summary { flex-basis: 100%; text-align: center; }
    .pagination-pages { justify-content: center; width: 100%; }
    input, textarea, select { font-size: 16px; }
}
