/* ── Panel admin (/admin) — memakai token warna dari style.css ─────────── */
.admin-body { overflow: auto; }
.admin-shell { min-height: 100vh; display: flex; flex-direction: column; }
.admin-shell[hidden] { display: none; }
.muted { color: var(--muted); font-size: 12.5px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.admin-top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 12px 22px;
  background: var(--bar-bg);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--line);
}
.admin-top .brand-name { font-size: 18px; }
.admin-top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.admin-email { color: var(--muted); font-size: 12.5px; margin-right: 6px; }

.admin-tabs { display: inline-flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-soft); }
.admin-tab { padding: 7px 16px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer; }
.admin-tab.active { background: var(--accent); color: #fff; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--surface-3); color: var(--text); font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: border-color 0.15s, background 0.15s;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-accent { background: var(--accent); border-color: transparent; color: #fff; }
.btn-accent:hover:not(:disabled) { background: var(--accent-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover:not(:disabled) { border-color: var(--danger); background: rgba(249, 99, 107, 0.1); }
.btn-xs { padding: 5px 10px; font-size: 12px; }
.icon-btn { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface-3); color: var(--text); cursor: pointer; }
.icon-btn:hover { border-color: var(--accent); }
html:not([data-theme="light"]) .icon-btn .icon-sun { display: none; }
html[data-theme="light"] .icon-btn .icon-moon { display: none; }

.input {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--input-bg); color: var(--text); font: inherit; font-size: 13.5px; min-width: 0;
}
.input:focus-visible { outline: none; border-color: var(--accent); }
select.input { padding-right: 28px; }

.admin-main { width: min(1180px, 100%); margin: 0 auto; padding: 22px 22px 60px; display: grid; gap: 18px; }
.admin-view { display: grid; gap: 16px; }
/* item grid tidak boleh melebar karena tabel: biarkan .table-wrap yang scroll */
.admin-main > *, .admin-view > *, .grid-2 > *, .card { min-width: 0; }
.admin-view[hidden] { display: none; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.view-head h1 { margin: 0; font-size: 22px; }
.view-head-right { display: flex; align-items: center; gap: 10px; }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile {
  display: grid; gap: 3px; padding: 16px 18px;
  background: var(--card-gradient); border: 1px solid var(--line); border-radius: var(--radius);
}
.tile-label { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.3px; text-transform: uppercase; }
.tile-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.3px; }
.tile-hero .tile-value { color: var(--accent); font-size: 28px; }
.tile-sub { color: var(--faint); font-size: 12px; }

.card { background: var(--panel-bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; position: relative; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; font-size: 15px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1.4fr; gap: 16px; }

/* grafik batang (SVG dibuat di admin.js) */
.chart { width: 100%; height: 240px; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .bar { fill: var(--accent); }
.chart .bar.empty { fill: var(--line-strong); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar.hover { fill: var(--accent-hover); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis-text { fill: var(--muted); font-size: 11px; }
.chart .today { fill: var(--text); font-weight: 700; }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none;
  padding: 7px 10px; border-radius: 8px; background: var(--menu-bg); border: 1px solid var(--line-strong);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.2); font-size: 12px; line-height: 1.4; white-space: nowrap;
}
.chart-tip[hidden] { display: none; }
.chart-tip b { font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.4px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--row-bg); }
.tbl .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; white-space: nowrap; }
.tbl .num { white-space: nowrap; }
.tbl .sub { display: block; color: var(--faint); font-size: 11.5px; }
.tbl .actions { white-space: nowrap; text-align: right; }
.tbl .actions .btn { margin-left: 4px; }
.dlg .tbl .actions { white-space: normal; }
.dlg .tbl .actions .btn { margin: 2px 0 2px 4px; }
.dlg .tbl td { padding: 8px 8px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-active, .badge-paid { color: var(--ok); background: rgba(52, 211, 153, 0.12); border-color: rgba(52, 211, 153, 0.3); }
.badge-pending { color: #f5a25c; background: rgba(245, 162, 92, 0.12); border-color: rgba(245, 162, 92, 0.3); }
.badge-expired { color: var(--danger); background: rgba(249, 99, 107, 0.1); border-color: rgba(249, 99, 107, 0.3); }
.badge-none { color: var(--muted); background: var(--surface-soft); border-color: var(--line); }
.badge-admin { color: #60a5fa; background: rgba(96, 165, 250, 0.12); border-color: rgba(96, 165, 250, 0.3); }
.badge-admin::before { display: none; }

.users-tools { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.users-tools #userSearch { flex: 1 1 260px; }
.grant-new { display: flex; gap: 8px; flex: 1 1 320px; }
.grant-new input { flex: 1; }

/* dialog */
.dlg {
  width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 20px 22px; border: 1px solid var(--line-strong); border-radius: 16px;
  background: var(--dialog-bg); color: var(--text); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.dlg-sm { width: min(440px, calc(100vw - 32px)); }
.dlg::backdrop { background: var(--overlay); backdrop-filter: blur(6px); }
.dlg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.dlg-head h2 { margin: 0; font-size: 17px; word-break: break-all; }
.dlg-head p { margin: 4px 0 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

.grant-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px; margin-bottom: 14px; border: 1px dashed var(--line-strong); border-radius: 12px; background: var(--surface-soft); }
.grant-title { font-weight: 700; font-size: 13px; margin-right: 4px; }
.grant-form select { min-width: 180px; }
.grant-form #grantDays { width: 90px; }
.grant-form #grantDays[hidden] { display: none; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.check input { accent-color: var(--accent); }

.edit-form { display: grid; gap: 12px; }
.edit-form label { display: grid; gap: 5px; font-size: 12.5px; color: var(--muted); }
.edit-quick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.denied-email { text-align: center; color: var(--text); font-weight: 600; margin: 0 0 16px; word-break: break-all; }
.denied-actions { display: flex; gap: 8px; justify-content: center; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200;
  padding: 10px 16px; border-radius: 999px; background: var(--menu-bg); border: 1px solid var(--line-strong);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); font-size: 13px; font-weight: 600;
}
.toast.error { color: var(--danger); }
.toast.ok { color: var(--ok); }
.toast[hidden] { display: none; }

@media (max-width: 1060px) { .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-top { padding: 10px 16px; gap: 10px; }
  .admin-main { padding: 16px 16px 60px; }
}
@media (max-width: 560px) {
  .admin-email { display: none; }
  .tile-value { font-size: 20px; }
  .tile-hero .tile-value { font-size: 22px; }
  .chart { height: 200px; }
}
