/* Sriracha Court — design tokens + components, adapted from the Claude "Modernist"
   design export (see ../README.md). Sharp corners, thick hairline borders —
   that structural language stays; palette below is the warm/teal revision
   picked from the font+color comparison, replacing the original cool-grey/red.
   --color-accent is the BRAND color (buttons, links, active states).
   --color-alert is a SEPARATE, deliberately-not-brand color reserved for
   overdue bills / validation errors, so urgency never blends into branding. */

@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@400;600;800&family=Noto+Sans+Thai:wght@400;600;700&display=swap');

:root {
  --color-bg: #ffffff;
  --color-surface: #f1e9da;
  --color-text: #26211c;
  --color-accent: #1f8a9e;
  --color-divider: rgba(38, 33, 28, 0.35);

  --color-neutral-100: #f5efe4;
  --color-neutral-200: #ebe2d0;
  --color-neutral-300: #d9cdb8;
  --color-neutral-400: #bfb096;
  --color-neutral-500: #a3927a;
  --color-neutral-600: #857763;
  --color-neutral-700: #665c4c;
  --color-neutral-800: #453e33;
  --color-neutral-900: #2c2820;

  --color-accent-100: #e3f3f5;
  --color-accent-800: #0f4a54;

  --color-alert: #d9502c;
  --color-alert-100: #fbe8de;
  --color-alert-800: #7a2c15;

  --font-heading: "Archivo", "Noto Sans Thai", system-ui, sans-serif;
  --font-body: "Archivo", "Noto Sans Thai", system-ui, sans-serif;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;

  --shadow-lg: 0 12px 32px rgba(44, 40, 32, 0.22);
}

* , *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; background: var(--color-bg); color: var(--color-text); font-family: var(--font-body); }
body { font-size: 15px; line-height: 1.5; }
h1, h2, h3, h4, h5, h6 { font-family: var(--font-heading); font-weight: 800; margin: 0; letter-spacing: -0.01em; }
button { font-family: inherit; }
input, textarea, select { font-family: inherit; }
img { display: block; max-width: 100%; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

/* — buttons — */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; text-decoration: none; border: 1px solid transparent;
  font-family: var(--font-heading); font-weight: 800; font-size: 14px; line-height: 1.2;
  color: var(--color-text); background: transparent; padding: var(--space-2) 14px;
  border-radius: 0;
}
.btn svg { display: block; flex: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--color-accent); color: #fff; }
.btn-primary:hover { background: #197483; }
.btn-primary:active { background: #145c68; }
.btn-secondary { border-color: var(--color-divider); }
.btn-secondary:hover { background: rgba(38, 33, 28, 0.07); }
.btn-secondary:active { background: rgba(38, 33, 28, 0.14); }
.btn-ghost { color: var(--color-accent); padding-inline: 4px; }
.btn-ghost:hover { background: rgba(31, 138, 158, 0.1); }
.btn-icon { width: 36px; height: 36px; padding: 0; flex: none; }
.btn-block { width: 100%; justify-content: center; text-align: center; }

/* — forms — */
.field { display: block; }
.field > label {
  display: block; font-size: 12px; margin-bottom: 5px; color: rgba(38, 33, 28, 0.7);
}
.input {
  width: 100%; min-height: 40px; padding: 8px 10px; font: inherit; font-size: 14px;
  color: var(--color-text); caret-color: var(--color-accent); background: var(--color-surface);
  border: 1px solid var(--color-divider); border-radius: 0;
}
.input:hover { border-color: rgba(38, 33, 28, 0.45); }
.input:focus-visible { border-color: var(--color-accent); }
.input:disabled { opacity: 0.65; }
textarea.input { min-height: 80px; resize: vertical; }

/* — tags — */
.tag {
  display: inline-flex; align-items: center; font-size: 11px; letter-spacing: 0.02em;
  padding: 3px 10px; border-radius: 0;
}
.tag-accent { background: var(--color-accent-100); color: var(--color-accent-800); }
.tag-neutral { background: var(--color-neutral-100); color: var(--color-neutral-800); }
.tag-outline { border: 1px solid var(--color-alert); color: var(--color-alert); }

/* — table — */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: rgba(38, 33, 28, 0.6); padding: var(--space-2); border-bottom: 2px solid var(--color-divider);
}
.table td { padding: var(--space-2); border-bottom: 1px solid var(--color-divider); }

/* — app shell — */
.app-shell {
  max-width: 460px; margin: 0 auto; min-height: 100vh; background: var(--color-bg);
  display: flex; flex-direction: column;
}
@media (min-width: 700px) {
  .app-shell {
    margin: 24px auto; min-height: calc(100vh - 48px); max-height: 900px;
    border: 2px solid var(--color-text); box-shadow: var(--shadow-lg);
  }
}

.header {
  flex: none; display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border-bottom: 2px solid var(--color-divider);
}
.header-kicker { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--color-accent); font-weight: 800; }
.header-title { font-size: 22px; line-height: 1.1; letter-spacing: -0.02em; }
.header-title.brand { font-family: var(--font-heading); font-weight: 800; color: var(--color-accent); font-size: 30px; }
.header-bell { position: relative; }
.header-bell .badge {
  position: absolute; top: -2px; right: -2px; min-width: 16px; height: 16px; padding: 0 3px;
  background: var(--color-alert); color: #fff; font-weight: 800; font-size: 10px; line-height: 16px; text-align: center;
}

