/* ===========================================================
   SolarLamp Monitor - POLITEKNIK NEGERI SEMARANG
   Palet: senja (indigo), lampu natrium (amber), silikon (biru)
   Huruf: Barlow Semi Condensed (dipasang lokal)
   =========================================================== */

@font-face { font-family: "Barlow Semi Condensed"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("../fonts/barlow-semi-condensed-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 500; font-style: normal; font-display: swap;
  src: url("../fonts/barlow-semi-condensed-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 600; font-style: normal; font-display: swap;
  src: url("../fonts/barlow-semi-condensed-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 700; font-style: normal; font-display: swap;
  src: url("../fonts/barlow-semi-condensed-latin-700-normal.woff2") format("woff2"); }

:root {
  --dusk: #1a2140;
  --dusk-2: #263057;
  --dusk-line: rgba(255, 255, 255, .16);
  --lamp: #f2a93b;
  --lamp-deep: #b46d00;
  --silicon: #1f5fbf;
  --leaf: #0f8f6a;
  --panel-c: #d98a00;      /* seri grafik: panel surya */
  --bat-c: #1f5fbf;        /* seri grafik: baterai */
  --ac-c: #0f8f6a;         /* seri grafik: keluaran AC */

  --bg: #eef1f6;
  --surface: #ffffff;
  --ink: #172033;
  --muted: #566480;
  --line: #d8deea;
  --line-soft: #e8ecf4;
  --danger: #a63232;

  --radius: 8px;
  --font: "Barlow Semi Condensed", "Arial Narrow", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, p, dl, dd, dt { margin: 0; }
button, input, select { font: inherit; color: inherit; }
b, strong { font-weight: 600; }

.wrap { width: 100%; max-width: 1320px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.gap { display: inline-block; width: 1rem; }

.skip { position: absolute; left: -9999px; top: 0; background: var(--lamp); color: #000; padding: 8px 12px; z-index: 20; }
.skip:focus { left: 8px; top: 8px; }

:focus-visible { outline: 3px solid var(--lamp); outline-offset: 2px; }

/* ---------- Header ---------- */
.top { background: var(--dusk); color: #fff; }
.top-inner { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 24px; padding-top: 14px; padding-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo { width: 56px; height: 56px; object-fit: contain; flex: none; }
.inst { font-size: clamp(1.2rem, 2.2vw, 1.75rem); font-weight: 700; letter-spacing: .02em; line-height: 1.1; }
.app { color: rgba(255, 255, 255, .78); font-size: 1rem; margin-top: 2px; }
.app strong { color: var(--lamp); font-weight: 600; margin-right: .6rem; }

.clock { text-align: right; line-height: 1.1; }
.clock time { display: block; font-size: 2.2rem; font-weight: 600; letter-spacing: .02em; }
.clock-date { display: block; color: rgba(255, 255, 255, .78); font-size: .98rem; margin-top: 3px; }

.lang { display: flex; flex-direction: column; gap: 3px; font-size: .88rem; color: rgba(255, 255, 255, .78); }
.lang select { min-width: 160px; }

/* ---------- Aliran energi ---------- */
.flow {
  background:
    radial-gradient(520px 260px at 92% -40px, rgba(242, 169, 59, .22), transparent 70%),
    var(--dusk);
  color: #fff;
  padding: 6px 0 30px;
  border-top: 1px solid var(--dusk-line);
}
.flow-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 24px; padding: 16px 0 14px; }
.flow-head h2 { font-size: 1.15rem; font-weight: 500; color: rgba(255, 255, 255, .88); }
.status { display: flex; align-items: center; gap: 8px; font-size: .98rem; color: rgba(255, 255, 255, .82); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #8a93ad; flex: none; }
.status.on .dot { background: #4cd39a; box-shadow: 0 0 0 4px rgba(76, 211, 154, .22); }
.status.off .dot { background: var(--lamp); }

.chain { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: stretch; gap: 14px; }
.link { display: flex; align-items: center; color: var(--lamp); }

.node { background: rgba(255, 255, 255, .07); border: 1px solid var(--dusk-line); border-radius: var(--radius); padding: 14px 16px 12px; min-width: 0; }
.node-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.node-head h3 { font-size: 1.12rem; font-weight: 600; }
.badge { font-size: .86rem; padding: 2px 10px; border-radius: 999px; background: rgba(255, 255, 255, .12); color: rgba(255, 255, 255, .9); white-space: nowrap; }
.badge.go { background: rgba(76, 211, 154, .2); color: #7fe6bb; }
.badge.warm { background: rgba(242, 169, 59, .22); color: #ffc873; }

.meters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 12px; }
.m dt { font-size: .86rem; color: rgba(255, 255, 255, .66); }
.m dd { display: flex; align-items: baseline; gap: 4px; }
.m b { font-size: 1.3rem; font-weight: 600; }
.m small { font-size: .85rem; color: rgba(255, 255, 255, .66); }
.m.main { grid-column: 1 / -1; padding-bottom: 6px; border-bottom: 1px solid var(--dusk-line); margin-bottom: 2px; }
.m.main b { font-size: 2.5rem; font-weight: 700; color: var(--lamp); line-height: 1.05; }
.m.main small { font-size: 1.05rem; color: var(--lamp); }
.sub { margin-top: 8px; font-size: .92rem; color: rgba(255, 255, 255, .72); }
.sub b { color: #fff; font-weight: 500; }
.sub-note { font-size: .84rem; }

/* ---------- Panel umum ---------- */
main { padding-top: 22px; padding-bottom: 32px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { font-size: 1.28rem; font-weight: 600; line-height: 1.2; }
.panel-head .unit { color: var(--muted); font-size: .92rem; }

.alert { background: #fbeaea; border: 1px solid #e3b3b3; color: var(--danger); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; }

/* ---------- Filter ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-size: .88rem; color: var(--muted); }
.field input, .field select, .lang select {
  height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; min-width: 150px;
}
.top .lang select { background: var(--dusk-2); color: #fff; border-color: var(--dusk-line); }
.top .lang select option { color: #172033; background: #fff; }
.chips { display: flex; gap: 6px; padding-bottom: 1px; }
.chip { height: 38px; padding: 0 12px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; }
.chip:hover { border-color: var(--silicon); }
.chip[aria-pressed="true"] { background: var(--dusk); border-color: var(--dusk); color: #fff; }
.actions { display: flex; gap: 8px; margin-left: auto; align-items: center; }

.btn { height: 38px; padding: 0 16px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--silicon); }
.btn.primary { background: var(--silicon); border-color: var(--silicon); color: #fff; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: #194f9d; border-color: #194f9d; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { height: 30px; padding: 0 10px; font-size: .92rem; }

.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: ""; margin-left: 8px; border: 5px solid transparent; border-top-color: currentColor; border-bottom: 0; }
.menu-list { position: absolute; right: 0; top: 42px; z-index: 10; min-width: 230px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(23, 32, 51, .16); padding: 6px; display: flex; flex-direction: column; }
.menu-list button { text-align: left; background: none; border: 0; padding: 9px 12px; border-radius: 5px; cursor: pointer; }
.menu-list button:hover { background: var(--bg); }

/* ---------- Kinerja ---------- */
.perf-grid { display: grid; grid-template-columns: minmax(230px, 300px) 1fr; gap: 24px; align-items: center; }
.eff { padding-right: 24px; border-right: 1px solid var(--line); }
.eff-num { line-height: 1; }
.eff-num span:first-child { font-size: 4rem; font-weight: 700; color: var(--lamp-deep); }
.eff-unit { font-size: 1.6rem; font-weight: 600; margin-left: 4px; color: var(--lamp-deep); }
.eff-label { font-size: 1.15rem; font-weight: 600; margin-top: 4px; }
.eff-note { color: var(--muted); font-size: .92rem; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 20px; }
.stats dt { color: var(--muted); font-size: .9rem; }
.stats dd { font-size: 1rem; color: var(--muted); }
.stats dd b { font-size: 1.5rem; font-weight: 600; color: var(--ink); }

/* ---------- Grafik ---------- */
.chart-note { font-size: .92rem; margin: -6px 0 8px; min-height: 1.3em; }
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 0; }
.chart { margin-bottom: 0; }
.chart .panel-head { margin-bottom: 6px; }
.canvas-box { position: relative; height: 300px; }

/* ---------- Tabel ---------- */
.tablewrap { overflow: auto; border: 1px solid var(--line-soft); border-radius: 6px; max-height: 70vh; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .98rem; }
th, td { padding: 6px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line-soft); }
thead th { position: sticky; background: #f4f6fb; font-weight: 600; z-index: 2; border-bottom: 1px solid var(--line); }
thead tr:first-child th { top: 0; text-align: center; border-left: 1px solid var(--line); }
thead tr:nth-child(2) th { top: 35px; font-size: .88rem; color: var(--muted); font-weight: 500; }
thead tr:first-child th.g-pv { border-top: 3px solid var(--panel-c); }
thead tr:first-child th.g-bat { border-top: 3px solid var(--bat-c); }
thead tr:first-child th.g-ac { border-top: 3px solid var(--ac-c); }
th.left, td.left { text-align: left; }
td.sep, th.sep { border-left: 1px solid var(--line-soft); }
tbody tr:nth-child(even) td { background: #fafbfd; }
tbody tr:hover td { background: #fff6e4; }
td.t-time { font-weight: 500; }
td.empty { text-align: center; color: var(--muted); padding: 34px 12px; white-space: normal; }
.hide-pv [data-grp="pv"] { display: none; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: .95rem; }
.check input { width: 18px; height: 18px; accent-color: var(--silicon); }

.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 12px; }
.pager-page { font-weight: 600; min-width: 130px; text-align: center; }
.pager-range { margin-left: auto; }

/* ---------- Footer ---------- */
.foot { background: var(--dusk); color: rgba(255, 255, 255, .78); padding: 18px 0 22px; font-size: .95rem; }
.foot-study { max-width: 78ch; color: rgba(255, 255, 255, .9); }
.foot-meta { margin-top: 6px; color: rgba(255, 255, 255, .62); }

.print-meta { display: none; }

/* ---------- Responsif ---------- */
@media (max-width: 1020px) {
  .chain { grid-template-columns: 1fr; }
  .link { justify-content: center; transform: rotate(90deg); height: 28px; }
  .perf-grid { grid-template-columns: 1fr; }
  .eff { border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 14px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .charts { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .top-inner { grid-template-columns: 1fr auto; row-gap: 10px; }
  .clock { text-align: left; grid-column: 1; }
  .lang { grid-column: 2; grid-row: 1 / span 2; align-self: start; }
  .lang select { min-width: 130px; }
  .actions { margin-left: 0; width: 100%; }
  .pager-range { margin-left: 0; width: 100%; }
}
@media (max-width: 480px) {
  body { font-size: 16px; }
  .wrap { padding: 0 14px; }
  .logo { width: 44px; height: 44px; }
  .clock time { font-size: 1.8rem; }
  .field, .field input, .field select { width: 100%; }
  .m.main b { font-size: 2.1rem; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* ---------- Cetak ---------- */
@page { size: A4 landscape; margin: 10mm; }
@media print {
  body { background: #fff; font-size: 12px; }
  .no-print, .skip { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .top { background: #fff; color: #000; border-bottom: 2px solid #000; }
  .top-inner { padding: 0 0 6px; grid-template-columns: 1fr auto; }
  .inst { font-size: 18px; }
  .app, .app strong, .clock-date { color: #000; }
  .clock time { font-size: 18px; }
  .lang { display: none; }
  .flow { background: #fff; color: #000; padding: 4px 0 8px; border: 0; }
  .flow *, .flow .m.main b, .flow .m.main small { color: #000 !important; }
  .node { background: #fff; border: 1px solid #888; padding: 6px 8px; }
  .badge { background: #eee; }
  .link { color: #000; }
  .m.main b { font-size: 22px; }
  .panel { border: 1px solid #aaa; break-inside: avoid; padding: 8px 10px; margin-bottom: 8px; }
  .print-meta { display: block; margin: 4px 0 8px; font-size: 12px; }
  .charts { grid-template-columns: 1fr 1fr; gap: 8px; }
  .canvas-box { height: 220px; }
  .tablepanel { break-inside: auto; }
  .tablewrap { max-height: none; overflow: visible; border: 0; }
  table { font-size: 10px; }
  th, td { padding: 2px 4px; }
  thead th { position: static; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
  .foot { background: #fff; color: #000; border-top: 1px solid #000; padding: 6px 0 0; }
  .foot-study, .foot-meta { color: #000; font-size: 10px; }
}

/* ---------- Tambahan: alarm, kinerja lanjutan ---------- */
.badge.bad { background: rgba(255, 99, 99, .25); color: #ffb3b3; }
td.alarm { color: var(--danger); font-weight: 600; }
.stats .warn dd b { color: var(--danger); }
.stats .save { grid-column: span 2; }
.pconv { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: .88rem; color: var(--muted); }
.pconv input { width: 84px; height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; }
@media (max-width: 1020px) { .stats .save { grid-column: span 2; } }
@media print { .pconv input { border: 0; padding: 0; width: auto; } }
