:root {
  --bg: var(--brand-paper);
  --card: var(--brand-card);
  --ink: var(--brand-ink);
  --line: var(--brand-line);
  --mute: var(--brand-muted);
  --ac: var(--brand-accent);
  --accent-soft: var(--brand-accent-wash);
  --accent-comfort: var(--brand-accent);
}

#app {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 194px minmax(0, 1fr);
}
#app .top {
  position: sticky;
  align-self: start;
  align-items: stretch;
  display: flex;
  flex-direction: column;
  justify-content: start;
  flex-wrap: nowrap;
  min-height: 100svh;
  gap: 28px;
  padding: 26px 14px 16px;
  border: 0;
  border-right: 1px solid var(--line);
}
.top .brand { padding-inline: 7px; }
.top .brand small { text-transform: none; letter-spacing: .02em; }
.top .tabs { flex-direction: column; gap: 5px; }
.top .tabs button { width: 100%; text-align: left; color: var(--mute); }
.top .tabs button.on { background: var(--accent-soft); color: var(--accent-comfort); }
.top .top-act {
  align-items: start;
  margin: auto 0 0;
  gap: 6px;
  display: flex;
  flex-wrap: wrap;
}
#app main {
  width: 100%;
  min-width: 0;
  padding: 34px clamp(18px, 3.7vw, 48px) 80px;
  max-width: 1240px;
}
.head h1 {
  font-size: clamp(2.4rem, 4.2vw, 3.5rem);
  line-height: .98;
  letter-spacing: -.048em;
}
.btn { border: 1px solid var(--line); }
.btn:hover { background: var(--accent-soft); }
.btn.pri { background: var(--accent-comfort); color: var(--brand-on-dark); border-color: var(--accent-comfort); }
.btn.pri:hover { background: var(--ac); }
.tabs button:hover { background: #efede7; }
.login-card, .panel, table, .row-inv, .mus-row, .dlg, input, select, textarea {
  border-width: 1px;
  border-color: var(--line);
}
.login-card { box-shadow: 0 20px 55px #232a1614; }

.overview-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0 18px;
}
.admin-metric {
  min-width: 0;
  padding: 17px 16px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}
.admin-metric h2 { font: 500 .9rem/1.2 var(--sans); color: var(--mute); }
.admin-metric b {
  display: block;
  font: 500 clamp(1.55rem, 2.8vw, 2.35rem)/1.1 var(--serif);
  font-variant-numeric: tabular-nums;
  margin-block: 13px 6px;
  overflow-wrap: anywhere;
}
.admin-metric p { margin: 0; color: var(--mute); font-size: .8rem; }
.trend { gap: 12px; }
.trend-head, .trend-options { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.trend-head { justify-content: space-between; }
.trend-options { gap: 13px; }
.trend-options button[aria-pressed=true] { background: var(--accent-soft); color: var(--accent-comfort); border-color: #b5bcaa; }
.trend-plot {
  display: grid;
  grid-template-columns: repeat(var(--period-count, 30), minmax(18px, 1fr));
  min-height: 146px;
  max-height: 235px;
  overflow-x: auto;
  gap: 4px;
  padding-block: 9px 2px;
}
.trend-point { min-width: 0; display: grid; grid-template-rows: 132px 25px; gap: 4px; }
.trend-point button {
  display: grid;
  align-items: end;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(to top, #e9e9de 1px, transparent 1px) bottom / 100% 33% repeat-y;
  cursor: pointer;
  padding: 0;
}
.trend-point button::before {
  content: '';
  display: block;
  margin-inline: auto;
  width: min(80%, 40px);
  height: max(2px, var(--point));
  background: #8c9b81;
  border-radius: 3px 3px 0 0;
}
.trend-point button:hover::before, .trend-point button:focus-visible::before { background: var(--ac); }
.trend-point small { color: var(--mute); white-space: nowrap; font-size: .68rem; min-width: 0; }
.trend-detail { min-height: 1.3em; }
.recent, .unmatched { margin-top: 27px; }
.recent .head { margin-bottom: 9px; }

.order-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(115px, 185px) minmax(115px, 185px);
  gap: 8px;
  margin-bottom: 15px;
}
.orders-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
}
.orders-table table { border: 0; border-radius: 0; background: transparent; }
.orders-table th { background: #f1efe8; color: #525748; text-transform: none; letter-spacing: .045em; }
.orders-table td { overflow-wrap: anywhere; }
.orders-table td small, .drawer-log small { display: block; color: var(--mute); font-size: .79rem; }
.orders-table .money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.orders-table tr:last-child td { border-bottom: 0; }
.orders-table tbody tr:focus-within, .orders-table tbody tr:hover { background: #f4f3eb; }
.pill { border-width: 1px; color: var(--mute); background: #f2f1ea; }
.pill.status-paid, .pill.status-free { background: var(--brand-sage); color: var(--brand-success); border-color: var(--brand-line); }
.pill.status-pending { background: #f1ebdd; color: #645138; }

.order-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  margin: 0;
  width: min(510px, 100%);
  height: 100dvh;
  max-height: 100dvh;
  max-width: 100%;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  overflow-y: auto;
}
.order-drawer::backdrop { background: #231a1661; }
.drawer-title {
  position: sticky;
  top: 0;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.drawer-title h2 { font-size: 1.85rem; overflow-wrap: anywhere; }
.drawer-content { padding: 18px 22px 38px; }
.drawer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-bottom: 20px; }
.drawer-content h3 { font-size: 1.35rem; margin-top: 20px; }
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 8px 0 0;
  padding: 8px 0;
}
.detail-grid dt { color: var(--mute); font-size: .8rem; }
.detail-grid dd { margin: 0; overflow-wrap: anywhere; }
.drawer-log { padding: 0; list-style: none; margin: 8px 0; }
.drawer-log li { border-bottom: 1px solid var(--line); padding: 8px 0; }
.drawer-log li p { margin: 5px 0; }
.override-status { border: 1px solid var(--line); border-radius: 7px; padding: 10px; margin-top: 14px; }
.override-status summary { cursor: pointer; }
.override-status form { margin-top: 10px; display: grid; gap: 8px; }
.copy-field { display: grid; gap: 7px; align-items: start; }
.copy-field [aria-pressed=true] { background: var(--accent-soft); }
.copy-field p { margin-top: 0; }
.legacy-photo {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.legacy-photo img { width: 70px; height: 68px; border-radius: 4px; object-fit: cover; }
.legacy-photo .acts { margin-top: 6px; }

@media (max-width: 1050px) {
  #app { grid-template-columns: 154px minmax(0, 1fr); }
  .overview-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 730px) {
  #app { display: block; }
  #app .top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: 'brand actions' 'nav nav';
    min-height: 0;
    gap: 7px;
    padding: 8px 11px;
    border: 0;
    border-bottom: 1px solid var(--line);
  }
  .top .brand { grid-area: brand; padding: 0; }
  .top .tabs { grid-area: nav; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; }
  .top .tabs button { width: 100%; min-width: 0; padding: 6px 2px; min-height: 40px; font-size: .83rem; text-align: center; }
  .top .top-act { grid-area: actions; margin: 0; }
  #app main { padding: 18px 12px 48px; }
  .overview-kpis { margin-top: 13px; }
  .admin-metric { padding: 13px 10px; }
  .order-filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .order-filters input { grid-column: 1 / -1; }
  .orders-table thead { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
  .orders-table :is(table, tbody) { display: block; }
  .orders-table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); border-bottom: 1px solid var(--line); }
  .orders-table td { padding: 7px 10px; border: 0; }
  .orders-table td[data-col=Acara] { grid-column: 1 / -1; }
  .orders-table td[data-col=Pemesan] { grid-column: 1 / -1; }
  .orders-table td[data-col=Aksi] { text-align: right; }
  .ed .prev { order: 0; }
}
