:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --ink: #1a2233;
    --muted: #6b7688;
    --line: #e4e9f0;
    --brand: #0f766e;
    --brand-dark: #0b5c56;
    --brand-soft: #e6f4f2;
    --danger: #c0392b;
    --danger-soft: #fdecea;
    --warn: #b7791f;
    --warn-soft: #fdf3dc;
    --ok: #1f7a4d;
    --ok-soft: #e7f6ee;
    --info: #2a5db0;
    --info-soft: #e9f0fb;
    --sidebar: #111a2b;
    --sidebar-ink: #aeb9cc;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.55;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 216px;
    background: var(--sidebar);
    color: var(--sidebar-ink);
    flex: 0 0 216px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    padding: 20px 18px 16px;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    letter-spacing: .5px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand small { display: block; color: #7f8ca3; font-size: 11px; font-weight: 400; letter-spacing: 2px; margin-top: 4px; }

.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--sidebar-ink);
    padding: 9px 12px;
    border-radius: 8px;
    margin-bottom: 2px;
    font-size: 13.5px;
    text-decoration: none;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav .nav-badge {
    background: #e0413a;
    color: #fff;
    border-radius: 10px;
    padding: 0 6px;
    font-size: 11px;
    min-width: 18px;
    text-align: center;
    line-height: 18px;
}
.nav-sep { margin: 12px 12px 6px; font-size: 11px; color: #5f6d85; letter-spacing: 1px; }

.sidebar-foot { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.06); font-size: 12px; color: #6f7d94; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: 58px;
    background: rgba(255,255,255,.9);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 650; }
.topbar .who { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 14px; }
.topbar .who a { color: var(--muted); }

.content { padding: 22px 24px 48px; max-width: 1480px; width: 100%; }

.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 15px; margin: 0; font-weight: 650; }
.card-head .sub { color: var(--muted); font-size: 12.5px; }

.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12.5px; }
.kpi .value { font-size: 27px; font-weight: 700; margin-top: 6px; letter-spacing: -.5px; }
.kpi .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.kpi.brand .value { color: var(--brand); }
.kpi.danger .value { color: var(--danger); }
.kpi.warn .value { color: var(--warn); }
.kpi.ok .value { color: var(--ok); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.toolbar .field { margin: 0; }
.toolbar .spacer { flex: 1; }

label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
    font: inherit;
    color: var(--ink);
    background: #fff;
    border: 1px solid #d5dce6;
    border-radius: 8px;
    padding: 8px 10px;
    outline: none;
    min-width: 0;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15,118,110,.12); }
