:root {
  --bg: #F3F6F9;
  --card: #FFFFFF;
  --text: #1F2933;
  --muted: #66727F;
  --line: #E1E7ED;
  --primary: #0E7AC4;
  --primary-dark: #0B5F99;
  --danger: #D64545;
  --success: #1F9D63;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 22px; margin: 0 0 2px; }
h2 { font-size: 16px; margin: 0 0 12px; }
code { background: #EEF2F6; padding: 2px 6px; border-radius: 4px; font-size: 13px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.text-danger { color: var(--danger); }
.nowrap { white-space: nowrap; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 58px;
  background: #0B2E4A; color: #fff; position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; white-space: nowrap; }
.brand-icon { color: #59B7F2; display: flex; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: #C7D6E3; padding: 8px 12px; border-radius: 6px; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.active { background: rgba(89,183,242,.18); color: #fff; }
.nav .logout { margin-left: auto; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; }

/* ---------- Layout ---------- */
.container { max-width: 1280px; margin: 0 auto; padding: 24px; }
.footer { text-align: center; color: var(--muted); padding: 20px; font-size: 12px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.card.empty { text-align: center; color: var(--muted); padding: 40px; }
.card-label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; margin-bottom: 18px; }
.grid-cards .card { margin-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 18px; }
.big { font-size: 28px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.big small { font-size: 14px; font-weight: 500; color: var(--muted); }

/* ---------- Level card + tangki ---------- */
.level-wrap { display: flex; align-items: center; gap: 18px; }
.tank { position: relative; width: 46px; height: 92px; border: 2px solid #9FB3C5; border-radius: 6px 6px 10px 10px; overflow: hidden; background: #F7FAFC; flex-shrink: 0; }
.tank-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(180deg, #4FB2EE, var(--primary)); transition: height .6s ease; }
.tank-fill.danger { background: linear-gradient(180deg, #F08080, var(--danger)); }
.tank-alarm { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--danger); bottom: 80%; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; margin-top: 6px; background: #EEF2F6; color: var(--muted); }
.badge-ok { background: #E3F5EC; color: var(--success); }
.badge-danger { background: #FBE6E6; color: var(--danger); }

.stat-line { display: flex; align-items: center; gap: 8px; font-size: 18px; margin-bottom: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #B8C2CC; }
.dot.on { background: var(--success); box-shadow: 0 0 0 4px rgba(31,157,99,.15); }
.dot.off { background: var(--danger); box-shadow: 0 0 0 4px rgba(214,69,69,.15); }

.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.mini-stats.two { grid-template-columns: repeat(2, 1fr); }
.mini-stats span { display: block; font-size: 12px; color: var(--muted); }
.mini-stats b { font-size: 16px; font-variant-numeric: tabular-nums; }

/* ---------- Grafik ---------- */
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.chart-head h2 { margin: 0; }
.chart-box { position: relative; height: 320px; }
.chart-box.short { height: 260px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 6px 12px; cursor: pointer; font: inherit; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--primary); color: #fff; }

/* ---------- Form ---------- */
input, select {
  font: inherit; padding: 7px 10px; border: 1px solid #CBD5DF; border-radius: 7px; background: #fff; color: var(--text); min-width: 0;
}
input:focus, select:focus { outline: 2px solid rgba(14,122,196,.25); border-color: var(--primary); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.inline-form { display: flex; align-items: center; gap: 8px; }
form.inline { display: inline; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.filter-actions { display: flex; gap: 8px; }
.form-card label { margin-bottom: 12px; }
.w-num { width: 90px; text-align: right; }
.table input:not(.w-num) { width: 100%; min-width: 120px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 7px; border: 1px solid #CBD5DF;
  background: #fff; color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #F4F7FA; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #18804F; }
.btn-danger { background: #fff; border-color: #F0B4B4; color: var(--danger); }
.btn-danger:hover { background: #FDF1F1; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }
.btn.disabled { pointer-events: none; opacity: .45; }

/* ---------- Tabel ---------- */
.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { background: #F7F9FB; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
.table tbody tr:hover { background: #FAFCFE; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.empty { text-align: center; color: var(--muted); padding: 36px; }
.pagination { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; flex-wrap: wrap; gap: 10px; }
.pagination div { display: flex; gap: 4px; }

.kv div { display: flex; gap: 12px; align-items: baseline; padding: 6px 0; flex-wrap: wrap; }
.kv span { width: 90px; color: var(--muted); }

/* ---------- Alert ---------- */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.alert-success { background: #E3F5EC; color: #146C44; }
.alert-danger { background: #FBE6E6; color: #A12D2D; }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #0B2E4A, #0E7AC4); padding: 20px; }
.login-card { background: #fff; padding: 32px; border-radius: 14px; width: 100%; max-width: 360px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-card h1 { text-align: center; }
.login-card p { text-align: center; margin: 0 0 20px; }
.login-card label { margin-bottom: 14px; }
.login-icon { width: 60px; height: 60px; margin: 0 auto 12px; border-radius: 50%; background: #E6F3FC; color: var(--primary); display: flex; align-items: center; justify-content: center; }

/* ---------- Responsif ---------- */
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; height: auto; min-height: 58px; padding: 10px 16px; gap: 8px; }
  .nav-toggle { display: block; }
  .nav { display: none; flex-direction: column; width: 100%; }
  .nav-open .nav { display: flex; }
  .nav .logout { margin-left: 0; }
  .container { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .chart-box { height: 260px; }
}
