/* Carpet Land Branch PWA — mobile-first. Palette taken from the web
   dashboard's design tokens (warm parchment ground, bronze-gold accent, dark
   "display case" hero banner) so all three surfaces share one visual language. */
:root {
  --paper: #f7f1e4;
  --surface: #ffffff;
  --surface-2: #fbf6e9;
  --hairline: #e4d9bf;
  --accent: #9c7a3c;
  --accent-bright: #b4903f;
  --ink: #2a2318;
  --muted: #7a6e5c;
  --emerald: #3f8a5c;
  --garnet: #a23b36;
  --amber: #b8792c;
  --banner-surface: #34291a;
  --banner-surface-2: #241c13;
  --banner-text: #f3ead6;
  --banner-text-muted: #b8a98a;
  --banner-accent-text: #e8ce93;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0b1220;
    --surface: #141c30;
    --surface-2: #101828;
    --hairline: #232d45;
    --accent: #22d3ee;
    --accent-bright: #67e8f9;
    --ink: #f1f5f9;
    --muted: #8b93a7;
    --emerald: #34d399;
    --garnet: #f87171;
    --amber: #fbbf24;
    --banner-surface: #141c30;
    --banner-surface-2: #101828;
    --banner-text: #f1f5f9;
    --banner-text-muted: #8b93a7;
    --banner-accent-text: #67e8f9;
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Cairo", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
}
button {
  font-family: inherit;
  cursor: pointer;
}

/* ---- Setup + PIN cards ---- */
#screen-setup,
#screen-pin {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.setup-card,
.pin-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 18px;
  padding: 24px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}
.setup-title {
  font-size: 22px;
  margin: 0 0 4px;
  color: var(--accent);
}
.setup-sub {
  color: var(--muted);
  margin: 0 0 18px;
  font-size: 14px;
}
.field {
  display: block;
  margin-bottom: 14px;
}
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--muted);
}
.field-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--hairline);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 16px;
}
.field-input:focus {
  outline: none;
  border-color: var(--accent);
}
textarea.field-input {
  min-height: 84px;
  resize: vertical;
}
.form-error {
  color: var(--garnet);
  font-size: 14px;
  min-height: 18px;
  margin: 4px 0;
}
.btn-primary {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  margin-top: 6px;
}
.btn-primary:active {
  background: var(--accent-bright);
}
.btn-outline {
  padding: 14px;
  border: 1.5px solid var(--hairline);
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}
.btn-outline.danger {
  border-color: var(--garnet);
  color: var(--garnet);
}
.btn-link {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--accent);
  margin-top: 12px;
  font-size: 14px;
  font-weight: 600;
}
.pin-input {
  text-align: center;
  letter-spacing: 8px;
  font-size: 26px;
}

/* ---- App shell ---- */
#screen-app {
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: 40px;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-top));
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
}
.branch-title {
  font-weight: 800;
  font-size: 17px;
}
.clock {
  font-size: 11px;
  color: var(--muted);
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.icon-btn {
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 16px;
}
.sync-badge {
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
}
.sync-ok {
  background: #e6f7e1;
  color: #2e7d32;
}
.sync-pending {
  background: #fdf1dc;
  color: var(--amber);
}
.sync-off {
  background: #f0f1f3;
  color: var(--muted);
}

/* ---- Hero banner (the "display case") ---- */
.hero {
  margin: 16px;
  padding: 18px;
  border-radius: 16px;
  background: linear-gradient(160deg, var(--banner-surface), var(--banner-surface-2));
  color: var(--banner-text);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 8px;
}
.hero-stat {
  min-width: 0;
}
.hero-label {
  font-size: 11px;
  color: var(--banner-text-muted);
  line-height: 1.3;
}
.hero-value {
  font-size: 17px;
  font-weight: 800;
  color: var(--banner-accent-text);
  margin-top: 2px;
}
.wa-btn {
  grid-column: 1 / -1;
  margin-top: 6px;
  padding: 11px;
  border: 1px solid var(--banner-hairline, #4a3b26);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--banner-text);
  font-weight: 700;
}

/* ---- Cards ---- */
.cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 0 16px;
}
@media (min-width: 560px) {
  .cards-grid {
    grid-template-columns: 1fr 1fr;
  }
}
.empty-hint {
  color: var(--muted);
  text-align: center;
  padding: 30px 10px;
}
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card-next {
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 3px rgba(156, 122, 60, 0.12);
}
.card-hold {
  opacity: 0.5;
}
.ribbon {
  align-self: flex-start;
  background: linear-gradient(180deg, #e4c077, #a6813f);
  color: #4a3a12;
  font-weight: 800;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 8px;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-name {
  font-weight: 800;
  font-size: 17px;
  flex: 1;
  min-width: 0;
}
.conv-pill {
  font-size: 11px;
  font-weight: 800;
  border-radius: 9px;
  padding: 2px 8px;
}
.conv-good {
  background: #e6f7e1;
  color: #2e7d32;
}
.conv-bad {
  background: #fce8ea;
  color: #b0263a;
}
.conv-mid {
  background: #f0f1f3;
  color: #65676b;
}
.rank-badge {
  font-size: 12px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 10px;
  color: #9c9280;
}
.rank-1 {
  background: linear-gradient(160deg, #fce9b8, #a6813f);
  color: #4a3a12;
}
.rank-2 {
  background: linear-gradient(160deg, #f7f7f7, #94969a);
  color: #333;
}
.rank-3 {
  background: linear-gradient(160deg, #efc49b, #8a4a15);
  color: #432a16;
}
.card-status {
  font-weight: 700;
  font-size: 14px;
}
.card-timer {
  font-size: 12px;
  color: var(--muted);
  min-height: 14px;
}
.metrics {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 4px 0;
}
.metric {
  display: flex;
  gap: 8px;
  font-size: 13px;
}
.metric-label {
  color: var(--muted);
}
.metric-value {
  font-weight: 700;
}
.action-btn {
  margin-top: 6px;
  padding: 15px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
}
.action-idle {
  background: var(--emerald);
}
.action-busy {
  background: var(--garnet);
}
.action-btn:disabled {
  opacity: 0.4;
}
.card-bottom {
  display: flex;
  gap: 8px;
}
.hold-btn,
.skip-btn {
  flex: 1;
  padding: 10px;
  border: 1.5px solid var(--hairline);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 700;
  font-size: 13px;
}

/* ---- Modals ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 50;
}
.modal {
  background: var(--surface);
  border-radius: 18px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-wide {
  max-width: 520px;
}
.modal-title {
  margin: 0 0 12px;
  font-size: 19px;
}
.modal-hint {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 10px;
}
.amount-input {
  text-align: center;
  font-size: 26px;
  font-weight: 700;
}
.dp-check {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 14px 0;
  font-size: 15px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.modal-actions > * {
  flex: 1;
}
.rota-list {
  margin: 8px 0;
}
.rota-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--hairline);
}
.rota-name {
  font-weight: 700;
}
.rota-controls {
  display: flex;
  gap: 6px;
}
.mini-btn {
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 14px;
}
.mini-btn.danger {
  color: var(--garnet);
  border-color: var(--garnet);
}
.mini-btn:disabled {
  opacity: 0.35;
}
.rota-add {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0;
}
.version-line {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin: 14px 0 0;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--paper);
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  max-width: 90vw;
  white-space: pre-line;
  opacity: 0;
  transition: all 0.3s;
  z-index: 100;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