textarea { resize: vertical; min-height: 76px; }
input[readonly] { background: #f7f9fb; color: var(--muted); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 8px 14px;
    font: inherit;
    font-size: 13.5px;
    font-weight: 550;
    cursor: pointer;
    background: #eef2f6;
    color: var(--ink);
    text-decoration: none;
    white-space: nowrap;
    transition: .15s;
}
.btn:hover { filter: brightness(.97); text-decoration: none; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: #fff; border-color: #d5dce6; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.table th {
    text-align: left;
    font-weight: 600;
    color: var(--muted);
    background: #f8fafc;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
    font-size: 12.5px;
}
table.table td { padding: 10px 12px; border-bottom: 1px solid #eef2f6; vertical-align: middle; }
table.table tr:last-child td { border-bottom: none; }
table.table tr:hover td { background: #fafcfd; }
table.table .num { font-variant-numeric: tabular-nums; }
table.table .actions { white-space: nowrap; }
table.table .actions a { margin-right: 10px; font-size: 12.5px; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 18px;
    background: #eef2f6;
    color: #55627a;
    white-space: nowrap;
}
.badge.passed { background: var(--ok-soft); color: var(--ok); }
.badge.failed { background: var(--danger-soft); color: var(--danger); }
.badge.pending { background: var(--info-soft); color: var(--info); }
.badge.submitted { background: var(--warn-soft); color: var(--warn); }
.badge.overdue { background: var(--danger-soft); color: var(--danger); }
.badge.invalid { background: #f2eefb; color: #6941c6; }
.badge.cancelled { background: #f0f2f5; color: #667085; text-decoration: line-through; }
.badge.watch { background: var(--danger-soft); color: var(--danger); }
.badge.ai { background: #eef4ff; color: #3538cd; }
.badge.slight { background: var(--warn-soft); color: var(--warn); }
.badge.severe { background: var(--danger-soft); color: var(--danger); }
.badge.clean { background: var(--ok-soft); color: var(--ok); }
.badge.unknown { background: #f0f2f5; color: #667085; }
.badge.open { background: var(--warn-soft); color: var(--warn); }
.badge.closed { background: var(--ok-soft); color: var(--ok); }
.badge.na { background: #f0f2f5; color: #667085; }
.badge.on { background: var(--ok-soft); color: var(--ok); }
.badge.off { background: #f0f2f5; color: #667085; }

.thumb { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: #eef2f6; display: block; }
.thumb-lg { width: 100%; max-height: 520px; object-fit: contain; border-radius: 10px; background: #0c1320; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.mt0 { margin-top: 0; }
.mt8 { margin-top: 8px; }
.mt16 { margin-top: 16px; }
.mb16 { margin-bottom: 16px; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.right { text-align: right; }

.flash { border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-size: 13.5px; border: 1px solid transparent; }
.flash.ok { background: var(--ok-soft); border-color: #b7e4c9; color: #14603c; }
.flash.err { background: var(--danger-soft); border-color: #f5c6c2; color: #962d22; }

.pager { display: flex; gap: 6px; padding: 14px 2px 2px; flex-wrap: wrap; align-items: center; }
.pager .page { padding: 4px 10px; border-radius: 7px; border: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 12.5px; }
.pager .page.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
    background: radial-gradient(1200px 600px at 15% 10%, #123c39 0%, #0d1726 55%, #0a111d 100%); }
.login-card { width: 380px; max-width: 100%; background: #fff; border-radius: 16px; padding: 34px 32px 28px; box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.login-card .logo { width: 44px; height: 44px; border-radius: 12px; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 20px; margin-bottom: 16px; }
.login-card h1 { font-size: 19px; margin: 0 0 4px; }
.login-card p.sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.login-card .btn { width: 100%; padding: 10px; margin-top: 6px; }
.login-card .foot { text-align: center; color: #9aa4b5; font-size: 12px; margin-top: 18px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }

#mapPicker { height: 380px; border-radius: 10px; border: 1px solid var(--line); background: #e9eef4; }
.map-hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }

.review-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); gap: 18px; align-items: start; }
.meta-list { display: grid; grid-template-columns: 92px 1fr; gap: 7px 12px; font-size: 13px; }
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; word-break: break-all; }
.problem-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 10px; }
.problem-chips button { font-size: 12px; padding: 4px 9px; border-radius: 999px; border: 1px solid #d5dce6; background: #fff; cursor: pointer; color: var(--muted); }
.problem-chips button:hover { border-color: var(--brand); color: var(--brand); }

.bar-row { display: grid; grid-template-columns: 92px 1fr 54px; gap: 10px; align-items: center; margin-bottom: 8px; font-size: 12.5px; }
.bar-track { height: 12px; background: #eef2f6; border-radius: 999px; overflow: hidden; display: flex; }
.bar-pass { height: 100%; background: #2e9e6b; }
.bar-fail { height: 100%; background: #d95c4f; }
.bar-label { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

.empty { padding: 36px 16px; text-align: center; color: var(--muted); font-size: 13px; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; color: var(--muted); font-size: 13px; border-bottom: 2px solid transparent; text-decoration: none; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

@media (max-width: 1100px) {
    .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .review-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .layout { display: block; }
    .sidebar { width: 100%; height: auto; position: static; flex: none; }
    .nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; }
    .nav a { margin: 0; }
    .nav-sep, .sidebar-foot { display: none; }
    .content { padding: 16px; }
    .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .topbar { padding: 0 16px; }
}
