/* SC Sales — สีตาม sc-brand (DEC-23): ปุ่มน้ำตาล, accent ส้ม */
:root {
  --bg: #faf7f4; --card: #fff; --text: #2b211c; --muted: #6b5d55; --line: #e6ddd5;
  --brand: #6b3e26; --brand-dark: #4f2c1a; --accent: #e8752a; --danger: #b3261e; --ok: #2e7d32;
  --focus: #e8752a;
  --s-available: #2e7d32; --s-available-bg: #e3f1e4;
  --s-booked: #8a5300; --s-booked-bg: #fff1d6;
  --s-contract: #1f5d99; --s-contract-bg: #e1ecf7;
  --s-transferred: #5b4a8b; --s-transferred-bg: #ebe7f5;
  --s-unknown: #6b5d55; --s-unknown-bg: #eee;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { font: 15px/1.5 "Sarabun", "Noto Sans Thai", system-ui, sans-serif; color: var(--text); background: var(--bg); }
#app { height: 100%; overflow: auto; padding: 12px 16px 40px; }
h1 { font-size: 20px; margin: 0; }
.title-row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.who { color: var(--muted); font-size: 13px; }
.status { margin: 6px 0 10px; font-size: 14px; }
.sample { margin: 8px 0 4px; padding: 8px 12px; border-radius: 6px; background: #fff1d6; border: 1px solid #f0c674; color: #6b4300; font-size: 14px; }
.status[data-kind="error"] { color: var(--danger); }
.status[data-kind="ok"] { color: var(--ok); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-bottom: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 200px; flex: 1; max-width: 520px; }
label { font-size: 13px; color: var(--muted); }
input, select { font: inherit; padding: 8px; border: 1px solid #c9bcb1; border-radius: 6px; background: #fff; min-height: 44px; }
button { font: inherit; min-height: 44px; padding: 8px 16px; border-radius: 6px; border: 1px solid var(--brand); background: var(--brand); color: #fff; cursor: pointer; }
button.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-bottom: 12px; }
.tile { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 8px; padding: 10px 12px; min-height: 64px; text-align: left; }
.tile:hover { border-color: var(--accent); background: #fffaf6; }
.tile[aria-pressed="true"] { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.tile .n { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile .l { font-size: 13px; color: var(--muted); }
.tile[data-status="available"] { border-left-color: var(--s-available); }
.tile[data-status="booked"] { border-left-color: var(--s-booked); }
.tile[data-status="contract"] { border-left-color: var(--s-contract); }
.tile[data-status="transferred"] { border-left-color: var(--s-transferred); }
.tile[data-status="locked"] { border-left-color: var(--danger); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; background: #fbf8f5; position: sticky; top: 0; }
td.code { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.scroll { max-height: 60vh; overflow: auto; }
.badge { display: inline-block; padding: 1px 10px; border-radius: 10px; font-size: 13px; font-weight: 600; }
.badge[data-status="available"] { color: var(--s-available); background: var(--s-available-bg); }
.badge[data-status="booked"] { color: var(--s-booked); background: var(--s-booked-bg); }
.badge[data-status="contract"] { color: var(--s-contract); background: var(--s-contract-bg); }
.badge[data-status="transferred"] { color: var(--s-transferred); background: var(--s-transferred-bg); }
.badge[data-status="unknown"] { color: var(--s-unknown); background: var(--s-unknown-bg); }
.lock { color: var(--danger); font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0; }

.open-atlas { display: flex; justify-content: center; padding: 32px 0; }
.open-atlas-link { display: inline-flex; align-items: center; gap: 14px; padding: 14px 20px 14px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: inherit; text-decoration: none; min-height: 44px; }
.open-atlas-link:hover, .open-atlas-link:focus-visible { border-color: var(--accent); }
.open-atlas-link img { border-radius: 10px; flex: none; }
.open-atlas-link span { display: flex; flex-direction: column; }
.open-atlas-link small { color: var(--muted); }

@media (max-width: 560px) {
  #app { padding: 10px 12px 32px; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .tile .n { font-size: 19px; }
}
