/* Tema limau ala XeroAppStudio. Warna datar: tanpa gradasi dan tanpa bayangan. */
:root {
  --bg: #f3f4f0;
  --surface: #ffffff;
  --surface-2: #eceee6;
  --border: #dcdfd2;
  --text: #1c1e21;
  --muted: #666a62;
  --accent: #4b6600;
  --accent-soft: #eef7c8;
  --brand: #d2fe3b;
  --on-brand: #1c1e21;
  --ok: #1f9d63;
  --ok-soft: #e4f6ec;
  --warn: #c27b0a;
  --warn-soft: #fdf1da;
  --bad: #d23b4b;
  --bad-soft: #fde7ea;
  --radius: 12px;
  font-family: 'Segoe UI Variable', 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
}
:root[data-theme='dark'] {
  --bg: #1c1e21;
  --surface: #25272b;
  --surface-2: #333538;
  --border: #404348;
  --text: #f1f3ec;
  --muted: #a0a59c;
  --accent: #d2fe3b;
  --accent-soft: rgba(210, 254, 59, 0.13);
  --ok: #3ec489;
  --ok-soft: #173126;
  --warn: #e9a63a;
  --warn-soft: #382c14;
  --bad: #ef6573;
  --bad-soft: #3b1b20;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }

.ico { display: inline-flex; width: 18px; height: 18px; flex: none; }
.ico svg { width: 100%; height: 100%; }

/* ---------- tombol & input ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); font-weight: 600; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { filter: brightness(0.95); }
.btn.danger { color: var(--bad); }
.btn.big { padding: 12px 20px; font-size: 15px; width: 100%; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.invisible { visibility: hidden; }
.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center; flex: none;
  border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.on { color: var(--accent); }

.input, .select, .textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); outline: none;
}
.textarea { min-height: 96px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .label { font-size: 12px; font-weight: 700; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; }
.row > .input { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.error-text { color: var(--bad); font-size: 13px; min-height: 18px; }

/* ---------- layar masuk ---------- */
.gate { height: 100%; display: grid; place-items: center; padding: 24px; overflow: auto; }
.gate-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; }
.gate-logo { display: block; width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 18px; }
.gate h1 { font-size: 22px; margin: 0 0 4px; text-align: center; }
.gate p.sub { text-align: center; margin: 0 0 20px; color: var(--muted); }
.meter { display: flex; gap: 4px; margin-top: 6px; }
.meter i { flex: 1; height: 5px; border-radius: 3px; background: var(--surface-2); }
.meter i.on1 { background: var(--bad); }
.meter i.on2 { background: var(--warn); }
.meter i.on3 { background: var(--ok); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; margin: 6px 0 16px; }
.check input { margin-top: 3px; accent-color: var(--accent); }
.link-btn { background: none; border: none; color: var(--muted); font-size: 13px; text-decoration: underline; margin-top: 14px; width: 100%; }

