:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --line: #e2e6ef;
  --line-soft: #eef1f7;
  --ink: #101828;
  --ink-2: #475467;
  --ink-3: #8a94a6;
  --brand: #123c8c;
  --brand-2: #1c56c4;
  --brand-soft: #eaf0fd;
  --ok: #067647;
  --ok-soft: #e6f4ec;
  --warn: #b54708;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
  --shadow-lg: 0 8px 28px rgba(16, 24, 40, .10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
a { color: var(--brand-2); }
.hidden { display: none !important; }

/* ------------------------------------------------------------- login ---- */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #dce7fb 0%, var(--bg) 60%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 32px 28px;
}
.login-card .brand { text-align: center; margin-bottom: 24px; }
.login-card .brand .mark {
  display: inline-grid; place-items: center;
  width: 52px; height: 52px; border-radius: 13px;
  background: var(--brand); color: #fff;
  font-weight: 750; font-size: 17px; letter-spacing: .5px;
  margin-bottom: 12px;
}
.login-card .brand h1 { font-size: 19px; }
.login-card .brand p { margin: 4px 0 0; color: var(--ink-3); font-size: 13px; }

/* ------------------------------------------------------------- shell ---- */

.topbar {
  background: var(--brand);
  color: #fff;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 56px;
  position: sticky; top: 0; z-index: 40;
}
.topbar .logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; letter-spacing: .3px; font-size: 15px;
  padding-right: 18px; border-right: 1px solid rgba(255,255,255,.18);
  height: 100%;
}
.topbar .logo .mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: rgba(255,255,255,.14);
  display: grid; place-items: center; font-size: 12px;
}
.topbar nav { display: flex; gap: 2px; height: 100%; flex: 1; overflow-x: auto; }
.topbar nav button {
  background: none; border: 0; color: rgba(255,255,255,.72);
  font: inherit; font-size: 13.5px; font-weight: 500;
  padding: 0 14px; cursor: pointer; white-space: nowrap;
  border-bottom: 2.5px solid transparent;
}
.topbar nav button:hover { color: #fff; background: rgba(255,255,255,.06); }
.topbar nav button.active { color: #fff; border-bottom-color: #ffd166; font-weight: 600; }

.userbox { display: flex; align-items: center; gap: 10px; }
.userbox .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,.16); display: grid; place-items: center;
  font-size: 12px; font-weight: 650;
}
.userbox .meta { line-height: 1.25; text-align: right; }
.userbox .meta .nm { font-size: 13px; font-weight: 600; }
.userbox .meta .rl { font-size: 11px; color: rgba(255,255,255,.65); text-transform: uppercase; letter-spacing: .4px; }
.userbox button {
  background: rgba(255,255,255,.12); border: 0; color: #fff;
  border-radius: 7px; padding: 7px 11px; font: inherit; font-size: 12.5px; cursor: pointer;
}
.userbox button:hover { background: rgba(255,255,255,.2); }

main { padding: 22px; max-width: 1500px; margin: 0 auto; }

.page-head { margin-bottom: 18px; }
.page-head h2 { font-size: 20px; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }

/* -------------------------------------------------------------- cards ---- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card > header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
}
.card > header h3 { font-size: 14.5px; }
.card > header .sub { color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }
.card .body { padding: 18px; }

/* -------------------------------------------------------------- forms ---- */

.grid { display: grid; gap: 14px; }
.form-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

label.field { display: block; }
label.field > span {
  display: block; font-size: 12px; font-weight: 600; color: var(--ink-2);
  margin-bottom: 6px; letter-spacing: .01em;
}
label.field > span .req { color: var(--danger); }

input, select, textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff; font: inherit; font-size: 13.5px; color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: 0; border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(28, 86, 196, .12);
}
input[readonly] { background: #f7f8fb; color: var(--ink-3); }
::placeholder { text-transform: none; color: var(--ink-3); opacity: 1; }
select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' fill='none' stroke='%23667' stroke-width='1.6' stroke-linecap='round'/></svg>"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }

.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; flex-wrap: wrap; }

/* password fields with a show/hide toggle */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 58px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; cursor: pointer; padding: 4px 7px; border-radius: 6px;
  font: inherit; font-size: 11.5px; font-weight: 700; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: .04em;
}
.pw-toggle:hover { color: var(--brand-2); background: var(--brand-soft); }
.pw-match { font-size: 11.5px; margin-top: 4px; min-height: 15px; font-weight: 600; color: var(--danger); }
.pw-match.ok { color: var(--ok); }

/* station type-ahead */
.ac { position: relative; }
.ac-list {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0;
  background: #fff; border: 1px solid var(--line); border-radius: 9px;
  box-shadow: var(--shadow-lg); max-height: 260px; overflow-y: auto; min-width: 260px;
}
.ac-item {
  padding: 8px 11px; cursor: pointer; display: flex; align-items: baseline; gap: 8px;
  border-bottom: 1px solid var(--line-soft);
}
.ac-item:last-child { border-bottom: 0; }
.ac-item:hover, .ac-item.on { background: var(--brand-soft); }
.ac-item b { font-size: 12.5px; color: var(--brand); min-width: 46px; font-variant-numeric: tabular-nums; }
.ac-item span { font-size: 12.5px; color: var(--ink-2); flex: 1; }
.ac-item em { font-size: 10.5px; color: var(--ink-3); font-style: normal; white-space: nowrap; }
.ac-add {
  padding: 9px 11px; cursor: pointer; font-size: 12.5px; font-weight: 600;
  color: var(--brand-2); background: #fafbfd; border-top: 1px solid var(--line);
  position: sticky; bottom: 0;
}
.ac-add:hover { background: var(--brand-soft); }
.ac-hint { font-size: 11.5px; color: var(--ok); margin-top: 4px; min-height: 15px; font-weight: 500; }
.ac-hint.warn { color: var(--warn); }

