/* Kas Cafe — stylesheet (vanilla CSS) */
:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --line: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --danger: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }

/* ---- topbar ---- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  background: var(--primary-dark); color: #fff;
  padding: 0 20px; height: 56px;
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 17px; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a {
  color: #d1fae5; padding: 8px 14px; border-radius: 8px; font-weight: 500;
}
.topbar nav a:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.topbar nav a.on { background: rgba(255, 255, 255, .18); color: #fff; }
.userbox { display: flex; align-items: center; gap: 10px; }
.username { color: #d1fae5; font-size: 14px; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; }

/* ---- cards ---- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat .stat-label { color: var(--muted); font-size: 13px; }
.stat .stat-value { font-size: 26px; font-weight: 700; margin: 6px 0 2px; color: var(--primary-dark); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---- bar chart (per kategori) ---- */
.bar-row { margin-bottom: 14px; }
.bar-head { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 4px; }
.bar-val { font-weight: 600; }
.bar-track { background: var(--bg); border-radius: 99px; height: 10px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; transition: width .4s; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }

/* ---- chart harian ---- */
.chart { display: flex; align-items: flex-end; gap: 3px; height: 170px; padding-top: 8px; }
.chart-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; min-width: 0; }
.chart-bar { background: var(--primary); border-radius: 3px 3px 0 0; }
.chart-x { font-size: 10px; color: var(--muted); text-align: center; height: 16px; }

