:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e2e5ea;
  --text: #1f2430;
  --muted: #6b7280;
  --accent: #2563eb;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #b45309;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-shell { min-height: 100vh; display: flex; }
.sidebar {
  width: 252px;
  flex: 0 0 252px;
  min-height: 100vh;
  padding: 26px 14px;
  background: #edf4fc;
  border-right: 1px solid #dce7f3;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 12px 25px; color: #146ee8; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(145deg, #2c8bff, #1267df); color: #fff; font-size: 25px; font-weight: 800; box-shadow: 0 5px 12px #9cc6f680; }
.brand strong { display: block; font-size: 17px; line-height: 1.15; letter-spacing: .02em; }
.brand small { display: block; margin-top: 3px; color: #5381b6; font-size: 12px; font-weight: 600; letter-spacing: .08em; }
.sidebar-primary { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0 0 24px; min-height: 48px; border-radius: 11px; background: linear-gradient(180deg, #2a88fa, #1474ed); box-shadow: inset 0 0 0 1px #0b5fc8, 0 3px 7px #9bbde680; color: #fff; font-size: 16px; font-weight: 700; text-decoration: none; }
.sidebar-primary:hover { filter: brightness(1.04); }
.primary-icon { font-size: 20px; line-height: 1; }
.nav-label { padding: 0 12px 8px; color: #6e8198; font-size: 12px; font-weight: 700; letter-spacing: .08em; }
.nav-label-lower { margin-top: 27px; }
.account-panel { margin: 28px 6px 0; padding: 11px 12px; border: 1px solid #cadcf1; border-radius: 9px; background: #f6faff; }
.account-panel > div { display: flex; justify-content: space-between; gap: 8px; color: #60758e; font-size: 12px; }
.account-panel strong { max-width: 125px; overflow: hidden; text-overflow: ellipsis; color: #354352; }
.account-panel form { margin-top: 9px; }
.account-panel button { width: 100%; padding: 6px 8px; border: 1px solid #cadcf1; border-radius: 6px; background: #fff; color: #52677f; cursor: pointer; }
.account-panel button:hover { color: var(--accent); border-color: #9fc3ee; }
.sidebar nav { display: flex; flex-direction: column; gap: 6px; }
.sidebar nav .nav-item { display: flex; align-items: center; gap: 13px; padding: 11px 12px; color: #354352; text-decoration: none; border-radius: 9px; font-size: 15px; font-weight: 600; }
.nav-item svg { width: 22px; height: 22px; flex: 0 0 22px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.sidebar nav .nav-item:hover { color: var(--accent); background: #e2efff; }
.sidebar nav .nav-item.active { color: #126ee5; background: #d4e7ff; font-weight: 750; }

.container { width: min(1080px, calc(100% - 48px)); margin: 0 auto; padding: 24px 0; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 24px;
  margin-bottom: 20px;
}

h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
h3 { font-size: 14px; color: var(--muted); margin: 18px 0 8px; }

.muted { color: var(--muted); font-size: 13px; }
.eyebrow { color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: .06em; margin-bottom: 6px; }

.date-form { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.date-form input[type=date] { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; }
.date-form button { padding: 6px 14px; border: none; border-radius: 6px; background: var(--accent); color: #fff; cursor: pointer; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-top: 14px; }
.stat-tile { background: var(--bg); border-radius: 8px; padding: 12px 14px; }
.stat-tile .label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.stat-tile .value { font-size: 18px; font-weight: 700; }
.stat-tile .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { color: var(--muted); font-weight: 600; font-size: 12px; }
.table-wrap { overflow-x: auto; }

.pos { color: var(--green); }
.neg { color: var(--red); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.met { background: #dcfce7; color: var(--green); }
.badge.unmet { background: #fee2e2; color: var(--red); }

.target-rows { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.target-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--bg); border-radius: 8px; }
.target-row .name { font-weight: 600; font-size: 13px; }
.target-row .detail { font-size: 12px; color: var(--muted); }

.rule-note { font-size: 13px; color: var(--muted); line-height: 1.7; background: var(--bg); border-radius: 8px; padding: 12px 16px; margin-bottom: 14px; }

.upload-form { display: flex; flex-direction: column; gap: 10px; max-width: 520px; }
.upload-form input[type=file] { padding: 8px; border: 1px dashed var(--border); border-radius: 8px; }
.upload-form input[type=date] { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; width: fit-content; }
.upload-form textarea {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
}
.upload-form button { padding: 10px; border: none; border-radius: 6px; background: var(--accent); color: #fff; font-size: 14px; cursor: pointer; margin-top: 4px; }
.field-label { font-size: 12px; color: var(--muted); font-weight: 600; }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.alert.error { background: #fee2e2; color: var(--red); }
.alert.success { background: #dcfce7; color: var(--green); }
.alert.warning { background: #fef3c7; color: var(--amber); margin-bottom: 0; }

.data-status { display: flex; align-items: center; gap: 11px; padding: 13px 15px; margin: 12px 0; border-radius: 10px; border: 1px solid; }
.data-status .status-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.data-status div { display: flex; flex-direction: column; gap: 3px; }
.data-status strong { font-size: 14px; }
.data-status span { font-size: 12px; }
.data-status.live { background: #ecfdf5; border-color: #a7f3d0; color: #047857; }
.data-status.live .status-dot { background: #10b981; box-shadow: 0 0 0 4px #d1fae5; }
.data-status.history { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.data-status.history .status-dot { background: #3b82f6; }
.data-status.unavailable { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.data-status.unavailable .status-dot { background: #f59e0b; }

.cta-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 12px 16px;
  margin-top: 12px;
  font-size: 13px;
}
.cta-banner .btn {
  padding: 6px 14px;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}

.notes-list { font-size: 13px; line-height: 1.8; margin: 0; padding-left: 18px; }
.empty-cell { color: var(--muted); text-align: center; }

.operator-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.operator-tab { color: var(--muted); background: var(--bg); border: 1px solid var(--border); padding: 6px 12px; border-radius: 999px; text-decoration: none; font-size: 13px; }
.operator-tab.active { color: #fff; background: var(--accent); border-color: var(--accent); }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(145deg, #edf4fc, #f7f9fc 58%, #e8f2ff); }
.login-card { width: min(410px, 100%); padding: 34px 36px 38px; border: 1px solid #dbe6f2; border-radius: 16px; background: #fff; box-shadow: 0 18px 55px #2d5f9630; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 30px; color: #146ee8; }
.login-brand > div { display: flex; flex-direction: column; }
.login-brand strong { font-size: 18px; }
.login-brand div span { margin-top: 3px; color: #6f8cab; font-size: 12px; letter-spacing: .1em; }
.login-card h1 { margin-bottom: 8px; font-size: 22px; }
.login-card > p { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.login-form { display: flex; flex-direction: column; gap: 8px; }
.login-form label { margin-top: 5px; color: #516174; font-size: 13px; font-weight: 650; }
.login-form input { width: 100%; padding: 11px 12px; border: 1px solid #d6dde6; border-radius: 8px; font: inherit; outline: none; }
.login-form input:focus { border-color: #6da7ef; box-shadow: 0 0 0 3px #dcecff; }
.login-form button { margin-top: 10px; padding: 11px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-size: 14px; font-weight: 700; cursor: pointer; }
.access-denied { max-width: 560px; margin: 80px auto; text-align: center; padding: 48px 32px; }
.access-icon { display: grid; place-items: center; width: 50px; height: 50px; margin: 0 auto 18px; border-radius: 50%; background: #fef3c7; color: var(--amber); font-size: 25px; font-weight: 800; }
.access-link { display: inline-block; margin-top: 14px; padding: 9px 16px; border-radius: 7px; background: var(--accent); color: #fff; text-decoration: none; font-size: 14px; font-weight: 600; }
.section-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.section-toolbar h2 { margin: 0; padding: 0; border: 0; }
.add-user-trigger { padding: 8px 14px; border: none; border-radius: 7px; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; }
.user-dialog { width: min(430px, calc(100vw - 32px)); padding: 22px 24px 24px; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 20px 60px #1f293733; color: var(--text); }
.user-dialog::backdrop { background: #17203373; backdrop-filter: blur(2px); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.dialog-heading h2 { margin: 0; padding: 0; border: 0; font-size: 17px; }
.dialog-close { width: 30px; height: 30px; padding: 0; border: none; border-radius: 50%; background: var(--bg); color: var(--muted); font-size: 22px; cursor: pointer; }
.settings-form { display: flex; flex-direction: column; gap: 8px; }
.settings-form label { margin-top: 4px; color: var(--muted); font-size: 12px; font-weight: 700; }
.settings-form input, .settings-form select { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 7px; background: #fff; color: var(--text); font: inherit; }
.settings-form button { padding: 10px 14px; border: none; border-radius: 7px; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.settings-form .secondary-button { background: #eef1f5; color: var(--text); }
.badge.role-admin { background: #dbeafe; color: #1d4ed8; }
.badge.role-operator { background: #e5e7eb; color: #4b5563; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--green); }
.city-metrics { margin-bottom: 20px; }
.city-metrics .stat-tile { background: var(--card); border: 1px solid var(--border); }
.city-toolbar-title { margin-bottom: 12px; }
.city-filter-form, .bulk-city-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.city-filter-form { margin-bottom: 12px; }
.city-filter-form input, .city-filter-form select, .bulk-city-actions select, .inline-city-form select { padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px; background: #fff; color: var(--text); }
.city-filter-form button, .bulk-city-actions button { padding: 7px 12px; border: none; border-radius: 7px; background: var(--accent); color: #fff; cursor: pointer; font-weight: 600; }
.city-filter-form a { color: var(--muted); text-decoration: none; font-size: 13px; }
.bulk-city-actions { margin-bottom: 12px; padding: 10px 12px; border-radius: 8px; background: var(--bg); font-size: 13px; }
.bulk-city-actions .warning-button { background: #d97706; }
.bulk-city-actions .secondary-button { background: #64748b; }
.city-table th:first-child, .city-table td:first-child { width: 34px; text-align: center; }
.city-status { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.city-status.effective { background: #dcfce7; color: #15803d; }
.city-status.paused { background: #fee2e2; color: #b91c1c; }
.city-status.inactive { background: #e5e7eb; color: #64748b; }
.inline-city-form { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.inline-city-form button { padding: 6px 8px; border: none; border-radius: 6px; background: #e8f1ff; color: var(--accent); cursor: pointer; font-weight: 600; }
.link-button { border: none; background: transparent; cursor: pointer; font-weight: 600; }
.link-button.pause { color: #b45309; }
.link-button.resume { color: var(--green); }

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { width: 100%; min-height: auto; padding: 14px 16px; border-right: none; border-bottom: 1px solid var(--border); }
  .brand { padding: 0 0 14px; }
  .sidebar-primary, .nav-label { display: none; }
  .sidebar nav { flex-direction: row; gap: 8px; overflow-x: auto; }
  .sidebar nav .nav-item { white-space: nowrap; padding: 7px 10px; font-size: 13px; }
  .nav-item svg { width: 18px; height: 18px; flex-basis: 18px; }
  .container { width: min(100% - 32px, 1080px); padding: 16px 0; }
  .city-filter-form, .bulk-city-actions { align-items: stretch; }
}
