/* Whale brand UI kit - shared by Whale POS and Whale Hub (and the model for the other systems).
   Navy sidebar, white work area, brand blue for actions, GOLD for accents. No external fonts or libraries; works under a strict CSP (no inline styles needed). */
:root {
  --navy: #0B1F3A; --navy-2: #12345A; --deep: #061427; --blue: #1C6FF2; --blue-2: #1458D6; --sky: #7DD3FC; --gold: #D9A94F; --gold-2: #F3D58E; --gold-3: #A87420;
  --bg: #F4F7FB; --surface: #fff; --text: #172B4D; --muted: #5b6b85; --border: #DFE7F1; --soft: #EEF3FA;
  --ok: #0b7a43; --ok-bg: #e3f6ec; --warn: #8a5300; --warn-bg: #fff2dc; --bad: #b42318; --bad-bg: #fde8e6; --info-bg: #e5f0ff;
  --radius: 14px; --shadow: 0 1px 2px rgba(11,31,58,.05), 0 8px 24px rgba(11,31,58,.07);
  --font: "Segoe UI", "Leelawadee UI", "Noto Sans Thai", "Sarabun", Tahoma, system-ui, -apple-system, Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--text); background: var(--bg); }
h1, h2, h3 { margin: 0 0 .4em; color: var(--navy); line-height: 1.25; } h1 { font-size: 1.45rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
a { color: var(--blue-2); } p { margin: 0 0 .8em; } .muted { color: var(--muted); } .small { font-size: .85rem; } .right { text-align: right; } .center { text-align: center; } .num { text-align: right; font-variant-numeric: tabular-nums; }
.hidden, [hidden] { display: none !important; }
:focus-visible { outline: 3px solid rgba(28,111,242,.5); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; } .row.between { justify-content: space-between; } .grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: 14px; } .grid > * { min-width: 0; } input[type=date] { min-width: 0; } .g2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); } .g3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); } .g4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.gold { color: var(--gold-3); } .gold-bar { height: 3px; width: 54px; border-radius: 3px; background: linear-gradient(90deg, var(--gold-2), var(--gold)); margin: 8px 0 14px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45em; min-height: 40px; padding: .5em 1em; border-radius: 11px; border: 1px solid var(--border); background: #fff; color: var(--navy); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, transform .1s; white-space: nowrap; }
.btn:hover { background: var(--soft); border-color: #c9d8ee; } .btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, var(--blue), var(--blue-2)); border-color: transparent; color: #fff; box-shadow: 0 6px 16px rgba(28,111,242,.28); } .btn-primary:hover { background: linear-gradient(135deg, #2a7bff, #1a63e6); border-color: transparent; }
.btn-gold { background: linear-gradient(135deg, var(--gold-2), var(--gold)); border-color: transparent; color: #3b2a07; } .btn-gold:hover { filter: brightness(1.05); background: linear-gradient(135deg, var(--gold-2), var(--gold)); border-color: transparent; }
.btn-danger { background: #fff; color: var(--bad); border-color: #f1c4bf; } .btn-danger:hover { background: var(--bad-bg); }
.btn-sm { min-height: 32px; padding: .25em .7em; font-size: .88rem; border-radius: 9px; } .btn-lg { min-height: 52px; padding: .7em 1.4em; font-size: 1.1rem; border-radius: 13px; } .btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* forms */
label { display: block; font-weight: 600; margin-bottom: 4px; font-size: .9rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=date], input[type=tel], input:not([type]), select, textarea {
  width: 100%; min-height: 40px; padding: .45em .75em; font: inherit; color: var(--text); background: #fff; border: 1px solid #b9c7dc; border-radius: 10px; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 4px rgba(28,111,242,.16); }
.field { margin-bottom: 12px; } .field .hint { color: var(--muted); font-size: .82rem; margin-top: 3px; } .field .err { color: var(--bad); font-size: .85rem; font-weight: 600; margin-top: 3px; }
.check { display: inline-flex; gap: 8px; align-items: center; font-weight: 500; } .check input { width: 18px; height: 18px; accent-color: var(--blue); }

/* cards, tables, badges */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card.flat { box-shadow: none; } .card h2 { margin-bottom: .6em; }
.tbl-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; } .tbl th, .tbl td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl thead th { background: var(--soft); color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; position: sticky; top: 0; }
.tbl tbody tr:hover td { background: #fafcff; } .tbl tbody tr:last-child td { border-bottom: 0; } .tbl td.num, .tbl th.num { text-align: right; }
.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--soft); color: var(--navy); }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); } .badge.bad { background: var(--bad-bg); color: var(--bad); } .badge.info { background: var(--info-bg); color: #0b57c9; } .badge.gold { background: #f8ecc9; color: var(--gold-3); }
.kpi { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); border-top: 3px solid var(--gold); } .kpi .n { font-size: 1.7rem; font-weight: 800; color: var(--navy); line-height: 1.1; font-variant-numeric: tabular-nums; } .kpi .l { color: var(--muted); font-size: .85rem; }
.empty { padding: 28px; text-align: center; color: var(--muted); background: #fff; border: 1px dashed #c3d3ea; border-radius: var(--radius); }
.alert { padding: 10px 14px; border-radius: 11px; margin-bottom: 12px; font-weight: 500; } .alert.ok { background: var(--ok-bg); color: var(--ok); } .alert.warn { background: var(--warn-bg); color: var(--warn); } .alert.bad { background: var(--bad-bg); color: var(--bad); } .alert.info { background: var(--info-bg); color: #0b57c9; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 14px; } .tabs button { border: 0; background: transparent; padding: 9px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; } .tabs button.on { color: var(--navy); border-bottom-color: var(--gold); }
.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(28,111,242,.25); border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; } @keyframes spin { to { transform: rotate(360deg); } }

/* app shell: navy side bar + white work area */
.shell { display: flex; min-height: 100vh; }
.side { width: 232px; flex: 0 0 232px; background: linear-gradient(180deg, var(--navy), var(--deep)); color: #cfe0f7; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; border-right: 1px solid rgba(217,169,79,.2); }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-weight: 800; font-size: 1.05rem; } .brand img { width: 34px; height: 34px; border-radius: 10px; box-shadow: 0 3px 12px rgba(28,111,242,.4); }
.nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow: auto; }
.nav button, .nav a { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; color: #cfe0f7; padding: 10px 12px; border-radius: 10px; font: inherit; font-weight: 600; text-align: left; cursor: pointer; text-decoration: none; }
.nav button:hover, .nav a:hover { background: rgba(255,255,255,.07); } .nav .on { background: var(--navy-2); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.side-foot { padding: 12px 18px; font-size: .8rem; color: #8fa8c8; border-top: 1px solid rgba(255,255,255,.08); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 20px; background: #fff; border-bottom: 1px solid var(--border); box-shadow: 0 1px 0 rgba(217,169,79,.25); position: sticky; top: 0; z-index: 20; }
.topbar h1 { margin: 0; flex: 1; font-size: 1.15rem; }
.content { padding: 20px; }


/* modal and toast */
.modal-back { position: fixed; inset: 0; background: rgba(6,20,39,.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100; }
.modal { background: #fff; border-radius: 18px; width: min(560px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 30px 80px rgba(2,10,24,.5); border-top: 4px solid var(--gold); } .modal.wide { width: min(860px, 100%); }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); } .modal header h2 { margin: 0; } .modal .body { padding: 16px 18px; } .modal footer { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; background: var(--soft); }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; } .toast { background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 12px; box-shadow: 0 10px 30px rgba(2,10,24,.4); border-left: 4px solid var(--gold); } .toast.bad { border-left-color: #ff6b5e; } .toast.ok { border-left-color: #4cd68a; }

/* sign-in / setup screen: the shared under-the-sea scene behind a white card */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(90deg, rgba(6,20,39,.5), rgba(6,20,39,.12)), url("sea-scene.svg") 76% center / cover no-repeat, var(--navy); }
.auth .card { width: 100%; max-width: 430px; padding: 26px; border: 1px solid rgba(217,169,79,.38); box-shadow: 0 24px 60px rgba(2,10,24,.5); }
.auth .logo { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-weight: 800; font-size: 1.1rem; color: var(--navy); } .auth .logo img { width: 40px; height: 40px; border-radius: 11px; }
/* ── every device: phone, tablet (iPad) and computer ────────────────────────────────────────────────────────────────────────────────
   desktop  >= 1100px : full navy side bar with labels
   tablet   700-1099  : slim icon rail (iPad portrait and landscape), two-column work screens
   phone    < 700     : bottom tab bar, one column, dialogs rise from the bottom like a phone sheet
   Also: iPhone notch / home-bar safe areas, 44px touch targets on touch screens, 16px inputs (iOS Safari zooms into smaller ones). */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { overflow-x: clip; }   /* safety net: one over-wide element must never make a phone zoom the whole page out */
body { min-height: 100vh; min-height: 100dvh; padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.shell { min-height: 100vh; min-height: 100dvh; } .side { height: 100vh; height: 100dvh; }
.nav .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-sep { height: 1px; background: rgba(255,255,255,.08); margin: 6px 6px; }
.topbar { padding-top: calc(10px + env(safe-area-inset-top)); }
.bottom-nav { display: none; }
.card, .tbl td, .toast, .modal .body { overflow-wrap: break-word; }
img, svg, video, canvas { max-width: 100%; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (hover: hover) { .btn:hover { background: var(--soft); } }

@media (min-width: 700px) and (max-width: 1099px) {
  .side { width: 78px; flex-basis: 78px; }
  .side .brand { justify-content: center; padding: 16px 0 10px; } .side .brand .brand-name, .side-foot .txt { display: none; }
  .nav { padding: 6px 7px; }
  .nav button, .nav a { flex-direction: column; justify-content: center; gap: 3px; padding: 10px 2px; text-align: center; }
  .nav .lbl { font-size: .66rem; font-weight: 600; max-width: 100%; }
  .nav svg { width: 22px; height: 22px; } .nav .on { box-shadow: inset 0 -3px 0 var(--gold); }
  .side-foot { padding: 10px 4px; text-align: center; }
  .content { padding: 16px; }
}
@media (max-width: 699px) {
  .side { display: none; }
  .content { padding: 12px 12px calc(84px + env(safe-area-inset-bottom)); }
  .topbar { padding: calc(8px + env(safe-area-inset-top)) 12px 8px; gap: 8px; } .topbar h1 { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: linear-gradient(180deg, var(--navy), var(--deep)); border-top: 2px solid var(--gold);
                padding: 5px max(4px, env(safe-area-inset-left)) calc(5px + env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-right)); }
  .bottom-nav button { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; border: 0; background: transparent; color: #b9cde8; font: inherit; font-size: .68rem; font-weight: 600; border-radius: 10px; cursor: pointer; }
  .bottom-nav svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .bottom-nav .on { color: #fff; background: rgba(255,255,255,.08); } .bottom-nav .on svg { color: var(--gold-2); }
  .bottom-nav .lbl { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=date], input[type=tel], input:not([type]), select, textarea { font-size: 16px; }
  h1 { font-size: 1.25rem; } .kpi .n { font-size: 1.35rem; } .kpi { padding: 10px 12px; }
  .modal-back { align-items: flex-end; padding: 0; }
  .modal, .modal.wide { width: 100%; max-height: 94vh; max-height: 94dvh; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .modal footer { position: sticky; bottom: 0; flex-wrap: wrap; } .modal footer .btn { flex: 1 1 auto; }
  .toasts { left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); } .toast { text-align: center; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; } .tabs button { white-space: nowrap; }
  .auth { padding: 12px; align-items: flex-end; } .auth .card { padding: 20px; max-width: none; }
  .tbl.stack thead { display: none; } .tbl.stack, .tbl.stack tbody, .tbl.stack tr, .tbl.stack td { display: block; width: 100%; }
  .tbl.stack tr { padding: 8px 12px; border-bottom: 1px solid var(--border); } .tbl.stack tr:last-child { border-bottom: 0; }
  .tbl.stack td { display: flex; justify-content: space-between; gap: 14px; padding: 3px 0; border: 0; text-align: right; }
  .tbl.stack td::before { content: attr(data-label); color: var(--muted); font-weight: 600; text-align: left; flex: none; }
  .tbl.stack td.actions { justify-content: flex-end; flex-wrap: wrap; } .tbl.stack td.actions::before, .tbl.stack td:empty { display: none; }
}
@media (max-height: 500px) and (orientation: landscape) { .topbar { padding-top: 4px; padding-bottom: 4px; } .content { padding-top: 8px; } .auth { align-items: center; } .modal { max-height: 100vh; } }
@media (pointer: coarse) {
  .btn { min-height: 46px; } .btn-sm { min-height: 40px; padding: .3em .85em; } .btn-lg { min-height: 56px; }
  input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=date], input[type=tel], input:not([type]), select { min-height: 46px; font-size: max(16px, 1em); }
  .nav button, .nav a, .tabs button { min-height: 46px; } .check input { width: 22px; height: 22px; }
}

@media print { .side, .topbar, .toasts, .no-print { display: none !important; } .content { padding: 0; } body { background: #fff; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
