/* Aksara Kendali — gaya bersama portal dan panel admin. */
:root {
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-2: #f7f9f8;
  --text: #17201d;
  --muted: #5d6b66;
  --border: #d8dfdc;
  --primary: #0f5c4a;
  --primary-text: #ffffff;
  --primary-hover: #0b4a3b;
  --accent: #f4c542;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --warn-bg: #fff6db;
  --ok: #1a7f4b;
  --ok-bg: #e5f5ec;
  --focus: #2f7dd1;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412;
    --surface: #171e1b;
    --surface-2: #1d2622;
    --text: #e5ece9;
    --muted: #97a6a0;
    --border: #2c3833;
    --primary: #2a9d7c;
    --primary-hover: #33b48f;
    --primary-text: #08110e;
    --danger: #f2877c;
    --danger-bg: #3a1714;
    --warn-bg: #3a3014;
    --ok: #57c48a;
    --ok-bg: #12301f;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
}
h1 { font-size: 1.35rem; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 1.25rem 0 .6rem; }
h3 { font-size: .95rem; margin: 1rem 0 .4rem; }
p { margin: .4rem 0; }
a { color: var(--primary); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono, code, pre { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }
.center-text { text-align: center; }
.noscript { padding: 1rem; background: var(--danger-bg); color: var(--danger); }

/* Tata letak */
.screen.center { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.card.auth { width: 100%; max-width: 420px; }
.card.wide-card { width: 100%; max-width: 760px; }
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 1rem; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; margin-top: 1rem; }
.center-row { justify-content: center; margin-top: 1rem; }
.foot { margin-top: 1rem; }
.panel { border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius); padding: 12px 16px; margin: 1rem 0; }
.panel h2 { margin-top: 0; }

/* Formulir */
label { display: block; margin: .75rem 0; font-weight: 500; font-size: .92rem; }
input, select, textarea {
  display: block; width: 100%; margin-top: .3rem; padding: .6rem .7rem;
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
}
input[type=checkbox], input[type=radio] { display: inline-block; width: auto; margin: 0 .4rem 0 0; vertical-align: middle; }
label.check { display: flex; align-items: center; font-weight: 400; }
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, .display:focus-visible {
  outline: 3px solid var(--focus); outline-offset: 1px;
}
.pw { display: flex; gap: 6px; align-items: stretch; }
.pw input { margin-top: .3rem; }
.pw button { margin-top: .3rem; }

button {
  font: inherit; cursor: pointer; border-radius: 8px; padding: .55rem 1rem;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
button:hover { background: var(--surface-2); }
button:disabled { opacity: .6; cursor: progress; }
button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 600; }
button.primary:hover { background: var(--primary-hover); }
button.ghost { background: transparent; }
button.danger { color: var(--danger); border-color: var(--danger); }
button.small { padding: .3rem .65rem; font-size: .85rem; }
button.wide { width: 100%; margin-top: .5rem; }
button.link { border: 0; background: none; color: var(--primary); padding: 0; text-decoration: underline; }

.alert { background: var(--danger-bg); color: var(--danger); border-radius: 8px; padding: .6rem .8rem; }
.notice { background: var(--warn-bg); border-radius: 8px; padding: .6rem .8rem; }
.ok { background: var(--ok-bg); color: var(--ok); border-radius: 8px; padding: .6rem .8rem; }
.broadcast { background: var(--accent); color: #2a2100; padding: .5rem 1rem; text-align: center; font-weight: 500; position: relative; z-index: 5; }
.broadcast p { margin: .1rem 0; }

/* Daftar aplikasi */
.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.app { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 16px; text-align: left; min-height: 110px; }
.app-icon { font-size: 1.6rem; }
.app-name { font-weight: 600; }

/* Sesi */
body.in-session { overflow: hidden; background: #000; }
.session { position: fixed; inset: 0; display: flex; flex-direction: column; background: #000; }
.display { flex: 1; overflow: hidden; position: relative; outline: none; }
.display, .display * { cursor: none; }
.session-bar {
  display: flex; gap: 6px; align-items: center; padding: 4px 8px;
  background: rgba(23, 30, 27, .96); color: #e5ece9; font-size: .85rem; flex-wrap: wrap;
}
.session-bar .title { font-weight: 600; margin-right: auto; }
.session-bar .status { color: #97a6a0; margin-right: 8px; }
.session-bar button { color: #e5ece9; border-color: #3c4a44; }
.session-bar button:hover { background: #26302c; }
.session-bar button.danger { color: #f2877c; border-color: #6a2a24; }
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.55); z-index: 10; padding: 16px; }
.overlay .card { max-width: 460px; text-align: center; }
.toast {
  position: absolute; top: 48px; left: 50%; transform: translateX(-50%);
  max-width: min(92vw, 640px); background: var(--accent); color: #2a2100; padding: .7rem 1rem;
  border-radius: 8px; box-shadow: var(--shadow); z-index: 20; font-weight: 500;
}
.spinner {
  width: 36px; height: 36px; margin: 0 auto 12px; border-radius: 50%;
  border: 4px solid var(--border); border-top-color: var(--primary); animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* Dialog */
dialog.dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); width: min(560px, 94vw); padding: 20px 24px; }
dialog::backdrop { background: rgba(0,0,0,.5); }
.qr { display: flex; justify-content: center; margin: .5rem 0; }
.qr img { background: #fff; padding: 8px; border-radius: 8px; image-rendering: pixelated; }
.codes { background: var(--surface-2); padding: 12px; border-radius: 8px; columns: 2; font-size: 1rem; }
.steps { padding-left: 1.2rem; }

/* Panel admin */
body.admin #app { display: flex; min-height: 100vh; }
.sidebar { width: 230px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar .brand { padding: 0 6px; }
.sidebar a { display: block; padding: .5rem .7rem; border-radius: 8px; color: var(--text); text-decoration: none; }
.sidebar a:hover { background: var(--surface-2); }
.sidebar a.active { background: var(--primary); color: var(--primary-text); }
.sidebar .spacer { flex: 1; }
.sidebar .who { font-size: .85rem; color: var(--muted); padding: 6px; }
.content { flex: 1; padding: 20px 24px; min-width: 0; }
.content > h1 { margin-bottom: 1rem; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.toolbar label { margin: 0; }
.toolbar input, .toolbar select { margin-top: .2rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .v { font-size: 1.6rem; font-weight: 700; }
.stat .k { color: var(--muted); font-size: .85rem; }
.host-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.host-card h3 { margin: 0 0 .4rem; display: flex; gap: 8px; align-items: center; }
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; margin: 2px 0 8px; }
.bar > span { display: block; height: 100%; background: var(--primary); }
.bar.warn > span { background: #d98b00; }
.bar.crit > span { background: var(--danger); }
.badge { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.bad { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: #8a5a00; border-color: transparent; }
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; font-size: .9rem; }
th { background: var(--surface-2); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 16px; }
.section { margin-bottom: 1.5rem; }
canvas.chart { width: 100%; height: 160px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.secret-box { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--warn-bg); padding: .6rem .8rem; border-radius: 8px; word-break: break-all; user-select: all; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.menu-toggle { display: none; }

@media (max-width: 820px) {
  body.admin #app { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar .spacer { display: none; }
  .content { padding: 16px; }
}
@media print {
  .sidebar, .toolbar, button { display: none !important; }
  body.admin #app { display: block; }
  body.admin { background: #fff; color: #000; }
  .content { padding: 0; }
  table { border: 1px solid #999; }
  canvas.chart { border: 1px solid #999; }
}
body.in-session .broadcast { display: none; }
