:root {
    --canvas: #f4f7f4;
    --surface: #ffffff;
    --line: #dbe3de;
    --ink: #17231e;
    --muted: #64736b;
    --accent: #087d6f;
    --accent-strong: #046357;
    --accent-soft: #ddf1ea;
    --warn: #a96000;
    --warn-soft: #fff3d9;
    --danger: #b13732;
    --danger-soft: #fee9e7;
    --radius: 6px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); }
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 236px;
    display: flex;
    flex-direction: column;
    background: #17231e;
    color: #eaf4ef;
    border-right: 1px solid #25362e;
}

.brand {
    height: 76px;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 22px;
    font-size: 18px;
    font-weight: 760;
}

.brand-mark, .user-initial {
    display: inline-grid;
    place-items: center;
    width: 31px;
    height: 31px;
    border-radius: 6px;
    background: var(--accent);
    color: white;
    font-weight: 800;
}

.sidebar nav { display: grid; gap: 4px; padding: 14px 12px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 40px;
    padding: 0 11px;
    border-radius: 5px;
    color: #aebdb5;
    font-size: 14px;
}
.nav-item svg, .icon-text svg, .button svg { width: 17px; height: 17px; stroke-width: 2; }
.nav-item:hover, .nav-item.active { color: white; background: #28453a; }
.sidebar-footer { margin-top: auto; padding: 14px; border-top: 1px solid #2a3d34; }

.main { margin-left: 236px; min-height: 100vh; padding: 28px clamp(22px, 4vw, 56px) 52px; }
.topbar, .section-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.topbar { padding-bottom: 29px; border-bottom: 1px solid var(--line); }
.topbar h1, .section-head h2 { margin: 0; letter-spacing: 0; color: var(--ink); }
.topbar h1 { font-size: 24px; }
.section-head { margin: 34px 0 14px; }
.section-head h2 { font-size: 18px; }
.eyebrow { margin: 0 0 5px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: 0; }
.user-chip { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 14px; }
.user-initial { width: 28px; height: 28px; font-size: 12px; background: #d7e8df; color: #205145; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 24px; }
.stats article, .plan-card, .auth-form, .auth-brand, .doc-layout article {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.stats article { min-height: 108px; padding: 19px; display: grid; align-content: space-between; }
.stats span { color: var(--muted); font-size: 13px; }
.stats strong { font-size: 30px; line-height: 1; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; min-width: 640px; border-collapse: collapse; text-align: left; }
th { padding: 12px 15px; color: var(--muted); background: #f8faf8; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 800; letter-spacing: 0; text-transform: uppercase; }
td { padding: 14px 15px; border-bottom: 1px solid #edf1ee; font-size: 14px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
td strong, td small { display: block; }
td small { margin-top: 3px; color: var(--muted); font-size: 12px; }

.status { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 4px; background: #eef2ef; color: #5e6c64; font-size: 12px; font-weight: 700; text-transform: capitalize; }
.status.success, .status.active { background: var(--accent-soft); color: var(--accent-strong); }
.status.pending { background: var(--warn-soft); color: var(--warn); }
.status.suspended { background: var(--danger-soft); color: var(--danger); }
.status.muted { background: #edf0ee; color: #65726b; }

.button, .icon-text {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    min-height: 37px;
    padding: 0 13px;
    border: 1px solid #b9c9c0;
    border-radius: 5px;
    background: white;
    color: #244238;
    font-size: 13px;
    font-weight: 750;
}
.button:hover, .icon-text:hover { border-color: var(--accent); color: var(--accent-strong); }
.button.primary { border-color: var(--accent); background: var(--accent); color: white; }
.button.primary:hover { border-color: var(--accent-strong); background: var(--accent-strong); color: white; }
.button.small { min-height: 30px; padding: 0 10px; font-size: 12px; }
.icon-text.quiet { width: 100%; justify-content: flex-start; border: 0; color: #b9c8c0; background: transparent; }
.icon-text.quiet:hover { background: #28453a; color: white; }

.notice { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 19px 0; padding: 13px 15px; border: 1px solid var(--line); border-left: 4px solid var(--accent); background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; font-size: 14px; }
.notice.success { border-left-color: var(--accent); background: #f6fcf9; }
.notice.warning { border-left-color: #d38d1f; background: var(--warn-soft); }
.notice.error { border-left-color: var(--danger); background: var(--danger-soft); }
.secret-output { margin: 0; max-width: 100%; overflow: auto; padding: 10px; background: #13221b; color: #d7f8e9; border-radius: 4px; font-size: 12px; }

.provider-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.provider-row { display: flex; align-items: center; gap: 10px; min-height: 78px; padding: 13px 15px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.provider-row:nth-child(3n) { border-right: 0; }
.provider-row.selected { background: #eff9f4; box-shadow: inset 0 -2px 0 var(--accent); }
.provider-row strong, .provider-row small { display: block; }
.provider-row small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.provider-row .status { margin-left: auto; }
.config-dot { color: #8d9b93; font-size: 11px; }
.config-dot.ready { color: var(--accent); }
.editor { margin-top: 24px; padding-top: 1px; border-top: 1px solid var(--line); }

.operation-tabs { display: flex; gap: 7px; margin: 20px 0 8px; overflow-x: auto; padding-bottom: 4px; }
.operation-tab { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; min-height: 37px; padding: 0 12px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 750; }
.operation-tab svg { width: 15px; height: 15px; }
.operation-tab:hover, .operation-tab.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }

.provider-scope-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.provider-scope-grid article { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 76px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.provider-scope-grid article > div:nth-child(2) span, .provider-scope-grid article > div:nth-child(2) strong { display: block; }
.provider-scope-grid article > div:nth-child(2) span { margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.provider-scope-grid article > div:nth-child(2) strong { font-size: 14px; }
.provider-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 6px; }
.provider-icon svg { width: 20px; height: 20px; }
.provider-icon.global { background: #e4eefc; color: #285b9c; }
.provider-icon.pg { background: #ffede7; color: #a84726; }

.activation-band, .empty-state { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 92px; padding: 18px 20px; border-block: 1px solid var(--line); background: var(--surface); }
.activation-band strong, .activation-band span { display: block; }
.activation-band span { margin-top: 5px; color: var(--muted); font-size: 13px; }
.empty-state { justify-content: flex-start; margin-top: 22px; }
.empty-state > svg { width: 25px; color: var(--muted); }
.empty-state h2, .empty-state p { margin: 0; }
.empty-state h2 { font-size: 17px; }
.empty-state p { margin-top: 5px; color: var(--muted); font-size: 13px; }

.provider-settings-form { display: grid; gap: 14px; padding-bottom: 78px; }
.config-section { padding: 19px 20px 21px; border-block: 1px solid var(--line); background: var(--surface); }
.config-section + .config-section { margin-top: -1px; }
.config-section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.config-section-head h3 { margin: 0; font-size: 16px; }
.config-section-head div > span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.config-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.config-fields.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.config-fields.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.config-fields.probability-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.config-fields label > small { overflow-wrap: anywhere; }

.segmented { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; min-width: 240px; padding: 3px; border: 1px solid #c8d5cd; border-radius: 5px; background: #f2f6f3; }
.segmented label { display: block; position: relative; }
.segmented input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.segmented span { display: grid; place-items: center; min-height: 31px; padding: 0 12px; border-radius: 3px; color: var(--muted); font-size: 12px; font-weight: 750; }
.segmented input:checked + span { background: var(--surface); color: var(--accent-strong); box-shadow: 0 1px 3px rgba(23, 35, 30, .14); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.mode-lock { display: inline-flex; align-items: center; gap: 7px; min-height: 31px; padding: 0 10px; border: 1px solid #bdd8cd; border-radius: 4px; background: var(--accent-soft); color: var(--accent-strong); font-size: 12px; font-weight: 750; }
.mode-lock svg { width: 15px; height: 15px; }

.input-suffix { position: relative; display: block; }
.input-suffix input { padding-right: 34px; }
.input-suffix b { position: absolute; top: 50%; right: 11px; transform: translateY(-50%); color: var(--muted); font-size: 12px; }
.config-groups { display: grid; gap: 8px; }
.config-group { border: 1px solid var(--line); border-radius: 5px; background: #fbfcfb; }
.config-group summary { display: grid; grid-template-columns: minmax(0, 1fr) auto 18px; align-items: center; gap: 10px; min-height: 46px; padding: 0 13px; cursor: pointer; list-style: none; font-size: 13px; font-weight: 800; }
.config-group summary::-webkit-details-marker { display: none; }
.config-group summary small { color: var(--muted); font-size: 11px; font-weight: 650; }
.config-group summary svg { width: 16px; transition: transform .18s ease; }
.config-group[open] summary svg { transform: rotate(180deg); }
.config-group .config-fields { padding: 14px; border-top: 1px solid var(--line); background: var(--surface); }
.setting-toggle { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px; min-height: 48px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 4px; background: #fafcfa; }
.setting-toggle > input[type="hidden"] { display: none; }
.setting-toggle > input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.setting-toggle strong, .setting-toggle small { display: block; }
.setting-toggle small { margin-top: 3px; overflow-wrap: anywhere; }
.sticky-actions { position: sticky; z-index: 4; bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 60px; padding: 10px 12px 10px 16px; border: 1px solid #b9c9c0; border-radius: 6px; background: rgba(255, 255, 255, .96); box-shadow: 0 7px 24px rgba(25, 47, 38, .12); backdrop-filter: blur(8px); }
.sticky-actions > span { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.sticky-actions > span svg { width: 17px; color: var(--accent); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px 17px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.form-grid.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
label { display: grid; gap: 7px; color: #394a41; font-size: 13px; font-weight: 700; }
label small { color: var(--muted); font-size: 11px; font-weight: 600; }
input, select { width: 100%; min-height: 39px; padding: 0 10px; border: 1px solid #c8d5cd; border-radius: 4px; background: white; color: var(--ink); outline: none; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(8, 125, 111, .12); }
.wide, .form-actions { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; padding-top: 4px; }
.toggle { grid-template-columns: auto 1fr; align-items: center; gap: 10px; min-height: 39px; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.inline-form { display: flex; align-items: center; gap: 7px; min-width: 320px; }
.inline-form select { min-height: 30px; font-size: 12px; }

.plan-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.plan-card { display: grid; gap: 14px; padding: 20px; }
.doc-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.doc-layout article { padding: 19px; }
.doc-layout h3 { margin: 0 0 10px; font-size: 16px; }
.doc-layout p { margin: 11px 0 0; color: var(--muted); line-height: 1.5; font-size: 14px; }
code { padding: 3px 5px; background: #e7efea; color: #1d5043; border-radius: 3px; overflow-wrap: anywhere; font-size: .9em; }

.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(260px, .85fr) minmax(340px, 430px); align-items: center; justify-content: center; gap: 40px; padding: 30px; }
.auth-brand { min-height: 260px; padding: 32px; background: #17231e; border-color: #17231e; color: #edf8f2; }
.auth-brand .brand-mark { width: 42px; height: 42px; margin-bottom: 29px; }
.auth-brand h1 { margin: 0 0 9px; font-size: 30px; letter-spacing: 0; }
.auth-brand p { margin: 0; color: #bdd2c6; line-height: 1.5; }
.auth-form { display: grid; gap: 17px; padding: 28px; }
.auth-form h2 { margin: 0 0 4px; font-size: 21px; }
.auth-form fieldset { display: grid; gap: 8px; padding: 0; border: 0; }
.auth-form legend { margin-bottom: 8px; color: #394a41; font-size: 13px; font-weight: 700; }
.choice { grid-template-columns: auto 1fr; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 4px; }
.choice input { width: 17px; height: 17px; accent-color: var(--accent); }
.choice strong, .choice small { display: block; }
.choice small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.auth-link { margin: 0; color: var(--muted); font-size: 13px; }
.auth-link a { color: var(--accent-strong); font-weight: 750; }
.field-error { margin: 0; color: var(--danger); font-size: 13px; font-weight: 700; }

@media (max-width: 1050px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .provider-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .provider-row:nth-child(3n) { border-right: 1px solid var(--line); }
    .provider-row:nth-child(2n) { border-right: 0; }
    .form-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .config-fields.four, .config-fields.probability-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .sidebar { position: static; width: auto; min-height: auto; }
    .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sidebar-footer { display: none; }
    .main { margin-left: 0; padding: 20px 15px 36px; }
    .topbar { align-items: flex-start; }
    .user-chip span:last-child { display: none; }
    .stats, .plan-grid, .doc-layout, .provider-list, .form-grid, .form-grid.compact, .provider-scope-grid, .config-fields, .config-fields.three, .config-fields.four, .config-fields.probability-grid { grid-template-columns: 1fr; }
    .provider-row, .provider-row:nth-child(2n), .provider-row:nth-child(3n) { border-right: 0; }
    .form-actions { justify-content: stretch; }
    .form-actions .button { width: 100%; }
    .auth-shell { grid-template-columns: 1fr; gap: 16px; padding: 16px; }
    .auth-brand { min-height: auto; }
    .notice { align-items: flex-start; flex-direction: column; }
    .provider-scope-grid article { grid-template-columns: 42px minmax(0, 1fr); }
    .provider-scope-grid article > .status { grid-column: 2; justify-self: start; }
    .activation-band, .config-section-head, .sticky-actions { align-items: stretch; flex-direction: column; }
    .activation-band .button, .sticky-actions .button { width: 100%; }
    .segmented { width: 100%; min-width: 0; }
}