button.btn {
  border: 1px solid transparent; border-radius: 8px;
  padding: 9px 16px; font: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer; background: var(--brand); color: #fff;
}
button.btn:hover { background: var(--brand-2); }
button.btn:disabled { opacity: .6; cursor: not-allowed; }
button.btn.ghost { background: #fff; color: var(--ink-2); border-color: var(--line); }
button.btn.ghost:hover { background: #f7f8fb; }
button.btn.danger { background: var(--danger); }
button.btn.sm { padding: 6px 11px; font-size: 12.5px; }

.link-btn {
  background: none; border: 0; color: var(--brand-2);
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 2px 4px;
}
.link-btn.danger { color: var(--danger); }

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

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--ink-3);
  background: #fafbfd; padding: 10px 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
  position: sticky; top: 0;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tbody tr:hover { background: #fbfcfe; }
tbody tr.flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: #fff5d6; } to { background: transparent; } }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.sno { font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; }
td.nowrap, th.nowrap { white-space: nowrap; }
.muted { color: var(--ink-3); font-size: 12px; }
code.uname {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
  background: #f4f6fa; border: 1px solid var(--line-soft); border-radius: 5px;
  padding: 2px 6px; color: var(--ink-2);
}
.empty { padding: 44px 20px; text-align: center; color: var(--ink-3); }

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 700; letter-spacing: .03em;
  background: var(--brand-soft); color: var(--brand);
}
.pill.grey { background: #f0f2f6; color: var(--ink-2); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.off { background: var(--danger-soft); color: var(--danger); }

.sector { font-weight: 600; }
.sector .arrow { color: var(--ink-3); margin: 0 5px; font-weight: 400; }

/* --------------------------------------------------------- dashboard ---- */

.stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 18px; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .k { font-size: 11.5px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.stat .v { font-size: 27px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; }
.stat .d { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

.bar-track { height: 6px; background: var(--line-soft); border-radius: 4px; overflow: hidden; min-width: 90px; }
.bar-fill { height: 100%; background: var(--brand-2); border-radius: 4px; }

.spark { display: flex; align-items: flex-end; gap: 6px; height: 90px; padding-top: 8px; }
.spark .col { flex: 1 1 0; max-width: 42px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 5px; min-width: 0; }
.spark .col i { width: 100%; background: var(--brand-2); border-radius: 3px 3px 0 0; display: block; min-height: 2px; opacity: .85; }
.spark .col span { font-size: 10px; color: var(--ink-3); white-space: nowrap; }

/* --------------------------------------------------------- utilities ---- */

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.toolbar label.field { min-width: 130px; }
.toolbar .grow { flex: 1; min-width: 180px; }

.msg { padding: 10px 13px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; font-weight: 500; }
.msg.error { background: var(--danger-soft); color: var(--danger); }
.msg.ok { background: var(--ok-soft); color: var(--ok); }

.two-col { display: grid; grid-template-columns: 380px 1fr; gap: 18px; align-items: start; }
@media (max-width: 980px) { .two-col { grid-template-columns: 1fr; } }

.placeholder {
  background: var(--surface); border: 1px dashed var(--line);
  border-radius: var(--radius); padding: 60px 24px; text-align: center;
}
.placeholder .icon { font-size: 30px; }
.placeholder h3 { margin: 14px 0 6px; font-size: 17px; }
.placeholder p { color: var(--ink-2); margin: 0 auto; max-width: 420px; line-height: 1.6; }

.modal-back {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .45);
  display: grid; place-items: center; padding: 20px; z-index: 60;
}
.modal {
  background: #fff; border-radius: 12px; width: 100%; max-width: 560px;
  box-shadow: var(--shadow-lg); max-height: 90vh; overflow: auto;
}
.modal header { padding: 16px 20px; border-bottom: 1px solid var(--line-soft); display: flex; justify-content: space-between; align-items: center; }
.modal .body { padding: 20px; }

/* wider daily chart on the report page */
.spark.wide { height: 110px; }
.spark.wide .col { max-width: 34px; }

.print-head { display: none; }

@media print {
  .topbar, .no-print, .toolbar, button { display: none !important; }
  body { background: #fff; font-size: 11px; }
  main { padding: 0; max-width: none; }
  .print-head { display: block; margin-bottom: 14px; }
  .print-head h2 { font-size: 17px; }
  .print-head p { margin: 3px 0 0; color: #444; font-size: 11px; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; margin-bottom: 10px; }
  .card > header { padding: 8px 10px; }
  .stats { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .stat { padding: 8px 10px; box-shadow: none; }
  .stat .v { font-size: 18px; }
  .two-col { grid-template-columns: 1fr 1fr; }
  tbody td, thead th { padding: 4px 6px; }
  .table-wrap { overflow: visible; }
}

@media (max-width: 640px) {
  main { padding: 14px; }
  .topbar { padding: 0 12px; gap: 10px; }
  .topbar .logo span.txt { display: none; }
}
