/* PIXELLA HUB — design tokens (สว่าง/มืด) + เลย์เอาต์ */
:root {
  --bg: #f6f6f9; --surface: #ffffff; --surface-2: #f1f1f6; --border: #e4e4ec; --border-strong: #c9c9d6; --text: #17171c; --muted: #6b6b78;
  --accent: #5b4bdb; --accent-2: #3b5bdb; --accent-soft: #ecebff; --accent-text: #ffffff;
  --nav-bg: #14141a; --nav-text: #c9c9d4; --nav-active: #ffffff; --nav-active-bg: rgba(124, 108, 255, .22); --nav-border: #262630;
  --green: #12a150; --green-soft: #e3f6ea; --blue: #2f6fed; --blue-soft: #e5eeff; --orange: #e07b00; --orange-soft: #fff0dc;
  --red: #d92d3a; --red-soft: #fde7e9; --gray: #7a7a86; --gray-soft: #ececf1; --pink-soft: #fde8f3; --violet-soft: #efe9ff;
  --shadow: 0 1px 2px rgba(20, 20, 40, .04), 0 4px 16px rgba(20, 20, 40, .05);
  --radius: 14px; --radius-sm: 9px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  /* text on *-soft backgrounds: darker than the base tone so contrast is >= 4.5:1 */
  --green-fg: #0e7a3d; --blue-fg: #2a63d3; --orange-fg: #a15900; --red-fg: #c52935; --gray-fg: #666671; --violet-fg: #5b4bdb;
  --font: "Noto Sans Thai", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}