.scroll-body { flex: 1; overflow-y: auto; overflow-x: hidden; }

.connection-banner {
  flex: none; padding: 8px 18px; font-size: 12px; background: var(--color-neutral-200); color: var(--color-neutral-700);
}
.connection-banner.offline { background: var(--color-alert-100); color: var(--color-alert-800); }

.bottom-nav {
  flex: none; display: grid; grid-template-columns: repeat(6, 1fr);
  border-top: 2px solid var(--color-text); background: var(--color-bg);
}
.bottom-nav button {
  cursor: pointer; background: none; border: 0; padding: 9px 0 14px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.bottom-nav .label { font-size: 10px; font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--color-text); color: var(--color-bg); padding: 12px 16px;
  display: flex; align-items: center; gap: 10px; max-width: 90%;
  box-shadow: var(--shadow-lg); z-index: 50; animation: toastIn 0.22s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }
.toast .title { font-weight: 700; font-size: 12px; }
.toast .sub { opacity: 0.75; font-size: 12px; }

.connection-loading, .connection-error {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 60vh; padding: 24px; text-align: center; gap: 6px;
}

/* — screen building blocks — */
.stat-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px; background: var(--color-divider);
  border: 2px solid var(--color-text); margin-bottom: 14px;
}
.stat-cell { background: var(--color-bg); padding: 14px 14px 12px; }
.stat-cell .value { font-family: var(--font-heading); font-weight: 800; font-size: 30px; line-height: 1; letter-spacing: -0.02em; }
.stat-cell .label { font-size: 12px; color: var(--color-neutral-700); margin-top: 4px; }

.section-title { font-weight: 800; font-size: 15px; margin: 6px 0 10px; letter-spacing: 0.02em; }
.section-row { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 0 10px; }
.section-meta { font-size: 12px; color: var(--color-neutral-600); }

.alert-banner {
  border-left: 4px solid var(--color-alert); background: var(--color-alert-100);
  padding: 11px 12px; margin-bottom: 14px;
}
.alert-banner .title { font-weight: 700; font-size: 13px; color: var(--color-alert-800); }

