/* ===== Theme: light, minimal, sky + gray ===== */
:root {
  --bg: #f8fafc; --card: #ffffff; --line: #e2e8f0; --txt: #0f172a; --muted: #64748b;
  --sky-50: #f0f9ff; --sky-100: #e0f2fe; --sky-200: #bae6fd; --sky-400: #38bdf8;
  --sky-600: #0284c7; --sky-700: #0369a1; --sky-900: #0c4a6e;
  --gray-50: #f8fafc; --gray-100: #f1f5f9; --gray-200: #e2e8f0; --gray-400: #94a3b8;
  --gray-600: #475569; --gray-700: #334155;
  --ok: #059669; --ok-bg: #ecfdf5; --bad: #dc2626; --bad-bg: #fef2f2;
  /* ตู้/หัว */
  --m1: #0284c7; --m2: #38bdf8; --m3: #475569; --m4: #94a3b8;
  /* ยอดเงิน */
  --cash: #0284c7; --transfer: #475569;
  /* กะ */
  --morning: #f0f9ff; --afternoon: #f8fafc;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 14px rgba(15, 23, 42, .04);
}
* { box-sizing: border-box; }
body { margin: 0; padding: 0; background: var(--bg); color: var(--txt);
  font-family: "ThaiSarabun", "Sarabun", "Leelawadee UI", "Segoe UI", Tahoma, sans-serif;
  font-size: 18px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1 { font-size: 26px; margin: 0; font-weight: 700; }
h2 { font-size: 26px; margin: 0 0 18px; font-weight: 700; color: var(--gray-900, #0f172a); }
h3 { font-size: 18px; margin: 4px 0 14px; font-weight: 600; color: var(--gray-700); }
.sub { color: var(--muted); font-size: 16px; }

/* ===== Navbar ===== */
.navbar { background: #fff; border-bottom: 1px solid var(--line); color: var(--txt);
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 8px; padding: 12px 24px; position: sticky; top: 0; z-index: 10; }
.navbar .brand { font-weight: 700; font-size: 19px; color: var(--sky-700); }
.navbar .links { display: flex; flex-wrap: wrap; gap: 4px; }
.navbar .links a { color: var(--gray-600); text-decoration: none; padding: 7px 13px;
  border-radius: 999px; font-size: 16px; transition: background .15s, color .15s; }
.navbar .links a:hover { background: var(--sky-50); color: var(--sky-700); }
.navbar .links a.current { background: var(--sky-600); color: #fff; }

.container { max-width: 1320px; margin: 0 auto; padding: 24px; }

/* ===== Cards ===== */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 22px; margin-bottom: 20px; box-shadow: var(--shadow); }

/* ===== Forms ===== */
label { display: block; font-size: 16px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
input, select, textarea { width: 100%; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 18px; font-family: inherit; background: #fff; color: var(--txt);
  transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--sky-600);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, .15); }
input[readonly] { background: var(--gray-100); color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.date-row { display: flex; gap: 8px; }
.date-row input[type=number] { width: 88px; }
.date-row select { flex: 1; }

.hint { font-size: 15px; color: var(--muted); margin-top: 8px; }
.mt { margin-top: 16px; }

/* Meter fields: colored left bar per head */
.meter-field { border-left: 5px solid var(--gray-400); padding-left: 12px; border-radius: 4px; }
.meter-field.m-1 { border-left-color: var(--m1); }
.meter-field.m-2 { border-left-color: var(--m2); }
.meter-field.m-3 { border-left-color: var(--m3); }
.meter-field.m-4 { border-left-color: var(--m4); }

.actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
button, .btn-primary { border: none; border-radius: 10px; padding: 12px 22px; font-size: 18px;
  font-weight: 600; cursor: pointer; font-family: inherit; transition: background .15s, transform .05s; }
button:active, .btn-primary:active { transform: translateY(1px); }
.btn-primary { background: var(--sky-600); color: #fff; }
.btn-primary:hover { background: var(--sky-700); }
.btn-primary.full { width: 100%; }
.btn-green { background: var(--ok); color: #fff; }
.btn-green:hover { background: #047857; }
.btn-danger { background: #fff; color: var(--bad); border: 1px solid #fecaca; }
.btn-danger:hover { background: var(--bad-bg); }
.btn-ghost { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--gray-200); }

/* ===== Tables ===== */
.tbl-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; background: #fff; font-size: 17px; }
th, td { padding: 12px 14px; text-align: right; border-bottom: 1px solid var(--gray-200); white-space: nowrap; }
th { background: var(--gray-50); color: var(--gray-600); font-weight: 600; font-size: 15px; }
th:first-child, td:first-child { text-align: left; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--sky-50); }
tfoot td, tfoot th { background: var(--sky-50); font-weight: 700; color: var(--sky-900); border-top: 1px solid var(--sky-200); }
.num { font-variant-numeric: tabular-nums; }
.sold { color: var(--ok); font-weight: 600; }
.bad { color: var(--bad); font-weight: 700; }
.empty { text-align: center; color: var(--muted); padding: 32px; }
.meter-cell { font-size: 15px; text-align: left; white-space: nowrap; min-width: 175px; padding-top: 10px; padding-bottom: 10px; }
.meter-cell .chip { display: block; width: max-content; margin: 0 0 4px 0; font-size: 15px; padding: 3px 10px; font-variant-numeric: tabular-nums; }
.note-cell { font-size: 15px; text-align: left; white-space: normal; max-width: 120px; color: var(--muted); }

/* Column colors for money + meter heads */
th.cash, td.cash { color: var(--cash); }
th.transfer, td.transfer { color: var(--transfer); }
th.m-1 { color: var(--m1); border-bottom: 3px solid var(--m1); }
th.m-2 { color: var(--sky-600); border-bottom: 3px solid var(--m2); }
th.m-3 { color: var(--m3); border-bottom: 3px solid var(--m3); }
th.m-4 { color: var(--gray-600); border-bottom: 3px solid var(--m4); }
td.m-1 { background: #bae6fd; color: #075985; font-weight: 600; }
td.m-2 { background: #e0f2fe; color: #0369a1; font-weight: 600; }
td.m-3 { background: #cbd5e1; color: #1e293b; font-weight: 600; }
td.m-4 { background: #e2e8f0; color: #334155; font-weight: 600; }

/* Shift rows */
tr.row-morning > td:not(.m-1):not(.m-2):not(.m-3):not(.m-4) { background: var(--morning); }
tr.row-afternoon > td:not(.m-1):not(.m-2):not(.m-3):not(.m-4) { background: var(--afternoon); }
tr.row-morning td:first-child { box-shadow: inset 4px 0 0 var(--sky-600); }
tr.row-afternoon td:first-child { box-shadow: inset 4px 0 0 var(--gray-400); }
tr.row-morning:hover td, tr.row-afternoon:hover td { background: var(--sky-100); }

/* Chips (meter / shift tags) */
.chip { display: inline-block; font-size: 13px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  margin: 0 4px 2px 0; background: var(--gray-100); color: var(--gray-700); white-space: nowrap; }
.chip.m-1 { background: #e0f2fe; color: var(--m1); }
.chip.m-2 { background: #f0f9ff; color: var(--sky-600); box-shadow: inset 0 0 0 1px var(--sky-200); }
.chip.m-3 { background: #e2e8f0; color: var(--m3); }
.chip.m-4 { background: #f8fafc; color: var(--gray-600); box-shadow: inset 0 0 0 1px var(--gray-200); }
.shift-tag { display: inline-block; font-size: 14px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.shift-tag.morning { background: var(--sky-100); color: var(--sky-700); }
.shift-tag.afternoon { background: var(--gray-200); color: var(--gray-700); }

/* ===== Alerts ===== */
.alert { background: var(--bad-bg); border: 1px solid #fecaca; color: #b91c1c; padding: 12px 16px;
  border-radius: 10px; margin-bottom: 16px; font-size: 16px; }
.alert-ok { background: var(--ok-bg); border-color: #a7f3d0; color: #065f46; }

/* ===== Login ===== */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px;
  background: linear-gradient(160deg, var(--sky-50) 0%, #fff 60%); }
.login-card { background: #fff; border: 1px solid var(--line); border-radius: 20px;
  padding: 36px; width: 100%; max-width: 400px; box-shadow: 0 20px 50px rgba(2, 132, 199, .08); }
.login-card h1 { font-size: 26px; margin-bottom: 6px; color: var(--sky-700); }
.login-card form { margin-top: 18px; }
.login-card label { margin-top: 14px; }
.login-card input { margin-bottom: 4px; }
.login-card button { margin-top: 18px; }

.footer { text-align: center; color: var(--muted); font-size: 15px; padding: 24px; margin-top: 28px;
  border-top: 1px solid var(--line); }

/* ===== Stat cards ===== */
.stat { text-align: left; border-top: 4px solid var(--sky-600); }
.stat:nth-child(2) { border-top-color: var(--gray-400); }
.stat:nth-child(3) { border-top-color: var(--ok); }
.stat:nth-child(4) { border-top-color: var(--sky-400); }
.stat-num { font-size: 28px; font-weight: 700; color: var(--txt); }
.stat-num.sold { color: var(--ok); }
.stat-num.bad { color: var(--bad); }
.stat-lbl { font-size: 15px; color: var(--muted); margin-top: 2px; }

/* ===== Week grouping (history) ===== */
.week-box { margin-bottom: 14px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.week-box > summary { cursor: pointer; padding: 14px 18px; background: var(--gray-50); font-weight: 600; list-style: none; }
.week-box > summary::-webkit-details-marker { display: none; }
.week-box > summary::before { content: '▸ '; color: var(--sky-600); }
.week-box[open] > summary::before { content: '▾ '; }
.week-box[open] > summary { border-bottom: 1px solid var(--line); }
.week-sum { float: right; color: var(--muted); font-weight: 400; font-size: 15px; }

/* ===== Calendar ===== */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-cell { border: 1px solid var(--line); border-radius: 12px; min-height: 80px; padding: 8px; background: #fff; }
.cal-cell.other { background: var(--gray-50); border-style: dashed; }
.cal-cell a { text-decoration: none; color: inherit; }
.cal-dow { text-align: center; font-weight: 600; color: var(--muted); font-size: 15px; padding: 4px 0; }
.cal-num { font-weight: 700; font-size: 16px; }
.cal-tag { display: inline-block; font-size: 13px; padding: 1px 8px; border-radius: 999px; margin-top: 4px; font-weight: 600; }
.tag-m { background: var(--sky-100); color: var(--sky-700); }
.tag-a { background: var(--gray-200); color: var(--gray-700); }
.tag-both { background: var(--ok-bg); color: var(--ok); }

/* ===== Pills (toggle) ===== */
.pills { display: inline-flex; gap: 6px; margin-left: 12px; vertical-align: middle; }
.pill { padding: 6px 14px; border-radius: 999px; background: var(--gray-100); color: var(--gray-700);
  text-decoration: none; font-size: 16px; border: 1px solid var(--line); }
.pill:hover { background: var(--gray-200); }
.pill.active { background: var(--sky-600); border-color: var(--sky-600); color: #fff; }

/* ===== Chart container ===== */
canvas { max-width: 100%; }

/* ===== Field accents ===== */
label.cash { color: var(--cash); font-weight: 600; }
label.transfer { color: var(--transfer); font-weight: 600; }
select[data-v="morning"] { border-left: 5px solid var(--sky-600); background: var(--sky-50); }
select[data-v="afternoon"] { border-left: 5px solid var(--gray-400); background: var(--gray-50); }