:root[data-theme="dark"] {
  --bg: #0e0e13; --surface: #17171e; --surface-2: #1f1f28; --border: #2a2a36; --border-strong: #3d3d4d; --text: #ececf2; --muted: #9393a3;
  --accent: #8b7dff; --accent-2: #6d8dff; --accent-soft: #272445; --accent-text: #10101a;
  --nav-bg: #0a0a0f; --nav-text: #a8a8b6; --nav-active: #ffffff; --nav-active-bg: rgba(139, 125, 255, .22); --nav-border: #1c1c26;
  --green: #3ccf7a; --green-soft: #12301f; --blue: #6c9bff; --blue-soft: #16264a; --orange: #ffa23a; --orange-soft: #3a2810;
  --red: #ff6670; --red-soft: #3d1a1e; --gray: #9a9aa8; --gray-soft: #26262f; --pink-soft: #3a1c2d; --violet-soft: #2a2250;
  --green-fg: #3ccf7a; --blue-fg: #6c9bff; --orange-fg: #ffa23a; --red-fg: #ff6670; --gray-fg: #9a9aa8; --violet-fg: #9a8eff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.55 var(--font); -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); letter-spacing: .02em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.nav { background: var(--nav-bg); color: var(--nav-text); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; border-right: 1px solid var(--nav-border); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 700; letter-spacing: .14em; font-size: 15px; }
.brand small { display: block; font-weight: 400; letter-spacing: .04em; color: var(--nav-text); font-size: 11px; }
.nav-group { margin: 14px 10px 6px; font-size: 11px; letter-spacing: .12em; color: #6f6f80; text-transform: uppercase; }
.nav a, .nav .nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--nav-text); text-decoration: none; cursor: pointer; font-size: 14px; }
.nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }
.nav a.active { background: var(--nav-active-bg); color: var(--nav-active); }
.nav .sub { padding-left: 38px; font-size: 13.5px; }
.nav .nav-item.disabled { opacity: .55; cursor: default; }
.nav .tag { margin-left: auto; font-size: 10.5px; padding: 1px 8px; border-radius: 99px; background: rgba(255, 255, 255, .1); color: #b9b9c7; white-space: nowrap; }
.nav .tag.ready { background: rgba(37, 211, 102, .18); color: #5be39a; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 22px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar .search { flex: 1; max-width: 460px; position: relative; }
.topbar .search input { width: 100%; padding: 9px 12px 9px 36px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface-2); }
.topbar .search > svg { position: absolute; left: 12px; top: 11px; color: var(--muted); pointer-events: none; }
.spacer { flex: 1; }
.icon-btn { position: relative; width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--text); }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn .count { position: absolute; top: -4px; right: -4px; background: var(--red); color: #fff; font-size: 10px; min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: #fff; display: grid; place-items: center; font-weight: 700; cursor: pointer; border: 0; }
.menu-btn { display: none; }
.content { padding: 20px 22px 60px; max-width: 1280px; width: 100%; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.crumbs a { color: var(--muted); }
h1.page { margin: 0 0 16px; font-size: 22px; font-weight: 700; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 22px; }
.pop { position: absolute; right: 0; top: 46px; width: min(340px, 92vw); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 8px; z-index: 40; }
.pop .row { display: flex; gap: 10px; padding: 9px 10px; border-radius: 8px; align-items: center; }
.pop a.row { color: var(--text); text-decoration: none; }
.pop a.row:hover { background: var(--surface-2); }
.pop hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.rel { position: relative; }

/* ---------- components ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h2 { margin: 0 0 12px; font-size: 15px; font-weight: 700; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.g-5 { grid-template-columns: repeat(5, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-main { grid-template-columns: 2fr 1fr; }
.stat { display: flex; gap: 12px; align-items: center; cursor: pointer; text-decoration: none; color: inherit; }
.stat:hover { text-decoration: none; border-color: var(--accent); }
.stat .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.stat .n { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: 12.5px; }
.tone-violet { background: var(--violet-soft); color: var(--violet-fg); } .tone-green { background: var(--green-soft); color: var(--green-fg); }
.tone-blue { background: var(--blue-soft); color: var(--blue-fg); } .tone-orange { background: var(--orange-soft); color: var(--orange-fg); }
.tone-red { background: var(--red-soft); color: var(--red-fg); } .tone-gray { background: var(--gray-soft); color: var(--gray-fg); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.soft-gray { background: var(--gray-soft); color: var(--gray-fg); }
.badge.st-Available { background: var(--green-soft); color: var(--green-fg); } .badge.st-In-Use { background: var(--blue-soft); color: var(--blue-fg); }
.badge.st-Repair { background: var(--orange-soft); color: var(--orange-fg); } .badge.st-Lost { background: var(--red-soft); color: var(--red-fg); }
.badge.st-Retired { background: var(--gray-soft); color: var(--gray-fg); }
.badge.warn { background: var(--orange-soft); color: var(--orange-fg); } .badge.bad { background: var(--red-soft); color: var(--red-fg); } .badge.good { background: var(--green-soft); color: var(--green-fg); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; min-height: 38px; text-decoration: none; color: var(--text); }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: #fff; border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--red); border-color: var(--red); }
.btn.ok { background: var(--green); color: #fff; border-color: transparent; }
.btn.sm { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.progress { height: 10px; border-radius: 99px; background: var(--gray-soft); overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: 99px; }
.banner { padding: 10px 14px; border-radius: 10px; background: var(--orange-soft); color: var(--orange-fg); margin-bottom: 14px; font-weight: 600; }
.banner.red { background: var(--red-soft); color: var(--red-fg); } .banner.green { background: var(--green-soft); color: var(--green-fg); } .banner.blue { background: var(--blue-soft); color: var(--blue-fg); }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }
.list-row { display: flex; gap: 10px; align-items: center; padding: 9px 4px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.list-row { color: inherit; text-decoration: none; } a.list-row:hover { background: var(--surface-2); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.seg { display: inline-flex; width: fit-content; max-width: 100%; align-self: flex-start; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { background: var(--surface); border: 0; padding: 7px 14px; cursor: pointer; font-weight: 600; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.active { background: var(--accent); color: var(--accent-text); }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); }
input[type=text], input[type=search], input[type=date], input[type=number], select, textarea { width: 100%; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); min-height: 40px; }
textarea { min-height: 80px; resize: vertical; }
input:disabled, select:disabled { background: var(--surface-2); color: var(--muted); }
.combo { position: relative; }
.combo ul { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); max-height: 240px; overflow-y: auto; }
.combo li { padding: 9px 10px; border-radius: 7px; cursor: pointer; }
.combo li[aria-selected=true], .combo li:hover { background: var(--accent-soft); }
.id-preview { padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.id-preview b { font-family: var(--mono); font-size: 18px; }
details.sect { border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px; }
details.sect > summary { cursor: pointer; font-weight: 600; padding: 4px 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.t td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: var(--surface-2); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input[type=search] { flex: 1; min-width: 200px; }
.toolbar select { width: auto; min-width: 130px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; white-space: pre-wrap; }

/* ---------- modal / toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--surface); border-radius: 16px; padding: 22px; width: min(440px, 100%); box-shadow: var(--shadow); max-height: 90vh; overflow: auto; }
.modal h3 { margin: 0 0 8px; }
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; width: min(440px, 92vw); }
.toast { background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow); }
.toast.err { background: var(--red); color: #fff; }

/* ---------- scan ---------- */
.scan-box video { width: 100%; max-height: 320px; background: #000; border-radius: 12px; object-fit: cover; }
.scan-line { display: flex; gap: 8px; }
.scan-line input { font-family: var(--mono); font-size: 16px; text-transform: uppercase; }
.result-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.result-btns .btn { min-height: 52px; font-size: 15px; }
.chk { display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-bottom: 1px solid var(--border); }
.chk input[type=checkbox] { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }
.chk.staged { background: var(--green-soft); }
.chk.staged-bad { background: var(--orange-soft); }
.sticky-bar { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding: 12px; margin: 12px -18px -18px; border-radius: 0 0 var(--radius) var(--radius); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

@media (max-width: 1100px) { .g-5 { grid-template-columns: repeat(3, 1fr); } .g-4 { grid-template-columns: repeat(2, 1fr); } .g-main { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .nav { position: fixed; left: 0; top: 0; z-index: 60; width: 270px; transform: translateX(-102%); transition: transform .2s; }
  .nav.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); }
  .menu-btn { display: inline-grid; }
  .content { padding: 14px 12px 70px; }
  .topbar { padding: 10px 12px; gap: 8px; }
  .g-3, .g-2 { grid-template-columns: 1fr; }
  .g-5 { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 110px 1fr; }
    table.t.stack thead { display: none; }
  table.t.stack, table.t.stack tbody, table.t.stack tr, table.t.stack td { display: block; width: 100%; }
  table.t.stack tr { padding: 10px 4px; border-bottom: 1px solid var(--border); }
  table.t.stack td { border: 0; padding: 2px 6px; }
  table.t.stack td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 12px; }
  table.t.stack td[data-label=""]::before { content: none; }
}
@media (max-width: 480px) { .g-5, .g-4 { grid-template-columns: 1fr 1fr; } .stat .n { font-size: 22px; } .result-btns { grid-template-columns: 1fr; } }
table.t td b.mono, .list-row .mono { white-space: nowrap; }

/* ---------- หน้ารีวิวนำเข้า ---------- */
.import-stats { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.import-grid { max-height: 62vh; overflow: auto; border: 1px solid var(--border); border-radius: 10px; margin-top: 12px; }
table.t.itable { width: max-content; min-width: 100%; }
table.t.itable th { position: sticky; top: 0; background: var(--surface-2); z-index: 2; }
table.t.itable td { padding: 4px 5px; }
table.t.itable input.cell, table.t.itable select.cell { min-height: 34px; padding: 4px 7px; font-size: 13px; }
table.t.itable tr.bad td { background: var(--red-soft); }
table.t.itable tr.dirty td { background: var(--orange-soft); }
table.t.itable tr.err-row td, table.t.itable tr.warn-row td { border-bottom: 1px solid var(--border); padding: 4px 10px 8px; font-size: 12.5px; }
table.t.itable tr.err-row td { background: var(--red-soft); color: var(--red-fg); font-weight: 600; }
table.t.itable tr.warn-row td { color: var(--orange-fg); }
.btn.sm svg { display: block; }
@media (max-width: 860px) { .import-grid { max-height: 70vh; } }
table.t.itable tr.err-row td .msg, table.t.itable tr.warn-row td .msg { position: sticky; left: 10px; display: inline-block; max-width: min(640px, 80vw); }
table.t.itable .idcell { display: inline-block; min-width: 96px; padding: 6px 10px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-weight: 700; white-space: nowrap; }
table.t.itable .idcell.none { background: var(--gray-soft); color: var(--gray-fg); font-weight: 400; }

/* ช่องวันที่ + ปฏิทินของแอป */
input.date-in { cursor: pointer; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6b78' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M16 3v4M8 3v4M3 11h18'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; }
table.t.itable input.date-in { padding-right: 30px; background-position: right 8px center; background-size: 15px; }
.cal { position: fixed; z-index: 150; width: 288px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 8px 30px rgba(0, 0, 0, .25); padding: 12px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 8px; }
.cal-title { display: flex; align-items: center; gap: 6px; }
.cal-title select { width: auto; min-height: 32px; padding: 2px 6px; }
.cal-nav { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 20px; line-height: 1; cursor: pointer; }
.cal-nav:hover { background: var(--surface-2); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-dow { font-size: 12px; color: var(--muted); padding: 4px 0; }
.cal-day { height: 34px; border: 0; border-radius: 9px; background: none; color: var(--text); cursor: pointer; font: inherit; }
.cal-day:hover { background: var(--accent-soft); }
.cal-day.today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.cal-day.sel { background: var(--accent); color: var(--accent-text); font-weight: 700; }
.cal-foot { display: flex; justify-content: space-between; margin-top: 8px; }
.vsep { width: 2px; align-self: stretch; min-height: 24px; background: var(--muted); opacity: .45; border-radius: 2px; margin: 4px 4px; }

/* ปุ่มเลือก (ผลตรวจ / สภาพ) */
.choice-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.choice { min-height: 52px; font-size: 15px; font-weight: 600; border: 2px solid var(--border); background: var(--surface); color: var(--text); border-radius: 12px; cursor: pointer; }
.choice:hover { background: var(--surface-2); }
.choice.sel.ok { border-color: var(--green); background: var(--green-soft); color: var(--green-fg); }
.choice.sel.bad { border-color: var(--red); background: var(--red-soft); color: var(--red-fg); }
.choice.sel.warn { border-color: var(--orange); background: var(--orange-soft); color: var(--orange-fg); }

/* ---------- Jobs: ปฏิทินเดือน / รายการ ---------- */
.jcal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.jcal .dow { padding: 6px 8px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.jcal-cell { min-height: 104px; padding: 4px 5px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); cursor: pointer; min-width: 0; }
.jcal-cell:nth-child(7n) { border-right: 0; }
.jcal-cell.out { background: var(--surface-2); color: var(--muted); }
.jcal-cell.sel { outline: 2px solid var(--accent); outline-offset: -2px; }
.jcal-day { font-size: 12.5px; font-weight: 600; margin-bottom: 2px; }
.jcal-cell.today .jcal-day { display: inline-block; min-width: 22px; text-align: center; border-radius: 99px; background: var(--accent); color: var(--accent-text); }
.jchip { display: block; font-size: 12px; line-height: 1.35; padding: 1px 6px; margin-bottom: 2px; border-radius: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.jchip.paid { background: var(--green-soft); color: var(--green-fg); }
.jchip.nocost { background: var(--gray-soft); color: var(--gray-fg); }
.jchip:hover { text-decoration: underline; }
.jmore { font-size: 11.5px; color: var(--muted); }
.jcount { display: none; font-size: 11px; font-weight: 700; color: var(--accent); }
@media (max-width: 640px) {
  .jcal-cell { min-height: 52px; padding: 3px; }
  .jcal-cell .jchip, .jcal-cell .jmore { display: none; }
  .jcal-cell .jcount { display: block; }
  .jrow .jtype { display: none; }
  .jrow .jtime { min-width: 78px; }
}
.jtime { min-width: 92px; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12.5px; }
.pre-msg { width: 100%; min-height: 220px; font-family: inherit; }

/* ---------- Home: one card per module ---------- */
.home-grid { align-items: start; }
.home-card hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.home-card-head { display: flex; align-items: flex-start; gap: 12px; }
.home-card-head h2 { margin: 0; font-size: 17px; }
.home-open { font-size: 13px; font-weight: 600; white-space: nowrap; }
.home-sec-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.home-sec-head h3 { margin: 0; font-size: 14px; }
.count-circle { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--blue-soft); color: var(--blue-fg); }
.count-circle.warn { background: var(--orange-soft); color: var(--orange-fg); }
.up-row { display: flex; align-items: center; gap: 12px; padding: 8px 4px; color: var(--text); text-decoration: none; border-radius: 8px; }
.up-row:hover { background: var(--surface-2); text-decoration: none; }
.up-date { width: 68px; white-space: nowrap; flex: none; text-align: center; line-height: 1.25; }
.up-wk { font-size: 11px; color: var(--muted); }
.up-dm { font-size: 16px; font-weight: 500; }
.up-days { font-size: 11px; color: var(--muted); }
.up-name { font-size: 14px; }
.home-card-head .grow { flex: 1; min-width: 0; }

.price-bar { padding: 8px 4px 12px; font-size: 13.5px; }
.home-small-row { margin-bottom: 16px; }
.home-outstanding { display: block; width: 240px; max-width: 100%; padding: 12px 16px; color: var(--text); text-decoration: none; }
.home-outstanding:hover { background: var(--surface-2); text-decoration: none; }
.out-amount { font-size: 20px; font-weight: 600; line-height: 1.3; }

/* ---------- phone layout fixes ---------- */
@media (max-width: 640px) {
  .chk { flex-wrap: wrap; row-gap: 6px; }
  .chk > div { flex: 1 1 calc(100% - 44px) !important; }
  .chk > .badge, .chk > .btn { margin-left: 34px; }
  .sticky-bar .btn { flex: 1 1 auto; white-space: normal; text-align: center; }
  .sticky-bar > .muted { flex: 1 0 100%; }
}

.date-range { display: flex; gap: 10px; align-items: flex-end; }
.date-field { display: flex; flex-direction: column; gap: 2px; min-width: 150px; }
@media (max-width: 640px) {
  /* filter bars: search on its own row, selects two per row, date range as a pair — no cut-off placeholders */
  .toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .toolbar > input[type=search], .toolbar > .date-range, .toolbar > .btn-row { grid-column: 1 / -1; }
  .toolbar input[type=search] { min-width: 0; width: 100%; }
  .toolbar select { width: 100%; min-width: 0; }
  .date-range { display: grid; grid-template-columns: 1fr 1fr; }
  .date-field { min-width: 0; }
}

/* Job List: sortable date header + cancelled jobs (faded + struck through; the red Cancelled pill stays readable) */
.th-sort { background: none; border: 0; padding: 0; font: inherit; font-weight: inherit; color: inherit; cursor: pointer; text-transform: inherit; letter-spacing: inherit; white-space: nowrap; }
.th-sort:hover { color: var(--accent); }
tr.cancelled > td:nth-child(-n+5), .list-row.cancelled, .up-row.cancelled, .jchip.cancelled { opacity: .45; }
tr.cancelled td b, .list-row.cancelled .t, .up-row.cancelled .up-name, .jchip.cancelled { text-decoration: line-through; }

.sort-phone { display: none; }
@media (max-width: 640px) {
  .sort-phone { display: block; margin: 8px 0 0; font-size: 13px; color: var(--muted); }
  .card > .tabs { gap: 0; } .card > .tabs button { padding: 10px 6px; font-size: 13px; }
}

/* fixed-width date column: the job name starts at the same x on every row */
.jdate { width: 108px; flex: none; font-variant-numeric: tabular-nums; white-space: nowrap; }
.jdate .jd { font-size: inherit; font-weight: inherit; color: inherit; }
@media (min-width: 641px) { table.t td.jdate-col, table.t th[aria-sort] { width: 124px; min-width: 124px; } }
@media (max-width: 640px) { .jdate { width: auto; } }
.filter-chip { margin-bottom: 10px; }

.home-divider { border: 0; border-top: 1px solid var(--border-strong); margin: 20px 0 16px; }

/* Google sign-in button (Google branding guidelines: 40px high, 12px side padding, 10px icon gap, 4px radius, 14px/500) */
.gsi-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; height: 40px; padding: 0 12px; box-sizing: border-box; background: #fff; border: 1px solid #747775; border-radius: 4px; color: #1f1f1f; font: 500 14px/20px Roboto, Arial, sans-serif; text-decoration: none; cursor: pointer; }
.gsi-btn:hover { background: #f5f5f5; text-decoration: none; }
.gsi-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.gsi-btn svg { flex: none; }
:root[data-theme="dark"] .gsi-btn { background: #131314; border-color: #8e918f; color: #e3e3e3; }
:root[data-theme="dark"] .gsi-btn:hover { background: #1f1f21; }