.room-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.room-tile {
  text-align: left; cursor: pointer; border: 2px solid var(--color-accent);
  padding: 9px 9px 8px; display: flex; flex-direction: column; gap: 6px;
  background: var(--color-accent-100); color: var(--color-accent-800);
}
.room-tile.vacant { border-color: var(--color-alert); background: var(--color-alert-100); color: var(--color-alert-800); }
.room-tile .top { display: flex; align-items: center; justify-content: space-between; }
.room-tile .num { font-weight: 800; font-size: 17px; }
.room-tile .dot { width: 9px; height: 9px; flex: none; }
.room-tile .sub { font-size: 10px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.list { display: flex; flex-direction: column; gap: 2px; background: var(--color-divider); border: 2px solid var(--color-text); }
.list-row {
  text-align: left; cursor: pointer; background: var(--color-bg); border: 0; border-left: 4px solid transparent;
  padding: 12px; display: flex; align-items: center; gap: 12px; width: 100%;
}
.list-row .num { font-weight: 800; font-size: 20px; width: 44px; flex: none; }
.list-row .main { flex: 1; min-width: 0; }
.list-row .name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .sub { font-size: 11px; color: var(--color-neutral-600); margin-top: 1px; }
.list-row .right { text-align: right; flex: none; }
.list-row .amt { font-weight: 800; font-size: 15px; }

/* — room rows (RoomsList tab) — occupied/vacant blue-red scheme, matching
   .room-tile on the dashboard. */
.room-row-list { display: flex; flex-direction: column; gap: 8px; }
.room-row {
  text-align: left; cursor: pointer; width: 100%;
  border: 2px solid var(--color-accent); background: var(--color-accent-100); color: var(--color-accent-800);
  padding: 12px; display: flex; align-items: center; gap: 12px;
}
.room-row.vacant { border-color: var(--color-alert); background: var(--color-alert-100); color: var(--color-alert-800); }
.room-row .num { font-weight: 800; font-size: 20px; width: 44px; flex: none; }
.room-row .main { flex: 1; min-width: 0; }
.room-row .name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-row .sub { font-size: 11px; opacity: 0.75; margin-top: 1px; }
.room-row .right { text-align: right; flex: none; }
.room-row .amt { font-weight: 800; font-size: 15px; }
.room-row .status { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700; }
.list-row .status { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700; }

/* — bill rows (บิล tab) — same bordered-card language: paid=blue (settled),
   unpaid=red (needs attention), pending=neutral (not billed yet this month). */
.bill-row-list { display: flex; flex-direction: column; gap: 8px; }
.bill-row {
  text-align: left; cursor: pointer; width: 100%;
  border: 2px solid var(--color-accent); background: var(--color-accent-100); color: var(--color-accent-800);
  padding: 12px; display: flex; align-items: center; gap: 12px;
}
.bill-row.unpaid { border-color: var(--color-alert); background: var(--color-alert-100); color: var(--color-alert-800); }
.bill-row.pending { border-color: var(--color-neutral-400); background: var(--color-neutral-100); color: var(--color-neutral-700); }
.bill-row .num { font-weight: 800; font-size: 18px; width: 40px; flex: none; }
.bill-row .main { flex: 1; min-width: 0; }
.bill-row .name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bill-row .sub { font-size: 11px; opacity: 0.75; margin-top: 1px; }
.bill-row .right { text-align: right; flex: none; }
.bill-row .amt { font-weight: 800; font-size: 15px; }

.legend { display: flex; gap: 14px; margin-bottom: 14px; font-size: 12px; color: var(--color-neutral-700); flex-wrap: wrap; }
.legend .item { display: inline-flex; align-items: center; gap: 6px; }
.legend .dot { width: 9px; height: 9px; }

.card-outline { border: 2px solid var(--color-text); padding: 14px; }

.avatar {
  flex: none; background: var(--color-neutral-800); color: var(--color-bg);
  display: grid; place-items: center; font-family: var(--font-heading); font-weight: 800;
}

.kv-list .kv-row {
  display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px;
  border-bottom: 1px solid var(--color-divider); font-size: 13px;
}
.kv-list .kv-row:last-child { border-bottom: 0; }
.kv-list .kv-row .k { color: var(--color-neutral-600); }
.kv-list .kv-row .v { font-weight: 600; text-align: right; }

.dashed-empty {
  border: 2px dashed var(--color-neutral-400); padding: 32px 18px; text-align: center;
}

.small-meta { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-neutral-600); margin-bottom: 2px; }

.tenant-card { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }

.alert-row {
  text-align: left; cursor: pointer; background: var(--color-bg); border: 2px solid var(--color-text);
  border-left: 4px solid var(--color-neutral-500); padding: 12px 14px; display: flex; gap: 12px; align-items: center; width: 100%;
}
.alert-row .title { font-weight: 700; font-size: 14px; }
.alert-row .sub { font-size: 12px; color: var(--color-neutral-600); margin-top: 1px; }
.alert-row .amt { font-weight: 800; font-size: 15px; }

/* — bill sheet — */
#billsheet { background: #fff; border: 2px solid var(--color-text); }
#billsheet .bs-header { background: var(--color-text); color: var(--color-bg); padding: 16px 16px 14px; display: flex; justify-content: space-between; align-items: flex-start; }
#billsheet .bs-tenant { padding: 14px 16px; border-bottom: 2px solid var(--color-divider); display: flex; justify-content: space-between; font-size: 12px; }
#billsheet .bs-total { background: var(--color-accent); color: #fff; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; }
