:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --ink: #1d2733;
    --muted: #6f7b88;
    --line: #d9e0e7;
    --nav: #17202a;
    --accent: #2077d4;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Segoe UI", Arial, sans-serif;
    letter-spacing: 0;
}

.layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 232px;
    background: var(--nav);
    color: #dce6f0;
    padding: 20px 14px;
    position: fixed;
    inset: 0 auto 0 0;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 21px; font-weight: 700; margin-bottom: 26px; }
.brand-mark { color: #77c56b; font-size: 24px; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #b9c5d1;
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 4px;
}
.sidebar nav a.active, .sidebar nav a:hover { background: #243241; color: #fff; }
.main { margin-left: 232px; padding: 28px; width: calc(100% - 232px); }

.page-head {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
    margin-bottom: 18px;
}
.page-head h1 { font-size: 26px; margin: 0 0 4px; font-weight: 700; }
.page-head p { margin: 0; color: var(--muted); }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.compact-alert { border-radius: 6px; padding: 10px 14px; }

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.metric {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}
.metric span { display: block; color: var(--muted); font-size: 13px; }
.metric strong { display: block; font-size: 24px; margin: 4px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric small { color: var(--muted); display: block; min-height: 20px; }

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}
.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.panel h2, .panel-head h2 { font-size: 17px; margin: 0 0 12px; font-weight: 700; }
.panel-head h2 { margin: 0; }
.table { margin-bottom: 0; }
.table th { color: #526171; font-size: 13px; background: #f8fafc; }
code { color: #31465d; background: #f1f4f7; padding: 2px 4px; border-radius: 4px; }
.reason { max-width: 520px; white-space: normal; }
.name-cell { max-width: 420px; }
.empty { text-align: center; color: var(--muted); padding: 34px 10px !important; }

.filter-bar {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) 160px 160px 44px;
    gap: 8px;
    margin-bottom: 12px;
}
.pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--line);
    padding-top: 12px;
    color: var(--muted);
}

.import-toolbar {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto auto;
    gap: 8px;
    margin-bottom: 10px;
}
.import-table-wrap {
    max-height: 58vh;
    overflow: auto;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.panel-form .panel label {
    display: block;
    font-size: 13px;
    color: #4b5968;
    margin-bottom: 12px;
}
.panel-form .form-control, .panel-form .form-select { margin-top: 5px; }
.field-note {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
}
.rule-mode-panel {
    border-color: #b9d4ef;
    background: #f8fbff;
}
.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0 14px;
}
.check-row label { margin: 0 !important; }
.form-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

@media (max-width: 980px) {
    .sidebar { position: static; width: 100%; }
    .layout { display: block; }
    .main { margin-left: 0; width: 100%; padding: 18px; }
    .metric-grid, .form-grid { grid-template-columns: 1fr; }
    .filter-bar, .import-toolbar { grid-template-columns: 1fr; }
    .page-head { display: block; }
    .head-actions { margin-top: 12px; }
}
