:root {
  --accent: #d9534f;
  --accent-dark: #b93f3b;
  --accent-soft: #fbeceb;
  --ink: #1f2430;
  --muted: #667085;
  --line: #e4e7ec;
  --bg: #f5f6f8;
  --card: #ffffff;
  --ok: #1a7f4b;
  --ok-soft: #e6f4ec;
  --warn: #9a6700;
  --warn-soft: #fff4d6;
  --info: #175cd3;
  --info-soft: #e8f0fe;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
h1, h2, h3 { line-height: 1.25; margin: 0; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background:
  linear-gradient(160deg, var(--accent-soft), var(--bg) 55%); }
.login-card {
  width: 100%; max-width: 400px; background: var(--card); border-radius: 16px; box-shadow: var(--shadow);
  padding: 32px 24px; text-align: center; display: grid; gap: 14px; justify-items: center;
}
.login-card h1 { font-size: 22px; }
.login-card p { margin: 0; }
.google-btn { min-height: 44px; display: flex; justify-content: center; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 12px; background: var(--accent);
  background-image: linear-gradient(#fff, #fff), linear-gradient(#fff, #fff), linear-gradient(#fff, #fff);
  background-repeat: no-repeat;
  background-size: 6px 16px, 6px 12px, 6px 24px;
  background-position: 12px 24px, 21px 28px, 30px 16px;
}
.brand-mark.small { width: 28px; height: 28px; border-radius: 8px; background-size: 4px 10px, 4px 7px, 4px 15px; background-position: 7px 14px, 12px 17px, 17px 9px; }

/* ---------- Topbar ---------- */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1100px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; min-width: 0; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.userbox { display: flex; align-items: center; gap: 8px; min-width: 0; }
.user-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.container { max-width: 1100px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- Filter ---------- */
.filters { padding: 14px 16px; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }
.field { display: grid; gap: 6px; min-width: 0; }
.field.grow { grid-column: span 1; }
.field > label, .field > .label, .form label { font-size: 13px; font-weight: 600; color: #344054; }
.period-pick { display: grid; grid-template-columns: 1fr 96px; gap: 8px; }
.period-row { display: flex; align-items: center; gap: 8px; min-height: 40px; flex-wrap: wrap; }

input, select, textarea {
  width: 100%; font: inherit; color: inherit; background: #fff;
  border: 1px solid #d0d5dd; border-radius: 8px; padding: 9px 11px; min-height: 40px;
}
textarea { resize: vertical; min-height: 84px; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
input:disabled, select:disabled, textarea:disabled { background: #f2f4f7; color: #98a2b3; cursor: not-allowed; }
.error-text { color: var(--accent-dark); font-size: 12px; min-height: 0; }

/* ---------- Chip & tombol ---------- */
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef0f3; color: #344054; white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--accent-soft); color: var(--accent-dark); }
.chip.info { background: var(--info-soft); color: var(--info); }

.btn {
  font: inherit; font-weight: 600; border-radius: 8px; border: 1px solid transparent; padding: 9px 16px; min-height: 40px;
  cursor: pointer; background: var(--accent); color: #fff;
}
.btn:hover { background: var(--accent-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost { background: transparent; color: #344054; border-color: #d0d5dd; }
.btn-ghost:hover { background: #f2f4f7; }
.btn-small { padding: 4px 10px; min-height: 30px; font-size: 13px; }

/* ---------- KPI ---------- */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); border-top: 3px solid var(--accent); }
.kpi .k-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kpi .k-value { font-size: 22px; font-weight: 700; margin-top: 4px; word-break: break-word; }
.kpi .k-sub { font-size: 12px; color: var(--muted); }

/* ---------- Tab ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.tab { font: inherit; font-weight: 600; background: none; border: 0; padding: 10px 14px; cursor: pointer; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--accent-dark); border-bottom-color: var(--accent); }

.panel { padding: 20px; }
.panel h2 { font-size: 18px; margin-bottom: 4px; }
.panel .lead { margin: 0 0 16px; color: var(--muted); }

.form { display: grid; gap: 14px; max-width: 720px; }
.form .row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form .actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.hint { font-size: 12px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 18px; min-height: 18px; height: 18px; }

.alert { padding: 10px 12px; border-radius: 8px; font-size: 14px; margin: 0; }
.alert-info { background: var(--info-soft); color: #0b3a8a; }
.alert-warn { background: var(--warn-soft); color: #6b4700; }
.alert-error { background: var(--accent-soft); color: var(--accent-dark); }
.alert-ok { background: var(--ok-soft); color: #11563a; }
.alert .btn { margin-left: 8px; }
.stack { display: grid; gap: 14px; }

/* ---------- Tabel ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.toolbar .grow { flex: 1 1 200px; }
.toolbar select { width: auto; min-width: 150px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #fafbfc; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); }
.mini-list { margin-top: 20px; }
.mini-list h3 { font-size: 15px; margin-bottom: 8px; }

/* ---------- Modal ---------- */
.modal { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 24px)); box-shadow: 0 20px 50px rgba(16, 24, 40, .3); }
.modal::backdrop { background: rgba(16, 24, 40, .45); }
.modal-body { padding: 20px; display: grid; gap: 14px; }
.modal-head { display: flex; justify-content: space-between; align-items: start; gap: 8px; }

/* ---------- Toast ---------- */
.toasts { position: fixed; right: 12px; bottom: 12px; display: grid; gap: 8px; z-index: 50; max-width: calc(100vw - 24px); }
.toast { background: #101828; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); font-size: 14px; }
.toast.error { background: var(--accent-dark); }
.toast.ok { background: var(--ok); }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .container { padding: 12px; gap: 12px; }
  .panel { padding: 14px; }
  .user-name { max-width: 90px; }
  .brand-name { max-width: 150px; }
  .kpi .k-value { font-size: 18px; }
  .btn { width: 100%; }
  .btn-small, .topbar .btn { width: auto; }
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { padding: 10px 12px; border-bottom: 1px solid var(--line); }
  table.cards td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.cards td::before { content: attr(data-label); font-weight: 600; color: var(--muted); text-align: left; }
  table.cards td.actions { justify-content: flex-end; padding-top: 8px; }
  table.cards td.actions::before { content: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .tab { transition: background .12s, color .12s, border-color .12s; }
}
