/* SPA REVENUE BOOK — mobile-first, intentionally minimal (M1). */
:root {
  --teal: #0f766e;
  --teal-dark: #115e59;
  --teal-light: #ccfbf1;
  --ink: #0f172a;
  --muted: #64748b;
  --bg: #f1f5f9;
  --card: #ffffff;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --ok: #15803d;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .12);
  --tap: 48px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

#app { max-width: 640px; margin: 0 auto; min-height: 100dvh; padding-bottom: 72px; }

.hidden { display: none !important; }

/* ---------- login ---------- */
#view-login { display: flex; min-height: 100dvh; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 22px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-card h1 { margin: 0 0 4px; font-size: 1.35rem; color: var(--teal-dark); }
.login-sub { margin: 0 0 18px; color: var(--muted); font-size: .9rem; }
.field { display: block; text-align: left; margin: 10px 0 6px; font-weight: 600; font-size: .9rem; }
input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  font-size: 1.05rem;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  min-height: 48px;
}
.btn-primary {
  width: 100%;
  margin-top: 14px;
  padding: 13px;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--teal);
  border: none;
  border-radius: 10px;
  min-height: 48px;
  cursor: pointer;
}
.btn-primary:active { background: var(--teal-dark); }
.btn-primary:disabled { opacity: .6; }
.error { color: var(--danger); font-size: .9rem; margin: 10px 0 0; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}
.topbar-left { display: flex; align-items: center; gap: 6px; min-width: 0; }
.icon-btn {
  min-width: var(--tap);
  min-height: var(--tap);
  font-size: 1.6rem;
  line-height: 1;
  border: none;
  background: transparent;
  color: var(--teal-dark);
  border-radius: 10px;
  cursor: pointer;
}
.icon-btn:active { background: var(--teal-light); }
.date-label {
  min-height: var(--tap);
  padding: 0 10px;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  background: transparent;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.mult-btn {
  min-width: 56px;
  min-height: 44px;
  border: 1px solid #cbd5e1;
  background: var(--card);
  border-radius: 10px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--teal-dark);
  cursor: pointer;
}
.mult-btn:active { background: var(--teal-light); }

/* ---------- totals ---------- */
.total-card {
  margin: 4px 12px 12px;
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  color: #fff;
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: var(--shadow);
}
.total-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; opacity: .85; }
.total-value { font-size: 1.9rem; font-weight: 800; line-height: 1.1; }
.total-count { font-size: .85rem; opacity: .9; }

/* ---------- services (fast entry) ---------- */
.services {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 12px 14px;
}
.service-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  min-height: 104px;
  padding: 14px;
  background: var(--card);
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.service-btn:active { transform: scale(.97); border-color: var(--teal); }
.service-name { font-weight: 700; font-size: .98rem; line-height: 1.25; }
.service-price { font-size: 1.05rem; font-weight: 800; color: var(--teal-dark); }
.service-hint { font-size: .72rem; color: var(--muted); }

/* ---------- day entries ---------- */
.section-title { font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 6px 14px; }
.entries { padding: 0 12px; display: flex; flex-direction: column; gap: 8px; }
.entry-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
}
.entry-time { color: var(--muted); font-size: .8rem; min-width: 44px; }
.entry-main { flex: 1; min-width: 0; }
.entry-name { font-weight: 600; font-size: .95rem; }
.entry-price { font-size: .95rem; font-weight: 700; color: var(--teal-dark); }
.entry-delete {
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.3rem;
  border-radius: 10px;
  cursor: pointer;
}
.entry-delete:active { background: var(--danger-bg); color: var(--danger); }
.entry-delete.armed { background: var(--danger); color: #fff; font-size: .8rem; }

/* ---------- month view ---------- */
.status-bar { margin: 0 12px 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.badge {
  padding: 5px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: .8rem;
}
.badge-open { background: var(--teal-light); color: var(--teal-dark); }
.badge-closed { background: #fef3c7; color: #92400e; }
.month-btn {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid #cbd5e1;
  background: var(--card);
  border-radius: 10px;
  font-weight: 700;
  color: var(--teal-dark);
  cursor: pointer;
}
.month-btn.danger { color: var(--danger); border-color: #fecaca; }
.month-btn:active { background: var(--teal-light); }
.reason-box { width: 100%; }
.reason-box textarea {
  width: 100%;
  min-height: 64px;
  padding: 10px;
  font-size: 1rem;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-family: inherit;
}
.reason-actions { display: flex; gap: 8px; margin-top: 8px; }
.reason-actions button { flex: 1; min-height: 44px; border-radius: 10px; font-weight: 700; cursor: pointer; }
.reason-ok { background: var(--teal); color: #fff; border: none; }
.reason-cancel { background: var(--card); color: var(--muted); border: 1px solid #cbd5e1; }

.month-entries { padding: 0 12px; display: flex; flex-direction: column; gap: 14px; }
.day-group { background: var(--card); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.day-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 12px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 700;
  font-size: .9rem;
}
.day-group-total { color: var(--teal-dark); }
.day-group-rows { display: flex; flex-direction: column; }
.day-group-rows .entry-row { border-radius: 0; box-shadow: none; border-bottom: 1px solid #f1f5f9; }
.day-group-rows .entry-row:last-child { border-bottom: none; }

/* ---------- month actions (M2: report + exports) ---------- */
.month-actions {
  margin: 0 12px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- historical fast-entry (M2) ---------- */
.date-input {
  flex: 1;
  min-width: 0;
  min-height: var(--tap);
  padding: 0 10px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid #cbd5e1;
  border-radius: 10px;
}
.histo-card {
  margin: 4px 12px 12px;
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  color: #fff;
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.histo-stats {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.histo-count { font-size: .95rem; opacity: .95; }
.histo-total { font-size: 1.6rem; font-weight: 800; line-height: 1.15; }
.histo-confirm { width: 100%; margin-top: 12px; }
.histo-confirm:disabled { opacity: .55; }
.histo-success {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,.16);
  font-size: .92rem;
  font-weight: 600;
  line-height: 1.4;
}
.histo-rows {
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.histo-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--card);
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.histo-info { flex: 1; min-width: 0; }
.histo-name { font-weight: 700; font-size: .95rem; line-height: 1.25; }
.histo-price { font-size: .9rem; font-weight: 800; color: var(--teal-dark); margin-top: 2px; }
.histo-stepper { display: flex; align-items: center; gap: 4px; }
.stepper-btn {
  width: 44px;
  height: 44px;
  border: 1px solid #cbd5e1;
  background: var(--card);
  border-radius: 10px;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--teal-dark);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.stepper-btn:active { background: var(--teal-light); }
.stepper-qty {
  min-width: 44px;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ---------- tabs ---------- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid #e2e8f0;
  max-width: 640px;
  margin: 0 auto;
  z-index: 10;
}
.tab {
  flex: 1;
  min-height: 60px;
  border: none;
  background: transparent;
  font-size: .95rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.tab.active { color: var(--teal-dark); border-top: 3px solid var(--teal); background: #f8fafc; }
.tab-logout { color: var(--danger); }

/* ---------- misc ---------- */
.empty { text-align: center; color: var(--muted); padding: 24px 12px; font-size: .95rem; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: .92rem;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }

/* ---------- desktop ---------- */
@media (min-width: 720px) {
  .services { grid-template-columns: repeat(4, 1fr); }
  .service-btn { min-height: 120px; }
}
