/* KAS KASIR KURONOA — warna sama dengan database (Config.gs THEME) */
:root {
  --yellow: #FAD23E;
  --yellow-soft: #FFF4CC;
  --cream: #FFFBEF;
  --gold: #A97F2E;
  --gold-dark: #8A6620;
  --ink: #3B2F1E;
  --muted: #8A7B60;
  --red: #C62828;
  --green: #2E7D32;
  --line: #EADBB0;
  --grey: #F1EEE6;
  --white: #FFFFFF;
  --bg: #FFFDF6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(59, 47, 30, .06), 0 6px 18px rgba(169, 127, 46, .10);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; touch-action: manipulation; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: var(--font); color: var(--ink); background: var(--bg);
  font-size: 15px; line-height: 1.4; min-height: 100vh;
  overscroll-behavior-y: none;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Tombol ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 42px; padding: 0 16px; border-radius: 12px; border: 1px solid transparent;
  background: var(--white); font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: transform .08s, background .15s, box-shadow .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--yellow); color: var(--ink); box-shadow: 0 2px 0 var(--gold); }
.btn.primary:hover { background: #F7C91F; }
.btn.danger { background: var(--red); color: #fff; }
.btn.outline { border-color: var(--line); background: var(--white); }
.btn.outline:hover { border-color: var(--gold); }
.btn.ghost { background: transparent; color: var(--gold-dark); }
.btn.block { width: 100%; }
.btn[disabled], .icon-btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  border: 0; background: transparent; cursor: pointer; color: var(--ink);
}
.icon-btn:hover { background: var(--yellow-soft); }
.icon-btn.soft { background: var(--white); border: 1px solid var(--line); }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Layout ---------- */
.app { width: 100%; padding: 0 max(12px, var(--safe-r)) 24px max(12px, var(--safe-l)); }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin: 0 calc(-1 * max(12px, var(--safe-l))); padding: calc(6px + env(safe-area-inset-top, 0px)) max(12px, var(--safe-r)) 6px max(12px, var(--safe-l));
  background: rgba(255, 253, 246, .92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { height: 46px; width: auto; display: block; }
.top-actions { display: flex; align-items: center; gap: 2px; }
.pill { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--grey); color: var(--muted); white-space: nowrap; }
.pill.ok { background: #E8F5E9; color: var(--green); }
.pill.off { background: #FDECEA; color: var(--red); }

.controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 0 10px; }
.period { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.exports { display: flex; gap: 8px; }
select {
  height: 42px; padding: 0 34px 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--white)
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23A97F2E' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 16px;
  -webkit-appearance: none; appearance: none; font-weight: 700; font-size: 16px; cursor: pointer;
}

/* ---------- Ringkasan ---------- */
.summary { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow);
  position: relative; min-width: 0;
}
.card .lbl { font-size: 12px; font-weight: 700; letter-spacing: .02em; color: var(--muted); text-transform: uppercase; display: flex; align-items: center; gap: 6px; }
.card .val { font-size: 19px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.card .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card.in .val { color: var(--green); }
.card.out .val { color: var(--red); }
.card.end { background: linear-gradient(135deg, var(--yellow) 0%, #FFE27A 100%); border-color: var(--gold); }
.card.end .lbl, .card.end .sub { color: var(--gold-dark); }
.card .edit { position: absolute; top: 6px; right: 6px; width: 34px; height: 34px; }
.card .edit svg { width: 16px; height: 16px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.status { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); padding: 10px 2px; }
.status .ok { color: var(--green); font-weight: 600; }
.status .warn { color: var(--red); font-weight: 600; }
.issues { width: 100%; background: #FDECEA; color: var(--red); border-radius: 10px; padding: 8px 12px; margin: 0; font-size: 13px; }

/* ---------- Tabel ---------- */
.table-wrap {
  width: 100%; overflow: auto; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); -webkit-overflow-scrolling: touch; max-height: calc(100vh - 120px);
}
table.kas { width: 100%; min-width: 860px; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.kas th, .kas td { padding: 0 10px; height: 40px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.kas thead th {
  position: sticky; top: 0; z-index: 3; background: var(--yellow); font-size: 12px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .02em; height: 44px; border-bottom: 2px solid var(--gold);
}
.kas .num { text-align: right; }
.kas .c-date { position: sticky; left: 0; z-index: 2; background: inherit; width: 168px; min-width: 168px; max-width: 168px; }
.kas thead .c-date { z-index: 4; background: var(--yellow); }
.kas tbody tr { background: var(--white); cursor: pointer; }
.kas tbody tr:nth-child(even) { background: var(--cream); }
.kas tbody tr:hover { background: var(--yellow-soft); }
.kas tbody tr.today { box-shadow: inset 4px 0 0 var(--gold); }
.kas .dwrap { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.kas .dwrap b { font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.kas tbody tr.today .dwrap small::after { content: " · hari ini"; font-weight: 700; color: var(--gold); }
.kas tbody tr.sunday .c-date { color: var(--red); }
.kas tbody tr.sa { background: var(--yellow-soft); font-weight: 700; cursor: default; }
.kas .c-date small { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kas tbody tr.sunday .c-date small { color: var(--red); }
.kas .c-note { white-space: normal; min-width: 180px; max-width: 320px; overflow-wrap: anywhere; font-size: 14px; }
.kas .c-saldo { background: rgba(255, 244, 204, .65); font-weight: 800; }
.kas thead .c-saldo { background: var(--yellow); }
.kas .c-act { width: 92px; text-align: right; padding-right: 6px; }
.kas .c-act .icon-btn { width: 36px; height: 36px; }
.kas .c-act .icon-btn svg { width: 17px; height: 17px; }
.kas .c-act .del { color: var(--red); }
.kas td.neg { color: var(--red); }
.kas tfoot td { position: sticky; bottom: 0; background: var(--gold); color: #fff; font-weight: 800; border-bottom: 0; height: 44px; z-index: 2; }
.kas tfoot .c-date { z-index: 3; background: var(--gold); }
.kas tfoot .c-saldo { background: var(--gold-dark); }
.empty-row td { color: var(--muted); text-align: center; height: 80px; }

.footer { text-align: center; padding: 18px 0 calc(8px + env(safe-area-inset-bottom, 0px)); }
.credit { font-size: 12px; color: var(--muted); margin: 0; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 20% 0%, var(--yellow-soft), var(--bg) 60%); }
.login-card { width: 100%; max-width: 400px; background: var(--white); border: 1px solid var(--line); border-radius: 20px; padding: 24px; box-shadow: var(--shadow); display: grid; gap: 12px; }
.login-logo { width: 100%; max-width: 300px; margin: 0 auto; display: block; }
.login-card h1 { margin: 4px 0 0; font-size: 22px; }
.login-card p { margin: 0; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
input[type=text], input[type=password], input[type=url], input:not([type]) {
  height: 46px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--white);
  font-size: 16px; font-weight: 600; color: var(--ink); width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--yellow); outline-offset: 1px; border-color: var(--gold); }
.error { color: var(--red); font-size: 13px; font-weight: 600; min-height: 1em; margin: 0; }
.login-credit { text-align: center; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(59, 47, 30, .45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.sheet {
  width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; background: var(--white);
  border-radius: 20px; padding: 18px; display: grid; gap: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
  animation: pop .16s ease-out;
}
@keyframes pop { from { transform: translateY(10px); opacity: 0; } }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.sheet h2 { margin: 0; font-size: 19px; }
.eyebrow { margin: 0; font-size: 12px; font-weight: 800; color: var(--gold); text-transform: uppercase; letter-spacing: .05em; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.in.plus { color: var(--green); }
.in.minus { color: var(--red); }
.in input { text-align: right; font-variant-numeric: tabular-nums; }
.in input[name=ket] { text-align: left; }
.preview { background: var(--cream); border: 1px dashed var(--line); border-radius: 12px; padding: 10px 12px; font-size: 14px; display: grid; gap: 2px; }
.preview b { font-variant-numeric: tabular-nums; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; }
.radio { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; color: var(--ink); font-weight: 400; }
.radio input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--gold); }
.radio small { color: var(--muted); }
.cmp { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.cmp th, .cmp td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: right; }
.cmp th:first-child, .cmp td:first-child { text-align: left; color: var(--muted); }
.cmp thead th { font-size: 12px; text-transform: uppercase; color: var(--gold-dark); }
.cmp tr.chg td { background: var(--yellow-soft); font-weight: 700; }
.cmp td.note { text-align: left; white-space: normal; overflow-wrap: anywhere; }
.confirm .lead { margin: 0; }
.menu-list { display: grid; gap: 6px; }
.menu-item { display: block; text-align: left; padding: 12px 14px; border-radius: 12px; background: var(--cream); border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 600; cursor: pointer; }
.menu-item.danger { color: var(--red); }
.about { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; margin: 6px 0 0; }
.about dt { color: var(--muted); }
.about dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 120px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  z-index: 80; transition: transform .25s; max-width: calc(100vw - 24px); text-align: center;
}
.toast.show { transform: translate(-50%, 0); }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }
.busy { position: fixed; inset: 0; z-index: 90; background: rgba(255, 253, 246, .6); display: grid; place-items: center; font-weight: 700; }

/* ---------- Responsif & rotasi ---------- */
@media (max-width: 1100px) { .summary { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  body { font-size: 14px; }
  .brand { height: 40px; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .card { padding: 10px 12px; }
  .card .val { font-size: 17px; }
  .controls { gap: 8px; }
  .period { width: 100%; display: grid; grid-template-columns: 40px minmax(0, 1fr) 86px 40px 44px; gap: 6px; }
  .period select { min-width: 0; width: 100%; padding: 0 26px 0 10px; background-position: right 8px center; font-size: 16px; }
  #btnToday span { display: none; }
  #btnToday { padding: 0; width: 44px; border: 1px solid var(--line); background: var(--white); }
  .exports { width: 100%; }
  .exports .btn { flex: 1; }
  .grid2 { grid-template-columns: 1fr; }
  .modal { align-items: flex-end; padding: 0; }
  .sheet { border-radius: 20px 20px 0 0; max-height: 92vh; padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
  #netPill { display: none; }
  .kas .c-date { width: 150px; min-width: 150px; max-width: 150px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .summary { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
  .card { padding: 8px 10px; }
  .card .val { font-size: 15px; }
  .card .sub { display: none; }
  .controls { flex-wrap: nowrap; padding: 8px 0; }
  .period { width: auto; }
  .exports { width: auto; }
  .brand { height: 34px; }
  .table-wrap { max-height: none; }
  .grid2 { grid-template-columns: 1fr 1fr; }
  .modal { align-items: center; padding: 8px; }
  .sheet { border-radius: 16px; max-height: calc(100vh - 16px); }
}

/* ---------- Tab tampilan ---------- */
.tabs { display: flex; gap: 6px; padding: 0 0 12px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--white); font-weight: 700; cursor: pointer; color: var(--muted);
}
.tab svg { width: 18px; height: 18px; }
.tab.active { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- Pilihan ekspor ---------- */
.choice {
  display: grid; gap: 3px; text-align: left; width: 100%; padding: 14px 16px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--cream); cursor: pointer;
}
.choice:hover { border-color: var(--gold); background: var(--yellow-soft); }
.choice b { font-size: 15px; }
.choice small { color: var(--muted); font-size: 13px; }
.choice[disabled] { opacity: .6; cursor: progress; }

/* ---------- Dashboard ---------- */
.dash-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--grey); border-radius: 12px; padding: 3px; }
.seg-btn { height: 36px; padding: 0 18px; border: 0; border-radius: 10px; background: transparent; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg-btn.active { background: var(--white); color: var(--ink); box-shadow: 0 1px 3px rgba(59, 47, 30, .15); }
.dash-period { margin: 0; font-weight: 800; font-size: 17px; }
.dash-note { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; min-height: 8px; padding: 6px 2px; }
.dash-note p { margin: 20px 0; color: var(--muted); font-weight: 600; }
.dash-note .warn { color: var(--red); font-weight: 600; }
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.kpi { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); min-width: 0; display: grid; gap: 3px; align-content: start; }
.kpi .lbl { font-size: 11.5px; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); }
.kpi .val { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; color: var(--ink); }
.kpi .sub { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.kpi .trend { font-size: 12.5px; font-weight: 700; }
.kpi .trend.up { color: var(--green); }
.kpi .trend.down { color: var(--red); }
.kpi.hero { background: linear-gradient(135deg, var(--yellow-soft), var(--white)); border-color: var(--yellow); }
.kpi.strong { background: linear-gradient(135deg, var(--yellow) 0%, #FFE27A 100%); border-color: var(--gold); }
.kpi.strong .lbl, .kpi.strong .sub { color: var(--gold-dark); }
.kpi.warn .sub { color: var(--red); font-weight: 600; }

.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.chart-card { margin: 0; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 14px 8px; box-shadow: var(--shadow); min-width: 0; }
.chart-card figcaption h3, .panel h3 { margin: 0; font-size: 15px; }
.chart-card figcaption p { margin: 2px 0 0; font-size: 12px; }
.legend { display: flex; gap: 14px; margin-top: 8px; font-size: 12.5px; font-weight: 600; color: var(--ink); }
.leg { display: inline-flex; align-items: center; gap: 6px; }
.key.box { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.plot { width: 100%; margin-top: 6px; position: relative; }
.plot svg { display: block; width: 100%; height: auto; overflow: hidden; touch-action: pan-y; stroke: none; stroke-width: 1; fill: none; }
.plot svg [hidden-mark] { visibility: hidden; }
.axis text { font-size: 11px; fill: var(--muted); stroke: none; font-variant-numeric: tabular-nums; }
.axis .grid { stroke: #F1E8CF; stroke-width: 1; }
.axis .zero { stroke: #CDBB8C; stroke-width: 1; }
.plot .hl { fill: var(--yellow-soft); opacity: .7; }
.plot .today { fill: var(--ink); opacity: .35; }
.plot .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.plot .dot { stroke: var(--white); stroke-width: 2; }
.plot .cross { stroke: var(--ink); stroke-width: 1; opacity: .35; }
.plot .hits rect:focus { outline: none; }
.plot .hits rect:focus-visible { stroke: var(--gold); stroke-width: 2; }
.empty-chart { position: absolute; inset: 40% 0 auto; text-align: center; color: var(--muted); font-size: 13px; margin: 0; }
.chart-tip {
  position: fixed; z-index: 70; pointer-events: none; background: var(--white); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; box-shadow: 0 8px 24px rgba(59, 47, 30, .18); font-size: 12.5px; min-width: 150px;
}
.tip-title { font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.tip-row { display: grid; grid-template-columns: 14px auto 1fr; gap: 6px; align-items: center; }
.tip-row b { font-variant-numeric: tabular-nums; color: var(--ink); }
.tip-row span:last-child { color: var(--muted); }
.tip-key { width: 12px; height: 0; border-top: 2px solid; display: inline-block; }

.dash-lower { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; margin-top: 12px; }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); min-width: 0; display: grid; gap: 10px; align-content: start; }
.mini-wrap { overflow-x: auto; }
table.mini { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.mini th { text-align: left; font-size: 11px; text-transform: uppercase; color: var(--gold-dark); padding: 6px 8px; border-bottom: 2px solid var(--yellow); white-space: nowrap; }
.mini td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.mini td:not(.num) { overflow-wrap: anywhere; }
.mini .num { text-align: right; white-space: nowrap; }
.mini tr.cur td { background: var(--yellow-soft); }
.mini tr.tot td { font-weight: 800; border-top: 2px solid var(--gold); border-bottom: 0; }
.split { display: grid; gap: 10px; }
.split-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.split-top b { font-variant-numeric: tabular-nums; }
.track { height: 10px; border-radius: 6px; background: var(--grey); overflow: hidden; margin-top: 4px; }
.track .fill { display: block; height: 100%; background: #3A6FC4; border-radius: 0 4px 4px 0; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .charts, .dash-lower { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .tabs { gap: 6px; }
  .tab { flex: 1; justify-content: center; padding: 0 10px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 10px 12px; }
  .kpi .val { font-size: 16px; }
  .seg { width: 100%; }
  .seg-btn { flex: 1; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
  .kpi .val { font-size: 15px; }
  .charts { grid-template-columns: 1fr 1fr; }
  .tabs { padding-bottom: 8px; margin-bottom: 8px; }
  .tab { height: 36px; }
}

@media print { .topbar, .controls, .tabs, .footer, .c-act { display: none !important; } }
