/* ===== SIM Geprek Bejo — mobile-first ===== */
:root {
  --red: #d63031;
  --red-dark: #b02324;
  --orange: #e17055;
  --green: #00b894;
  --green-dark: #00997a;
  --blue: #0984e3;
  --amber: #fdcb6e;
  --ink: #2d3436;
  --muted: #636e72;
  --line: #dfe6e9;
  --bg: #f5f6fa;
  --card: #ffffff;
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5;
  padding-bottom: 76px;
}
.hidden { display: none !important; }
h2 { font-size: 19px; margin: 14px 0 10px; }
h3 { font-size: 16px; margin-bottom: 8px; }
h4 { font-size: 14px; margin: 10px 0 6px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0; }
.error-text { color: var(--red); font-size: 13px; margin-top: 8px; min-height: 18px; }
.date-label { font-size: 13px; color: var(--muted); font-weight: 400; }
.badge {
  display: inline-block; background: var(--amber); color: #5d4a00; font-size: 11px;
  font-weight: 700; padding: 2px 8px; border-radius: 20px; vertical-align: middle;
}
.badge.ok { background: #55efc4; color: #00543f; }
.badge.warn { background: #ff7675; color: #fff; }

/* ===== Login ===== */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--red) 0%, #e17055 100%); padding: 16px;
}
.login-card {
  background: #fff; border-radius: 20px; padding: 28px 22px; width: 100%; max-width: 380px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25); text-align: center;
}
.login-logo { font-size: 54px; }
.login-card h1 { font-size: 26px; margin: 4px 0; }
.login-sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.role-picker { display: flex; gap: 8px; margin-bottom: 16px; }
.role-btn {
  flex: 1; padding: 10px; border: 2px solid var(--line); border-radius: 10px;
  background: #fff; font-size: 15px; cursor: pointer; font-weight: 600;
}
.role-btn.active { border-color: var(--red); background: #ffeaea; }
.field-label { display: block; text-align: left; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
#pinInput {
  width: 100%; font-size: 24px; text-align: center; letter-spacing: 10px;
  padding: 10px; border: 2px solid var(--line); border-radius: 10px; margin-bottom: 12px;
}
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pin-pad button {
  padding: 14px 0; font-size: 20px; border: 1px solid var(--line); border-radius: 10px;
  background: #f8f9fa; cursor: pointer;
}
.pin-pad button:active { background: var(--line); }
.login-hint { font-size: 12px; color: var(--muted); margin-top: 14px; }

/* ===== Header ===== */
.app-header {
  position: sticky; top: 0; z-index: 20; background: var(--red); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header-logo { font-size: 28px; }
.header-title { font-weight: 800; font-size: 17px; line-height: 1.1; }
.header-date { font-size: 12px; opacity: .9; }
.header-right { display: flex; align-items: center; gap: 8px; }
.header-user { font-size: 12px; font-weight: 600; background: rgba(255,255,255,.2); padding: 4px 8px; border-radius: 20px; }
#dayStatusBadge { background: rgba(255,255,255,.25); color: #fff; }

/* ===== Layout ===== */
main { max-width: 860px; margin: 0 auto; padding: 4px 12px 12px; }
.view { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.card {
  background: var(--card); border-radius: var(--radius); padding: 14px;
  margin-bottom: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat { padding: 14px; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 21px; font-weight: 800; margin: 2px 0; }
.stat-sub { font-size: 12px; color: var(--muted); }
.stat.highlight { background: #fff3e0; border: 1px solid #ffcc80; }
.diff-card { border: 2px solid var(--red); background: #fff5f5; }
.diff-title { font-weight: 700; color: var(--red); }
.diff-value { font-size: 24px; font-weight: 800; margin: 4px 0; }
.diff-sub { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.warning-card { border: 2px solid #fdcb6e; background: #fffdf0; }

/* ===== Forms ===== */
.form-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.form-row label { font-size: 13px; font-weight: 600; }
input, select, textarea {
  width: 100%; padding: 10px 12px; font-size: 15px; border: 1.5px solid var(--line);
  border-radius: 9px; background: #fff; font-family: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--red); }
input[type="number"] { font-variant-numeric: tabular-nums; }
.btn {
  padding: 10px 16px; border: none; border-radius: 9px; font-size: 15px; font-weight: 600;
  cursor: pointer; background: var(--line); color: var(--ink);
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:disabled { background: #fab1a0; cursor: not-allowed; }
.btn-secondary { background: var(--blue); color: #fff; }
.btn-warning { background: #fdcb6e; color: #5d4a00; }
.btn-danger { background: var(--red-dark); color: #fff; }
.btn-ghost { background: transparent; border: 1.5px solid var(--line); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 6px; }
.seg { display: flex; gap: 6px; }
.seg-btn {
  flex: 1; padding: 10px; border: 2px solid var(--line); border-radius: 9px;
  background: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
}
.seg-btn.active { border-color: var(--red); background: #ffeaea; }
.danger-zone { border: 2px dashed var(--red); }

/* ===== Tables & lists ===== */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.row-total td { font-weight: 800; border-top: 2px solid var(--ink); }
.kv-table td:first-child { color: var(--muted); }
.kv-table td:last-child { text-align: right; white-space: nowrap; }
.list-item {
  display: flex; justify-content: space-between; gap: 8px; padding: 10px 4px;
  border-bottom: 1px solid var(--line); font-size: 14px; align-items: flex-start;
}
.list-item:last-child { border-bottom: none; }
.list-item .li-main { flex: 1; }
.list-item .li-sub { font-size: 12px; color: var(--muted); }
.list-item .li-amt { font-weight: 700; white-space: nowrap; }
.tag {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px;
  border-radius: 12px; background: #dfe6e9; color: var(--ink);
}
.tag.tunai { background: #55efc4; color: #00543f; }
.tag.nontunai { background: #74b9ff; color: #003a66; }
.tag.void { background: #ff7675; color: #fff; }
.tag.low { background: #ff7675; color: #fff; }
.tag.ok { background: #55efc4; color: #00543f; }
.tag.pending { background: #fdcb6e; color: #5d4a00; }
.stock-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.stock-row:last-child { border-bottom: none; }
.stock-row input { width: 90px; text-align: right; padding: 6px; }
.activity-list .list-item { padding: 7px 2px; }

/* ===== Kasir ===== */
.product-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.product-btn {
  border: 2px solid var(--line); background: #fff; border-radius: 10px; padding: 12px 8px;
  text-align: left; cursor: pointer;
}
.product-btn:active { border-color: var(--red); background: #ffeaea; }
.product-btn .p-name { font-weight: 700; font-size: 14px; }
.product-btn .p-price { color: var(--red); font-weight: 700; font-size: 13px; }
.product-btn .p-recipe { font-size: 11px; color: var(--muted); }
.cart-box { border-top: 2px dashed var(--line); padding-top: 10px; }
.cart-line { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-size: 14px; }
.qty-ctl { display: flex; align-items: center; gap: 6px; }
.qty-ctl button {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
  background: #f8f9fa; font-size: 16px; font-weight: 700; cursor: pointer;
}
.cart-total { display: flex; justify-content: space-between; font-size: 17px; padding: 8px 0; border-top: 1px solid var(--line); margin-top: 6px; }
.denom-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.denom-grid .form-row { margin-bottom: 0; }
.diff-box {
  display: flex; justify-content: space-between; align-items: center;
  background: #f5f6fa; border-radius: 9px; padding: 10px 12px; margin: 10px 0; font-size: 14px;
}
.diff-box b { font-size: 18px; }
.diff-box b.neg { color: var(--red); }
.diff-box b.pos { color: var(--green-dark); }
.thumb { max-width: 100%; border-radius: 8px; margin-top: 6px; max-height: 180px; object-fit: contain; }

/* ===== Bottom nav ===== */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: #fff;
  display: flex; border-top: 1px solid var(--line); box-shadow: 0 -2px 10px rgba(0,0,0,.06);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1; background: none; border: none; padding: 8px 2px 6px; font-size: 19px;
  color: var(--muted); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.nav-btn span { font-size: 10px; font-weight: 600; }
.nav-btn.active { color: var(--red); }

/* ===== Subtabs ===== */
.subtabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 4px; }
.subtab-btn {
  flex-shrink: 0; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 20px;
  background: #fff; font-size: 13px; font-weight: 600; cursor: pointer;
}
.subtab-btn.active { border-color: var(--red); background: #ffeaea; color: var(--red); }

/* ===== Modal & toast ===== */
.modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-card {
  background: #fff; border-radius: 16px 16px 0 0; width: 100%; max-width: 560px;
  max-height: 88vh; overflow-y: auto; padding: 18px;
}
.modal-actions { display: flex; gap: 8px; margin-top: 14px; }
.modal-actions .btn { flex: 1; }
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 24px;
  font-size: 14px; box-shadow: 0 4px 16px rgba(0,0,0,.3); max-width: 90vw; text-align: center;
}

/* ===== Laporan ===== */
.report-table-wrap { overflow-x: auto; }
.report-title { font-size: 17px; font-weight: 800; margin-bottom: 2px; }
.report-sub { font-size: 13px; color: var(--muted); margin-bottom: 10px; }

@media (min-width: 700px) {
  .cards { grid-template-columns: repeat(4, 1fr); }
  .product-grid { grid-template-columns: repeat(3, 1fr); }
  .form-row { flex-direction: row; align-items: center; }
  .form-row label { width: 190px; flex-shrink: 0; }
  .form-row input, .form-row select { flex: 1; }
  .modal { align-items: center; }
  .modal-card { border-radius: 16px; }
}

/* ===== Print: hanya laporan ===== */
@media print {
  body { padding-bottom: 0; background: #fff; }
  .app-header, .bottom-nav, #loginScreen, .toast, .modal,
  #view-reports .card:first-child { display: none !important; }
  main { max-width: none; padding: 0; }
  .view { display: none !important; }
  #view-reports { display: block !important; }
  #view-reports .card { box-shadow: none; border: none; padding: 0; }
  .card { box-shadow: none; }
}
