:root {
  --cream: #faf7f0;
  --cream-deep: #f2eee2;
  --forest: #2c4034;
  --gold: #c9860f;
  --gold-dark: #a86e0a;
  --sour: #7a9a4a;
  --sour-light: #eef3e3;
  --red: #b5402f;
  --red-light: #fbe8e4;
  --border: #e6ddc8;
  --gray: #837a69;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Noto Sans Thai', sans-serif;
  background: var(--cream);
  color: var(--forest);
  -webkit-tap-highlight-color: transparent;
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Topbar ---------- */
.topbar {
  background: var(--forest);
  color: white;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 1.05rem; margin: 0; font-weight: 700; }
.topbar .back-btn {
  background: none; border: none; color: white; font-size: 1.3rem;
  padding: 4px 10px; cursor: pointer; border-radius: 8px; min-width: 40px;
}
.topbar .back-btn:active { background: rgba(255,255,255,0.15); }

.container { padding: 18px 16px 32px; max-width: 560px; margin: 0 auto; width: 100%; flex: 1; }

/* ---------- Cards ---------- */
.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 14px;
}

/* ---------- Buttons ---------- */
.btn {
  display: block;
  width: 100%;
  padding: 15px;
  font-size: 1.05rem;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
  margin-bottom: 10px;
  min-height: 52px;
}
.btn:active { opacity: 0.85; }
.btn-primary { background: var(--gold); color: white; }
.btn-primary:active { background: var(--gold-dark); }
.btn-primary:disabled { background: #ddd0b3; cursor: not-allowed; }
.btn-secondary { background: var(--sour-light); color: var(--forest); border: 1px solid var(--sour); }
.btn-danger { background: var(--red-light); color: var(--red); border: 1px solid var(--red); }
.btn-outline { background: transparent; color: var(--forest); border: 1px solid var(--forest); }
.btn-sm { padding: 12px; font-size: 0.95rem; min-height: 46px; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.98rem; color: var(--forest); }

input, select {
  width: 100%;
  padding: 13px 14px;
  font-size: 1.05rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 16px;
  font-family: inherit;
  background: var(--cream-deep);
  color: var(--forest);
}
input:focus, select:focus { outline: none; border-color: var(--gold); background: white; }

/* ---------- Login ---------- */
.login-hero {
  text-align: center;
  padding: 30px 10px 4px;
}
.login-hero .fruit-icon { font-size: 2.2rem; display: block; margin-bottom: 6px; }
.login-hero h2 { font-size: 1.2rem; margin: 0 0 2px; color: var(--forest); }
.login-hero p { color: var(--gray); margin: 0; font-size: 0.88rem; }

/* ---------- Branch grid ---------- */
.branch-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.branch-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 10px;
  text-align: center;
  cursor: pointer;
}
.branch-card:active { border-color: var(--gold); background: #fdf8ef; }
.branch-card .b-icon { font-size: 1.3rem; display: block; margin-bottom: 4px; }
.branch-card .b-name { font-size: 1rem; font-weight: 700; color: var(--forest); }

/* ---------- Item rows (bill form) ---------- */
.item-row {
  display: grid;
  grid-template-columns: 2fr 1fr 32px;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}
.item-row select { margin-bottom: 0; }
.item-row input { margin-bottom: 0; text-align: center; }
.remove-btn {
  background: none; border: none; color: var(--red); font-size: 1.3rem; cursor: pointer;
  height: 44px; width: 32px;
}

/* ---------- Totals ---------- */
.total-box {
  background: var(--forest); color: white; border-radius: 10px;
  padding: 14px; text-align: center; font-size: 1.25rem; font-weight: 800;
  margin: 14px 0;
}

/* ---------- Bill list ---------- */
.bill-list-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 4px; border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.bill-list-item:active { background: var(--cream-deep); }
.bill-list-item .meta { font-size: 0.85rem; color: var(--gray); margin-top: 2px; }
.bill-list-item .amount { font-weight: 700; font-size: 1.05rem; color: var(--forest); }

/* ---------- Status banners ---------- */
.status-banner {
  padding: 13px; border-radius: 10px; margin-bottom: 12px; font-weight: 600; text-align: center; font-size: 0.95rem;
}
.status-success { background: var(--sour-light); color: var(--forest); }
.status-error { background: var(--red-light); color: var(--red); }
.status-warning { background: #fbf3e2; color: var(--gold-dark); }

.filter-row { display: flex; gap: 8px; }
.filter-row > * { flex: 1; }

.center-text { text-align: center; }
.mt-16 { margin-top: 14px; }
.small-gray { color: var(--gray); font-size: 0.88rem; }

.spinner {
  border: 3px solid var(--border); border-top: 3px solid var(--gold);
  border-radius: 50%; width: 32px; height: 32px; animation: spin 0.8s linear infinite; margin: 28px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

table.detail-table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 0.9rem; }
table.detail-table th, table.detail-table td { border: 1px solid var(--border); padding: 7px 6px; }
table.detail-table th { background: var(--cream-deep); color: var(--forest); font-weight: 700; }
