:root {
    color-scheme: light;
    font: 14px/1.55 "Inter", "Microsoft YaHei", system-ui, sans-serif;
    color: #192a43;
    background: #f1f5fa;
    --ink: #192a43;
    --muted: #54657d;
    --line: #dce5ef;
    --paper: #fff;
    --blue: #2158b3;
    --blue-dark: #174890;
    --nav: #112440;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: var(--blue-dark); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid #68a2ed; outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(25px, 3vw, 34px); letter-spacing: -.025em; line-height: 1.24; }
h2 { font-size: 16px; margin-bottom: 16px; }
h3 { font-size: 15px; }
small, .muted, .rule-description { color: var(--muted); }
.muted { margin-top: 6px; }
.workspace { display: grid; grid-template-columns: 202px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 26px 16px 18px;
    background: var(--nav);
    color: #eaf1fc;
}
.brand { display: flex; align-items: center; gap: 11px; margin: 0 4px 34px; color: #fff; text-decoration: none; white-space: nowrap; }
.brand strong { font-size: 16px; }
.brand-mark {
    width: 34px;
    height: 34px;
    display: inline-grid;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 9px;
    color: #fff;
    background: var(--blue);
    font-size: 20px;
    line-height: 1;
}
.sidebar .brand-mark { background: #3776d3; }
.sidebar nav { display: grid; gap: 6px; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: #bdcde5;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 8px;
    white-space: nowrap;
}
.sidebar nav a:hover { background: #193352; color: #fff; }
.sidebar nav a[aria-current] { background: #243f63; border-color: #38577e; color: #fff; font-weight: 650; }
.nav-icon { display: inline-flex; justify-content: center; width: 17px; font-size: 17px; color: #a5c9fb; }
.sidebar-footer { margin-top: auto; padding-top: 15px; border-top: 1px solid #2a3e5c; }
.sidebar-footer button.secondary { width: 100%; color: #d9e8fa; background: transparent; border-color: #456083; }
.sidebar-footer button.secondary:hover { background: #243f63; color: #fff; }
.workspace-content { width: min(100%, 1680px); min-width: 0; padding: 30px clamp(16px, 2.5vw, 40px); justify-self: center; }
.page-heading, section > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.page-heading { margin-bottom: 22px; }
section {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 7px rgb(23 43 75 / 4%);
}
section > header { margin-bottom: 12px; }
section > header h2 { margin: 0; }
label { display: block; min-width: 0; margin-bottom: 14px; font-weight: 600; }
input:not([type=checkbox]):not([type=hidden]), select {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 40px;
    margin-top: 5px;
    padding: 7px 10px;
    border: 1px solid #b8c8dc;
    border-radius: 7px;
    color: var(--ink);
    background: #fff;
    font: inherit;
    font-weight: 450;
}
input::placeholder { color: #65748a; opacity: 1; }
input[type=checkbox] { width: 16px; height: 16px; margin: 0; flex: 0 0 auto; accent-color: var(--blue); }
button, .button {
    display: inline-flex;
    min-height: 37px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 13px;
    border: 1px solid var(--blue);
    border-radius: 7px;
    background: var(--blue);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    font: inherit;
    font-weight: 600;
}
button:hover, .button:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
button.secondary, .button.secondary { color: var(--blue-dark); background: #fff; border-color: #c8d6e7; }
button.secondary:hover, .button.secondary:hover { background: #edf4fc; border-color: #9ab4d5; }
.form-actions, .admin-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.form-actions { margin-top: 14px; }
.editor-grid, .rule-grid, .record-filter-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 16px;
    align-items: end;
}
.editor-grid > label, .rule-grid label, .record-filter-grid label { margin: 0; }
.record-filter-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.4fr) repeat(2, minmax(126px, .8fr)); }
.full-row { grid-column: 1 / -1; }
.plan-editor #alternate { grid-column: 1 / -1; }
.plan-editor .editor-grid > label:nth-of-type(2) { grid-column: 1 / -1; }
fieldset.rule-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); border: 1px solid var(--line); border-radius: 8px; margin: 0 0 14px; padding: 12px; }
fieldset legend { color: #2d4669; font-weight: 650; padding: 0 5px; }
form.rule-grid { margin-bottom: 16px; }
.check-option { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.rule-enabled { margin: 14px 0; }
.device-checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.advanced-filter { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 9px; }
.advanced-filter summary { cursor: pointer; width: fit-content; color: var(--blue-dark); font-weight: 650; }
.advanced-filter .rule-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 10px; }
.record-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.record-metrics > div { padding: 13px 16px; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.record-metrics strong { display: block; margin-top: 2px; color: var(--ink); font-size: clamp(19px, 2.7vw, 27px); line-height: 1.2; font-variant-numeric: tabular-nums; }
.record-metrics > div:last-child strong { color: var(--blue-dark); }
.table-scroll { max-width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; text-align: left; }
.data-panel table { min-width: 850px; }
.record-data table { min-width: 1250px; font-size: 13px; }
th, td { padding: 10px 11px; border-bottom: 1px solid #e7edf4; vertical-align: middle; }
th { color: #394e69; background: #eef3f9; font-weight: 650; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f6f9fd; }
td:first-child, td:last-child { min-width: 135px; }
.record-data td:first-child, .record-data td:nth-child(5) { font-variant-numeric: tabular-nums; }
.record-data td code { white-space: nowrap; font-size: 12px; }
.offer { overflow-wrap: anywhere; min-width: 140px; max-width: 280px; }
.rule-actions { display: inline-flex; gap: 5px; margin-left: 5px; }
.rule-actions button, td .copy { min-height: 30px; padding: 4px 8px; font-size: 12px; }
td .copy { margin: 0 5px; }
.data-panel > .admin-actions { margin-top: 12px; }
.record-badge { display: inline-block; padding: 3px 7px; border-radius: 8px; background: #edf2f8; color: #3b506d; white-space: nowrap; font-size: 12px; }
.record-badge.allow { background: #e3f4ea; color: #185631; }
.record-badge.alternate, .record-badge.error { background: #ffebe8; color: #921c1c; }
.rule-tabs, .rule-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.rule-tabs { width: fit-content; padding: 4px; border: 1px solid var(--line); border-radius: 9px; background: #eaf0f7; }
.rule-tabs a { padding: 6px 10px; color: #435775; text-decoration: none; border-radius: 6px; }
.rule-tabs a[aria-current] { background: #fff; color: var(--blue-dark); box-shadow: 0 1px 3px #c8d6e7; font-weight: 650; }
.rule-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 11px; }
.rule-cards article { display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--line); border-radius: 9px; padding: 13px; background: #fcfdff; }
.rule-cards header, .rule-cards footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.rule-cards footer { margin-top: auto; }
.rule-description { overflow-wrap: anywhere; }
.error, .success { border-radius: 8px; padding: 9px 12px; margin-bottom: 14px; }
.error { background: #fff1ee; color: #921c1c; }
.success { background: #e6f6ea; color: #185631; }
.login-page { display: grid; min-height: 100vh; place-items: center; padding: 20px; background: #eaf1fa; }
.login-content { width: min(100%, 405px); }
.login { padding: 28px; box-shadow: 0 14px 40px rgb(22 49 85 / 12%); }
.login h1 { margin: 16px 0 22px; font-size: 25px; }
.login button { width: 100%; }
@media (max-width: 1100px) {
    .record-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 740px) {
    .workspace { display: block; }
    .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 9px; padding: 10px 14px; }
    .brand { margin: 0; }
    .brand strong { font-size: 14px; }
    .sidebar nav { display: flex; flex: 0 0 100%; order: 3; gap: 4px; }
    .sidebar nav a { padding: 6px 7px; gap: 4px; font-size: 13px; }
    .sidebar-footer { margin: 0 0 0 auto; border: 0; padding: 0; }
    .sidebar-footer button { min-height: 32px; padding: 4px 8px; font-size: 12px; }
    .workspace-content { padding: 18px 12px; }
    .page-heading { margin-bottom: 14px; }
    section { padding: 13px; margin-bottom: 12px; }
    .record-metrics { gap: 5px; margin-bottom: 12px; }
    .record-metrics > div { padding: 8px; font-size: 12px; }
}
@media (max-width: 425px) {
    .record-filter-grid, .advanced-filter .rule-grid { gap: 8px; }
    .record-filter-grid > label:nth-child(-n+2), .advanced-filter .rule-grid label { grid-column: 1 / -1; }
    .editor-grid, .rule-grid { grid-template-columns: 1fr; }
    .page-heading .button { padding-inline: 8px; }
}
