:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --text: #17202a;
    --muted: #66717f;
    --border: #dce2e8;
    --accent: #0e6655;
    --accent-dark: #0a4b3f;
    --warning: #8a5200;
    --warning-bg: #fff7e8;
    --danger: #a02828;
    --danger-bg: #fff0f0;
    --success: #1d6b3c;
    --success-bg: #edf8f1;
    --radius: 8px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(24px, 3vw, 34px); line-height: 1.15; letter-spacing: -0.025em; }
h2 { margin-bottom: 14px; font-size: 17px; }
code { padding: 2px 5px; border-radius: 4px; background: #eef1f4; font-size: 12px; }

.topbar { min-height: 68px; display: flex; align-items: center; gap: 24px; padding: 10px 28px; border-bottom: 1px solid var(--border); background: var(--surface); }
.brand { display: inline-flex; align-items: center; gap: 10px; min-width: max-content; color: var(--text); font-weight: 750; font-size: 15px; }
.brand:hover { text-decoration: none; }
.brand small, .account small { display: block; color: var(--muted); font-size: 11px; font-weight: 500; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 7px; background: var(--accent); color: white; font-size: 19px; }
.topbar nav { display: flex; align-items: center; gap: 4px; flex: 1; overflow-x: auto; }
.topbar nav a { padding: 8px 10px; border-radius: 6px; color: #4b5663; white-space: nowrap; font-size: 13px; font-weight: 600; }
.topbar nav a:hover, .topbar nav a.active { background: #edf5f3; color: var(--accent-dark); text-decoration: none; }
.account { display: flex; align-items: center; justify-content: flex-end; gap: 12px; text-align: right; white-space: nowrap; }

.shell { width: min(1480px, calc(100% - 40px)); margin: 30px auto 80px; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.page-heading p, .section-heading p { margin-bottom: 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 20px; box-shadow: 0 1px 2px rgb(20 32 45 / 4%); }

.button { appearance: none; display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 8px 14px; border: 1px solid #c9d1d9; border-radius: 6px; background: white; color: #293540; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.button:hover { border-color: #9da8b3; text-decoration: none; }
.button-primary { border-color: var(--accent); background: var(--accent); color: white; }
.button-primary:hover { border-color: var(--accent-dark); background: var(--accent-dark); }
.button-quiet { min-height: 32px; padding: 5px 9px; }
.button-small { min-height: 32px; padding: 5px 10px; }

.notice { margin-bottom: 18px; padding: 12px 15px; border: 1px solid; border-radius: 6px; }
.notice ul { margin: 6px 0 0; padding-left: 20px; }
.notice-success { border-color: #b9dec6; background: var(--success-bg); color: var(--success); }
.notice-warning { border-color: #ecd39d; background: var(--warning-bg); color: var(--warning); }
.notice-error { border-color: #efb8b8; background: var(--danger-bg); color: var(--danger); }

.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric-grid article { min-height: 112px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: white; }
.metric-grid span { display: block; color: var(--muted); font-size: 12px; font-weight: 650; }
.metric-grid strong { display: block; margin-top: 12px; font-size: 28px; line-height: 1; letter-spacing: -0.03em; }
.two-column { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 18px; align-items: start; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.section-heading h2 { margin-bottom: 3px; }
.config-summary dl { margin: 0; }
.config-summary dl div { display: flex; justify-content: space-between; gap: 18px; padding: 10px 0; border-bottom: 1px solid #edf0f2; }
.config-summary dt { color: var(--muted); }
.config-summary dd { margin: 0; text-align: right; font-weight: 700; }
.profile-warning { margin: 16px 0 0; padding: 10px; border-left: 3px solid #d69b2d; background: var(--warning-bg); color: var(--warning); font-size: 12px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 12px; border-bottom: 1px solid #edf0f2; text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .045em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
.empty { padding: 28px; color: var(--muted); text-align: center; }
.error-list { max-width: 420px; color: var(--danger); font-size: 12px; }
.state { padding: 3px 7px; border-radius: 4px; background: #eef1f4; color: #4c5865; font-size: 11px; font-weight: 750; }
.state-applied, .state-resolved { background: var(--success-bg); color: var(--success); }
.state-needs_review { background: var(--warning-bg); color: var(--warning); }
.state-critical { background: var(--danger-bg); color: var(--danger); }
.operation-section + .operation-section { margin-top: 18px; }

.login-panel { min-height: calc(100vh - 160px); display: grid; grid-template-columns: 1fr 420px; align-items: center; gap: clamp(40px, 8vw, 120px); max-width: 980px; margin: 0 auto; }
.login-panel > div p { max-width: 520px; color: var(--muted); font-size: 17px; }
.form-stack { display: grid; gap: 16px; }
label { display: grid; gap: 6px; color: #3e4955; font-size: 12px; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid #cbd3db; border-radius: 5px; background: white; color: var(--text); font: inherit; font-size: 13px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgb(14 102 85 / 13%); border-color: var(--accent); }
input[readonly] { background: #f1f3f5; color: #596573; }
label small { color: var(--muted); font-weight: 500; }
.check-row { display: flex; align-items: center; gap: 8px; }
.check-row input { width: 16px; min-height: 16px; }

.record-form { display: grid; gap: 16px; }
.form-toolbar { display: flex; align-items: start; gap: 16px; }
.form-toolbar > label:first-child { min-width: 260px; }
.grow { flex: 1; }
.form-section h2 { padding-bottom: 12px; border-bottom: 1px solid #edf0f2; }
.field-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.field-name { overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.field-error input, .field-error select { border-color: #d56b6b; background: #fffafa; }
.error-code { color: var(--danger); }
.sticky-actions { position: sticky; bottom: 12px; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px 14px; border: 1px solid #bfc9d1; border-radius: 8px; background: rgb(255 255 255 / 96%); box-shadow: 0 8px 28px rgb(31 45 59 / 15%); color: var(--muted); font-size: 12px; backdrop-filter: blur(8px); }
.settings-form { max-width: 760px; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 18px; margin-top: 18px; color: var(--muted); }
.search-row { display: flex; gap: 8px; max-width: 560px; margin-bottom: 16px; }

@media (max-width: 1050px) {
    .topbar { align-items: flex-start; flex-wrap: wrap; }
    .topbar nav { order: 3; width: 100%; flex-basis: 100%; }
    .metric-grid { grid-template-columns: repeat(3, 1fr); }
    .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .topbar { padding: 10px 16px; gap: 12px; }
    .account { margin-left: auto; }
    .shell { width: min(100% - 24px, 1480px); margin-top: 20px; }
    .page-heading, .form-toolbar, .sticky-actions { align-items: stretch; flex-direction: column; }
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .two-column, .login-panel { grid-template-columns: 1fr; }
    .login-panel { align-content: center; gap: 24px; }
    .field-grid { grid-template-columns: 1fr; }
    .form-toolbar > label:first-child { min-width: 0; }
}
