/* geomonitor dashboard styles — hand-written, no framework/CDN. Dark default. */
:root {
  --bg: #f8fafc; --card-bg: #ffffff; --text: #111827; --muted: #6b7280;
  --border: rgba(0,0,0,0.08); --accent: #2563eb; --running: #10b981; --off: #9ca3af;
}
html.dark {
  --bg: #07090b; --card-bg: #0b1220; --text: #e6eef8; --muted: #9ca3af;
  --border: rgba(255,255,255,0.08); --accent: #60a5fa; --running: #34d399; --off: #6b7280;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; line-height: 1.5; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 1.25rem; }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
a { color: var(--accent); }
.text-muted, .muted { color: var(--muted); font-size: .9rem; }
.small { font-size: .8rem; }

.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 1rem; }

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; gap: 1rem; flex-wrap: wrap; }
.topbar .actions { display: flex; align-items: center; gap: .75rem; }
.btn { background: transparent; color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: .4rem .8rem; cursor: pointer; font: inherit; }
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); color: #fff; border-color: transparent; }

.grid { display: grid; gap: 1rem; }
.cards { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 1.25rem; }
.cols-3 { grid-template-columns: 2fr 1fr; margin-bottom: 1.25rem; }
.charts-2 { grid-template-columns: 1fr 1fr; gap: 1rem; }
.charts-3 { grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .cols-3, .charts-2, .charts-3 { grid-template-columns: 1fr; } }

.stat { font-size: 1.6rem; font-weight: 700; }
.status-running { color: var(--running); }
.status-off { color: var(--off); }
.subgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: .75rem; }
.subgrid .box { border: 1px solid var(--border); border-radius: 8px; padding: .5rem; }

canvas { background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; padding: 6px; }

.alert-item { border: 1px solid var(--border); border-radius: 8px; padding: .5rem .6rem; margin-bottom: .5rem; }
.alert-title { font-weight: 600; }

.tabs { display: flex; gap: .5rem; margin-bottom: .75rem; }
.tab { background: transparent; border: 1px solid var(--border); border-radius: 8px; padding: .35rem .8rem; cursor: pointer; color: var(--text); font: inherit; }
.tab.active { background: var(--accent); color: #fff; border-color: transparent; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table-scroll { overflow-x: auto; }
th.table-cell, td.table-cell, table th, table td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
thead th { color: var(--muted); font-weight: 600; }

/* mini-datatable */
.mt-bar { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.mt-count { white-space: nowrap; }
.mt-h { cursor: pointer; user-select: none; white-space: nowrap; }
.mt-h:hover { color: var(--accent); }
.mt-h.sorted { color: var(--accent); }
.mt-h.sorted::after { content: attr(data-dir); margin-left: .3rem; font-size: .75rem; }
.mt-f { width: 100%; min-width: 64px; padding: .2rem .35rem; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; font: inherit; font-size: .78rem; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.25rem; }
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { font-size: 1.3rem; margin-bottom: 1rem; }
.field { margin-bottom: .9rem; }
.field label { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .9rem; }
.field input { width: 100%; padding: .6rem .7rem; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; font: inherit; }
.err { color: #ef4444; font-size: .9rem; margin-bottom: .8rem; }

/* Layout utilities — replace former inline style="" attributes (blocked by the CSP). */
.row-between { display: flex; justify-content: space-between; align-items: flex-start; }
.text-right { text-align: right; }
.strong { font-weight: 600; }
.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }
.mt-lg { margin-top: 1.25rem; }
.mb-lg { margin-bottom: 1.25rem; }
.wrap.narrow { max-width: 640px; }
.card.ok { border-color: var(--running); }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.btn-block { width: 100%; }
.inline-form { display: inline; margin: 0; }

/* Health page */
.group-title { margin: 1.25rem 0 .6rem; font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.health-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.check h3 { font-size: 1rem; margin: 0; }
.check p { margin: .5rem 0 0; }
.check.status-watch { border-color: #f59e0b; }
.check.status-alert { border-color: #ef4444; }
.check.status-idle, .check.status-learning { opacity: .8; }
.overall.status-ok { border-color: var(--running); }
.overall.status-watch { border-color: #f59e0b; }
.overall.status-alert { border-color: #ef4444; }
.pill { font-size: .75rem; font-weight: 600; padding: .1rem .55rem; border-radius: 999px; border: 1px solid var(--border); white-space: nowrap; }
.pill-ok { color: var(--running); border-color: var(--running); }
.pill-watch { color: #f59e0b; border-color: #f59e0b; }
.pill-alert { color: #ef4444; border-color: #ef4444; }
.pill-learning, .pill-idle { color: var(--muted); }
.chart-box { position: relative; height: 170px; margin-top: .75rem; }
.log-form { display: grid; grid-template-columns: 160px 1fr; gap: 0 1rem; align-items: end; }
.log-form .field-wide { grid-column: 1 / -1; }
.log-form select { width: 100%; padding: .6rem .7rem; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; font: inherit; }
.check-label { display: flex; align-items: center; gap: .4rem; margin-bottom: .9rem; }
.btn-small { padding: .2rem .55rem; font-size: .8rem; }
.btn-health.status-watch { border-color: #f59e0b; color: #f59e0b; }
.btn-health.status-alert { border-color: #ef4444; color: #ef4444; }
@media (max-width: 600px) { .log-form { grid-template-columns: 1fr; } .health-grid { grid-template-columns: 1fr; } }
.health-grid > .card { min-width: 0; } /* let charts shrink instead of widening the column */
.chart-box canvas { max-width: 100%; }