/* ---------- aplikasi utama ---------- */
.app { height: 100%; display: grid; grid-template-columns: 240px 1fr; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.brand b { display: block; font-size: 14px; line-height: 1.2; }
.brand small { color: var(--muted); font-size: 11px; }
.nav { flex: 1; overflow-y: auto; padding: 0 10px 10px; }
.nav h6 { margin: 16px 8px 6px; font-size: 11px; letter-spacing: 0.6px; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.nav-item {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: none; border-radius: 9px;
  background: transparent; text-align: left; color: var(--text);
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .count { font-size: 11.5px; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 1px 8px; }
.nav-item.active .count { background: var(--surface); }
.side-foot { border-top: 1px solid var(--border); padding: 8px 10px; display: flex; gap: 4px; }
.side-foot .btn { flex: 1; }

.list-col { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.list-head { padding: 14px; display: flex; gap: 8px; border-bottom: 1px solid var(--border); background: var(--surface); }
.search { position: relative; flex: 1; min-width: 0; }
.search .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 36px; }
.sort-select { width: auto; padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.list-sub { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px 2px; min-height: 36px; font-size: 13px; }
/* Item mengalir ke bawah; kolom penuh -> lanjut ke kolom di kanannya (geser horizontal bila perlu). */
.list { flex: 1; min-height: 0; overflow-x: auto; overflow-y: hidden; padding: 8px; column-width: 300px; column-gap: 10px; column-fill: auto; }
.list .item { break-inside: avoid; margin-bottom: 4px; }
.list .empty { column-span: all; }
.item {
  width: 100%; display: flex; gap: 12px; align-items: center; padding: 10px; border: 1px solid transparent;
  border-radius: 10px; background: transparent; text-align: left;
}
.item:hover { background: var(--surface-2); }
.item.active { background: var(--accent-soft); border-color: var(--accent); }
.badge-ico { width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); color: var(--accent); display: grid; place-items: center; flex: none; }
.item.active .badge-ico { background: var(--surface); }
.badge-ico .logo-site { width: 24px; height: 24px; object-fit: contain; border-radius: 5px; }
.detail-head .badge-ico .logo-site { width: 32px; height: 32px; border-radius: 7px; }
.item .t { flex: 1; min-width: 0; }
.item .t b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .t span { display: block; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .star { color: var(--accent); }
.tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.empty { text-align: center; color: var(--muted); padding: 48px 20px; }
.empty .ico { width: 40px; height: 40px; margin-bottom: 10px; }

/* Panel detail melayang dari kanan, hanya muncul saat item dipilih. */
.detail {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw);
  overflow-y: auto; background: var(--bg); border-left: 1px solid var(--border);
  transform: translateX(100%); transition: transform 0.18s ease; z-index: 30;
}
.app.show-detail .detail { transform: none; }
.detail-top { display: flex; justify-content: flex-end; margin-bottom: 4px; }
.detail-inner { max-width: 640px; margin: 0 auto; padding: 24px; }
.detail-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.detail-head .badge-ico { width: 48px; height: 48px; }
.detail-head h2 { margin: 0; font-size: 20px; overflow: hidden; text-overflow: ellipsis; }
.detail-head small { color: var(--muted); }
.detail-head .grow { flex: 1; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.kv { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.kv:last-child { border-bottom: none; }
.kv .k { font-size: 12px; font-weight: 700; color: var(--muted); }
.kv .v { word-break: break-word; white-space: pre-wrap; font-family: inherit; }
.kv .v.mono { font-family: Consolas, 'Cascadia Mono', monospace; }
.kv .body { flex: 1; min-width: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.placeholder { height: 100%; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 24px; }
.placeholder img { width: 84px; opacity: 0.9; margin-bottom: 12px; }
.back-btn { display: none; margin-bottom: 10px; }

/* ---------- modal & toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { width: 100%; max-width: 440px; max-height: 92vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 22px; }
.modal h3 { margin: 0 0 14px; font-size: 17px; }
.modal .actions { justify-content: flex-end; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { padding: 7px 12px; border: none; background: transparent; }
.seg button.on { background: var(--brand); color: var(--on-brand); font-weight: 700; }
.gen-out { font-family: Consolas, monospace; background: var(--surface-2); border-radius: 10px; padding: 12px; word-break: break-all; margin-bottom: 12px; }
.opt { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.opt input[type='range'] { flex: 1; accent-color: var(--accent); }
.opt input[type='checkbox'] { accent-color: var(--accent); }
.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.type-grid .btn { justify-content: flex-start; padding: 12px; }

#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 80; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; max-width: 90vw; }
.toast.bad { background: var(--bad); color: #fff; }

/* ---------- responsif ---------- */
@media (max-width: 1000px) {
  .app { grid-template-columns: 64px 1fr; }
  .brand div, .nav h6, .nav-item .name, .nav-item .count, .side-foot .btn span.lbl { display: none; }
  .brand { justify-content: center; padding: 14px 0; }
  .nav-item { justify-content: center; }
  .side-foot { flex-direction: column; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 56px 1fr; }
  .detail { width: calc(100vw - 56px); }
  /* Layar sempit: kembali satu kolom, gulir ke bawah. */
  .list { column-width: auto; columns: auto; overflow-x: hidden; overflow-y: auto; padding-bottom: 28px; }
}
@media (max-width: 520px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .sidebar { grid-row: 2; flex-direction: row; border-right: none; border-top: 1px solid var(--border); overflow-x: auto; }
  .brand { display: none; }
  .nav { display: flex; padding: 4px; overflow: visible; flex: 1; }
  .nav .group { display: flex; }
  .side-foot { border-top: none; flex-direction: row; }
  .detail { width: 100vw; }
  .detail-inner { padding: 16px; }
}
