/* ==========================================================================
   水質監控儀表板 — 工業樣式
   ========================================================================== */

:root {
  --primary:        #1a3d80;
  --primary-dark:   #11295a;
  --primary-light:  #2c5cb5;
  --accent-red:     #d32f2f;
  --accent-red-bg:  #fdecea;
  --bg:             #ffffff;
  --bg-soft:        #f5f7fb;
  --border:         #c7d2e6;
  --text:           #1f2937;
  --text-soft:      #4b5563;
  --table-head-bg:  #e8eef9;
  --status-ok-bg:   #e6f4ea;
  --status-ok-fg:   #1b873b;
  --status-bad-bg:  #fdecea;
  --status-bad-fg:  #c62828;
  --shadow:         0 1px 3px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Microsoft JhengHei", "Segoe UI", Roboto, "Noto Sans TC", "Noto Sans", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ─── Header ────────────────────────────────────────────────────────────── */
.topbar {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 20px;
  align-items: center;
  background: var(--primary);
  color: #fff;
  padding: 14px 20px;
  border-bottom: 3px solid var(--primary-dark);
}

.logo-circle {
  width: 88px; height: 88px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent-red);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
}

.company .company-name {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}

.company .company-line {
  font-size: 13px;
  line-height: 1.5;
}

.company .lbl {
  display: inline-block;
  min-width: 130px;
  color: #d8e0f3;
}

.topbar-actions {
  display: flex; gap: 8px;
}

.btn-action {
  background: rgba(255,255,255,0.95);
  color: var(--primary-dark);
  border: 1px solid rgba(255,255,255,0.4);
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
}
.btn-action:hover { background: #fff; }
.btn-action .icon { font-size: 14px; }

/* ─── Tabs ──────────────────────────────────────────────────────────────── */
.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: #fff;
  border-bottom: 2px solid var(--border);
}

.tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-soft);
  text-decoration: none;
  border-right: 1px solid var(--border);
  background: var(--bg-soft);
  transition: background 0.15s;
}

.tab:last-child { border-right: none; }

.tab .tab-icon {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #d6dff1;
  color: var(--primary-dark);
  font-size: 16px;
}

.tab.active {
  background: var(--primary);
  color: #fff;
}
.tab.active .tab-icon {
  background: #fff;
  color: var(--primary);
}

.tab:hover:not(.active) { background: #eaeff8; }

/* ─── Main content ──────────────────────────────────────────────────────── */
.content {
  padding: 18px 22px 40px;
  max-width: 1500px;
  margin: 0 auto;
}

.page-title {
  margin: 8px 0 14px;
  text-align: center;
  color: var(--accent-red);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.page-title .branch { color: var(--accent-red); }

.time-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
}
.time-row .time-label { color: var(--text); }
.time-row .time-value { color: var(--primary); font-weight: 700; }
.mock-badge {
  margin-left: 8px;
  background: #fff7e0;
  color: #b06900;
  border: 1px solid #f0c97a;
  padding: 2px 8px;
  font-size: 12px;
  border-radius: 3px;
  font-weight: 600;
}

.alert-banner {
  background: var(--status-bad-bg);
  color: var(--status-bad-fg);
  border: 1px solid #f5b3ad;
  border-radius: 4px;
  padding: 10px 14px;
  margin: 8px 0 12px;
  font-weight: 700;
}

/* ─── Tables ───────────────────────────────────────────────────────────── */
.tables-row {
  display: grid;
  grid-template-columns: 1fr 1.05fr;
  gap: 18px;
  margin-bottom: 24px;
}

.table-block { min-width: 0; }

.table-caption {
  color: var(--primary);
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--border);
  font-size: 13px;
  table-layout: fixed;
}

.data-table th,
.data-table td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: center;
  vertical-align: middle;
  word-break: break-word;
}

.data-table th {
  background: var(--table-head-bg);
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 12.5px;
  line-height: 1.35;
}

.data-table td.name {
  text-align: left;
  font-weight: 600;
}

.data-table td.value {
  font-weight: 700;
  color: var(--text);
}
.data-table td.value.over {
  color: var(--status-bad-fg);
}

.data-table .status-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.data-table .status-pill.normal {
  background: var(--status-ok-bg);
  color: var(--status-ok-fg);
}
.data-table .status-pill.critical {
  background: var(--status-bad-bg);
  color: var(--status-bad-fg);
}
.data-table .status-pill.unknown {
  background: #eef0f3;
  color: #6b7280;
}

.data-table .loading {
  padding: 20px;
  color: #888;
  font-style: italic;
}

/* ─── Charts ───────────────────────────────────────────────────────────── */
.charts-title {
  color: var(--accent-red);
  font-size: 16px;
  font-weight: 700;
  margin: 18px 0 10px;
}

.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.chart-block {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px;
  min-width: 0;
}

/* ─── 響應式 ───────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .topbar { grid-template-columns: 90px 1fr; }
  .topbar-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .tables-row, .charts-row { grid-template-columns: 1fr; }
  .tabs { grid-template-columns: repeat(2, 1fr); }
  .tab { font-size: 14px; }
  .company .lbl { min-width: 90px; }
}
