/* Panel admin — mobile-first (design.md §5) */

:root {
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --focus: 0 0 0 2px var(--accent);
  --nav-h: 64px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f7; --surface: #ffffff; --surface-2: #eef0f3; --border: #dde1e7;
    --text: #1d2129; --text-muted: #667085; --shadow: 0 10px 30px rgba(20, 30, 50, .12);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font-ui); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); }
.ico { flex: none; vertical-align: middle; }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.layout { min-height: 100vh; }
.side { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 17px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.content { padding: 16px 16px calc(var(--nav-h) + 90px); max-width: 920px; margin: 0 auto; }
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; height: var(--nav-h); display: flex;
  background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; color: var(--text-muted); text-decoration: none; font-weight: 600;
}
.bottomnav a.on { color: var(--primary); }

@media (min-width: 900px) {
  .layout { display: grid; grid-template-columns: 250px 1fr; }
  .side {
    display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow: auto;
    background: var(--surface); border-right: 1px solid var(--border); padding: 18px 12px;
  }
  .side .brand { display: flex; gap: 10px; align-items: center; padding: 4px 10px 18px; font-weight: 800; }
  .side .brand .brand-mark { color: var(--accent); }
  .side .brand small { display: block; font-weight: 400; color: var(--text-muted); font-size: 12px; }
  .side a {
    display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 10px;
    color: var(--text-muted); text-decoration: none; font-weight: 600;
  }
  .side a:hover { background: var(--surface-2); color: var(--text); }
  .side a.on { background: color-mix(in srgb, var(--primary) 18%, transparent); color: var(--primary); }
  .side .spacer { flex: 1; }
  .bottomnav { display: none; }
  .content { padding: 24px 32px 120px; }
}

/* ---------- Komponen ---------- */
.section { margin: 26px 0 12px; display: flex; align-items: center; gap: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.section h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: .01em; text-transform: capitalize; color: var(--text-muted); flex: 1; }
.section:first-child { margin-top: 4px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 12px; }
.muted { color: var(--text-muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 12px; }
.row > .grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.grid2 { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 16px; padding-bottom: 2px; scrollbar-width: none; }
.tabs a {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); text-decoration: none; white-space: nowrap; font-weight: 600; font-size: 14px;
}
.tabs a.on { background: var(--primary); border-color: var(--primary); color: #fff; }

.field { display: block; }
.field > span:first-child { display: block; font-size: 14px; margin-bottom: 6px; }
.field > span:first-child small { color: var(--text-muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); outline: none;
}
textarea.input { min-height: 110px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--accent); }
.input[dir='rtl'] { font-family: var(--font-arab); font-size: 20px; }

.setting { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.setting + .setting { border-top: 1px solid var(--border); }
.setting > .label { flex: 1; }
.setting > .label small { display: block; color: var(--text-muted); font-size: 12.5px; }

.num { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.num button { width: 40px; height: 42px; border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--text-muted); }
.num button:hover { color: var(--text); }
.num input { width: 58px; height: 42px; border: 0; background: none; text-align: center; font-weight: 700; -moz-appearance: textfield; outline: none; }
.num input::-webkit-inner-spin-button { -webkit-appearance: none; }

.toggle { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle .track { width: 50px; height: 28px; border-radius: 999px; background: var(--border); position: relative; transition: background .2s; }
.toggle .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle input:checked + .track { background: var(--primary); }
.toggle input:checked + .track::after { transform: translateX(22px); }
.toggle input:focus-visible + .track { box-shadow: var(--focus); }
.toggle .state { font-size: 13px; color: var(--text-muted); min-width: 64px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); cursor: pointer;
  font-weight: 700; text-decoration: none; color: var(--text); white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.gold { background: var(--accent); border-color: var(--accent); color: #1a1a1a; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn.block { width: 100%; }
.btn.sm { min-height: 34px; padding: 0 10px; font-size: 13px; }
.icon-btn { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px; border: 0; background: none; color: var(--text-muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); }

.test-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 640px) { .test-grid { grid-template-columns: repeat(4, 1fr); } }
.test-grid .btn { min-height: 64px; flex-direction: column; gap: 4px; line-height: 1.2; }

.savebar {
  position: fixed; left: 0; right: 0; bottom: var(--nav-h); z-index: 25; padding: 10px 16px;
  background: linear-gradient(transparent, var(--bg) 30%); display: none;
}
.savebar.show { display: block; }
.savebar .btn { max-width: 888px; margin: 0 auto; display: flex; width: 100%; box-shadow: var(--shadow); }
@media (min-width: 900px) { .savebar { left: 250px; bottom: 0; } }

.item { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.item + .item { margin-top: 8px; }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 700; }
.item .preview { color: var(--text-muted); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item .ar { font-family: var(--font-arab); direction: rtl; font-size: 17px; color: var(--text); }
.item.off { opacity: .55; }
.item .order { display: flex; flex-direction: column; }
.item .order .icon-btn { width: 30px; height: 26px; }
.item .acts { display: flex; align-items: center; gap: 2px; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; letter-spacing: 0; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.badge.green { background: color-mix(in srgb, var(--primary) 18%, transparent); color: var(--primary); border-color: transparent; }
.badge.gold { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); border-color: transparent; }
.badge.red { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); border-color: transparent; }

.gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .gallery { grid-template-columns: repeat(3, 1fr); } }
.thumb { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); }
.thumb .img { aspect-ratio: 16 / 9; background: #fff center / contain no-repeat; position: relative; }
.thumb .img .badge { position: absolute; top: 6px; left: 6px; }
.thumb .bar { display: flex; align-items: center; gap: 2px; padding: 4px 6px; }
.thumb.off .img { opacity: .4; }
.upload-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; aspect-ratio: 16 / 9;
  border: 2px dashed var(--border); border-radius: 12px; color: var(--text-muted); cursor: pointer; text-align: center; padding: 8px;
}
.upload-box:hover { border-color: var(--primary); color: var(--primary); }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .tbl td { padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.tbl th { color: var(--text-muted); font-weight: 600; font-size: 12.5px; }
.tbl td.num-cell { font-variant-numeric: tabular-nums; }
.tbl tr.today td { background: color-mix(in srgb, var(--primary) 14%, transparent); font-weight: 700; }
.tbl-wrap { overflow-x: auto; }

.money { text-align: right; font-variant-numeric: tabular-nums; }
.kas-line { display: grid; grid-template-columns: 1fr 132px 34px; gap: 8px; align-items: center; }
.kas-line + .kas-line { margin-top: 8px; }
.kas-total { display: flex; justify-content: space-between; align-items: baseline; font-weight: 800; font-size: 20px; padding: 12px 0 4px; border-top: 1px solid var(--border); margin-top: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; font-size: 13.5px; font-weight: 600; }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--surface-2); padding: 9px 14px; cursor: pointer; font-weight: 600; color: var(--text-muted); }
.seg button.on { background: var(--primary); color: #fff; }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-size: 14px; border: 1px solid; }
.alert.warn { border-color: color-mix(in srgb, var(--accent) 50%, transparent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.alert.err { border-color: color-mix(in srgb, var(--danger) 50%, transparent); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.alert.ok { border-color: color-mix(in srgb, var(--primary) 50%, transparent); background: color-mix(in srgb, var(--primary) 10%, transparent); }

.theme-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .theme-grid { grid-template-columns: repeat(5, 1fr); } }
.theme-card { display: flex; flex-direction: column; gap: 8px; padding: 8px; border: 2px solid var(--border); border-radius: 14px; background: var(--surface); cursor: pointer; }
.theme-card.on { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.theme-swatch { display: grid; grid-template-columns: 1.4fr 1fr; grid-template-rows: 1fr 10px; gap: 5px; padding: 7px; border-radius: 9px; aspect-ratio: 16 / 9; }
.theme-swatch i { display: grid; place-items: center; border-radius: 5px; font-style: normal; font-weight: 800; font-size: 13px; font-family: var(--font-num); }
.theme-swatch i:nth-child(3) { grid-column: 1 / -1; }
.theme-name { font-weight: 700; font-size: 14px; text-align: center; }
.seg { flex-wrap: wrap; }

.preview-frame { width: 100%; aspect-ratio: 16 / 9; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: #000; }
.preview-frame iframe { width: 1920px; height: 1080px; border: 0; transform-origin: 0 0; pointer-events: none; }

.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--text-muted); }
.status-dot.on { background: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }

.today-sched { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 640px) { .today-sched { grid-template-columns: repeat(6, 1fr); } }
.today-sched div { background: var(--surface-2); border-radius: 10px; padding: 8px; text-align: center; }
.today-sched b { display: block; font-size: 20px; font-family: var(--font-num); }
.today-sched span { font-size: 12px; color: var(--text-muted); }

/* ---------- Dialog & toast ---------- */
dialog.modal {
  border: 1px solid var(--border); border-radius: 16px; padding: 0; background: var(--surface); color: var(--text);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: var(--shadow);
}
dialog.modal::backdrop { background: rgba(0, 0, 0, .55); }
.modal-head { display: flex; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; flex: 1; font-size: 17px; }
.modal-body { padding: 16px; overflow: auto; max-height: calc(100vh - 190px); }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--border); }

.toasts { position: fixed; z-index: 100; left: 50%; bottom: calc(var(--nav-h) + 16px); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 24px)); }
.toast { background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 600; font-size: 14px; animation: toast-in .2s ease-out; }
.toast.err { background: var(--danger); color: #fff; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(380px, 100%); padding: 28px 24px; }
.login .logo { display: flex; justify-content: center; margin-bottom: 12px; color: var(--accent); }
.login h1 { text-align: center; margin: 4px 0 2px; font-size: 20px; }
.login p { text-align: center; margin: 0 0 20px; }
.err-msg { color: var(--danger); font-size: 14px; min-height: 20px; margin: 8px 0; }

.empty { text-align: center; padding: 28px 12px; color: var(--text-muted); border: 1px dashed var(--border); border-radius: 12px; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
