:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1b2733;
  --muted: #6b7a8d;
  --line: #e2e8f0;
  --brand: #14507a;
  --brand-ink: #0b3350;
  --accent: #2f80c7;
  --on: #1a9d5a;
  --off: #b04242;
  --idle: #9aa7b5;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--brand); color: #fff; padding: 12px 20px;
}
.topbar .brand a { color: #fff; font-weight: 700; letter-spacing: .3px; display: flex; align-items: center; gap: 10px; }
.brandlogo { height: 34px; width: auto; display: block; background: #fff; padding: 3px 5px; border-radius: 6px; }
.topbar nav { display: flex; align-items: center; gap: 16px; }
.topbar nav a { color: #dcebf7; }
.topbar .who { color: #bcd6ec; font-size: 13px; }
.inline { display: inline; margin: 0; }
.linkbtn { background: none; border: none; color: #dcebf7; cursor: pointer; font-size: 14px; }
.linkbtn:hover { text-decoration: underline; }

.container { max-width: 1160px; margin: 24px auto; padding: 0 20px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 24px; }

h1 { font-size: 22px; margin: 0 0 8px; }
h2 { font-size: 16px; margin: 28px 0 12px; color: var(--brand-ink); }
.muted { color: var(--muted); }
.back { display: inline-block; margin-bottom: 6px; }
.metaline { font-size: 12.5px; margin-bottom: 14px; }

table.grid { width: 100%; border-collapse: collapse; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.grid th, .grid td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.grid th { background: #eef3f8; font-weight: 600; font-size: 12.5px; color: var(--brand-ink); }
.grid tr:last-child td { border-bottom: none; }
.grid td.title { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.idlerow td { color: var(--idle); }

.pill { padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; color: #fff; }
.pill.on { background: var(--on); }
.pill.off { background: var(--off); }

.btn { display: inline-block; padding: 5px 12px; background: var(--accent); color: #fff !important;
  border-radius: 6px; font-size: 12.5px; }
.btn:hover { text-decoration: none; background: #276fae; }

.empty { padding: 18px; background: var(--panel); border: 1px dashed var(--line);
  border-radius: 8px; color: var(--muted); }

.cards { display: flex; gap: 14px; margin: 8px 0 4px; flex-wrap: wrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 18px; min-width: 130px; }
.card .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.card .v { font-size: 22px; font-weight: 700; color: var(--brand-ink); }

.bars { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.barrow { display: grid; grid-template-columns: 160px 1fr 84px; align-items: center; gap: 12px; margin: 7px 0; }
.barlabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.bartrack { background: #eef3f8; border-radius: 6px; height: 16px; overflow: hidden; }
.barfill { background: linear-gradient(90deg, var(--accent), var(--brand)); height: 100%; }
.barval { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12.5px; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.gallery figure { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.gallery img { width: 100%; height: 118px; object-fit: cover; display: block; background: #dde5ee; }
.gallery figcaption { padding: 6px 8px; font-size: 12px; color: var(--muted); }

.dayform, .metaline { margin-bottom: 12px; }
.dayform { display: flex; gap: 10px; align-items: end; }
.dayform label { font-size: 12.5px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.dayform input, .loginform input { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; }
.dayform button, .loginform button {
  padding: 7px 14px; background: var(--brand); color: #fff; border: none; border-radius: 6px; cursor: pointer; }

.loginwrap { max-width: 340px; margin: 60px auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; padding: 26px; }
.loginform { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.loginform label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.error { background: #fbe9e9; color: #a02f2f; padding: 8px 10px; border-radius: 6px; font-size: 13px; }
.notice { background: #e6f5ec; color: #1a7a44; padding: 8px 10px; border-radius: 6px; font-size: 13px; margin-bottom: 10px; }

.pill.idle2 { background: #c58a2a; }

.rowform { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.rowform label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.rowform input { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; }
.rowform button { padding: 7px 16px; background: var(--brand); color: #fff; border: none; border-radius: 6px; cursor: pointer; }
.rowform label { align-items: flex-start; }

.inlineset { display: flex; align-items: center; gap: 6px; margin: 0; }
.inlineset input { padding: 4px 6px; border: 1px solid var(--line); border-radius: 5px; font-size: 13px; }
.inlineset .unit { color: var(--muted); font-size: 12px; }
.btnsm { padding: 4px 10px; background: var(--accent); color: #fff; border: none; border-radius: 5px; font-size: 12px; cursor: pointer; }
.btnsm:hover { background: #276fae; }
.small { font-size: 11.5px; }

.periodbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 6px 0 16px; }
.tabs { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.tabs a { padding: 6px 14px; font-size: 13px; color: var(--brand-ink); background: var(--panel); }
.tabs a:hover { text-decoration: none; background: #eef3f8; }
.tabs a.active { background: var(--brand); color: #fff; }
.periodbar form { display: inline-flex; gap: 8px; align-items: center; margin: 0; }
.periodbar input[type=date] { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
.periodbar .navbtn { padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--brand-ink); font-size: 13px; }
.periodlabel { font-weight: 600; color: var(--brand-ink); }

.exportbar { display: flex; gap: 10px; margin: 4px 0 16px; flex-wrap: wrap; }
.exportbtn { display: inline-block; padding: 6px 14px; border-radius: 6px; font-size: 13px; border: 1px solid var(--line);
  background: var(--panel); color: var(--brand-ink); cursor: pointer; }
.exportbtn:hover { text-decoration: none; background: #eef3f8; }
.exportbtn.xls { border-color: #1a7a44; color: #1a7a44; }
.exportbtn.pdf { border-color: #b04242; color: #b04242; }

@media print {
  .topbar, .foot, .exportbar, .periodbar, .back, .btn, nav { display: none !important; }
  body { background: #fff; }
  .container { margin: 0; max-width: 100%; padding: 0; }
  a { color: #000; }
  .card, .bars, .grid, .gallery figure, section { break-inside: avoid; }
  .gallery { grid-template-columns: repeat(4, 1fr); }
}