/* ---- table ---- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: 12.5px;
  text-transform: uppercase; letter-spacing: .03em;
  border-bottom: 2px solid var(--line); padding: 8px 10px;
}
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:hover td { background: #f8fafc; }
.table .num { text-align: right; }
.amount { font-weight: 600; white-space: nowrap; }
.note { max-width: 340px; word-break: break-word; }
.row-actions { white-space: nowrap; text-align: right; }

/* Wrapper agar tabel lebar bisa digeser horizontal di layar kecil. */
.table-wrap {
  width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.table-wrap::-webkit-scrollbar { height: 8px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }
.table-wrap::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
.table-wrap::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.badge {
  display: inline-block; font-size: 12px; font-weight: 600;
  padding: 2px 8px; border-radius: 99px; border: 1px solid transparent;
}
.badge-wa { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.badge-manual { background: #e0f2fe; color: #075985; border-color: #bae6fd; }
.badge-ok { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.badge-off { background: #f1f5f9; color: var(--muted); border-color: var(--line); }

/* ---- buttons ---- */
.btn {
  display: inline-block; border: 1px solid transparent; cursor: pointer;
  border-radius: 8px; padding: 8px 14px; font-size: 14px; font-weight: 600;
  background: #e2e8f0; color: var(--text); text-align: center;
}
.btn:hover { filter: brightness(.96); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); filter: none; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-danger { background: #fee2e2; color: var(--danger); border-color: #fecaca; }
.btn-mini { padding: 3px 8px; font-size: 13px; border-radius: 6px; background: #f1f5f9; }
.btn-block { width: 100%; }

/* ---- forms ---- */
label { display: block; font-size: 13.5px; font-weight: 600; color: #334155; }
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=month], input[type=color], select {
  width: 100%; margin-top: 4px; padding: 9px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus { outline: 2px solid #99f6e4; border-color: var(--primary); }
label.check { display: flex; align-items: center; gap: 8px; margin-top: 22px; }
label.check input { width: auto; margin: 0; }

.filters {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  padding-bottom: 14px; margin-bottom: 6px; border-bottom: 1px dashed var(--line);
}
.filters label { min-width: 150px; }
.filter-btns { display: flex; gap: 8px; }
.summary { margin: 10px 0 6px; font-size: 14px; }
.inline-form { display: inline-block; }
.inline-form input { margin: 0; min-width: 170px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .span2 { grid-column: span 2; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span2 { grid-column: auto; } }

/* ---- modal ---- */
.modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 60px 16px; z-index: 50; overflow: auto;
}
.modal[hidden] { display: none; }
.modal-box {
  background: #fff; border-radius: 12px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
  width: 100%; max-width: 540px; padding: 22px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---- toast ---- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 11px 18px; border-radius: 10px;
  font-size: 14px; z-index: 99; box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
  max-width: 90vw;
}
.toast.err { background: var(--danger); }
.toast[hidden] { display: none; }

.alert {
  background: #fee2e2; color: #991b1b; border: 1px solid #fecaca;
  padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 12px;
}

/* ---- login ---- */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.login-card {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 10px 40px rgba(15, 23, 42, .12);
  padding: 34px 30px; width: 100%; max-width: 380px;
}
.login-brand { font-size: 24px; font-weight: 800; color: var(--primary-dark); text-align: center; }
.login-card p.muted { text-align: center; margin-top: 4px; }
.login-card label { margin-top: 16px; }
.login-card .btn { margin-top: 22px; }

/* ================= Mobile view ================= */
@media (max-width: 700px) {
  body { -webkit-text-size-adjust: 100%; }

  /* topbar: baris 1 = brand + user, baris 2 = menu yang bisa digeser */
  .topbar {
    flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px 12px;
  }
  .topbar .brand { font-size: 16px; }
  .topbar nav {
    order: 3; flex: 1 1 100%; width: 100%;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    gap: 2px; padding-bottom: 2px;
  }
  .topbar nav a { padding: 7px 12px; white-space: nowrap; }
  .topbar nav::-webkit-scrollbar { display: none; }
  .userbox { margin-left: auto; gap: 8px; }
  .username {
    max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .userbox .btn { padding: 6px 12px; }

  .wrap { padding: 16px 12px 48px; }
  h1 { font-size: 20px; }

  /* kartu & grid */
  .card { padding: 14px; border-radius: 8px; margin-bottom: 14px; }
  .cards { grid-template-columns: 1fr; gap: 10px; }
  .stat .stat-value { font-size: 22px; }
  .card-head { flex-wrap: wrap; gap: 8px; }

  /* judul halaman + tombol aksi menumpuk penuh */
  .page-head { flex-direction: column; align-items: stretch; gap: 10px; margin-bottom: 14px; }
  .page-head .actions { flex-wrap: wrap; }
  .page-head .actions .btn { flex: 1 1 0; }
  .inline-form { width: 100%; }
  .inline-form input { min-width: 0; width: 100%; }

  /* filter menumpuk satu kolom */
  .filters { gap: 10px; }
  .filters label { flex: 1 1 100%; min-width: 0; }
  .filter-btns { flex: 1 1 100%; }
  .filter-btns .btn { flex: 1; }
  .summary { margin-top: 12px; }

  /* chart harian */
  .chart { gap: 2px; height: 140px; }
  .chart-x { font-size: 9px; height: 14px; }

  /* tabel */
  .table { font-size: 13px; }
  .table th, .table td { padding: 8px; }
  .note { max-width: 200px; }

  /* font 16px mencegah iOS auto-zoom saat fokus input */
  input[type=text], input[type=password], input[type=number], input[type=date],
  input[type=month], input[type=color], select { font-size: 16px; }

  /* modal */
  .modal { padding: 24px 12px; }
  .modal-box { padding: 18px; }
  .modal-actions .btn { flex: 1; }

  /* login */
  .login-page { padding: 16px; }
  .login-card { padding: 26px 20px; }
}

@media (max-width: 420px) {
  .topbar .brand { font-size: 15px; }
  .table th, .table td { padding: 7px 6px; }
  .note { max-width: 150px; }
  .btn { padding: 8px 12px; }
}


/* Laporan harian: kotak teks siap kirim WhatsApp */
.report-text {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .86rem;
  line-height: 1.5;
  padding: .75rem;
  border: 1px solid #cbd5e1;
  border-radius: .5rem;
  background: #f8fafc;
  color: #0f172a;
  resize: vertical;
  white-space: pre;
  box-sizing: border-box;
}
