:root {
  --bg: #0b1017; --panel: #121a24; --panel-2: #172231; --line: #223044;
  --text: #e8eef6; --muted: #8fa1b8; --accent: #5cc8f0; --good: #4fd18b;
  --warn: #f2b84b; --bad: #f2667a;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { padding: max(16px, env(safe-area-inset-top)) 16px 48px; max-width: 1100px; margin: 0 auto; }
a { color: inherit; text-decoration: none; }

header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 8px 0 20px; }
header h1 { font-size: 26px; margin: 0; letter-spacing: .2px; }
header .when { color: var(--muted); font-size: 14px; }
header form button { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; }

h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--accent); margin: 28px 0 10px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; gap: 14px; align-items: flex-start; transition: background .15s, border-color .15s; min-height: 92px; }
.tile:hover { background: var(--panel-2); border-color: #2e4260; }
.tile svg { flex: 0 0 auto; width: 28px; height: 28px; stroke: var(--accent); }
.tile .t { font-weight: 600; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.tile .b { color: var(--muted); font-size: 13px; margin-top: 4px; line-height: 1.35; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.up { background: var(--good); } .dot.down { background: var(--bad); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.signals { display: grid; gap: 8px; }
.sig { display: grid; grid-template-columns: 44px 1fr; gap: 8px; align-items: baseline; padding: 8px 10px; background: var(--panel-2); border-radius: 10px; }
.sig .v { font-weight: 700; font-size: 13px; }
.sig .v.yes { color: var(--good); } .sig .v.no { color: var(--bad); } .sig .v.q { color: var(--warn); }
.sig .l { font-size: 14px; } .sig .d { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.kpi { background: var(--panel-2); border-radius: 10px; padding: 10px; }
.kpi .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .8px; }
.kpi .n { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
td.y { font-weight: 700; } td.y.hi { color: var(--good); } td.y.mid { color: var(--warn); } td.y.lo { color: var(--bad); }
h3.sub { font-size: 13px; color: var(--muted); font-weight: 600; margin: 16px 0 6px; }
.tablewrap { overflow-x: auto; }
.foot { color: var(--muted); font-size: 12px; margin-top: 10px; }

.screens { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.screen { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: zoom-in; }
.screen img { width: 100%; aspect-ratio: 800 / 1280; object-fit: cover; display: block; background: #000; }
.screen .cap { display: flex; justify-content: space-between; padding: 8px 10px; font-size: 13px; }
.age { color: var(--muted); } .age.stale { color: var(--warn); }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); display: none; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.lightbox.on { display: flex; }
.lightbox img { max-height: 100%; max-width: 100%; border-radius: 10px; }

.login { max-width: 340px; margin: 18vh auto 0; }
.login h1 { font-size: 24px; margin-bottom: 18px; }
.login input, .login button { width: 100%; font-size: 16px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.login button { margin-top: 10px; background: var(--accent); color: #062033; font-weight: 700; border: 0; cursor: pointer; }
.err { color: var(--bad); font-size: 14px; margin-top: 10px; }

@media (max-width: 520px) {
  .kpi .n { font-size: 18px; }
  .screens { grid-template-columns: repeat(2, 1fr); }
  .hide-sm { display: none; }
}
