:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1c2733;
  --muted: #64748b;
  --line: #dfe6ee;
  --brand: #0b3d91;      /* deep civic blue */
  --brand-2: #1058b8;
  --accent: #0a7d4f;     /* civic green */
  --danger: #b3372f;
  --warn-bg: #fef3c7;
  --open-bg: #dcfce7;
  --open-ink: #14532d;
  --closed-bg: #fee2e2;
  --closed-ink: #7f1d1d;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 42, 67, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ---------------- header ---------------- */

.site-header {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  padding: 22px 0 0;
  box-shadow: var(--shadow);
}

.masthead { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
.masthead h1 { margin: 0 0 4px; font-size: 1.6rem; letter-spacing: 0.3px; }
.subtitle { margin: 0; max-width: 640px; opacity: 0.92; font-size: 0.95rem; }
.subtitle strong { color: #ffe9a8; }

.refresh-box { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.refresh-status { font-size: 0.8rem; opacity: 0.9; min-height: 1em; max-width: 300px; text-align: right; }
.scheduler-status { font-size: 0.78rem; opacity: 0.88; min-height: 1em; max-width: 320px; text-align: right; }

.btn {
  border: 0; border-radius: 8px; padding: 9px 16px;
  font-size: 0.9rem; font-weight: 600; cursor: pointer;
}
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn-accent { background: #ffe9a8; color: #5b4300; }
.btn-accent:hover:not(:disabled) { background: #ffdf7e; }

/* ---------------- tabs ---------------- */

.town-tabs { display: flex; gap: 6px; margin-top: 18px; flex-wrap: wrap; }
.tab {
  border: 0; border-radius: 10px 10px 0 0;
  background: rgba(255, 255, 255, 0.14);
  color: #fff; padding: 11px 18px;
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
}
.tab:hover { background: rgba(255, 255, 255, 0.24); }
.tab.active { background: var(--bg); color: var(--brand); }
.badge {
  background: rgba(15, 23, 42, 0.14); border-radius: 999px;
  font-size: 0.75rem; padding: 1px 9px; font-weight: 700;
}
.tab.active .badge { background: var(--brand); color: #fff; }
.badge-new { background: #15803d; color: #fff; margin-left: 2px; }
.tab.active .badge-new { background: #15803d; }

/* ---------------- controls & stats ---------------- */

main { padding: 20px 20px 40px; }

.controls { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.controls input[type="search"] {
  flex: 1 1 260px; padding: 9px 13px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 0.95rem;
}
.controls select {
  padding: 9px 10px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 0.9rem; background: var(--card);
}

.stats { margin-bottom: 12px; font-size: 0.88rem; color: var(--muted); }
.stats strong { color: var(--ink); }

/* ---------------- table ---------------- */

.table-wrap {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }

thead th {
  text-align: left; padding: 11px 12px;
  background: #eef2f7; color: #334155;
  border-bottom: 2px solid var(--line);
  white-space: nowrap; user-select: none;
}
thead th.sortable { cursor: pointer; }
thead th.sortable:hover { color: var(--brand); }
thead th .dir { font-size: 0.7rem; margin-left: 3px; }

tbody td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:hover { background: #f8fafc; }

.pos { font-weight: 600; color: var(--brand); max-width: 300px; }
.agy { max-width: 220px; color: #475569; }
.plc { color: #475569; }
.item { font-family: Consolas, Menlo, monospace; font-size: 0.8rem; white-space: nowrap; }

.pill {
  display: inline-block; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; padding: 3px 10px; white-space: nowrap;
}
.pill.open { background: var(--open-bg); color: var(--open-ink); }
.pill.closed { background: var(--closed-bg); color: var(--closed-ink); }
.pill.new { background: var(--warn-bg); color: #92400e; }

.btn-detail {
  border: 1px solid var(--brand-2); color: var(--brand-2); background: #fff;
  border-radius: 7px; padding: 5px 11px; font-size: 0.8rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.btn-detail:hover { background: var(--brand-2); color: #fff; }

.empty { text-align: center; color: var(--muted); padding: 34px 12px !important; }

/* ---------------- pager ---------------- */

.pager { display: flex; gap: 6px; justify-content: center; padding: 14px; flex-wrap: wrap; }
.pager button {
  border: 1px solid var(--line); background: #fff; border-radius: 7px;
  padding: 6px 12px; cursor: pointer; font-size: 0.85rem;
}
.pager button:hover:not(:disabled) { border-color: var(--brand-2); color: var(--brand-2); }
.pager button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager button:disabled { opacity: 0.45; cursor: default; }

/* ---------------- footer ---------------- */

.site-footer { margin-top: 26px; font-size: 0.8rem; color: var(--muted); }
.site-footer a { color: var(--brand-2); }

@media (max-width: 720px) {
  .pos, .agy, .plc { max-width: none; }
  .masthead { flex-direction: column; }
  .refresh-box { align-items: flex-start; }
  .refresh-status, .scheduler-status { text-align: left; }
}
