/* หน้าตาเว็บ Bossnoi Studio — มินิมอลทันสมัย: ค่าเริ่มต้น = พื้นสว่างเกือบขาว (data-theme="light"), สีเน้นฟ้าอมเขียว,
   แถบเมนู 5 สี (แดงเลือดหมู/ฟ้า/ครีม/ขาว/ดำ) แบบจาง, หัวข้อ Libre Baskerville + เนื้อหา Outfit (แทน Garet)
   โหมดมืดเลือกได้จากเมนูชื่อ (ใช้ชุดสี Premium Dark ด้านล่าง) */
:root {
  --font: 'Outfit', 'IBM Plex Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Libre Baskerville', 'Noto Serif Thai', Georgia, serif;

  --accent: #22c7e3;
  --accent-hover: #4fd6ec;
  --accent-ink: #5fdcf0;
  --accent-soft: rgba(34, 199, 227, 0.13);
  --accent-rgb: 34, 199, 227;
  --on-accent: #ffffff;
  --accent-grad: linear-gradient(180deg, #3fd3ea 0%, #0aa5c9 100%);

  --bg: #0a0a0b;
  --surface: #151517;
  --surface-2: #1c1c1f;
  --surface-3: #26262a;
  --side: rgba(18, 18, 20, 0.72);
  --glass: rgba(22, 22, 24, 0.72);
  --hover: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.075);
  --line-strong: rgba(255, 255, 255, 0.14);
  --hairline-top: rgba(255, 255, 255, 0.06);
  --ink: #f5f5f7;
  --ink-2: #d2d2d7;
  --muted: #8e8e93;
  --faint: #5a5a5f;

  --red: #ff453a;
  --red-soft: rgba(255, 69, 58, 0.14);
  --red-ink: #ff6961;
  --blue: #0a84ff;
  --blue-soft: rgba(10, 132, 255, 0.15);
  --green: #30d158;
  --green-soft: rgba(48, 209, 88, 0.14);
  --purple: #bf5af2;
  --purple-soft: rgba(191, 90, 242, 0.15);
  --amber: #ffd60a;
  --amber-soft: rgba(255, 214, 10, 0.13);
  --gray-soft: rgba(255, 255, 255, 0.07);
  --dark-chip: #48484a;

  --radius: 18px;
  --radius-sm: 11px;
  --shadow-xs: inset 0 1px 0 var(--hairline-top);
  --shadow: inset 0 1px 0 var(--hairline-top), 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  --ring: 0 0 0 3px rgba(var(--accent-rgb), 0.28);
  --ease: cubic-bezier(0.25, 0.8, 0.25, 1);
  --topbar-h: 56px;
  --side-w: 248px;
  --page-glow: radial-gradient(1200px 600px at 50% -200px, rgba(34, 199, 227, 0.10), transparent 70%);
  /* ผงกลิตเตอร์โหมดมืด */
  --glit-1: rgba(255, 255, 255, 0.5);
  --glit-2: rgba(255, 221, 150, 0.38);
  --glit-3: rgba(170, 215, 255, 0.32);

  /* แถบเมนู (โหมดมืด) */
  --nav-red: #c26777;
  --nav-sky: #7ccdd3;
  --nav-cream: #fbf8f3;
  --nav-black: #1c1c1e;
  --nav-bg: #141416;
  --nav-ink: #f5f1ea;
  --nav-ink-2: rgba(245, 241, 234, 0.6);
  --nav-hover: rgba(124, 205, 211, 0.12);

  /* สีไอคอนเมนู (พาสเทล มินิมอล) — โหมดมืดสว่างกว่านิดให้เห็นชัด */
  --ic-rose: #f08a9b;
  --ic-coral: #ffa877;
  --ic-honey: #f3c46b;
  --ic-sage: #86d3a3;
  --ic-sky: #6fd3dd;
  --ic-blue: #7fb4f0;
  --ic-lilac: #b89ae6;
  --ic-pink: #f29ccd;

  /* ชื่อเดิม เผื่อโค้ดเก่าใช้อยู่ */
  --orange: var(--accent);
  --orange-dark: var(--accent-ink);
  --orange-soft: var(--accent-soft);
  --black: #000000;
  --card: var(--surface);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --font: 'Outfit', 'IBM Plex Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Libre Baskerville', 'Noto Serif Thai', Georgia, serif;

  --accent: #2d8a92;
  --accent-hover: #257780;
  --accent-ink: #226f77;
  --accent-soft: #e8f6f7;
  --accent-rgb: 45, 138, 146;
  --on-accent: #ffffff;

  /* โทนสว่างแบบถนอมสายตา: เทาอ่อนกลาง ๆ ไม่ขาวจ้าและไม่เหลือง (ไม่เปลี่ยนเฉดสีอื่น) */
  --bg: #f1f2f3;
  /* ไล่สีฟุ้ง ๆ บนพื้นหลัง: มิ้นต์ → ฟ้า → ม่วง → ชมพู → ส้มโอโรส (จาง ๆ ไม่มีเหลือง ไม่แสบตา) */
  --bg-tint-1: rgba(139, 222, 218, 0.4);
  --bg-tint-2: rgba(67, 173, 208, 0.28);
  --bg-tint-3: rgba(153, 142, 224, 0.3);
  --bg-tint-4: rgba(225, 125, 194, 0.26);
  --bg-tint-5: rgba(239, 147, 147, 0.24);
  --surface: #fbfbfc;
  --surface-2: #eaebec;
  --surface-3: #e0e1e3;
  --side: #fbfbfc;
  --hover: rgba(31, 42, 44, 0.05);
  --line: #ebebe7;
  --line-strong: #dcdcd7;
  --ink: #1c1d1f;
  --ink-2: #3d4043;
  --muted: #737b7c;
  --faint: #a7acac;

  --red: #b04a5a;
  --red-soft: #faedef;
  --red-ink: #933a49;
  --blue: #234563;
  --blue-soft: #e3f1f6;
  --green: #4e6b40;
  --green-soft: #e6f3df;
  --purple: #6e5585;
  --purple-soft: #efe7f8;
  --amber: #96621a;
  --amber-soft: #fdebd9;
  --gray-soft: #f0f0ed;
  --dark-chip: #273d41;

  --shadow-xs: 0 1px 2px rgba(39, 61, 65, 0.05);
  --shadow: 0 1px 2px rgba(39, 61, 65, 0.05), 0 2px 8px rgba(39, 61, 65, 0.05);
  --shadow-lg: 0 8px 28px rgba(39, 61, 65, 0.16), 0 0 0 1px rgba(39, 61, 65, 0.06);
  --ring: 0 0 0 3px rgba(var(--accent-rgb), 0.22);
  /* แถบเมนู: แดงเลือดหมู / ฟ้า / ครีม / ขาว / ดำ (ลดความเข้มลงให้เข้ากับทั้งเว็บ) */
  --nav-red: #c26777;
  --nav-sky: #7ccdd3;
  --nav-cream: #fbf8f3;
  --nav-black: #1c1c1e;
  --nav-bg: var(--nav-cream);
  --nav-ink: var(--nav-black);
  --nav-ink-2: rgba(28, 28, 30, 0.5);
  --nav-hover: rgba(124, 205, 211, 0.16);

  /* สีไอคอนเมนู (พาสเทล มินิมอล) — โหมดสว่างเข้มขึ้นนิดให้ตัดกับพื้นครีม */
  --ic-rose: #e0788a;
  --ic-coral: #e89156;
  --ic-honey: #cf9a33;
  --ic-sage: #5fae82;
  --ic-sky: #3bb6c3;
  --ic-blue: #5a99da;
  --ic-lilac: #9177cb;
  --ic-pink: #d97cb4;

  /* ชื่อเดิม เผื่อโค้ดเก่าใช้อยู่ */
  --orange: var(--accent);
  --orange-dark: var(--accent-ink);
  --orange-soft: var(--accent-soft);
  --black: #1b2a2d;
  --card: var(--surface);
  --accent-grad: linear-gradient(180deg, #3aa1a9 0%, #2d8a92 100%);
  --glass: rgba(255, 255, 255, 0.82);
  --hairline-top: rgba(255, 255, 255, 0.9);
  /* พื้นหลังไล่สีฟุ้ง ๆ 3 จุด: เหลืองนวล (ซ้ายบน) → ฟ้ามิ้นต์ (ขวาบน) → ชมพูม่วง (ล่าง) */
  --page-glow:
    radial-gradient(62% 50% at 0% -6%, var(--bg-tint-1), transparent 70%),
    radial-gradient(58% 46% at 100% 6%, var(--bg-tint-2), transparent 70%),
    radial-gradient(60% 52% at 8% 92%, var(--bg-tint-3), transparent 72%),
    radial-gradient(58% 48% at 96% 104%, var(--bg-tint-4), transparent 72%),
    radial-gradient(55% 45% at 50% 112%, var(--bg-tint-5), transparent 72%);
  /* ผงกลิตเตอร์: ขาววิบ + ม่วงอ่อน + มิ้นต์ (จาง ๆ ไม่แสบตา ไม่มีเหลือง) */
  --glit-1: rgba(255, 255, 255, 0.85);
  --glit-2: rgba(153, 142, 224, 0.28);
  --glit-3: rgba(139, 222, 218, 0.3);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* ผงกลิตเตอร์จาง ๆ บนพื้นหลัง — ติดอยู่กับจอ อยู่หลังเนื้อหา กดอะไรไม่โดน */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 22% 34%, var(--glit-1) 0 0.6px, transparent 1.2px),
    radial-gradient(circle at 68% 61%, var(--glit-2) 0 0.7px, transparent 1.3px),
    radial-gradient(circle at 44% 86%, var(--glit-3) 0 0.5px, transparent 1px),
    radial-gradient(circle at 83% 17%, var(--glit-1) 0 0.45px, transparent 0.9px);
  background-size: 59px 53px, 83px 71px, 43px 47px, 31px 37px;
  animation: glitter 9s ease-in-out infinite alternate;
}
@keyframes glitter { from { opacity: 0.7; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { body::before { animation: none; } }

body {
  margin: 0;
  background: var(--page-glow), var(--bg);
  background-attachment: fixed;
  isolation: isolate; /* ให้ชั้นกลิตเตอร์ (z-index:-1) อยู่เหนือพื้นหลัง แต่ยังอยู่หลังเนื้อหา */
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, .brand, .pay-num, .stat-num {
  font-family: var(--font);
  line-height: 1.3;
  letter-spacing: -0.01em;
}
/* หัวข้อใหญ่ใช้ตัวมีเชิง ให้ดูจริงจัง — หัวข้อการ์ด/ตัวเลขใช้ Outfit หนาแทน */
h1 { font-family: var(--font-display); letter-spacing: 0; }
h1 { font-size: 1.6rem; font-weight: 700; margin: 0.3rem 0 0.9rem; line-height: 1.35; }
h2 { font-size: 1.02rem; font-weight: 600; margin: 0 0 0.75rem; }
h3 { font-size: 0.95rem; font-weight: 600; }
a { color: var(--accent-ink); text-decoration: none; text-underline-offset: 2px; }
a:hover { text-decoration: underline; }
.btn:hover, .task:hover, .card:hover, .folder-tile:hover, .file-row:hover, .sidenav a:hover, .menu-pop a:hover, .crumbs a:hover, .tabs a:hover, .event-row:hover, .notif-list a:hover, .person:hover, .project-card:hover, .back:hover, .drive-menu-item:hover, .cal-cell:hover, .brand:hover, .bell:hover, .current a:hover { text-decoration: none; }
code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 0.86em; background: var(--surface-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; word-break: break-all; }
::selection { background: rgba(var(--accent-rgb), 0.22); }

.muted { color: var(--muted); }
.small { font-size: 0.84rem; }
.center-text { text-align: center; }
.text-red { color: var(--red); }
.req { color: var(--red); }
.plain { list-style: none; padding: 0; margin: 0; }
.row { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.plain > li.row { padding: 8px 0; border-bottom: 1px solid var(--line); }
.plain > li.row:last-child { border-bottom: 0; }
.danger { color: var(--red) !important; }

/* ---------- โครงหน้า ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.brand { color: var(--ink); text-decoration: none; font-weight: 700; font-size: 1rem; display: flex; align-items: center; gap: 10px; letter-spacing: -0.015em; }
.brand-dot {
  width: 24px; height: 24px; border-radius: 7px; display: inline-block; flex-shrink: 0;
  background: radial-gradient(circle at 50% 50%, #fff 0 22%, transparent 24%), linear-gradient(var(--nav-black), var(--nav-black));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}
.brand-dot.big { width: 52px; height: 52px; border-radius: 15px; box-shadow: 0 8px 24px rgba(var(--accent-rgb), 0.3); }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.menu { position: relative; }
.menu summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px; border-radius: 999px; font-size: 0.88rem; font-weight: 500; color: var(--ink-2);
  border: 1px solid transparent; transition: background 0.15s;
}
.menu summary:hover, .menu[open] summary { background: var(--hover); }
.menu summary .avatar.sm { margin: 0; border: 0; width: 30px; height: 30px; font-size: 0.8rem; }
.menu summary::-webkit-details-marker { display: none; }
.menu-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; z-index: 40;
  background: var(--surface); color: var(--ink); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px;
  display: flex; flex-direction: column; gap: 1px; animation: pop-in 0.12s ease-out;
}
.menu-who { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; line-height: 1.35; }
.menu-pop a, .menu-pop .linklike { color: var(--ink); text-decoration: none; padding: 7px 10px; border-radius: 6px; font-size: 0.9rem; display: block; width: 100%; }
.menu-pop a:hover, .menu-pop .linklike:hover { background: var(--hover); }
.menu-pop form { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.menu-pop .linklike { color: var(--red); }
.theme-pick { padding: 6px 10px 8px; display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line); margin-top: 4px; }
.seg { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; gap: 2px; }
.seg button { flex: 1; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 0.8rem; padding: 5px 4px; border-radius: 6px; cursor: pointer; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--accent-ink); font-weight: 600; box-shadow: var(--shadow-xs), 0 0 0 1px var(--line); }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }

.page { max-width: 760px; margin: 0 auto; padding: 18px 16px calc(48px + env(safe-area-inset-bottom)); }
.center { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; background: radial-gradient(ellipse at top, var(--accent-soft), transparent 60%), var(--bg); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.page-head h1, .page-head h2 { margin-bottom: 0.6rem; }
.card > .page-head h2 { margin-bottom: 0.6rem; }
.back { display: inline-flex; align-items: center; gap: 2px; margin-bottom: 6px; text-decoration: none; color: var(--muted); font-size: 0.88rem; padding: 2px 8px 2px 4px; margin-left: -4px; border-radius: 6px; }
.back:hover { background: var(--hover); color: var(--ink); }

/* เมนู: จอคอม = แถบซ้ายถาวร / มือถือ = กด ☰ แล้วเลื่อนออกมาจากซ้าย (ใช้พื้นที่เต็มจอ ไม่มีเมนูค้างด้านล่าง) */
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.hamburger { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; margin-left: -6px; border-radius: 8px; cursor: pointer; color: var(--ink); -webkit-tap-highlight-color: transparent; }
.hamburger:hover { background: var(--hover); }
.topbar .brand { margin-right: auto; }
.nav-scrim { display: none; }
.fs-btn { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 7px; border: 0; background: none; font: inherit; font-size: 0.9rem; font-weight: 500; color: var(--ink-2); cursor: pointer; text-align: left; }
.fs-btn:hover { background: var(--hover); }
.fs-btn .ico { width: 18px; height: 18px; color: var(--muted); }
.sidenav {
  display: flex; flex-direction: column; gap: 2px;
  position: fixed; z-index: 60; left: 0; top: 0; bottom: 0; width: min(300px, 84vw);
  padding: calc(14px + env(safe-area-inset-top)) 10px calc(14px + env(safe-area-inset-bottom)); background: var(--side); border-right: 1px solid var(--line); overflow-y: auto;
  transform: translateX(-102%); transition: transform 0.22s ease; visibility: hidden;
}
.sidenav nav { display: flex; flex-direction: column; gap: 1px; }
.sidenav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-size: 1rem; font-weight: 500; }
.sidenav a.active { background: var(--surface-3); color: var(--ink); font-weight: 600; }
.sidenav a.active .ico { color: var(--accent); }
.sidenav .ico { width: 20px; height: 20px; color: var(--muted); }
.sidenav .ally-fab-dot { width: 10px; height: 10px; margin: 0 5px; box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.2); }
.sidenav-label { font-size: 0.74rem; font-weight: 600; color: var(--faint); padding: 18px 10px 6px; letter-spacing: 0.02em; }
.nav-toggle:checked ~ .sidenav { transform: none; visibility: visible; box-shadow: var(--shadow-lg); }
.nav-toggle:checked ~ .nav-scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, 0.4); }
@media (min-width: 1024px) {
  .hamburger, .nav-scrim, .nav-toggle:checked ~ .nav-scrim { display: none; }
  .sidenav, .nav-toggle:checked ~ .sidenav { transform: none; visibility: visible; box-shadow: none; }
}
@media (min-width: 1024px) {
  .sidenav { z-index: 15; top: var(--topbar-h); width: var(--side-w); padding: 14px 10px; }
  .sidenav a, .fs-btn { gap: 10px; padding: 6px 10px; border-radius: 7px; font-size: 0.9rem; }
  .sidenav a:hover { background: var(--hover); color: var(--ink); }
  .sidenav .ico { width: 18px; height: 18px; }
  .fs-btn { display: none; }
  .topbar { padding-left: 22px; }
  .page.has-side { margin-left: var(--side-w); margin-right: 0; max-width: none; padding: 28px max(40px, calc((100vw - var(--side-w) - 920px) / 2)) 64px; }
  .page.has-side:has(.board), .page.has-side:has(.drive-wide) { padding-left: 40px; padding-right: 40px; }
}
/* แถบเมนู 5 สี แบบมินิมอล: พื้นครีมอ่อน, หน้าที่เปิดอยู่เป็นพื้นแดงจางตัวแดง, ชี้แล้วเป็นฟ้าจาง */
.bell-badge { background: var(--nav-red); color: #fff; }
.sidenav { background: var(--nav-bg); border-right: 1px solid var(--line); }
.sidenav a, .sidenav .fs-btn { color: var(--nav-ink); }
.sidenav .ico, .sidenav .fs-btn .ico { color: var(--nav-ink-2); }
.sidenav a:hover, .sidenav .fs-btn:hover { background: var(--nav-hover); color: var(--nav-ink); }
.sidenav a.active, .sidenav a.active:hover { background: color-mix(in srgb, var(--nav-red) 13%, transparent); color: color-mix(in srgb, var(--nav-red) 80%, var(--nav-ink)); }
.sidenav a.active .ico { color: var(--nav-red); }
.sidenav-label { color: var(--nav-ink-2); text-transform: none; }

.ico { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

.card {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow-xs);
  padding: 18px; margin: 12px 0;
}
.card.narrow { max-width: 480px; margin-left: auto; margin-right: auto; }
.card.login { width: 100%; max-width: 380px; padding: 28px 24px; box-shadow: var(--shadow-lg); border: 0; }
.login-brand { text-align: center; margin-bottom: 16px; display: flex; flex-direction: column; align-items: center; }
.login-brand h1 { margin: 14px 0 2px; font-size: 1.4rem; }
.login-brand p { margin: 0; }

/* ---------- ฟอร์ม ---------- */
.stack { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 0.9rem; color: var(--ink-2); }
label.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; color: var(--ink); }
label.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--accent); flex-shrink: 0; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  font: inherit; font-size: 16px; width: 100%; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); transition: border-color 0.15s, box-shadow 0.15s;
}
input[type=radio] { accent-color: var(--accent); width: 18px; height: 18px; margin-top: 3px; flex-shrink: 0; }
input::placeholder, textarea::placeholder { color: var(--faint); }
select {
  -webkit-appearance: none; appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a7974' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
input:hover:not(:disabled):not(:focus), select:hover:not(:focus), textarea:hover:not(:focus) { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
input:disabled { background: var(--surface-2); color: var(--muted); }
@media (min-width: 768px) { input:not([type=checkbox]):not([type=radio]), select, textarea { font-size: 0.94rem; } }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; margin: 0; display: flex; flex-direction: column; gap: 10px; }
legend { font-weight: 600; padding: 0 6px; font-size: 0.9rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.inline-form { display: flex; gap: 8px; margin-top: 8px; }
.danger-zone { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 20px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 0.9rem; font-weight: 600; padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); text-decoration: none; cursor: pointer; min-height: 40px;
  box-shadow: var(--shadow-xs); transition: background 0.15s, border-color 0.15s, transform 0.05s; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .linklike:focus-visible, a:focus-visible, summary:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 1px 2px rgba(var(--accent-rgb), 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--surface); border-color: color-mix(in srgb, var(--red) 45%, transparent); color: var(--red); }
.btn-danger:hover { background: var(--red-soft); }
.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; font-size: 1.3rem; min-height: 36px; padding: 2px 12px; color: var(--muted); }
.btn-ghost:hover { background: var(--hover); color: var(--ink); }
.btn-block { width: 100%; margin: 6px 0; }
.btn-ok { background: var(--green); border-color: var(--green); color: #fff; }
.btn-ok:hover { background: var(--green); filter: brightness(1.06); }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--accent-ink); cursor: pointer; text-align: left; }
.linklike:hover { text-decoration: underline; }
summary.btn { list-style: none; }
summary.btn::-webkit-details-marker { display: none; }

/* ---------- แจ้งเตือน / ป้าย ---------- */
.flash { padding: 10px 14px; border-radius: var(--radius-sm); margin: 10px 0; font-size: 0.9rem; border: 1px solid transparent; }
.flash-ok { background: var(--green-soft); color: var(--green); border-color: color-mix(in srgb, var(--green) 22%, transparent); }
.flash-error { background: var(--red-soft); color: var(--red-ink); border-color: color-mix(in srgb, var(--red) 22%, transparent); }
.flash p { margin: 4px 0; }
.bigcode { font-size: 1.25rem; letter-spacing: 1px; display: inline-block; margin: 4px 0; background: var(--surface); }
.tag, .pill, .brand-tag {
  display: inline-flex; align-items: center; gap: 4px; font-size: 0.74rem; font-weight: 600; line-height: 1.5;
  padding: 1px 8px; border-radius: 6px; white-space: nowrap; flex-shrink: 0; vertical-align: middle;
}
.tag-red { background: var(--red-soft); color: var(--red); }
.tag-blue { background: var(--blue-soft); color: var(--blue); }
.tag-gray { background: var(--gray-soft); color: var(--muted); }
.tag-orange { background: var(--accent-soft); color: var(--accent-ink); }
.tag-green { background: var(--green-soft); color: var(--green); }
.empty { color: var(--muted); text-align: center; padding: 22px 0; margin: 0; font-size: 0.9rem; }

/* ---------- หน้าแรก: แถบเข้างานแบบนาฬิกาดิจิตอล (มินิมอล) ----------
   ยังไม่เข้า = ขาว, กำลังทำงาน = ฟ้า, ออกไปข้างนอก = แดงเลือดหมู, ออกงานแล้ว = ครีมจางลง (สีพื้นอ่อน ตัวเลขเข้ม) */
.clockbar {
  --cb-tone: #9aa0a3; --cb-bg: var(--surface); --cb-line: var(--line);
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 20px; flex-wrap: wrap;
  background: var(--cb-bg); color: var(--ink); border: 1px solid var(--cb-line); border-radius: 20px; padding: 18px 20px 20px; margin: 0 0 6px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03), 0 8px 24px -12px rgba(0, 0, 0, 0.12);
  transition: background 0.3s, border-color 0.3s;
}
.clock-face { display: flex; flex-direction: column; min-width: 0; }
.clockbar-status {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 7px; margin-bottom: 10px;
  font-size: 0.8rem; font-weight: 500; line-height: 1.3; color: var(--ink-2);
  background: color-mix(in srgb, var(--cb-tone) 16%, transparent); padding: 4px 10px 4px 8px; border-radius: 999px;
}
.clockbar-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cb-tone); flex-shrink: 0; }
.clock-timer, .clock-now { font-family: var(--font); font-variant-numeric: tabular-nums; line-height: 1; }
.clock-timer { font-size: clamp(2rem, 8.5vw, 2.6rem); font-weight: 600; letter-spacing: -0.03em; }
.clock-sub-label { font-size: 0.74rem; color: var(--muted); margin: 6px 0 12px; }
.clock-now { font-size: 0.82rem; font-weight: 400; color: var(--muted); }
.clock-date { font-size: 0.82rem; color: var(--muted); margin-top: 3px; }
.clockbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.clockbar-hint { margin: 0 4px 12px; }
.clockbar.is-working { --cb-tone: #4fc3cb; --cb-bg: linear-gradient(180deg, #effafb, var(--surface) 75%); --cb-line: #d3eff1; }
.clockbar.is-working .clockbar-dot { animation: live 1.8s ease-out infinite; }
.clockbar.is-away { --cb-tone: #c26777; --cb-bg: linear-gradient(180deg, #fcf0f2, var(--surface) 75%); --cb-line: #f1d9de; }
.clockbar.is-done { --cb-tone: #c9b79c; --cb-bg: #fbf8f3; --cb-line: #efe7da; }
.clockbar.is-done .clock-timer, .clockbar.is-done .clock-now { color: var(--muted); }
/* โหมดมืด: พื้นการ์ดเข้มตามสถานะ (เดิมใช้พื้นอ่อนแบบโหมดสว่าง → ตัวหนังสือสีอ่อนบนพื้นเกือบขาว อ่านไม่ออก) */
:root:not([data-theme="light"]) .clockbar.is-working { --cb-bg: linear-gradient(180deg, #10343a, var(--surface) 75%); --cb-line: #1f4c54; }
:root:not([data-theme="light"]) .clockbar.is-away { --cb-bg: linear-gradient(180deg, #3a1c23, var(--surface) 75%); --cb-line: #5a2c36; }
:root:not([data-theme="light"]) .clockbar.is-done { --cb-bg: #26231e; --cb-line: #3b352b; }
:root:not([data-theme="light"]) .clockbar-status { color: var(--ink); background: color-mix(in srgb, var(--cb-tone) 26%, transparent); }
@keyframes live { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--cb-tone) 60%, transparent); } 100% { box-shadow: 0 0 0 7px transparent; } }

/* ปุ่มนูนแบบนุ่ม: เงาฟุ้งสีเดียวกับปุ่ม กดแล้วยุบลงเล็กน้อย */
.btn3d {
  --b3-bg: var(--surface); --b3-ink: var(--ink); --b3-glow: rgba(0, 0, 0, 0.12);
  min-height: 46px; padding: 10px 22px; border: 1px solid transparent; border-radius: 14px; font-weight: 600; font-size: 0.95rem;
  background: var(--b3-bg); color: var(--b3-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 18px -8px var(--b3-glow);
  transition: transform 0.1s, box-shadow 0.15s, filter 0.15s;
}
.btn3d:hover { background: var(--b3-bg); filter: brightness(1.03); transform: translateY(-1px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 1px 2px rgba(0, 0, 0, 0.06), 0 12px 22px -8px var(--b3-glow); }
.btn3d:active, .away-pop[open] > summary.btn3d { transform: translateY(1px); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12); }
.btn3d[disabled] { opacity: 0.6; transform: none; }
.btn3d-sky { --b3-bg: #4fc3cb; --b3-ink: #0c3236; --b3-glow: rgba(79, 195, 203, 0.7); }
.btn3d-red { --b3-bg: #c26777; --b3-ink: #ffffff; --b3-glow: rgba(194, 103, 119, 0.65); }
.btn3d-cream { --b3-bg: #f6efe4; --b3-ink: var(--ink); --b3-glow: rgba(150, 120, 80, 0.3); border-color: #ebe1d1; }
.clock-form { margin: 0; }
.away-pop { position: relative; }
.away-pop summary { list-style: none; }
.away-pop summary::-webkit-details-marker { display: none; }
.away-box {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: min(300px, calc(100vw - 32px));
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 12px; animation: pop-in 0.12s ease-out;
}
.away-box .clock-form { display: flex; flex-direction: column; gap: 8px; }
/* ---------- หน้าแรก: ปฏิทิน 7 วัน / ทั้งเดือน + โน้ตสี + โพสต์อิท ---------- */
.nt-sky { --nt: #4fc3cb; --nt-soft: #e9f8f9; --nt-ink: #1d6f76; }
.nt-blue { --nt: #6f9ccf; --nt-soft: #edf3fa; --nt-ink: #2f5e93; }
.nt-red { --nt: #c26777; --nt-soft: #fbeef0; --nt-ink: #9b3f50; }
.nt-green { --nt: #7fb38a; --nt-soft: #edf6ef; --nt-ink: #3f7a4c; }
.nt-purple { --nt: #9a86b8; --nt-soft: #f3eff8; --nt-ink: #614c82; }
.nt-amber { --nt: #d9a75b; --nt-soft: #fbf3e5; --nt-ink: #8a5f1c; }
.nt-gray { --nt: #9aa0a3; --nt-soft: #f1f2f2; --nt-ink: #4f5558; }
.cal-chip.cc-sky, .dot.cc-sky, .event-row.cc-sky::before { background: #4fc3cb; }
.tag.cc-sky { background: #e9f8f9; color: #1d6f76; }
.cat-pick { display: flex; flex-direction: row; flex-wrap: wrap; gap: 8px; border: 0; padding: 0; margin: 0; }
.cat-pick > .cat-chip { width: auto; flex: 0 0 auto; }
.cat-pick legend { width: 100%; padding: 0 0 6px; font-size: 0.9rem; font-weight: 500; color: var(--ink-2); }
.cat-chip { flex-direction: row; display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 0.88rem; font-weight: 500; color: var(--nt-ink, var(--ink-2)); background: var(--nt-soft, var(--surface-2)); border: 1.5px solid transparent; padding: 7px 14px 7px 10px; border-radius: 999px; text-decoration: none; }
.cat-chip::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--nt, var(--faint)); }
.cat-chip input { position: absolute; opacity: 0; pointer-events: none; }
.cat-chip:has(input:checked) { border-color: var(--nt); background: color-mix(in srgb, var(--nt) 22%, var(--surface)); font-weight: 700; }
.cat-chip-add { color: var(--accent-ink); background: transparent; border: 1.5px dashed var(--line-strong); }
.cat-chip-add::before { display: none; }
.cat-chip-add:hover { text-decoration: none; border-color: var(--accent); }
/* Property ที่ตั้งเอง: ป้ายสีเล็กบนการ์ด + ช่องในฟอร์ม + หน้าตั้งค่า */
.prop-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.prop-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 0.72rem; font-weight: 600; line-height: 1.5; color: var(--nt-ink, var(--ink-2)); background: var(--nt-soft, var(--surface-2)); padding: 1px 8px 1px 6px; border-radius: 999px; white-space: nowrap; }
.prop-chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--nt, var(--faint)); }
summary .prop-chip { margin-left: 2px; }
.prop-fields { display: flex; flex-direction: column; gap: 14px; }
.prop-fields > .cat-chip-add { align-self: flex-start; font-size: 0.82rem; padding: 5px 12px; }
.opt-rows { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; }
.opt-rows legend { padding: 0 0 4px; font-size: 0.9rem; font-weight: 500; color: var(--ink-2); }
.opt-row { display: grid; grid-template-columns: 1fr 130px; gap: 8px; }
.cal-add { margin-left: auto; font-size: 0.74rem; font-weight: 600; color: var(--accent-ink); text-decoration: none; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); }
.cal-add:hover { text-decoration: none; filter: brightness(0.97); }
.week-date { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.week-date .cal-add { margin-left: 0; }

/* หน้าต่างรายการของวัน (กดวันที่ในปฏิทิน) — คอม = การ์ดกลางจอ, มือถือ = แผ่นเลื่อนขึ้นจากล่าง */
.daysheet {
  width: min(420px, 92vw); max-height: min(78vh, 640px); margin: auto; padding: 0; border: 1px solid var(--line); border-radius: 20px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg, 0 24px 48px -20px rgba(0, 0, 0, 0.35));
  flex-direction: column; overflow: hidden;
}
.daysheet:popover-open { display: flex; animation: postit-in 0.18s var(--ease, ease-out); }
.daysheet::backdrop { background: rgba(20, 20, 22, 0.28); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.daysheet-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 16px 10px; border-bottom: 1px solid var(--line); }
.daysheet-title { margin: 0 0 2px; font-size: 1.08rem; font-weight: 700; letter-spacing: -0.01em; }
.daysheet-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 6px; -webkit-overflow-scrolling: touch; }
.daysheet-list .event-row { margin-bottom: 0; }
.daysheet-empty { margin: 8px 0; color: var(--muted); font-size: 0.9rem; text-align: center; }
.daysheet-foot { padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
.daysheet-add {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; border-radius: 12px;
  font-weight: 700; font-size: 0.95rem; color: var(--on-accent, #fff); background: var(--accent); text-decoration: none;
}
.daysheet-add span { font-size: 1.25rem; line-height: 1; }
.daysheet-add:hover { text-decoration: none; filter: brightness(1.05); }
.daysheet-extra { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; font-size: 0.84rem; }
@media (max-width: 640px) {
  .daysheet { width: 100%; max-width: 100%; min-height: 62vh; max-height: 88vh; max-height: 88dvh; margin: auto 0 0; border-radius: 20px 20px 0 0; border-bottom: 0; }
  .daysheet:popover-open { animation: sheet-up 0.22s var(--ease, ease-out); }
  .daysheet-top::before { content: ''; position: absolute; left: 50%; top: 6px; width: 38px; height: 4px; margin-left: -19px; border-radius: 4px; background: var(--line-strong, var(--line)); }
  .daysheet-top { position: relative; padding-top: 20px; }
}
@keyframes sheet-up { from { transform: translateY(100%); } }
.week-list { display: flex; flex-direction: column; }
.week-day { display: grid; grid-template-columns: 86px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.week-day:first-child { border-top: 0; }
.week-date { font-size: 0.8rem; font-weight: 600; color: var(--muted); padding-top: 7px; }
.week-day.today .week-date { color: var(--accent-ink); }
.week-notes { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.week-empty { font-size: 0.8rem; color: var(--faint); padding-top: 7px; }
.postit {
  width: min(340px, 90vw); margin: auto; border: 1px solid color-mix(in srgb, var(--nt) 30%, transparent); padding: 18px 18px 16px; color: var(--ink);
  background: linear-gradient(180deg, var(--nt-soft), var(--surface) 85%); border-radius: 20px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 24px 48px -20px color-mix(in srgb, var(--nt) 55%, rgba(0, 0, 0, 0.3));
}
.postit:popover-open { animation: postit-in 0.18s var(--ease, ease-out); }
@keyframes postit-in { from { opacity: 0; transform: translateY(8px) scale(0.97); } }
.postit::backdrop { background: rgba(20, 20, 22, 0.28); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.postit-top { display: flex; align-items: center; justify-content: space-between; }
.postit-cat { display: inline-flex; align-items: center; gap: 6px; font-size: 0.74rem; font-weight: 600; color: var(--nt-ink); background: color-mix(in srgb, var(--nt) 16%, transparent); padding: 3px 10px 3px 8px; border-radius: 999px; }
.postit-cat::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--nt); }
.postit-x { border: 0; background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--muted); width: 28px; height: 28px; border-radius: 50%; font-size: 1.1rem; line-height: 1; cursor: pointer; }
.postit-x:hover { color: var(--ink); }
.postit-title { font-family: var(--font); font-size: 1.2rem; font-weight: 700; margin: 12px 0 14px; line-height: 1.3; letter-spacing: -0.01em; }
.postit-info { display: grid; grid-template-columns: 64px 1fr; gap: 9px 10px; margin: 0; font-size: 0.88rem; }
.postit-info dt { color: var(--muted); font-size: 0.8rem; padding-top: 1px; }
.postit-info dd { margin: 0; font-weight: 500; white-space: pre-wrap; }
.postit-open { display: block; margin-top: 16px; text-align: center; padding: 10px; border-radius: 12px; font-size: 0.88rem; font-weight: 600; color: #fff; background: var(--nt); text-decoration: none; }
.postit-open:hover { text-decoration: none; filter: brightness(1.04); }
.agenda-day { margin-bottom: 8px; }
.agenda-date { font-size: 0.8rem; font-weight: 600; color: var(--muted); margin: 6px 2px 4px; }

/* เงินเดือนพนักงาน */
.pay-hero { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0 12px; }
.pay-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.pay-box-future { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.pay-num { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
@media (max-width: 420px) { .pay-hero { grid-template-columns: 1fr; } }

/* ประกาศด่วน: บังหน้าจอจนกว่าจะกดรับทราบ */
.urgent { position: fixed; inset: 0; z-index: 1500; display: grid; place-items: center; padding: 16px; background: rgba(10, 10, 10, 0.62); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.urgent-box { width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; background: var(--surface); color: var(--ink); border-radius: 18px; padding: 22px 20px 16px; box-shadow: var(--shadow-lg); border-top: 6px solid var(--red); animation: pop-in 0.15s ease-out; }
.urgent-badge { display: inline-block; background: var(--red-soft); color: var(--red-ink); font-weight: 700; font-size: 0.85rem; padding: 3px 10px; border-radius: 999px; margin-bottom: 8px; }
.urgent-box h2 { font-size: 1.45rem; margin: 4px 0 8px; }
.urgent-ok { min-height: 50px; font-size: 1.05rem; margin-top: 8px; }
.ack-list { list-style: none; padding: 0; margin: 4px 0 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 12px; }
.ack-list li.is-ack { color: var(--green); }
.announce-card.is-closed { opacity: 0.7; }

/* สีหมวดหมู่ปฏิทิน */
.cal-chip.cc-blue, .dot.cc-blue { background: var(--blue); }
.cal-chip.cc-green, .dot.cc-green { background: var(--green); }
.cal-chip.cc-purple, .dot.cc-purple { background: var(--purple); }
.cal-chip.cc-amber, .dot.cc-amber { background: var(--amber); }
.cal-chip.cc-red, .dot.cc-red { background: var(--red); }
.cal-chip.cc-gray, .dot.cc-gray { background: var(--dark-chip); }
.event-row.cc-blue::before { background: var(--blue); }
.event-row.cc-green::before { background: var(--green); }
.event-row.cc-purple::before { background: var(--purple); }
.event-row.cc-amber::before { background: var(--amber); }
.event-row.cc-red::before { background: var(--red); }
.event-row.cc-gray::before { background: var(--dark-chip); }
.tag.cc-blue { background: var(--blue-soft); color: var(--blue); }
.tag.cc-green { background: var(--green-soft); color: var(--green); }
.tag.cc-purple { background: var(--purple-soft); color: var(--purple); }
.tag.cc-amber { background: var(--amber-soft); color: var(--amber); }
.tag.cc-red { background: var(--red-soft); color: var(--red); }
.tag.cc-gray { background: var(--gray-soft); color: var(--muted); }

/* ---------- รายการ ---------- */
.shift { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--line); }
.shift:last-of-type { border-bottom: 0; }
.shift-time { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 110px; }

.monthpicker { display: flex; align-items: center; justify-content: space-between; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin: 8px 0 12px; }
.monthpicker strong { font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 10px; margin: 12px 0; }
.stat { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.stat-num { font-size: 1.55rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { line-height: 1.3; color: var(--muted); font-size: 0.8rem; }
.stat-warn .stat-num { color: var(--red); }

.daylist { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.day { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.day:last-child { border-bottom: 0; }
.day-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 2px; }
.day-tags { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.person { display: flex; align-items: center; gap: 12px; padding: 10px 8px; margin: 0 -8px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; border-radius: 0; }
a.person:hover { background: var(--hover); border-radius: var(--radius-sm); }
.person:last-child { border-bottom: 0; }
.person.is-off { opacity: 0.5; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; flex-shrink: 0;
  background: #e8f6f7; color: #226f77; font-size: 0.95rem;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { background: linear-gradient(135deg, #16343c, #205461); color: #d8eef4; } }
:root[data-theme="dark"] .avatar { background: linear-gradient(135deg, #16343c, #205461); color: #d8eef4; }
.person-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.person-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; }
.quicklinks { display: flex; gap: 8px; flex-wrap: wrap; }

.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); margin: 12px 0; }
.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table th, .table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { color: var(--muted); font-weight: 500; font-size: 0.78rem; background: var(--surface-2); position: sticky; top: 0; }
.table tbody tr:hover td { background: var(--hover); }
.table tr:last-child td { border-bottom: 0; }
.table a { text-decoration: none; font-weight: 600; color: var(--ink); }
.table a:hover { color: var(--accent-ink); }
.table th.num, .table td.num { text-align: right; }

.editlog { list-style: none; padding: 0; margin: 0; }
.editlog li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.editlog li:last-child { border-bottom: 0; }

.iplist { list-style: none; padding: 0; margin: 12px 0; }
.iplist li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }

@media (min-width: 768px) {
  .page { padding-top: 26px; }
  .card { padding: 20px 22px; }
}

/* ---------- งาน ---------- */
.prewrap { white-space: pre-wrap; word-break: break-word; }
.break { word-break: break-all; }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 6px; background: var(--gray-soft); color: var(--muted); font-size: 0.74rem; font-weight: 600; text-align: center; vertical-align: middle; line-height: 1.6; }
.section-title { margin: 24px 0 6px; }
h2.inline { display: inline; margin: 0; }
details > summary { cursor: pointer; }

.tabs { display: inline-flex; gap: 2px; background: var(--surface-3); border-radius: 9px; padding: 3px; margin: 8px 0; width: 100%; }
.tabs a { flex: 1; text-align: center; padding: 6px 14px; border-radius: 7px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: 0.88rem; transition: color 0.15s; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.02); }
@media (min-width: 640px) { .tabs { width: auto; } }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0 14px; }
.filters { display: flex; gap: 8px; flex: 1; min-width: 0; }
.filters select { flex: 1; min-width: 0; padding: 7px 30px 7px 10px; font-size: 0.88rem; min-height: 40px; }

.task-group { margin-bottom: 20px; }
.task-group h2 { font-size: 0.92rem; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.task {
  display: block; background: var(--surface); border-radius: 10px; border: 1px solid var(--line);
  padding: 10px 12px 9px 15px; margin-bottom: 6px; color: inherit; text-decoration: none; position: relative;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.task::before { content: ''; position: absolute; left: 5px; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--blue); }
.task:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.task.tone-red::before { background: var(--red); }
.task.tone-gray::before { background: var(--faint); }
.task.is-done { opacity: 0.6; }
.task.is-done .task-title { text-decoration: line-through; }
.task-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.task-title { font-weight: 500; line-height: 1.45; word-break: break-word; }
.task-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; color: var(--muted); font-size: 0.79rem; margin-top: 3px; }
.meta-project::before { content: '▸ '; color: var(--accent); }
.meta-who::before { content: '@'; opacity: 0.6; margin-right: 1px; }
.flag { display: inline-block; background: var(--red); color: #fff; font-size: 0.68rem; font-weight: 700; padding: 0 6px; border-radius: 5px; margin-right: 6px; vertical-align: 2px; line-height: 1.6; }
.card .task { box-shadow: none; }

.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.pill-todo { background: var(--gray-soft); color: var(--muted); }
.pill-doing { background: var(--blue-soft); color: var(--blue); }
.pill-review { background: var(--purple-soft); color: var(--purple); }
.pill-revise { background: var(--amber-soft); color: var(--amber); }
.pill-done { background: var(--green-soft); color: var(--green); }

.brand-tag { background: var(--gray-soft); color: var(--ink-2); }
.brand-bossnoi { background: var(--accent-soft); color: var(--accent-ink); }
.brand-thebossnoi { background: var(--ink); color: var(--surface); }
.brand-restaurant { background: var(--green-soft); color: var(--green); }

.board { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 12px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scroll-snap-type: x mandatory; scroll-padding: 16px; }
.column { flex: 0 0 84%; max-width: 310px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; scroll-snap-align: start; display: flex; flex-direction: column; }
.column h2 { font-size: 0.9rem; display: flex; align-items: center; gap: 6px; margin: 2px 4px 8px; }
.column-body { min-height: 80px; flex: 1; border-radius: 8px; }
.column .task { margin-bottom: 6px; box-shadow: var(--shadow-xs); }
.column .task-top .pill { display: none; }
.drag-ghost { opacity: 0.4; }
@media (min-width: 900px) {
  .page:has(.board) { max-width: 1400px; }
  .board { margin: 0; padding-left: 0; padding-right: 0; }
  .column { flex: 1 1 0; max-width: none; min-height: 60vh; }
}

.project-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.project-head h1 { margin: 6px 0 2px; }
.project-head p { margin: 2px 0; }
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.project-card { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); padding: 16px; color: inherit; text-decoration: none; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s; }
.project-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.project-card h2 { margin: 2px 0 0; }
.project-card.is-off { opacity: 0.55; }
.project-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 6px; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 0; }
.avatars { display: flex; }
.avatar.sm { width: 26px; height: 26px; font-size: 0.72rem; border: 2px solid var(--surface); margin-left: -6px; }
.avatars .avatar.sm:first-child { margin-left: 0; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
textarea { font: inherit; resize: vertical; }

.task-detail h1 { margin: 8px 0 12px; word-break: break-word; }
.task-detail-head { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.props { display: grid; grid-template-columns: 110px 1fr; gap: 4px 12px; margin: 0 0 12px; align-items: baseline; }
.props dt { color: var(--muted); font-size: 0.86rem; padding: 4px 0; }
.props dd { margin: 0; min-width: 0; padding: 4px 0; }
.note { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; margin: 8px 0; }
.status-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.quick-status { border-top: 1px solid var(--line); padding-top: 12px; }
.comments { list-style: none; padding: 0; margin: 0 0 12px; }
.comments li { display: flex; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.comments li:last-child { border-bottom: 0; }
.comments .avatar.sm { margin-left: 0; border: 0; width: 30px; height: 30px; }
.events { list-style: none; padding: 0; margin: 0; font-size: 0.85rem; border-left: 2px solid var(--line); padding-left: 12px; }
.events li { padding: 4px 0; position: relative; }
.events li::before { content: ''; position: absolute; left: -17px; top: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-strong); }
.person-group h3 { font-size: 0.92rem; margin: 14px 0 6px; }

/* ---------- ปฏิทิน ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.cal-head { text-align: center; font-size: 0.74rem; font-weight: 500; color: var(--muted); padding: 6px 0; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.cal-cell { min-height: 68px; padding: 3px; display: flex; flex-direction: column; gap: 2px; color: inherit; text-decoration: none; overflow: hidden; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); transition: background 0.12s; }
.cal-cell:nth-child(7n) { border-right: 0; }
a.cal-cell:hover { background: var(--hover); }
.cal-cell.is-empty { background: var(--surface-2); }
.cal-cell.is-today .cal-num { background: var(--accent); color: var(--on-accent); }
.cal-cell.is-selected { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.cal-num { font-size: 0.78rem; font-weight: 600; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.cal-chip { font-size: 0.64rem; font-weight: 500; line-height: 1.35; padding: 1px 4px; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; }
.cal-more { font-size: 0.66rem; color: var(--muted); padding-left: 3px; }
.ev-company { background: var(--dark-chip); }
.ev-workshop { background: var(--accent); }
.ev-private { background: var(--purple); }
.tk-blue { background: var(--blue); }
.tk-red { background: var(--red); }
.tk-gray, .tk-done { background: var(--faint); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 2px; }
.legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; vertical-align: 0; }
@media (min-width: 768px) {
  .cal-cell { min-height: 104px; padding: 6px; }
  .cal-chip { font-size: 0.72rem; padding: 1px 6px; }
}

.event-row { display: flex; gap: 12px; align-items: center; padding: 10px 12px 10px 14px; border-radius: 10px; margin-bottom: 6px; background: var(--surface); border: 1px solid var(--line); color: inherit; text-decoration: none; position: relative; transition: border-color 0.15s, background 0.15s; }
.event-row::before { content: ''; position: absolute; left: 5px; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--dark-chip); }
.event-row:hover { background: var(--hover); }
.event-row.ev-company, .event-row.ev-workshop, .event-row.ev-private, .event-row.tk-blue, .event-row.tk-red, .event-row.tk-gray, .event-row.tk-done { background: var(--surface); }
.event-row.ev-workshop::before { background: var(--accent); }
.event-row.ev-private::before { background: var(--purple); }
.event-row.tk-blue::before { background: var(--blue); }
.event-row.tk-red::before { background: var(--red); }
.event-row.tk-gray::before, .event-row.tk-done::before { background: var(--faint); }
.event-time { font-size: 0.8rem; font-weight: 600; min-width: 74px; color: var(--muted); font-variant-numeric: tabular-nums; }
.event-main { display: flex; flex-direction: column; min-width: 0; }
.ev-tag-company { background: var(--dark-chip); color: #fff; }
.ev-tag-workshop { background: var(--accent); color: var(--on-accent); }
.ev-tag-private { background: var(--purple); color: #fff; }

/* ---------- นักเรียน workshop ---------- */
.students { list-style: none; padding: 0; margin: 0 0 12px; }
.student { display: flex; justify-content: space-between; gap: 10px; padding: 12px 8px; margin: 0 -8px; border-bottom: 1px solid var(--line); flex-wrap: wrap; border-radius: 6px; }
.student-main { display: flex; flex-direction: column; min-width: 0; flex: 1 1 180px; }
.att-buttons { display: flex; gap: 6px; align-items: flex-start; flex-wrap: wrap; }
.att-btn { min-height: 36px; padding: 5px 12px; font-size: 0.85rem; }
.att-btn.on-present { background: var(--green); border-color: var(--green); color: #fff; }
.att-btn.on-absent { background: var(--red); border-color: var(--red); color: #fff; }
.student.att-present { background: linear-gradient(90deg, var(--green-soft), transparent 60%); }
.student.att-absent { background: linear-gradient(90deg, var(--red-soft), transparent 60%); }
.student-edit { width: 100%; }
.student-edit summary { color: var(--muted); padding: 4px 0; font-size: 0.86rem; }
.add-student > summary { list-style: none; }
.add-student > summary::-webkit-details-marker { display: none; }

/* ---------- แจ้งเตือน ---------- */
.bell { position: relative; color: var(--ink-2); display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; transition: background 0.15s; }
.bell:hover { background: var(--hover); color: var(--ink); }
.bell .ico { width: 20px; height: 20px; }
.bell-badge { position: absolute; top: 3px; right: 2px; background: var(--accent); color: var(--on-accent); font-size: 0.64rem; font-weight: 700; min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; border: 2px solid var(--surface); box-sizing: content-box; line-height: 1; }
.notif-list { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.notif-list li + li { border-top: 1px solid var(--line); }
.notif-list li a { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; color: inherit; text-decoration: none; position: relative; }
.notif-list li a:hover { background: var(--hover); }
.notif-list li.is-new a { background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }
.notif-list li.is-new a::after { content: ''; position: absolute; right: 14px; top: 18px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.notif-list .avatar.sm { margin-left: 0; border: 0; width: 32px; height: 32px; }
.notif-main { display: flex; flex-direction: column; padding-right: 16px; }

/* ---------- ไฟล์ (แบบ Google Drive) ---------- */
.drive-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 2px 0 6px; }
.drive-head h1 { margin: 0; flex: 1; min-width: 0; }
.drive-actions { display: flex; align-items: center; gap: 8px; }
.drive-new { position: relative; }
.drive-new > summary {
  list-style: none; display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 9px 18px 9px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(60, 64, 67, 0.15), 0 4px 8px rgba(60, 64, 67, 0.08); font-weight: 600; font-size: 0.92rem; color: var(--ink);
  transition: box-shadow 0.15s, background 0.15s; -webkit-tap-highlight-color: transparent;
}
.drive-new > summary:hover { background: var(--surface-2); box-shadow: 0 1px 3px rgba(60, 64, 67, 0.2), 0 6px 14px rgba(60, 64, 67, 0.12); }
.drive-new > summary::-webkit-details-marker { display: none; }
.drive-new > summary .plus { font-size: 1.35rem; line-height: 1; color: var(--accent); font-weight: 400; }
.drive-menu {
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 25; min-width: 260px;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; animation: pop-in 0.12s ease-out;
}
.drive-menu-item { display: flex; flex-direction: row; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 7px; cursor: pointer; font-weight: 500; font-size: 0.9rem; color: var(--ink); text-decoration: none; }
.drive-menu-item:hover { background: var(--hover); }
.drive-menu-item .ico { width: 20px; height: 20px; color: var(--muted); }
.drive-menu-item input[type=file] { display: none; }
.drive-menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.drive-menu form { padding: 6px 8px 8px; }
.drive-menu .stack { margin-top: 4px; gap: 10px; }
@media (max-width: 560px) {
  .drive-menu { position: fixed; left: 8px; right: 8px; top: auto; bottom: calc(68px + env(safe-area-inset-bottom)); min-width: 0; max-height: 70vh; overflow-y: auto; z-index: 45; }
  .drive-new[open]::before { content: ''; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.3); z-index: 44; }
}

.view-toggle { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; background: var(--surface); }
.view-toggle button { border: 0; background: none; padding: 5px 12px; cursor: pointer; color: var(--muted); display: grid; place-items: center; min-height: 34px; }
.view-toggle button + button { border-left: 1px solid var(--line-strong); }
.view-toggle button.on { background: var(--accent-soft); color: var(--accent-ink); }
.view-toggle .ico { width: 18px; height: 18px; }

.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; font-size: 0.9rem; color: var(--muted); margin: 0 0 4px -6px; }
.crumbs a { color: var(--muted); text-decoration: none; padding: 3px 8px; border-radius: 7px; }
.crumbs a:hover { background: var(--hover); color: var(--ink); }
.crumbs .sep { color: var(--faint); font-size: 0.9rem; }
.crumbs .here { color: var(--ink); font-weight: 600; padding: 3px 8px; }
.drive-crumbs { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; margin: 4px 0 8px -8px; }
.drive-crumbs a { padding: 4px 10px; border-radius: 10px; }
.drive-crumbs .here { color: var(--ink); padding: 4px 10px; }
.drive-crumbs .sep { font-size: 1.1rem; }
.drive-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: 0 0 6px; }

.drive-section { margin: 18px 0 10px; font-size: 0.86rem; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin: 8px 0; }
.folder-tile {
  display: flex; align-items: center; gap: 12px; background: var(--surface-2); border-radius: 12px; padding: 12px 14px;
  color: var(--ink); text-decoration: none; border: 1px solid transparent; min-width: 0; transition: background 0.15s, box-shadow 0.15s;
}
.folder-tile:hover { background: var(--surface-3); }
.folder-tile:active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.folder-tile strong { font-weight: 500; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.folder-tile .folder-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.folder-ico { flex-shrink: 0; width: 22px; height: 22px; color: var(--muted); line-height: 1; }
.folder-ico svg { width: 22px; height: 22px; display: block; }
.folder-tile.is-shared .folder-ico { color: var(--accent); }

/* ไฟล์: มุมมองรายการ */
.file-list { list-style: none; padding: 0; margin: 0; }
.file-list-head { display: none; }
.file-row { display: flex; gap: 12px; align-items: center; padding: 9px 4px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.file-row:hover { background: var(--hover); }
.file-list li:last-child .file-row { border-bottom: 0; }
.file-ico { width: 34px; height: 34px; display: grid; place-items: center; flex-shrink: 0; font-size: 1.3rem; }
.file-ico svg { width: 26px; height: 26px; display: block; }
.file-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.file-main strong { font-weight: 500; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; word-break: normal; }
.file-col { display: none; color: var(--muted); font-size: 0.84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-thumb { display: none; }
.drive-files { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 2px 10px; }
@media (min-width: 720px) {
  .drive-files .file-list-head, .drive-files .file-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px 120px 90px; gap: 12px; align-items: center; }
  .drive-files .file-list-head { padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: 0.8rem; font-weight: 500; color: var(--muted); }
  .drive-files .file-row > .file-name { display: flex; align-items: center; gap: 12px; min-width: 0; }
  .drive-files .file-col { display: block; }
  .drive-files .file-main .muted { display: none; }
  .drive-files .file-col.num { text-align: right; }
}
.file-row > .file-name { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }

/* ไฟล์: มุมมองตาราง (grid) */
.drive-files[data-view=grid] { background: none; border: 0; padding: 0; }
.drive-files[data-view=grid] .file-list-head { display: none; }
.drive-files[data-view=grid] .file-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
@media (min-width: 720px) { .drive-files[data-view=grid] .file-list { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; } }
.drive-files[data-view=grid] .file-row {
  display: flex; flex-direction: column-reverse; align-items: stretch; gap: 0; padding: 0; border: 1px solid var(--line);
  background: var(--surface-2); border-radius: 12px; overflow: hidden; height: 100%; transition: background 0.15s, box-shadow 0.15s;
}
.drive-files[data-view=grid] .file-row:hover { background: var(--surface-3); box-shadow: var(--shadow); }
.drive-files[data-view=grid] .file-col { display: none; }
.drive-files[data-view=grid] .file-row > .file-name { padding: 10px 12px; gap: 10px; }
.drive-files[data-view=grid] .file-name .file-ico { width: 22px; height: 22px; }
.drive-files[data-view=grid] .file-name .file-ico svg { width: 20px; height: 20px; }
.drive-files[data-view=grid] .file-main .muted { display: block; font-size: 0.74rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drive-files[data-view=grid] .file-main strong { font-size: 0.86rem; }
.drive-files[data-view=grid] .file-thumb {
  display: grid; place-items: center; aspect-ratio: 4 / 3; margin: 0 8px; border-radius: 8px; background: var(--surface); overflow: hidden;
}
.drive-files[data-view=grid] .file-thumb svg { width: 56px; height: 56px; }
.drive-files[data-view=grid] .file-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* อัปโหลด */
.dropzone {
  display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 10px; padding: 16px; border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius); background: var(--surface); cursor: pointer; text-align: left; font-weight: 400; color: var(--ink); transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover { border-color: var(--faint); background: var(--surface-2); }
.dropzone > span:not(.dz-ico) { display: flex; flex-direction: column; }
.dropzone .dz-ico { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); flex-shrink: 0; }
.dropzone .dz-ico .ico { width: 20px; height: 20px; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { display: none; }
.dropzone strong { color: var(--ink); font-weight: 600; }

.drop-overlay {
  position: fixed; inset: 0; z-index: 60; display: none; place-items: center; pointer-events: none;
  background: color-mix(in srgb, var(--accent) 10%, transparent); border: 3px solid var(--accent); border-radius: 4px;
}
.drop-overlay.show { display: grid; }
.drop-overlay div {
  background: var(--accent); color: var(--on-accent); padding: 12px 22px; border-radius: 999px; font-weight: 600; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px; animation: pop-in 0.15s ease-out;
}
.drop-overlay .ico { width: 20px; height: 20px; }

/* แผงความคืบหน้า (มุมขวาล่างแบบ Drive) */
.up-panel {
  position: fixed; z-index: 50; right: 16px; bottom: calc(140px + env(safe-area-inset-bottom)); width: min(380px, calc(100vw - 16px));
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; animation: pop-in 0.15s ease-out;
}
@media (max-width: 560px) { .up-panel { right: 8px; left: 8px; width: auto; } }
@media (min-width: 1024px) { .up-panel { bottom: 88px; right: 24px; } }
.up-panel-head { display: flex; align-items: center; gap: 6px; padding: 10px 8px 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.up-panel-title { flex: 1; font-weight: 600; font-size: 0.92rem; }
.up-panel-head button { border: 0; background: none; color: var(--muted); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 1rem; display: grid; place-items: center; }
.up-panel-head button:hover { background: var(--hover); color: var(--ink); }
.up-panel-bar { height: 3px; background: var(--surface-3); }
.up-panel-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }
.up-panel:not(.busy) .up-panel-bar i { background: var(--green); }
.up-panel.min .upload-list { display: none; }
.up-panel.min .up-min { transform: rotate(180deg); }
.up-panel .upload-list { max-height: 300px; overflow-y: auto; margin: 0; }
.upload-list { list-style: none; padding: 0; margin: 8px 0; }
.upload-list li { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.upload-list li:last-child { border-bottom: 0; }
.up-body { flex: 1; min-width: 0; }
.up-name { font-weight: 500; font-size: 0.86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-status { font-size: 0.76rem; }
.up-status a { font-weight: 600; }
.up-ring { width: 26px; height: 26px; flex-shrink: 0; position: relative; display: grid; place-items: center; }
.up-ring svg { width: 26px; height: 26px; transform: rotate(-90deg); }
.up-ring circle { fill: none; stroke-width: 3; }
.up-ring .trk { stroke: var(--surface-3); }
.up-ring .val { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 0.3s; }
.up-ring .mark { position: absolute; inset: 0; display: none; place-items: center; border-radius: 50%; color: #fff; font-size: 0.8rem; font-weight: 700; }
.upload-list li.done .up-ring .mark { display: grid; background: var(--green); }
.up-cancel { border: 0; background: none; color: var(--muted); width: 28px; height: 28px; border-radius: 50%; cursor: pointer; flex-shrink: 0; display: grid; place-items: center; }
.up-cancel:hover { background: var(--red-soft); color: var(--red); }
.upload-list li.done .up-cancel, .upload-list li.failed .up-cancel, .upload-list li.cancelled .up-cancel { display: none; }
.upload-list li.cancelled { opacity: 0.6; }
.upload-list li.failed .up-ring .mark { display: grid; background: var(--red); }
.upload-list li.done .up-ring svg, .upload-list li.failed .up-ring svg { visibility: hidden; }
.upload-list li.failed .up-status { color: var(--red); }
.bar { height: 4px; background: var(--surface-3); border-radius: 3px; overflow: hidden; margin: 5px 0 3px; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }
.upload-list li.done .bar span { background: var(--green); }
.upload-list li.failed .bar span { background: var(--red); }

.viewer { background: #0f0f0f; border-radius: var(--radius); overflow: hidden; margin: 8px 0; display: flex; justify-content: center; }
.viewer video, .viewer img { width: 100%; max-height: 72vh; object-fit: contain; display: block; }
.viewer audio { width: 100%; margin: 20px; }
.viewer iframe { width: 100%; height: 75vh; border: 0; background: #fff; }
.viewer-none { color: #bbb; padding: 48px 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; font-size: 2rem; }
.viewer-none svg { width: 72px; height: 72px; }
.viewer-none span { font-size: 0.9rem; }
.timecode { background: var(--accent); color: var(--on-accent); border: 0; border-radius: 6px; font: inherit; font-size: 0.74rem; font-weight: 700; padding: 1px 7px; margin-right: 6px; cursor: pointer; font-variant-numeric: tabular-nums; }
.comments li.is-resolved { opacity: 0.5; }
.grow { flex: 1; min-width: 0; }
.rec-preview { width: 100%; border-radius: var(--radius); background: #111; aspect-ratio: 16 / 9; }
.new-folder > summary { list-style: none; }
.new-folder > summary::-webkit-details-marker { display: none; }

/* ---------- Whiteboard ---------- */
.board-page { margin: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.board-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--surface); color: var(--ink); border-bottom: 1px solid var(--line); }
.board-back { color: var(--ink); text-decoration: none; font-size: 1.6rem; line-height: 1; padding: 0 6px; border-radius: 6px; }
.board-back:hover { background: var(--hover); }
.board-title-form { flex: 1; min-width: 0; }
.board-title-form input:not([type=checkbox]) { background: transparent; border: 1px solid transparent; color: var(--ink); font-size: 1.02rem; font-weight: 600; padding: 5px 8px; width: 100%; }
.board-title-form input:not([type=checkbox]):focus { background: var(--surface-2); outline: none; }
.board-status { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.board-status.ok { color: var(--green); }
.board-status.err { color: var(--red); }
.board-del { background: none; border: 0; cursor: pointer; font-size: 1.1rem; }
#board { flex: 1; min-height: 0; }
.board-thumb { font-size: 1.8rem; color: var(--accent); }

/* ---------- เงินเดือน ---------- */
.num { text-align: right; font-variant-numeric: tabular-nums; }
.slip { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); padding: 20px; margin: 12px 0; position: relative; overflow: hidden; }
.slip::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: linear-gradient(90deg, var(--accent), #7ee3f3); }
.slip-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.slip-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.slip-table td { padding: 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.slip-sec td { font-weight: 600; color: var(--muted); font-size: 0.8rem; padding-top: 16px; border-bottom: 0; }
.slip-total td { font-weight: 600; }
.slip-net td { font-size: 1.25rem; font-weight: 700; border-bottom: 0; padding-top: 12px; color: var(--accent-ink); }
.pay-list { list-style: none; padding: 0; margin: 0 0 10px; }
.pay-list li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.pay-list li:last-child { border-bottom: 0; }

/* ---------- Dashboard ---------- */
.chart { margin: 0; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { font-size: 11px; fill: var(--muted); font-family: var(--font); }
.chart .bar { fill: var(--accent); }
.chart .hit { fill: transparent; }
.chart .bar-g:hover .hit { fill: var(--hover); }
.chart .bar-g:hover .bar { fill: var(--accent-hover); }
.hbars { list-style: none; padding: 0; margin: 0; }
.hbars li { padding: 8px 0; }
.hbar-label { display: flex; justify-content: space-between; gap: 10px; font-size: 0.9rem; }
.hbar { height: 8px; background: var(--surface-3); border-radius: 4px; margin: 5px 0 2px; overflow: hidden; }
.hbar span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.link-card { display: flex; justify-content: space-between; align-items: center; color: inherit; text-decoration: none; transition: border-color 0.15s, box-shadow 0.15s; }
.link-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.link-card h2 { margin: 0; }
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.person-card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.person-card-head { display: flex; align-items: center; gap: 10px; }
.mini-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; text-align: center; font-size: 0.7rem; color: var(--muted); }
.mini-stats span { background: var(--surface-2); border-radius: 8px; padding: 6px 2px; display: flex; flex-direction: column; }
.mini-stats b { font-size: 1.05rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.mini-stats .warn b { color: var(--red); }
.current { list-style: none; padding: 0; margin: 0; }
.current li a { display: flex; gap: 6px; align-items: baseline; padding: 4px 0; color: inherit; text-decoration: none; font-size: 0.88rem; flex-wrap: wrap; }
.current li a:hover { color: var(--accent-ink); }
.person-card-foot { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 8px; margin-top: auto; }
.stats-wide { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stats-wide .stat-num { font-size: clamp(1.1rem, 5vw, 1.45rem); word-break: break-all; }
.change { font-size: 0.8rem; font-weight: 600; }

/* ---------- Ally ผู้ช่วย AI ---------- */
.ally-fab {
  position: fixed; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 30;
  width: 52px; height: 52px; border-radius: 50%; border: 0; cursor: pointer;
  background: #1c1c1c; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(255, 255, 255, 0.06) inset; display: grid; place-items: center;
  transition: transform 0.15s, box-shadow 0.15s; -webkit-tap-highlight-color: transparent;
}
.ally-fab:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28); }
.ally-fab:active { transform: scale(0.95); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ally-fab { background: #2e2e2e; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1) inset; } }
:root[data-theme="dark"] .ally-fab { background: #2e2e2e; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1) inset; }
@media (min-width: 1024px) { .ally-fab { bottom: 24px; right: 24px; } }
.ally-fab-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); display: inline-block; box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.25); flex-shrink: 0; }
.ally-panel {
  position: fixed; right: 16px; bottom: calc(140px + env(safe-area-inset-bottom)); z-index: 31;
  width: min(400px, calc(100vw - 32px)); height: min(560px, calc(100vh - 210px));
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg);
  display: none; flex-direction: column; overflow: hidden;
}
@media (min-width: 1024px) { .ally-panel:not(.ally-panel-full) { bottom: 88px; right: 24px; height: min(600px, calc(100vh - 160px)); } }
.ally-panel.open { display: flex; animation: pop-in 0.15s ease-out; }
.ally-panel-full { position: static; width: auto; height: calc(100vh - 240px); height: calc(100dvh - 240px); min-height: 380px; box-shadow: none; border: 1px solid var(--line); margin-bottom: 16px; }
.ally-head { display: flex; align-items: center; gap: 2px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.ally-title { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.ally-title .ally-fab-dot { width: 10px; height: 10px; box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.2); }
.ally-status { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ally-icon-btn { border: 0; background: none; font-size: 1rem; padding: 6px 8px; border-radius: 8px; cursor: pointer; color: var(--ink-2); min-width: 32px; }
.ally-icon-btn:hover { background: var(--hover); color: var(--ink); }
a.ally-icon-btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
/* ปุ่มแตะคัดลอก (เบอร์ เลขบัญชี รหัส) ในข้อความ Ally */
.ally-copy { display: inline-flex; align-items: center; gap: 6px; margin: 2px 0; padding: 3px 10px; border: 1px solid var(--accent); border-radius: 999px; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--ink); font: inherit; font-variant-numeric: tabular-nums; letter-spacing: .02em; cursor: pointer; user-select: all; -webkit-tap-highlight-color: transparent; }
.ally-copy .ally-copy-ico { font-size: .85em; color: var(--accent); }
.ally-copy:active { transform: scale(.97); }
.ally-copy.done { background: var(--accent); color: #fff; border-color: var(--accent); }
.ally-copy.done .ally-copy-ico { color: #fff; }
.ally-copy.done .ally-copy-ico::before { content: '✓ '; }
.ally-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.ally-msg { max-width: 85%; padding: 8px 12px; border-radius: 16px; line-height: 1.55; word-wrap: break-word; font-size: 0.92rem; }
.ally-msg p { margin: 0.3em 0; }
.ally-user { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 5px; }
.ally-user a { color: var(--on-accent); }
.ally-ally { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.ally-msg.pending::after { content: '…'; animation: ally-blink 1s infinite; }
.ally-error { background: var(--red-soft); color: var(--red-ink); border-color: transparent; }
.ally-input { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); align-items: flex-end; background: var(--surface); }
.ally-input textarea { flex: 1; resize: none; border: 1px solid var(--line-strong); border-radius: 20px; padding: 9px 14px; font: inherit; max-height: 120px; }
.ally-mic, .ally-send { width: 40px; height: 40px; flex: none; border-radius: 50%; border: 0; cursor: pointer; font-size: 1.05rem; touch-action: none; user-select: none; -webkit-user-select: none; transition: transform 0.1s, background 0.15s, box-shadow 0.2s; }
.ally-mic:active, .ally-send:active { transform: scale(0.94); }
.ally-send { background: var(--accent); color: var(--on-accent); }
/* ปุ่มไมค์: วงกลมฟ้าไล่เฉด มีแสงเรือง */
.ally-mic {
  width: 44px; height: 44px; display: grid; place-items: center; color: #fff;
  background: radial-gradient(circle at 32% 26%, #8ff0ff 0%, #22c7e3 38%, #0891b2 78%, #0b6378 100%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18) inset, 0 6px 16px rgba(8, 145, 178, 0.38), 0 0 0 4px rgba(var(--accent-rgb), 0.12);
}
.ally-mic svg { width: 46%; height: 46%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25)); }
.ally-mic svg rect { fill: currentColor; }
.ally-panel.listening .ally-mic { animation: ally-pulse 1.2s ease-out infinite; transform: scale(1.06); }
.ally-token { display: block; padding: 10px; margin: 6px 0; user-select: all; }
.ally-devices summary { cursor: pointer; font-weight: 600; }
.ally-devices .row { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-top: 8px; }
.ally-devices input { flex: 1; }
@keyframes ally-blink { 50% { opacity: 0.2; } }
@keyframes ally-pulse { 0% { box-shadow: 0 0 0 0 rgba(34, 199, 227, 0.55), 0 6px 16px rgba(8, 145, 178, 0.4); } 100% { box-shadow: 0 0 0 18px rgba(34, 199, 227, 0), 0 6px 16px rgba(8, 145, 178, 0.4); } }
.ally-rate { font-size: 0.78rem; font-weight: 600; min-width: 44px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.drive-menu-label { cursor: default; padding-bottom: 2px; }
.drive-menu-label:hover { background: none; }
.uploader > .upload-list:empty { display: none; }
.drive-head .drive-crumbs { flex: 1; min-width: 0; }

/* Ally แบบแอปบนมือถือ: เต็มจอ ไม่มีเมนูอื่น */
body.ally-app .topbar, body.ally-app .sidenav, body.ally-app .bottomnav, body.ally-app .ally-devices, body.ally-app .ally-fab { display: none !important; }
body.ally-app main.page { padding: 0; margin: 0; max-width: none; }
html:has(body.ally-app), body.ally-app { overflow: hidden; overscroll-behavior: none; height: 100%; }
/* แผงเต็มจอ ความสูงตามพื้นที่ที่มองเห็น (JS ปรับตอนแป้นพิมพ์ขึ้น) แถบชื่อเลยไม่เลื่อนหาย */
body.ally-app .ally-panel-full {
  position: fixed; top: 0; left: 0; right: 0; width: auto; height: 100dvh; min-height: 0; margin: 0; border: 0; border-radius: 0; z-index: 40;
  padding-top: env(safe-area-inset-top); will-change: transform;
}
body.ally-app .ally-head { flex: none; }
body.ally-app .ally-log { overscroll-behavior: contain; touch-action: manipulation; -webkit-user-select: text; }
body.ally-app .ally-input { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
body.ally-app .ally-send { display: none; }
/* ม่านตอนกำลังฟัง */
.ally-veil { display: none; }
body.ally-app .ally-panel.listening .ally-veil {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  position: absolute; inset: 0; z-index: 3; border: 0; cursor: pointer; font: inherit; color: var(--ink);
  background: color-mix(in srgb, var(--surface) 82%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  animation: pop-in 0.15s ease-out;
}
.ally-veil-text { text-align: center; font-size: 1.15rem; font-weight: 600; line-height: 1.5; }
.ally-veil-text small { font-size: 0.85rem; font-weight: 400; color: var(--muted); }

body.ally-app .ally-head { padding-top: 10px; padding-bottom: 10px; }
body.ally-app .ally-log { padding: 16px; }
/* แถวเดียว: ช่องพิมพ์ · ไมค์ · ส่ง (ประหยัดพื้นที่) */
body.ally-app .ally-input { padding-top: 10px; padding-left: 12px; padding-right: 12px; gap: 10px; align-items: center; }
body.ally-app .ally-input textarea { font-size: 16px; min-width: 0; }
body.ally-app .ally-mic { width: 52px; height: 52px; }
body.ally-app .ally-send { width: 44px; height: 44px; }
body.ally-app .flash { position: fixed; top: calc(60px + env(safe-area-inset-top)); left: 12px; right: 12px; z-index: 50; }
.ally-sheet {
  display: none; position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; flex-direction: column; gap: 10px;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0; box-shadow: var(--shadow-lg);
}
.ally-sheet.open { display: flex; }
.ally-sheet label { font-weight: 600; }
.ally-sheet select { font-size: 16px; }
.ally-sheet .btn { justify-content: center; text-align: center; }
@media (max-width: 767px) {
  .ally-panel-full .ally-send { width: 48px; height: 48px; }
  .ally-panel-full .ally-input textarea { font-size: 16px; }
}
.ally-fab[hidden] { display: none; }
.ally-connect label { display: flex; flex-direction: column; gap: 6px; }
.ally-connect label > span:first-child { display: flex; gap: 8px; align-items: center; font-weight: 600; }
body.ally-app .ally-sheet .btn + .btn { margin-top: -2px; }
.ally-handbook { width: 100%; font: inherit; font-size: 0.86rem; line-height: 1.55; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink); resize: vertical; }
.ally-usage { text-align: center; padding: 2px 0; }
.ally-usage-log { text-align: left; margin-top: 8px; }
.ally-usage-log summary { cursor: pointer; text-align: center; }
.ally-usage-row { display: flex; flex-direction: column; gap: 1px; padding: 6px 0; border-top: 1px solid var(--line); }
.ally-usage-row.hi .ally-usage-meta { color: var(--red); font-weight: 600; }
.ally-usage-text { overflow-wrap: anywhere; opacity: .85; }
.mini-stats.three { grid-template-columns: repeat(3, 1fr); margin-bottom: 10px; }
.link-card > strong { white-space: nowrap; margin-right: 10px; }

/* เจ้าของกำลังเข้าในชื่อพนักงาน: แถบเตือนติดล่างจอตลอด กดกลับบัญชีตัวเองได้ */
.impersonate-bar {
  position: fixed; z-index: 70; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px 14px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--amber-soft); color: var(--amber); border-top: 2px solid var(--amber); font-size: 0.9rem;
}
.impersonate-bar .btn { background: var(--amber); color: #fff; border-color: var(--amber); }
body:has(.impersonate-bar) { padding-bottom: 72px; }
.impersonate-log { margin: 12px 0 0; padding-left: 18px; }

/* =====================================================================
   PREMIUM LAYER — ชั้นหน้าตาแบบแอป Apple (วางท้ายไฟล์ เพื่อทับสไตล์ด้านบน)
   ===================================================================== */

/* ---------- พื้นฐาน / ตัวอักษร ---------- */
html { background: var(--bg); }
body {
  background: var(--page-glow), var(--bg);
  background-attachment: fixed;
  font-size: 15px; letter-spacing: -0.006em;
  font-feature-settings: 'kern', 'cv11';
  text-rendering: optimizeLegibility;
}
h1, .clock-card .clock-now, .clock-btn-label { font-family: var(--font-display); }
h1 { font-size: clamp(1.65rem, 1.2rem + 1.6vw, 2.15rem); font-weight: 700; letter-spacing: -0.028em; line-height: 1.15; margin: 0.4rem 0 1rem; }
h2 { font-size: 1.06rem; font-weight: 600; letter-spacing: -0.016em; }
h3 { letter-spacing: -0.012em; }
.muted { color: var(--muted); }
::selection { background: rgba(var(--accent-rgb), 0.35); }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }
a, .btn, .card, .task, .project-card, .folder-tile, .stat, input, select, textarea, .sidenav a, .bottomnav a { transition: background-color 0.18s var(--ease), border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), transform 0.18s var(--ease), color 0.18s var(--ease); }

/* ---------- แถบบน: กระจกฝ้า ----------
   เบลอไว้ที่ ::before แทนตัวแถบ: Safari บน iPhone ซ่อน/ตัดเมนูที่ห้อยลงจากกล่องที่มี backdrop-filter
   (กดรูปโปรไฟล์แล้วเหมือนกดได้ แต่เมนูไม่ขึ้น) */
.topbar {
  background: transparent;
  -webkit-backdrop-filter: none; backdrop-filter: none;
  border-bottom: 1px solid var(--line);
}
.topbar::before {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
}
.menu-pop { max-height: calc(100dvh - var(--topbar-h) - env(safe-area-inset-top) - 16px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.brand { font-weight: 650; font-size: 0.98rem; letter-spacing: -0.02em; }
.brand-dot {
  width: 26px; height: 26px; border-radius: 8px;
  background: radial-gradient(circle at 50% 50%, var(--bg) 0 18%, transparent 20%), var(--accent-grad);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset, 0 4px 14px rgba(34, 199, 227, 0.35);
}
.brand-dot.big { width: 64px; height: 64px; border-radius: 18px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1) inset, 0 18px 40px rgba(34, 199, 227, 0.35); }
.icon-btn, .bell {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: transparent; border: 0; color: var(--ink-2); cursor: pointer; padding: 0; position: relative;
}
.icon-btn:hover, .bell:hover { background: var(--hover); color: var(--ink); }
.icon-btn .ico, .bell .ico { width: 19px; height: 19px; stroke-width: 1.7; }
.icon-btn .ico-exit { display: none; }
.icon-btn.on .ico-exit { display: block; }
.icon-btn.on .ico-enter { display: none; }
.bell-badge { background: var(--accent); color: #fff; box-shadow: 0 0 0 2px var(--bg); font-size: 0.66rem; min-width: 17px; height: 17px; top: 2px; right: 2px; }
.menu summary { border-radius: 10px; padding: 3px 8px 3px 3px; }
/* พื้นทึบ: เมนูอยู่ในแถบบนที่เบลออยู่แล้ว เบลอซ้อนเบลอไม่ทำงาน → พื้นใสจนอ่านไม่ออก */
.menu-pop {
  background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px;
}
.menu-pop a, .menu-pop .linklike { border-radius: 8px; font-size: 0.9rem; }

/* ---------- เมนูข้าง (คอม) ---------- */
@media (min-width: 1024px) {
  .sidenav {
    background: var(--side);
    -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
    border-right: 1px solid var(--line); padding: 16px 12px;
  }
  .sidenav a { padding: 8px 11px; border-radius: 9px; font-size: 0.9rem; color: var(--ink-2); }
  .sidenav a.active { background: var(--hover); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
  .sidenav a.active .ico { color: var(--accent); }
  .sidenav-label { font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); padding: 20px 11px 6px; }
  .page.has-side { padding-top: 34px; }
}

/* ---------- ไอคอนเมนูมีสี: ไอคอนสีพาสเทล + พื้นรองสีจาง ๆ (วางไว้ท้ายสุดเพื่อให้ชนะกฎเมนูด้านบน) ---------- */
.sidenav a[data-ic] { --ic: var(--nav-ink-2); }
.sidenav a[data-ic="home"] { --ic: var(--ic-rose); }
.sidenav a[data-ic="brain"] { --ic: var(--ic-lilac); }
.sidenav a[data-ic="dashboard"] { --ic: var(--ic-sage); }
.sidenav a[data-ic="tasks"] { --ic: var(--ic-sky); }
.sidenav a[data-ic="projects"] { --ic: var(--ic-honey); }
.sidenav a[data-ic="files"] { --ic: var(--ic-blue); }
.sidenav a[data-ic="team"] { --ic: var(--ic-pink); }
.sidenav a[data-ic="sale"] { --ic: var(--ic-coral); }
.sidenav a[data-ic="sales"] { --ic: var(--ic-sage); }
.sidenav a[data-ic="saleslog"] { --ic: var(--ic-sage); }
.sidenav a[data-ic="analytics"] { --ic: var(--ic-lilac); }
.sidenav a[data-ic="workshops"] { --ic: var(--ic-honey); }
.sidenav a[data-ic="payroll"] { --ic: var(--ic-blue); }
.sidenav a[data-ic="history"] { --ic: var(--ic-sky); }
.sidenav a[data-ic="pay"] { --ic: var(--ic-sage); }
.sidenav a[data-ic="announce"] { --ic: var(--ic-coral); }
.sidenav a[data-ic="settings"] { --ic: var(--ic-pink); }
.sidenav a[data-ic="ally"] { --ic: var(--accent); }
.sidenav a[data-ic] .ico {
  color: var(--ic);
  box-sizing: content-box;
  padding: 5px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--ic) 18%, transparent);
}
.sidenav a[data-ic]:hover .ico { background: color-mix(in srgb, var(--ic) 26%, transparent); }
/* Ally กับปุ่มเต็มจอใช้พื้นรองทรงเดียวกัน จะได้เรียงสวยกับไอคอนอื่น */
.sidenav a[data-ic="ally"] .ally-mark {
  box-sizing: content-box;
  width: 16px; height: 16px; margin: 0;
  padding: 6px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--ic) 18%, transparent);
}
.sidenav a[data-ic="ally"]:hover .ally-mark { background: color-mix(in srgb, var(--ic) 26%, transparent); }
.sidenav .fs-btn .ico { box-sizing: content-box; padding: 5px; border-radius: 9px; background: var(--hover); }
/* หน้าที่เปิดอยู่: ใช้สีของเมนูนั้นเอง (ตัวหนังสือยังเป็นสีปกติเพื่อให้อ่านง่าย) */
.sidenav a.active[data-ic], .sidenav a.active[data-ic]:hover {
  background: color-mix(in srgb, var(--ic) 14%, transparent);
  color: var(--nav-ink);
  box-shadow: none;
}
.sidenav a.active[data-ic] .ico { color: var(--ic); background: color-mix(in srgb, var(--ic) 28%, transparent); }

/* ---------- เมนูล่าง (มือถือ): กระจกฝ้า ---------- */
.bottomnav {
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
  border-top: 1px solid var(--line);
}
.bottomnav a { font-size: 0.68rem; letter-spacing: 0; }
.bottomnav a.active { color: var(--accent); }
.bottomnav a.active::before { display: none; }
.bottomnav a.active .ico { color: var(--accent); }

/* ---------- การ์ด / พื้นผิว ---------- */
.card, .stat, .daylist, .table-wrap, .monthpicker, .project-card, .folder-tile, .person-card, .slip, .notif-list li a, .upload-list li, .day {
  border: 1px solid var(--line);
  box-shadow: var(--shadow-xs);
}
.card, .stat, .daylist, .table-wrap, .project-card, .folder-tile, .person-card, .slip {
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 100%, white 2.5%), var(--surface));
  border-radius: var(--radius);
}
:root[data-theme="light"] .card, :root[data-theme="light"] .stat, :root[data-theme="light"] .daylist, :root[data-theme="light"] .table-wrap,
:root[data-theme="light"] .project-card, :root[data-theme="light"] .folder-tile, :root[data-theme="light"] .person-card, :root[data-theme="light"] .slip {
  background: var(--surface); box-shadow: var(--shadow);
}
.card { padding: 20px; margin: 14px 0; }
.card h2 { margin-bottom: 0.85rem; }
.project-card:hover, .folder-tile:hover, a.person-card:hover, .task:hover { border-color: var(--line-strong); transform: translateY(-1px); box-shadow: var(--shadow); }
.monthpicker { background: var(--surface); border-radius: 14px; }

/* ---------- ปุ่ม ---------- */
.btn {
  border-radius: 11px; min-height: 42px; padding: 9px 16px; font-weight: 600; font-size: 0.9rem; letter-spacing: -0.01em;
  background: var(--hover); border: 1px solid var(--line); color: var(--ink); box-shadow: none;
}
.btn:hover { background: color-mix(in srgb, var(--ink) 10%, transparent); border-color: var(--line-strong); }
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--accent-grad); border: 1px solid rgba(255, 255, 255, 0.12); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 6px 18px rgba(34, 199, 227, 0.28);
}
.btn-primary:hover { background: var(--accent-grad); filter: brightness(1.08); border-color: rgba(255, 255, 255, 0.18); }
.btn-danger { background: transparent; border-color: color-mix(in srgb, var(--red) 40%, transparent); color: var(--red); }
.btn-danger:hover { background: var(--red-soft); }
.btn-ok { background: var(--green); border-color: transparent; color: #fff; box-shadow: 0 6px 18px color-mix(in srgb, var(--green) 30%, transparent); }
.btn-ghost { background: transparent; border-color: transparent; }
.linklike { color: var(--accent-ink); }

/* ---------- ช่องกรอก ---------- */
input:not([type=checkbox]):not([type=radio]), select, textarea {
  background: color-mix(in srgb, var(--ink) 4%, var(--surface)); border: 1px solid var(--line); border-radius: 11px;
  color: var(--ink); padding: 11px 13px;
}
input:focus, select:focus, textarea:focus { border-color: rgba(var(--accent-rgb), 0.7); box-shadow: var(--ring); background: var(--surface); }
label { color: var(--ink-2); font-size: 0.86rem; font-weight: 500; }
fieldset { border-radius: 14px; border-color: var(--line); }

/* ---------- แท็บแบบ iOS ---------- */
.tabs { background: color-mix(in srgb, var(--ink) 7%, transparent); border-radius: 11px; padding: 3px; border: 0; }
.tabs a { border-radius: 8px; padding: 7px 16px; font-size: 0.88rem; }
.tabs a.active { background: color-mix(in srgb, var(--surface-3) 100%, white 6%); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35), inset 0 1px 0 var(--hairline-top); }
:root[data-theme="light"] .tabs a.active { background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.seg { background: color-mix(in srgb, var(--ink) 7%, transparent); border: 0; border-radius: 9px; }
.seg button.on { background: var(--surface-3); color: var(--ink); }
:root[data-theme="light"] .seg button.on { background: #fff; }

/* ---------- ป้าย / สถานะ ---------- */
.tag, .pill, .brand-tag { border-radius: 7px; font-weight: 600; letter-spacing: -0.005em; }
.flash { border-radius: 12px; }
.count { border-radius: 7px; background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--muted); }

/* ---------- หน้าเข้างาน: การ์ดหลัก + ปุ่มทรงกลมเรืองแสง ---------- */
.clock-card {
  border-radius: 28px; padding: 26px 20px 22px;
  background:
    radial-gradient(80% 60% at 50% 0%, rgba(34, 199, 227, 0.16), transparent 70%),
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 100%, white 3%), var(--surface));
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.clock-card::before { display: none; }
:root[data-theme="light"] .clock-card { background: radial-gradient(80% 60% at 50% 0%, rgba(34, 199, 227, 0.1), transparent 70%), #fff; }
.clock-card .clock-date { font-size: 0.86rem; letter-spacing: 0.01em; text-transform: none; }
.clock-card .clock-now { font-size: clamp(3.4rem, 2.6rem + 4vw, 4.6rem); font-weight: 700; letter-spacing: -0.045em; line-height: 1.05; margin: 2px 0 10px; font-variant-numeric: tabular-nums; }
.clock-status { border-radius: 999px; background: color-mix(in srgb, var(--ink) 6%, transparent); border: 1px solid var(--line); }
.clock-btn { width: min(62vw, 220px); }
.clock-btn-in {
  background: radial-gradient(circle at 32% 24%, #ffb27a 0%, #22c7e3 36%, #0aa5c9 62%, #b8430f 100%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18) inset, 0 -10px 30px rgba(0, 0, 0, 0.18) inset,
    0 0 0 12px rgba(34, 199, 227, 0.1), 0 0 0 26px rgba(34, 199, 227, 0.05), 0 22px 60px rgba(34, 199, 227, 0.45);
}
.clock-btn-in:hover { filter: brightness(1.05); }
.clock-btn-out {
  background: radial-gradient(circle at 32% 24%, #4b4b50 0%, #2c2c30 55%, #18181b 100%);
  border: 0; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1) inset, 0 0 0 2px rgba(34, 199, 227, 0.8), 0 0 0 12px rgba(34, 199, 227, 0.08), 0 22px 60px rgba(0, 0, 0, 0.5);
}
.clock-btn-label { font-size: 2.15rem; letter-spacing: -0.03em; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); }

/* ---------- ตัวเลข ---------- */
.stat { padding: 14px 16px; }
.stat-num { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.03em; }
.stat-label { font-size: 0.78rem; color: var(--muted); }

/* ---------- รายการงาน / ตาราง ---------- */
.task { border-radius: 14px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-xs); }
.table th { background: transparent; color: var(--faint); text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.7rem; font-weight: 600; }
.column { background: color-mix(in srgb, var(--ink) 3%, transparent); border: 1px solid var(--line); border-radius: 16px; }

/* ---------- รูปประจำตัว ---------- */
.avatar, :root[data-theme="dark"] .avatar {
  background: linear-gradient(145deg, #3a3a3f, #232326); color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 0 0 1px rgba(255, 255, 255, 0.06);
  font-weight: 600;
}
:root[data-theme="light"] .avatar { background: linear-gradient(145deg, #ffe3d1, #ffd0b3); color: #9a3a0c; box-shadow: none; }

/* ---------- หน้าล็อกอิน ---------- */
.center { background: radial-gradient(900px 500px at 50% 0%, rgba(34, 199, 227, 0.14), transparent 70%), var(--bg); }
.card.login { border-radius: 26px; padding: 34px 28px; border: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 92%, transparent); -webkit-backdrop-filter: blur(30px); backdrop-filter: blur(30px); }
.login-brand h1 { font-size: 1.55rem; letter-spacing: -0.03em; }

/* ---------- เงินเดือน ---------- */
.slip::before { background: var(--accent-grad); }

/* ---------- เต็มจอ: ซ่อนแถบล่างของเบราว์เซอร์มือถือ ---------- */
:fullscreen body, :-webkit-full-screen body { background: var(--page-glow), var(--bg); }
@media (display-mode: standalone), (display-mode: fullscreen) {
  .topbar { padding-top: env(safe-area-inset-top); }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* หน้าแรก: สลับปฏิทิน 7 วัน / ทั้งเดือน */
#calendar .cal { margin-top: 8px; }
#calendar .agenda-day { margin-top: 12px; }

/* ไฟล์: สีโฟลเดอร์, ตั้งค่าโฟลเดอร์, ลิงก์แชร์ */
.color-pick { display: flex; flex-wrap: wrap; gap: 8px; border: 0; padding: 0; margin: 0; }
.color-pick legend { font-size: 0.86rem; margin-bottom: 6px; }
.color-pick label { cursor: pointer; }
.color-pick input { position: absolute; opacity: 0; pointer-events: none; }
.color-pick .swatch { display: block; width: 24px; height: 24px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 1px var(--line-strong); }
.color-pick input:checked + .swatch { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.folder-settings summary, .share-box h2 { cursor: pointer; font-weight: 600; }
.share-box .row { gap: 8px; align-items: center; margin: 8px 0; }
.share-box input[readonly] { min-width: 0; font-size: 0.85rem; }
.share-page { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }

/* เปลี่ยนหน้าแบบลื่น (ค่อยๆ จาง ไม่กระพริบขาว) — เบราว์เซอร์ที่รองรับ */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.14s; }
.topbar { view-transition-name: topbar; }
.sidenav { view-transition-name: sidenav; }
/* โลโก้ Ally ในหัวแชท */
.ally-logo { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); flex-shrink: 0; }
.ally-logo svg { width: 20px; height: 20px; }
.ally-word { display: inline-flex; align-items: flex-end; gap: 3px; font-weight: 700; font-size: 17px; line-height: 0.8; letter-spacing: 0.02em; }
.ally-word i { display: inline-block; width: 3px; border-radius: 2px; background: var(--accent); box-shadow: 0 0 6px rgba(var(--accent-rgb), 0.6); }
.ally-word i:nth-of-type(1) { height: 10px; }
.ally-word i:nth-of-type(2) { height: 6px; }
.ally-word b { font-weight: 700; margin-left: -2px; }
body.ally-app .ally-logo svg { width: 24px; height: 24px; }
body.ally-app .ally-word { font-size: 20px; }
body.ally-app .ally-word i:nth-of-type(1) { height: 12px; }
body.ally-app .ally-word i:nth-of-type(2) { height: 7px; }

/* สัญลักษณ์ Ally (A + จุดฟ้า) แทนจุดกลมเดิมทุกที่ */
.ally-mark { width: 22px; height: 22px; color: var(--ink); flex-shrink: 0; overflow: visible; }
.ally-mark circle { fill: var(--accent); filter: drop-shadow(0 0 6px rgba(var(--accent-rgb), 0.7)); }
.ally-fab .ally-mark { width: 26px; height: 26px; }
.sidenav .ally-mark { width: 16px; height: 16px; margin: 0 4px; }
/* ตอนกำลังฟัง: โลโก้ใหญ่ จุดฟ้าเต้นตามจังหวะ */
.ally-veil-mark { width: 132px; height: 132px; }
.ally-veil-mark circle { transform-box: fill-box; transform-origin: center; animation: ally-listen 1.2s ease-in-out infinite; }
@keyframes ally-listen {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 6px rgba(var(--accent-rgb), 0.6)); }
  50% { transform: scale(1.35); filter: drop-shadow(0 0 22px rgba(var(--accent-rgb), 0.95)); }
}

/* ===== Ally: ธีมสว่างใสแบบกระจก (glass) — ใช้กับหน้าแชท Ally เสมอ ไม่ว่าเว็บจะโหมดไหน ===== */
.ally-panel {
  --ink: #1d1d1f; --ink-2: #3a3a3c; --muted: #6e6e73; --faint: #a1a1a6;
  --line: rgba(15, 23, 42, 0.07); --line-strong: rgba(15, 23, 42, 0.12);
  --accent: #0891b2; --accent-ink: #0e7490; --accent-rgb: 8, 145, 178; --on-accent: #ffffff;
  --glass: rgba(255, 255, 255, 0.55); --glass-strong: rgba(255, 255, 255, 0.78); --glass-edge: rgba(255, 255, 255, 0.75);
  color: var(--ink); color-scheme: light;
  background:
    radial-gradient(55% 40% at 12% 8%, rgba(125, 211, 252, 0.7), transparent 70%),
    radial-gradient(45% 38% at 92% 18%, rgba(196, 181, 253, 0.55), transparent 70%),
    radial-gradient(60% 45% at 85% 92%, rgba(103, 232, 249, 0.55), transparent 72%),
    radial-gradient(45% 35% at 8% 88%, rgba(251, 207, 232, 0.6), transparent 70%),
    linear-gradient(170deg, #f8fbfd 0%, #eef3f8 100%);
  border: 1px solid var(--glass-edge);
}
.ally-panel .ally-head,
.ally-panel .ally-input {
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(180%); backdrop-filter: blur(22px) saturate(180%);
  border-color: rgba(255, 255, 255, 0.6);
}
.ally-panel .ally-head { box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04); }
.ally-panel .ally-input { box-shadow: 0 -1px 0 rgba(15, 23, 42, 0.04); }
.ally-panel .ally-input textarea {
  background: rgba(255, 255, 255, 0.72); color: var(--ink); border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.04);
}
.ally-panel .ally-input textarea::placeholder { color: var(--faint); }
.ally-panel .ally-ally {
  background: var(--glass-strong); border: 1px solid var(--glass-edge);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
}
.ally-panel .ally-user {
  background: linear-gradient(135deg, #22c7e3, #0891b2 70%); color: #fff;
  box-shadow: 0 6px 16px rgba(8, 145, 178, 0.25);
}
.ally-panel .ally-error { background: rgba(254, 226, 226, 0.8); color: #b91c1c; }
.ally-panel .ally-icon-btn { color: var(--ink-2); }
.ally-panel .ally-icon-btn:hover { background: rgba(255, 255, 255, 0.6); color: var(--ink); }
.ally-panel .ally-status { color: var(--muted); }
/* ตอนกำลังฟัง: กระจกฝ้าเต็มจอ */
body.ally-app .ally-panel.listening .ally-veil,
.ally-panel.listening .ally-veil { background: rgba(255, 255, 255, 0.45); color: var(--ink); -webkit-backdrop-filter: blur(24px) saturate(160%); backdrop-filter: blur(24px) saturate(160%); }
/* แผงตั้งค่า */
.ally-panel .ally-sheet {
  background: var(--glass-strong); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
  border-top: 1px solid var(--glass-edge); box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.12); color: var(--ink);
}
.ally-panel .ally-sheet select { background: rgba(255, 255, 255, 0.85); color: var(--ink); border: 1px solid var(--line-strong); }
.ally-panel .ally-sheet .btn:not(.btn-primary) { background: rgba(255, 255, 255, 0.7); color: var(--ink); border-color: var(--line-strong); }
.ally-panel .ally-sheet .btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.ally-panel .ally-msg a { color: var(--accent-ink); }
.ally-panel .ally-user a { color: #fff; }
/* เบราว์เซอร์ที่ไม่รองรับกระจกฝ้า: ใช้พื้นขาวทึบแทน (ยังอ่านง่าย) */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .ally-panel .ally-head, .ally-panel .ally-input, .ally-panel .ally-ally, .ally-panel .ally-sheet { background: rgba(255, 255, 255, 0.92); }
}
/* แอป Ally เต็มจอ: พื้นหลังหน้าเป็นโทนเดียวกัน */
body.ally-app { background: #eef3f8; }
/* แอป Ally บนมือถือ: ไม่มีปุ่มไมค์ (แตะจอ 2 ครั้งเพื่อพูดแทน) */
body.ally-app .ally-mic { display: none; }

/* ===== โลโก้ Bossnoi Studio: B◉SSNOI + STUDIO ===== */
.bn-word { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px; color: var(--ink); line-height: 1; }
.bn-main { display: inline-flex; align-items: center; gap: 1px; font-weight: 700; font-size: 1.02rem; letter-spacing: 0.12em; }
.bn-lens { width: 0.82em; height: 0.82em; margin: 0 0.06em 0 0.02em; overflow: visible; }
.bn-dot { fill: var(--accent); filter: drop-shadow(0 0 4px rgba(var(--accent-rgb), 0.7)); }
.bn-sub { font-size: 0.5rem; font-weight: 400; letter-spacing: 0.62em; color: var(--muted); padding-left: 0.1em; }
.bn-word.big { align-items: center; gap: 8px; }
.bn-word.big .bn-main { font-size: 2.1rem; letter-spacing: 0.12em; }
.bn-word.big .bn-sub { font-size: 0.78rem; letter-spacing: 0.9em; margin-right: -0.9em; }
.login-logo { margin: 0 0 6px; display: flex; justify-content: center; }

/* ---------- งาน: ไทม์ไลน์ (แบบ ClickUp) ---------- */
.tl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.tl { --tl-w: 34px; display: grid; grid-template-columns: minmax(160px, 220px) repeat(var(--tl-days), var(--tl-w)); grid-auto-rows: minmax(36px, auto); position: relative; min-width: max-content; }
.tl-corner, .tl-day { position: sticky; top: 0; background: var(--surface); border-bottom: 1px solid var(--line); font-size: 0.72rem; color: var(--muted); display: grid; place-items: center; z-index: 2; }
.tl-corner { left: 0; z-index: 3; justify-items: start; padding-left: 12px; font-weight: 600; }
.tl-day.weekend { background: var(--surface-2); }
.tl-day.today { color: var(--accent-ink); font-weight: 700; }
.tl-day b { font-size: 0.66rem; white-space: nowrap; }
.tl-group { grid-column: 1 / -1; z-index: 1; padding: 10px 12px 4px; font-size: 0.78rem; font-weight: 700; color: var(--ink-2); background: var(--surface-2); position: sticky; left: 0; }
.tl-label { grid-column: 1; position: sticky; left: 0; z-index: 1; background: var(--surface); display: flex; flex-direction: column; justify-content: center; padding: 4px 12px; font-size: 0.84rem; color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tl-label span { font-size: 0.7rem; color: var(--muted); }
.tl-line { grid-column: 2 / -1; border-bottom: 1px solid var(--line); }
.tl-today { background: color-mix(in srgb, var(--accent) 10%, transparent); border-left: 2px solid var(--accent); }
.tl-note { padding: 8px 12px; margin: 0; }
.tl-bar { z-index: 2; align-self: center; height: 24px; margin: 0 2px; border-radius: 7px; padding: 0 8px; font-size: 0.74rem; font-weight: 600; line-height: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; color: #0c3236; background: #bfe8eb; box-shadow: inset 3px 0 0 #4fc3cb; position: relative; }
.tl-bar:hover { text-decoration: none; filter: brightness(0.97); }
.tl-doing { background: #cfe8f7; box-shadow: inset 3px 0 0 #6f9ccf; color: #1d3f63; }
.tl-review, .tl-revise { background: #f1ebf8; box-shadow: inset 3px 0 0 #9a86b8; color: #4d3a6b; }
.tl-late { background: #fbe3e7; box-shadow: inset 3px 0 0 #c26777; color: #8a3242; }
.tl-done { background: var(--surface-3); box-shadow: inset 3px 0 0 var(--faint); color: var(--muted); text-decoration: line-through; }
.tabs a { white-space: nowrap; }

/* หน้าต่างรายการของวัน: การ์ดเต็มของแต่ละกิจกรรม เรียงกันเลื่อนดูได้ */
.day-item { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px 10px 14px; border-radius: 12px; background: var(--nt-soft); border-left: 4px solid var(--nt); color: var(--ink); text-decoration: none; }
.day-item:hover { text-decoration: none; filter: brightness(0.98); }
.day-item-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.day-item-time { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.day-item-title { font-size: 0.98rem; line-height: 1.35; }
.day-item-line { font-size: 0.84rem; color: var(--ink-2); }
.day-item-note { font-size: 0.84rem; color: var(--muted); white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.daysheet-list .event-row { flex-shrink: 0; }
.daysheet-list .day-item { flex-shrink: 0; }

/* แถบโหลดบางๆ ด้านบน ตอนกดเปลี่ยนหน้า (ให้รู้ว่ากดติดแล้ว) */
html.nav-busy::before { content: ''; position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 1000; background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 50% 100%; background-repeat: no-repeat; animation: nav-busy 0.9s linear infinite; }
@keyframes nav-busy { from { background-position: -50% 0; } to { background-position: 150% 0; } }

/* ป๊อปอัพ: เลื่อนเฉพาะในรายการ ไม่ให้ไหลไปเลื่อนพื้นหลัง */
.daysheet, .postit { overscroll-behavior: contain; }
.daysheet-list { overscroll-behavior: contain; touch-action: pan-y; }
.daysheet-top, .daysheet-foot { touch-action: none; }
/* ===================================================================
   ค้นหารวม (ปุ่มแว่นขยายบนแถบด้านบน + หน้าต่างค้นหา + หน้า /search)
   คอม = กล่องกลางจอด้านบน · มือถือ = เต็มความกว้างจากขอบบน
   =================================================================== */
.search-dialog {
  width: min(640px, 92vw); max-height: min(72vh, 620px); margin: 10vh auto auto; padding: 0;
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-lg, 0 24px 48px -20px rgba(0, 0, 0, 0.35)); overflow: hidden;
}
.search-dialog[open] { display: flex; flex-direction: column; animation: postit-in 0.16s var(--ease, ease-out); }
.search-dialog::backdrop { background: rgba(20, 20, 22, 0.32); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.search-bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); margin: 0; }
.search-bar .ico { width: 20px; height: 20px; flex: none; color: var(--muted); fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.search-dialog .search-bar input[type=search] {
  flex: 1; min-width: 0; border: 0; outline: 0; box-shadow: none; background: transparent; color: var(--ink);
  font: inherit; font-size: 1.05rem; padding: 8px 0; margin: 0; -webkit-appearance: none; appearance: none;
}
.search-dialog .search-bar input[type=search]:focus, .search-dialog .search-bar input[type=search]:hover { box-shadow: none; border: 0; background: transparent; }
.search-dialog .search-bar input::-webkit-search-cancel-button { display: none; }
.search-close { flex: none; border: 0; background: var(--surface-2); color: var(--muted); font: inherit; font-size: 0.82rem; padding: 6px 10px; border-radius: 8px; cursor: pointer; }
.search-close:hover { color: var(--ink); }
.search-panel { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px 8px 10px; }
.search-hint { margin: 14px 10px; font-size: 0.9rem; text-align: center; }
.search-group + .search-group { margin-top: 6px; }
.search-group-title { font-size: 0.74rem; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; margin: 8px 8px 4px; font-family: var(--font); }
.search-group ul { list-style: none; margin: 0; padding: 0; }
.search-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: inherit; text-decoration: none; min-height: 44px; }
.search-item:hover, .search-item.is-active { background: var(--accent-soft); text-decoration: none; }
.search-item.is-active { box-shadow: inset 2px 0 0 var(--accent); }
.search-ico { flex: none; width: 24px; text-align: center; font-size: 1.05rem; }
.search-txt { display: flex; flex-direction: column; min-width: 0; }
.search-txt strong { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-txt .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* หน้า /search (ไม่มี JavaScript) */
.search-page-form { display: flex; gap: 8px; margin: 4px 0 16px; }
.search-page-form input { flex: 1; min-width: 0; }
.page .search-results { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 8px 10px; }
@media (max-width: 640px) {
  .search-dialog { width: 100%; max-width: 100%; max-height: 88dvh; margin: 0 auto auto; border-radius: 0 0 18px 18px; border-top: 0; padding-top: env(safe-area-inset-top); }
  .search-dialog[open] { animation: none; }
  .search-dialog .search-bar input[type=search] { font-size: 16px; } /* iPhone ไม่ซูมเมื่อแตะช่องพิมพ์ */
}

/* ===================================================================
   แจ้งเตือน: แท็บ ทั้งหมด / ยังไม่อ่าน + ป้าย "ยังไม่อ่าน"
   =================================================================== */
.notif-tabs { max-width: 360px; margin: 0 0 12px; }
.notif-list li.is-new .notif-main > span:first-child { font-weight: 600; }
.notif-new-label { color: var(--accent-ink); font-weight: 600; }
/* ======================================================================
   งาน: ติ๊กเสร็จ/เปลี่ยนสถานะในรายการ · เพิ่มงานด่วน · หน้าต่างงานด้านข้าง · เช็กลิสต์ · @แท็ก
   ====================================================================== */
/* การ์ดงาน: ชื่องานเป็นลิงก์ที่ยืดเต็มการ์ด (กดตรงไหนก็เปิดงาน) · วงกลม/ตัวเลือกสถานะอยู่ชั้นบน กดได้แยก */
.task-title { color: inherit; text-decoration: none; }
.task-title:hover { text-decoration: none; }
.task-title::after { content: ''; position: absolute; inset: 0; border-radius: inherit; }
.task-title:focus-visible { box-shadow: none; }
.task:has(.task-title:focus-visible) { box-shadow: var(--ring); }
.task .prop-chips, .task .status-pick, .task .task-check { position: relative; z-index: 1; }
.task.has-check { padding-left: 46px; }
.task-check-form { position: absolute; left: 10px; top: 7px; margin: 0; z-index: 1; }
.task-check {
  width: 30px; height: 30px; padding: 0; border: 0; background: transparent; cursor: pointer; border-radius: 50%;
  display: grid; place-items: center; -webkit-tap-highlight-color: transparent;
}
.task-check::before {
  content: ''; width: 20px; height: 20px; border-radius: 50%; border: 1.8px solid var(--faint); box-sizing: border-box;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.task-check:hover::before { border-color: var(--green); background: var(--green-soft); }
.task-check:active::before { transform: scale(0.88); }
.task-check[aria-pressed="true"]::before {
  border-color: var(--green); background: var(--green) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 13px no-repeat;
}
.task-check:focus-visible { outline: none; box-shadow: var(--ring); }
.task.has-check::before { left: 4px; }
/* ตัวเลือกสถานะหน้าตาเหมือนป้าย */
select.status-pick {
  width: auto; min-height: 0; flex-shrink: 0; padding: 2px 22px 2px 9px; font-size: 0.74rem; font-weight: 600; line-height: 1.6;
  border: 0; border-radius: 999px; cursor: pointer; box-shadow: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 6px center; background-size: 11px;
}
select.status-pick:focus { box-shadow: var(--ring); }
select.status-pick option { color: var(--ink); background: var(--surface); }
.column .task-top .status-pick { display: none; }
.meta-ck { font-variant-numeric: tabular-nums; }
.meta-ck.all { color: var(--green); }
.task.just-added { animation: task-in 0.35s var(--ease); }
@keyframes task-in { from { opacity: 0; transform: translateY(-4px); background: var(--accent-soft); } }

/* เพิ่มงานด่วน */
.quick-add { display: flex; gap: 6px; margin: 0 0 14px; }
.quick-add input[name=title] {
  flex: 1; min-width: 0; border-style: dashed; background: transparent; min-height: 44px;
}
.quick-add input[name=title]:focus { border-style: solid; background: var(--surface); }
.quick-add select { flex: 0 1 40%; min-width: 0; min-height: 44px; font-size: 0.88rem; }
.column .quick-add { margin: 4px 0 0; }
.column .quick-add input[name=title] { min-height: 38px; font-size: 0.86rem; padding: 6px 10px; }
.quick-added { margin: -6px 0 14px; }

/* ข้อความเด้งล่างจอ + ปุ่มย้อนกลับ */
.toast {
  position: fixed; inset: auto auto calc(16px + env(safe-area-inset-bottom)) 50%; transform: translate(-50%, 12px); margin: 0;
  z-index: 1000; display: flex; align-items: center; gap: 14px; max-width: min(92vw, 440px);
  padding: 10px 12px 10px 16px; border: 0; border-radius: 14px; background: var(--ink); color: var(--surface);
  font-size: 0.9rem; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity 0.18s, transform 0.18s var(--ease);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast[popover]:not(:popover-open) { display: none; }
.toast-error { background: var(--red); color: #fff; }
.toast button {
  border: 0; background: color-mix(in srgb, currentColor 14%, transparent); color: inherit; font: inherit; font-weight: 700; padding: 6px 10px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}

/* หน้าต่างงานด้านข้าง (คอม = แผงขวา, มือถือ = แผ่นเลื่อนขึ้นจากล่าง) */
.tpanel {
  position: fixed; inset: 0 0 0 auto; margin: 0; width: min(520px, 100vw); height: 100dvh; max-height: none; padding: 0;
  border: 0; border-left: 1px solid var(--line); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); overflow: hidden;
}
.tpanel:popover-open { display: flex; flex-direction: column; animation: panel-in 0.2s var(--ease); }
.tpanel::backdrop { background: rgba(20, 20, 22, 0.28); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
@keyframes panel-in { from { transform: translateX(40px); opacity: 0; } }
.tp { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.tp-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.tp-full { min-height: 34px; padding: 4px 12px; font-size: 0.84rem; }
.tp-back { display: none; }
.tp-body { flex: 1; overflow-y: auto; padding: 14px 16px calc(24px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.tp-body .task-h { font-size: 1.2rem; margin: 8px 0 12px; word-break: break-word; }
.tp-comments { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
.tp-comments h2 { font-size: 1rem; }
.tp-more { margin-top: 14px; }
@media (max-width: 640px) {
  .tpanel { inset: auto 0 0 0; width: 100%; height: auto; max-height: 90dvh; border-left: 0; border-top: 1px solid var(--line); border-radius: 20px 20px 0 0; }
  .tpanel:popover-open { animation: sheet-up 0.22s var(--ease); }
  .tpanel .tp { height: auto; max-height: 90dvh; }
  .tp-top { position: relative; padding-top: 18px; }
  .tp-top::before { content: ''; position: absolute; left: 50%; top: 6px; width: 38px; height: 4px; margin-left: -19px; border-radius: 4px; background: var(--line-strong); }
  /* มือถือ: ปุ่ม ‹ กลับ ใหญ่ เข้ม กดง่าย (ปิดหน้าต่างงาน) */
  .tp-back { display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px 0 8px; margin-right: auto; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; font-size: 1rem; font-weight: 700; cursor: pointer; }
  .back { min-height: 40px; padding: 4px 12px 4px 8px; margin-left: 0; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--ink); font-size: 1rem; font-weight: 700; }
  .props { grid-template-columns: 96px 1fr; }
}
/* ช่องที่แก้ในที่ได้ (เปลี่ยนแล้วบันทึกทันที) */
.props .field-pick { width: auto; max-width: 100%; min-height: 36px; padding: 4px 30px 4px 10px; font-size: 0.9rem; }
.props input.field-pick { padding-right: 10px; }
.field-due { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.props dd .status-pick { font-size: 0.8rem; padding: 4px 24px 4px 10px; }

/* เช็กลิสต์ */
.checklist { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.checklist h3 { font-size: 0.98rem; margin: 0 0 8px; display: flex; align-items: center; gap: 6px; }
.ck-bar { height: 4px; border-radius: 4px; background: var(--gray-soft); overflow: hidden; margin-bottom: 6px; }
.ck-bar i { display: block; height: 100%; background: var(--green); transition: width 0.25s var(--ease); }
.ck-list { list-style: none; margin: 0; padding: 0; }
.ck-list li { display: flex; align-items: center; gap: 4px; min-height: 40px; border-bottom: 1px solid var(--line); }
.ck-list form { margin: 0; }
.ck-tick, .ck-del { flex-shrink: 0; }
.ck-box {
  width: 34px; height: 34px; padding: 0; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; flex-shrink: 0;
}
.ck-box::before {
  content: ''; width: 18px; height: 18px; border-radius: 5px; border: 1.8px solid var(--faint); box-sizing: border-box; transition: background 0.15s, border-color 0.15s;
}
span.ck-box { cursor: default; }
.ck-list li.done .ck-box::before {
  border-color: var(--green); background: var(--green) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 12px no-repeat;
}
.ck-edit { flex: 1; min-width: 0; }
.ck-edit input { width: 100%; border-color: transparent; background: transparent; padding: 6px 8px; min-height: 36px; box-shadow: none; }
.ck-edit input:hover:not(:focus) { border-color: var(--line); }
.ck-text { flex: 1; min-width: 0; padding: 6px 8px; word-break: break-word; }
.ck-list li.done .ck-edit input, .ck-list li.done .ck-text { color: var(--muted); text-decoration: line-through; }
.ck-x { width: 32px; height: 32px; border: 0; background: transparent; color: var(--faint); font-size: 1.2rem; border-radius: 8px; cursor: pointer; }
.ck-x:hover { color: var(--red); background: var(--red-soft); }
.ck-add { margin-top: 6px; }
.ck-add input { width: 100%; border-style: dashed; background: transparent; min-height: 40px; }
.ck-add input:focus { border-style: solid; }

/* @แท็กเพื่อนในความคิดเห็น */
.mention { color: var(--accent-ink); background: var(--accent-soft); border-radius: 5px; padding: 0 3px; font-weight: 600; }
.comment-form { position: relative; }
.mention-pick {
  display: flex; flex-direction: column; max-height: 220px; overflow-y: auto; margin-top: -4px; padding: 4px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.mention-opt { text-align: left; border: 0; background: transparent; color: var(--ink); font: inherit; padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.mention-opt.on, .mention-opt:hover { background: var(--accent-soft); color: var(--accent-ink); }
/* ==========================================================================
   ไฟล์: จัดการรายการแบบ Google Drive — เมนู ⋯ (เปลี่ยนชื่อ/ย้าย/ลบ), โหมด "เลือก",
   แถบล่างเมื่อเลือกหลายรายการ, หน้าต่างย้าย, ช่องค้นหา (public/files-manage.js)
   ========================================================================== */
.drive-item { position: relative; min-width: 0; }
.drive-item > .folder-tile { padding-right: 44px; height: 100%; }
.drive-item .file-row { padding-right: 44px; }
.drive-files[data-view=grid] .drive-item .file-row { padding-right: 0; }
.drive-files[data-view=grid] .drive-item .file-row > .file-name { padding-right: 40px; }

/* ปุ่ม ⋯ */
.item-menu { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); z-index: 3; }
.drive-files[data-view=grid] .item-menu { top: auto; bottom: 8px; transform: none; }
.item-menu > summary {
  list-style: none; width: 36px; height: 36px; border-radius: 999px; display: grid; place-items: center; cursor: pointer; color: var(--muted);
}
.item-menu > summary::-webkit-details-marker { display: none; }
.item-menu > summary:hover, .item-menu[open] > summary { background: var(--hover); color: var(--ink); }
.item-menu > summary .ico { width: 20px; height: 20px; stroke-width: 3; }
.item-pop {
  position: absolute; right: 0; top: calc(100% + 4px); min-width: 230px; max-width: 300px; z-index: 46; padding: 6px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow-lg);
}
.item-pop-name { padding: 6px 12px 8px; font-size: 0.8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.item-pop .drive-menu-item { width: 100%; background: none; border: 0; font: inherit; font-weight: 500; font-size: 0.9rem; text-align: left; }
.item-pop .drive-menu-item.text-red, .item-pop .drive-menu-item.text-red .ico { color: var(--red); }
.item-pop form { margin: 0; }
.item-rename { display: flex; flex-direction: column; gap: 6px; padding: 6px 8px 4px; }
.item-rename[hidden] { display: none; }
.item-rename label { display: flex; flex-direction: column; gap: 4px; font-size: 0.84rem; }
.file-title { display: flex; align-items: flex-start; gap: 8px; }
.file-title h1 { flex: 1; min-width: 0; }
.file-title .item-menu { position: relative; top: auto; right: auto; transform: none; }
@media (max-width: 560px) {
  /* มือถือ: เมนูเลื่อนขึ้นจากด้านล่าง (นิ้วกดง่าย) */
  .item-pop { position: fixed; left: 8px; right: 8px; top: auto; bottom: calc(12px + env(safe-area-inset-bottom)); max-width: none; max-height: 75vh; overflow-y: auto; }
  .item-menu[open]::before { content: ''; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.3); z-index: 45; }
  .item-pop .drive-menu-item { padding: 12px; }
}
.item-path { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drive-files[data-view=grid] .file-main .item-path { display: block; }
@media (min-width: 720px) { .drive-files .file-main .item-path { display: block; } }

/* โหมด "เลือก" */
.item-check { display: none; }
.is-selecting .item-check {
  display: grid; place-items: center; position: absolute; left: 6px; top: 50%; transform: translateY(-50%); z-index: 4; width: 30px; height: 30px; cursor: pointer;
}
.is-selecting .item-check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.is-selecting .drive-files[data-view=grid] .item-check { top: 8px; left: 8px; transform: none; background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); }
.is-selecting .drive-item > .folder-tile { padding-left: 42px; }
.is-selecting .drive-files:not([data-view=grid]) .drive-item .file-row { padding-left: 40px; }
.is-selecting .item-menu { display: none; }
.is-selecting .drive-item:has(.item-check input:checked) > .folder-tile,
.is-selecting .drive-item:has(.item-check input:checked) .file-row { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.is-selecting .select-btn { background: var(--accent-soft); color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

/* แถบล่างตอนเลือก */
.bulk-bar { display: none; }
.is-selecting .bulk-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; position: fixed; z-index: 40; left: 50%; transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom)); width: min(560px, calc(100vw - 24px)); padding: 10px 12px;
  background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: var(--shadow-lg);
}
.bulk-count { flex: 1 1 100%; font-size: 0.9rem; }
.bulk-bar .btn { flex: 1; min-height: 42px; }
.bulk-bar .btn:disabled { opacity: 0.45; cursor: default; }
.bulk-bar .bulk-x { flex: 0 0 auto; font-size: 1rem; }
@media (min-width: 560px) { .bulk-count { flex: 1 1 auto; } .bulk-bar .btn { flex: 0 0 auto; } }
.is-selecting main.page { padding-bottom: 150px; }

/* หน้าต่างย้าย */
.move-dialog {
  width: min(460px, calc(100vw - 24px)); border: 1px solid var(--line-strong); border-radius: 16px; padding: 18px; color: var(--ink);
  background: var(--surface); box-shadow: var(--shadow-lg);
}
.move-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.move-dialog h2 { margin: 0 0 4px; font-size: 1.1rem; }
.move-dialog label { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.move-dialog select { width: 100%; max-width: 100%; }
.folder-dialog { max-height: calc(100dvh - 32px); overflow-y: auto; }
.folder-dialog .share-box { border: 0; box-shadow: none; background: none; padding: 0; margin: 0; }
.folder-dialog .share-box h2 { cursor: default; }
.folder-dialog .check-grid { max-height: 220px; overflow-y: auto; }
.folder-self-menu { position: relative; top: auto; right: auto; transform: none; }
.folder-self-menu > summary { width: 40px; height: 40px; }
.move-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ช่องค้นหา */
.drive-search { position: relative; margin: 6px 0 4px; max-width: 560px; }
.drive-search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
/* input[type=search] ให้ชนะกฎช่องพิมพ์ทั่วไป input:not(...) ไม่งั้นตัวหนังสือไปทับแว่นขยาย */
.drive-search input[type=search] { width: 100%; padding-left: 40px; border-radius: 999px; min-height: 42px; }
.drive-search .ico { z-index: 1; }

/* ---------- ลงยอดขาย ---------- */
.sl-stats { margin-bottom: 10px; }
.sl-brand-tabs { margin: 0 0 10px; }
.sl-search { display: flex; gap: 6px; margin: 0 0 12px; }
.sl-search input { flex: 1; min-width: 0; }
.sl-scroll { overflow-x: auto; margin: 0 -4px; -webkit-overflow-scrolling: touch; }
.sl-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; min-width: 860px; }
.sl-table th { position: sticky; top: 0; text-align: left; font-weight: 600; font-size: 0.78rem; color: var(--muted); background: var(--surface-2); padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.sl-table td { padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.sl-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sl-table tbody + tbody tr:first-child td { border-top: 2px solid var(--line-strong, var(--line)); }
.sl-date { white-space: nowrap; font-weight: 600; color: var(--ink-2); }
.sl-today .sl-date { color: var(--accent-ink); }
.sl-cust { max-width: 200px; }
.sl-prod { font-weight: 600; }
.sl-note { color: var(--muted); font-size: 0.8rem; }
.sl-edit { display: inline-block; margin-left: 6px; font-size: 0.78rem; }
.sl-editable { cursor: pointer; }
.sl-editable:hover td { background: var(--hover); }
.sl-sum td { background: var(--surface-2); font-weight: 600; font-size: 0.82rem; }
.sl-kind { display: inline-block; font-size: 0.74rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.sl-new { background: var(--accent-soft); color: var(--accent-ink); }
.sl-upsell { background: color-mix(in srgb, var(--amber, #d9a75b) 18%, transparent); color: var(--amber-ink, #8a5f1c); }
.sl-tb { display: inline-block; margin-left: 4px; font-size: 0.68rem; font-weight: 700; padding: 0 5px; border-radius: 4px; background: var(--dark-chip, #333); color: #fff; }
.sl-web { background: var(--accent, #2563eb); }
.sl-breaks { display: grid; gap: 14px; }
.sl-breaks h2 { margin-bottom: 0; }
.sl-break h3 { font-size: 0.9rem; margin: 0 0 6px; }
.sl-break-row { display: grid; grid-template-columns: minmax(80px, 1.2fr) 2fr auto; gap: 8px; align-items: center; padding: 3px 0; font-size: 0.86rem; }
.sl-break-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sl-break-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.sl-break-bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.sl-break-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (min-width: 900px) { .sl-breaks { grid-template-columns: 1fr 1fr; } .sl-breaks h2 { grid-column: 1 / -1; } }
.sl-dialog { width: min(520px, 94vw); max-height: 92vh; padding: 0; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); overflow: auto; overscroll-behavior: contain; }
.sl-dialog::backdrop { background: rgba(20, 20, 22, 0.32); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.sl-dialog-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.sl-dialog-top h2 { margin: 0; }
.sl-dialog .sl-form { padding: 6px 16px calc(16px + env(safe-area-inset-bottom)); }
.sl-seg { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sl-seg-label { font-size: 0.86rem; color: var(--muted); margin-right: 2px; }
.sl-opt { position: relative; cursor: pointer; }
.sl-opt input { position: absolute; opacity: 0; pointer-events: none; }
.sl-opt span { display: inline-block; padding: 7px 14px; border-radius: 999px; border: 1.5px solid var(--line); font-size: 0.88rem; background: var(--surface-2); }
.sl-opt input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; }
.sl-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.sl-actions { display: flex; gap: 8px; }
.sl-actions .btn { flex: 1; justify-content: center; min-height: 46px; }
.sl-form input[name="amount"] { font-size: 1.1rem; font-weight: 700; }
@media (max-width: 640px) {
  .sl-dialog { width: 100%; max-width: 100%; max-height: 92vh; margin: auto 0 0; border-radius: 20px 20px 0 0; }
}
/* ลงยอดขาย บนมือถือ: แต่ละรายการเป็นการ์ด อ่านง่าย ไม่ต้องเลื่อนตารางซ้ายขวา */
@media (max-width: 640px) {
  .sl-table { min-width: 0; font-size: 0.86rem; }
  .sl-table thead { display: none; }
  .sl-table, .sl-table tbody { display: block; }
  .sl-table tbody + tbody tr:first-child td { border-top: 0; }
  .sl-table tr.sl-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
  .sl-table tr.sl-row td { display: block; padding: 0; border: 0; }
  .sl-table td.sl-date { order: 0; flex-basis: 100%; font-size: 0.82rem; margin-bottom: 2px; }
  .sl-table td.sl-date:empty { display: none; }
  .sl-table td.sl-prod { order: 1; flex: 1; font-size: 0.98rem; }
  .sl-table td.sl-amt { order: 2; font-size: 1rem; }
  .sl-table td.sl-cust { order: 3; flex-basis: 100%; max-width: none; }
  .sl-table td.sl-k { order: 4; }
  .sl-table td.sl-ch, .sl-table td.sl-acc, .sl-table td.sl-seller { font-size: 0.78rem; color: var(--muted); }
  .sl-table td.sl-ch { order: 5; }
  .sl-table td.sl-acc { order: 6; }
  .sl-table td.sl-seller { order: 7; }
  .sl-table td.sl-acc::before { content: '· เข้า'; }
  .sl-table td.sl-seller::before { content: '· ขายโดย '; }
  .sl-table tr.sl-row td.sl-qty { display: none; }
  .sl-table tr.sl-row td.sl-date:empty, .sl-table tr.sl-row td.sl-note:empty { display: none; }
  .sl-table td.sl-note { order: 8; flex-basis: 100%; }
  .sl-table tr.sl-sum { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; padding: 8px 8px; background: var(--surface-2); border-radius: 8px; margin: 4px 0 12px; }
  .sl-table tr.sl-sum td { display: block; padding: 0; border: 0; background: none; }
  .sl-table tr.sl-sum td:empty { display: none; }
  .sl-scroll { overflow: visible; margin: 0; }
}

/* ---------- ออฟไลน์: แถบบอกสถานะเน็ตด้านบน + รายการที่รอส่ง ---------- */
.netbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 900; margin: 0;
  padding: calc(3px + env(safe-area-inset-top)) 12px 3px; text-align: center;
  font-size: 0.78rem; line-height: 1.35; font-weight: 500; color: #fff; background: #57534e;
}
.netbar[hidden] { display: none; }
.netbar.is-off { background: #b45309; }
.netbar.is-wait { background: #57534e; }
.netbar.is-sent { background: #15803d; }
html.has-netbar body { padding-top: var(--netbar-h, 0px); }
html.has-netbar .topbar { top: var(--netbar-h, 0px); }
html.has-netbar .topbar { padding-top: 0; height: var(--topbar-h); }
@media (min-width: 1024px) { html.has-netbar .sidenav { top: calc(var(--topbar-h) + var(--netbar-h, 0px)); } }
.task.is-pending, .ck-list li.is-pending { opacity: 0.6; border-style: dashed; }
.offline-card { max-width: 420px; }
.offline-card .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
/* ---------- หน้านัดแบบ Notion: ชื่อใหญ่ + แถว property แตะแก้ได้ในที่ (views/event-page.tsx + event-page.js) ---------- */
.nt-page { padding: 22px 44px 34px; }
.nt-bar { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-height: 30px; }
.nt-status { font-size: 0.8rem; color: var(--faint); }
.nt-status.is-bad { color: var(--red); font-weight: 600; }
.nt-menu { position: relative; }
/* ••• ปุ่มใหญ่ เข้ม กดง่ายบนมือถือ (เป้ากด 40px) */
.nt-menu > summary { list-style: none; cursor: pointer; display: inline-grid; place-items: center; width: 40px; height: 36px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-size: 1.05rem; font-weight: 800; letter-spacing: 1px; line-height: 1; }
.nt-menu > summary::-webkit-details-marker, .nt-pop > summary::-webkit-details-marker { display: none; }
.nt-menu > summary:hover { background: var(--hover); }
.nt-menu > .nt-pop-panel { right: 0; left: auto; min-width: 160px; }
.nt-page textarea.nt-title, .nt-title-static {
  display: block; width: 100%; font-family: var(--font-display); font-size: 2.3rem; font-weight: 700; line-height: 1.25; color: var(--ink);
  border: 0; background: transparent; padding: 4px 0 6px; margin: 4px 0 10px; resize: none; overflow: hidden; box-shadow: none; border-radius: 0; field-sizing: content;
}
.nt-page textarea.nt-title:focus, .nt-page textarea.nt-title:hover { box-shadow: none; border: 0; }
.nt-props { display: grid; grid-template-columns: minmax(130px, 180px) minmax(0, 1fr); row-gap: 2px; }
.nt-row { display: contents; }
.nt-row[hidden] { display: none; }
.nt-label { display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 6px; color: var(--muted); font-size: 0.92rem; }
.nt-ic { flex-shrink: 0; opacity: 0.8; }
.nt-val { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; min-height: 38px; padding: 1px 4px; border-radius: 7px; color: var(--ink); min-width: 0; }
.nt-form .nt-val:hover, .nt-form .nt-val:focus-within { background: var(--hover); }
.nt-page input.nt-input {
  width: auto; min-width: 0; border: 0; background: transparent; box-shadow: none; padding: 6px 6px; border-radius: 6px; color: var(--ink); font-size: 0.95rem;
}
.nt-page input.nt-input:focus { background: var(--surface-2); box-shadow: none; }
.nt-page input.nt-input.is-empty { color: var(--faint); }
.nt-page input.nt-grow { flex: 1; }
.nt-page input.nt-num { width: 90px; }
.nt-arrow { color: var(--faint); }
.nt-hint { font-size: 0.8rem; color: var(--faint); margin-left: 4px; }
.nt-empty { color: var(--faint); }
.nt-chip { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 6px; font-size: 0.88rem; font-weight: 500; line-height: 1.5; background: var(--nt-soft, var(--gray-soft)); color: var(--nt-ink, var(--ink-2)); white-space: nowrap; }
.nt-pop { position: relative; flex: 1; min-width: 0; }
.nt-pop > summary { list-style: none; cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 5px; min-height: 36px; padding: 0 4px; }
.nt-pop-panel {
  position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; min-width: 230px; max-width: min(340px, 86vw); max-height: 320px; overflow: auto;
  display: flex; flex-direction: column; gap: 1px; padding: 6px; background: var(--surface); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
}
.nt-opt { display: flex; flex-direction: row; align-items: center; gap: 9px; width: 100%; padding: 6px 8px; border: 0; border-radius: 6px; background: transparent; font: inherit; font-weight: 400; font-size: 0.92rem; color: var(--ink); text-align: left; cursor: pointer; text-decoration: none; }
.nt-opt:hover { background: var(--hover); text-decoration: none; }
.nt-opt:has(input:checked) { background: var(--accent-soft); }
.nt-opt input[type=radio] { position: absolute; opacity: 0; pointer-events: none; }
.nt-opt input[type=checkbox] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); flex-shrink: 0; }
.nt-opt-add { color: var(--accent-ink); border-top: 1px solid var(--line); border-radius: 0 0 6px 6px; margin-top: 4px; }
.nt-opt.text-red { color: var(--red); }
.nt-add-prop { display: inline-block; margin: 6px 0 0 6px; font-size: 0.86rem; color: var(--faint); }
.nt-add-prop:hover { color: var(--accent-ink); }
.nt-sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0 14px; }
.nt-page textarea.nt-body, .nt-page div.nt-body {
  display: block; width: 100%; min-height: 90px; border: 0; background: transparent; box-shadow: none; padding: 4px 6px; resize: none; overflow: hidden;
  font-size: 1rem; line-height: 1.65; color: var(--ink); field-sizing: content;
}
.nt-page textarea.nt-body:focus { box-shadow: none; }
.nt-save { margin-top: 14px; }
@media (max-width: 640px) {
  .nt-page { padding: 14px 16px 22px; }
  .nt-page textarea.nt-title, .nt-title-static { font-size: 1.75rem; }
  .nt-props { grid-template-columns: 112px minmax(0, 1fr); }
  .nt-label { font-size: 0.86rem; gap: 6px; }
  .nt-hint { width: 100%; margin: 0 0 4px 6px; }
}

/* ---------- รูปโปรไฟล์ ---------- */
.avatar.has-img { padding: 0; overflow: hidden; background: var(--surface-2); }
.avatar.has-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.lg { width: 52px; height: 52px; font-size: 1.2rem; }
.avatar.xl { width: 88px; height: 88px; font-size: 2rem; }
.avatar-edit { display: flex; align-items: center; gap: 18px; margin: 8px 0 16px; }
.avatar-edit-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.avatar-pick { position: relative; display: block; cursor: pointer; border-radius: 50%; flex-shrink: 0; }
.avatar-pick:hover .avatar { filter: brightness(0.92); }
.avatar-pick-badge {
  position: absolute; right: -2px; bottom: -2px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); border: 3px solid var(--surface);
}
.avatar-pick:focus-within { box-shadow: var(--ring); }
.avatar-nudge { border: 1.5px dashed var(--accent); background: var(--accent-soft); }
.avatar-nudge .avatar-edit { margin: 0; }
.avatar-nudge .avatar-pick-badge { border-color: var(--surface); }
.person-head { align-items: center; gap: 14px; justify-content: flex-start; flex-wrap: wrap; }
.person-head .avatar.xl { width: 64px; height: 64px; }
.person-group-head { display: flex; align-items: center; gap: 8px; }
.person-group-head .avatar.sm { margin: 0; border: 0; }

/* ---------- หน้าทีม: ภาพรวม (กดกรอง) + การ์ดพนักงานคนละใบ ---------- */
.team-overview { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; margin: 16px 0 8px; }
.team-tile {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 400;
}
.team-tile:hover { border-color: var(--line-strong); text-decoration: none; }
.team-tile-num { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.team-tile-label { font-size: 0.8rem; color: var(--muted); }
.team-tile.is-warn .team-tile-num { color: var(--red); }
.team-tile:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.team-tile:has(input:focus-visible) { box-shadow: var(--ring); }
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.tcard {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--line); color: inherit; text-decoration: none; transition: border-color 0.15s, transform 0.15s;
}
a.tcard:hover { border-color: var(--line-strong); text-decoration: none; transform: translateY(-1px); }
.tcard[data-st=late] { border-color: color-mix(in srgb, var(--red) 45%, var(--line)); }
.tcard-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.tcard-name { font-size: 1rem; line-height: 1.3; }
.tcard-dept { font-size: 0.8rem; color: var(--muted); }
.tcard-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 0.76rem; color: var(--muted); margin-top: 2px; }
.tstatus { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--ink-2); margin-top: 3px; }
.tstatus i { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex-shrink: 0; }
.ts-working i { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.ts-late { color: var(--red); font-weight: 600; }
.ts-late i { background: var(--red); }
.ts-leave i { background: var(--amber); }
.ts-left { color: var(--muted); }
.ts-flex { color: var(--muted); }
.tstatus-late { font-size: 0.7rem; font-weight: 700; color: var(--red); background: var(--red-soft); padding: 1px 6px; border-radius: 5px; }
/* กรองการ์ดตามสถานะที่กด (ใช้ CSS ล้วน) */
.team:has(input[value=working]:checked) .tcard:not([data-st=working]),
.team:has(input[value=late]:checked) .tcard:not([data-st=late]),
.team:has(input[value=left]:checked) .tcard:not([data-st=left]),
.team:has(input[value=leave]:checked) .tcard:not([data-st=leave]) { display: none; }
@media (max-width: 640px) {
  /* มือถือ: ตัวเลขภาพรวมเป็นแถบเลื่อนแถวเดียว ไม่กินที่ */
  .team-overview { display: flex; overflow-x: auto; gap: 8px; margin: 12px -16px 6px; padding: 0 16px 4px; scrollbar-width: none; }
  .team-overview::-webkit-scrollbar { display: none; }
  .team-tile { padding: 9px 12px; flex: 0 0 auto; min-width: 92px; }
  .team-tile-num { font-size: 1.3rem; }
  .team-grid { grid-template-columns: 1fr; }
  .avatar-edit { gap: 14px; }
  .avatar.xl { width: 76px; height: 76px; }
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* รูปเล็กข้างชื่อคนรับงานบนการ์ดงาน */
.avatar.xs { width: 18px; height: 18px; font-size: 0.6rem; margin: 0 5px 0 0; border: 0; vertical-align: -4px; display: inline-grid; }
.meta-who { display: inline-flex; align-items: center; }
.meta-who:has(.avatar)::before { display: none; }
/* หน้าต่างจัดตำแหน่งรูปโปรไฟล์ (ลากเลื่อน + ซูม) */
.crop-dlg { border: 0; border-radius: var(--radius); background: var(--surface); color: var(--ink); padding: 20px; width: min(340px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); }
.crop-dlg::backdrop { background: rgba(0, 0, 0, 0.55); }
.crop-title { font-weight: 700; font-size: 1.05rem; margin-bottom: 14px; text-align: center; }
.crop-stage { position: relative; width: 280px; height: 280px; margin: 0 auto; border-radius: 50%; overflow: hidden; background: var(--surface-2); cursor: grab; touch-action: none; user-select: none; }
.crop-stage:active { cursor: grabbing; }
.crop-stage img { position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; pointer-events: none; -webkit-user-drag: none; }
.crop-hint { text-align: center; font-size: 0.8rem; color: var(--muted); margin: 10px 0 4px; }
.crop-zoom { display: flex; flex-direction: row; align-items: center; gap: 10px; color: var(--muted); font-size: 1.1rem; margin: 6px 4px 16px; }
.crop-zoom input { flex: 1; accent-color: var(--accent); }
.crop-actions { display: flex; gap: 10px; }
.crop-actions .btn { flex: 1; }
.profile-info { margin: 4px 0 16px; } .profile-info .props { margin-top: 8px; }
/* แท็บย่อยของหมวด (ทีม): เลื่อนได้บนมือถือ */
.section-tabs { overflow-x: auto; scrollbar-width: none; margin: 4px 0 14px; }
.section-tabs::-webkit-scrollbar { display: none; }
.section-tabs a { white-space: nowrap; }
.sidenav-label + nav { margin-bottom: 4px; }

/* ปฏิทินวันหยุดรายคน (หน้าทีม → พนักงาน) */
.leave-cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 6px 0 14px; }
.leave-cal-h { text-align: center; font-size: 12px; color: var(--muted); padding-bottom: 2px; }
.leave-cal-d { display: flex; align-items: center; justify-content: center; height: clamp(38px, 7vw, 64px); border-radius: 8px; font-size: 13px; color: inherit; text-decoration: none; }
.leave-cal-d.off { background: #e5484d; color: #fff; font-weight: 600; }
.leave-cal-d.half { background: color-mix(in srgb, #e5484d 30%, transparent); font-weight: 600; }
.leave-cal-d.today { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------- Workshop: รายชื่อ + สถานะจ่ายเงิน (views/roster.tsx, routes/workshops.tsx) ---------- */
.ws-chip { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; line-height: 1.6; background: var(--surface-3); color: var(--muted); white-space: nowrap; vertical-align: middle; }
.ws-chip.ws-paid { background: var(--green-soft); color: var(--green); }
.ws-chip.ws-deposit { background: var(--amber-soft); color: var(--amber-ink, var(--amber)); }
.ws-chip.ws-booked { background: var(--red-soft); color: var(--red-ink); }
.ws-chip.ws-wait { background: var(--surface-3); color: var(--muted); border: 1px dashed var(--line-strong); }
.ws-money.ws-deposit b, .ws-money.ws-booked b:last-child { color: var(--red-ink); }
.ws-seat { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; }
.ws-seat-bar { flex: 1; height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; max-width: 320px; }
.ws-seat-bar i { display: block; height: 100%; background: var(--green); border-radius: 999px; }
.ws-seat.is-low .ws-seat-bar i { background: var(--amber); }
.ws-seat.is-full .ws-seat-bar i { background: var(--red); }
.ws-seat-num { font-size: 0.85rem; white-space: nowrap; }
.ws-seat.is-full .ws-seat-num { color: var(--red-ink); }
.ws-stats .stat-label { font-size: 0.75rem; }
.ws-sum { margin: 4px 0 12px; }
.ws-h3 { margin: 18px 0 8px; font-size: 1rem; }
.student.is-wait { opacity: 0.85; border-style: dashed; }
.ws-pay { text-decoration: none; }
.ws-move { display: flex; gap: 8px; align-items: flex-end; margin: 10px 0; flex-wrap: wrap; }
.ws-move label { flex: 1 1 200px; }
.ws-rounds { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); margin-top: 12px; }
.ws-round { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; margin: 0; }
.ws-round:hover { border-color: var(--line-strong); }
.ws-round-top { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.ws-date { font-weight: 600; color: var(--accent); }
.ws-title { font-size: 1.05rem; }
.ws-counts { display: flex; gap: 6px; flex-wrap: wrap; }
.ws-round-money { margin-top: 4px; }
.ws-found { list-style: none; padding: 0; margin: 0; }
.ws-found li a { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.ws-found li:last-child a { border-bottom: 0; }
/* ลงยอดขาย: เลือกรอบ Workshop */
.sl-ws { border: 1px solid var(--line-strong); border-radius: 12px; padding: 10px 12px; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.sl-ws legend { font-size: 0.85rem; padding: 0 4px; }
.sl-ws select { width: 100%; }
.sl-ws .sl-ws-more { display: none; flex-direction: column; gap: 8px; }
.sl-ws.has-round .sl-ws-more { display: flex; }
.sl-ws-linked { background: var(--green-soft); border-color: transparent; }
.sl-ws-round { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.sl-ws .sl-ws-round select { width: 100%; min-width: 0; grid-column: 1 / -1; }
.sl-ws-round + .sl-ws-round { border-top: 1px dashed var(--line-strong); padding-top: 8px; }
.sl-ws-round [data-sl-round-del] { display: none; }
.sl-ws.has-round .sl-ws-round [data-sl-round-del] { display: inline-flex; }
.sl-ws [data-sl-round-add] { align-self: flex-start; }
.sl-linked { margin: 4px 0 8px; padding-left: 1.2em; }
.sl-items { border: 1px solid var(--line-strong); border-radius: 12px; padding: 10px 12px; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.sl-items legend { font-size: 0.85rem; padding: 0 4px; }
.sl-item { display: flex; gap: 6px; align-items: center; }
.sl-item input[name="product"] { flex: 1; min-width: 0; }
.sl-item input[name="item_qty"] { width: 64px; flex: none; text-align: center; }
.sl-items [data-sl-item-add] { align-self: flex-start; }
@media (max-width: 640px) { .ws-rounds { grid-template-columns: 1fr; } }

/* ยอดขาย: แถบ "รวมทั้งหมด" ของแต่ละวัน — ใส่สีให้เห็นชัดว่าจบวันแล้ว + เว้นระยะก่อนวันถัดไป */
.sl-table tr.sl-sum td { background: color-mix(in srgb, var(--accent) 17%, var(--surface)); color: var(--accent-ink); border-top: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); border-bottom: 3px solid var(--accent); font-size: 0.86rem; padding-top: 9px; padding-bottom: 9px; }
.sl-table tr.sl-sum td:first-child { border-left: 4px solid var(--accent); }
.sl-table tr.sl-sum td strong { color: inherit; font-size: 0.95rem; }
.sl-table tbody + tbody tr:first-child td { border-top: 0; padding-top: 14px; }
@media (max-width: 640px) {
  .sl-table tr.sl-sum { background: color-mix(in srgb, var(--accent) 17%, var(--surface)); border-left: 4px solid var(--accent); color: var(--accent-ink); margin: 6px 0 18px; }
  .sl-table tr.sl-sum td { background: none; border: 0; padding: 0; }
  .sl-table tr.sl-sum td:first-child { border-left: 0; }
}

/* ---------- Second Brain (routes/brain.tsx + brain.js) ---------- */
.brain-card { padding: 12px; }
.brain-capture { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.brain-capture textarea { width: 100%; resize: vertical; font-size: 1rem; min-height: 64px; }
.brain-capture-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.brain-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 8px; }
.brain-item { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.brain-item.is-pinned { border-color: var(--accent); }
.brain-todo { border-left: 4px solid var(--amber); }
.brain-idea { border-left: 4px solid var(--accent); }
.brain-main { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.brain-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.brain-kind { font-weight: 600; }
.brain-kind-todo { color: var(--amber); }
.brain-kind-idea { color: var(--accent-ink); }
.brain-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: flex-start; }
.brain-actions form { margin: 0; }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 0.82rem; }
.brain-move[open], .brain-edit[open] { flex-basis: 100%; order: 9; }
.brain-edit > summary { min-height: 32px; align-items: center; padding: 0 6px; }
.brain-move > summary, .brain-edit > summary { list-style: none; cursor: pointer; display: inline-flex; }
.brain-move > summary::-webkit-details-marker, .brain-edit > summary::-webkit-details-marker { display: none; }
.brain-move[open] form, .brain-edit[open] form { margin-top: 10px; }
.brain-actions:has(details[open]) { flex-basis: 100%; }
.brain-dialog { width: min(560px, calc(100vw - 24px)); border: 1px solid var(--line-strong); border-radius: 18px; padding: 14px; background: var(--surface); color: var(--ink); margin: 12vh auto auto; }
.brain-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.brain-dialog-top { display: flex; justify-content: space-between; align-items: center; }
@media (max-width: 640px) { .brain-dialog { margin: auto auto 0; width: 100%; max-width: 100%; border-radius: 18px 18px 0 0; } }
/* มือถือจอแคบ: ปุ่มบนแถบด้านบนเพิ่ม (💡) → ซ่อนชื่อข้างรูป ไม่ให้ล้นจอ */
@media (max-width: 420px) { .topbar .menu-name { display: none; } }
/* ส่งเสียงแล้ว รอแปลงเป็นข้อความ / แปลงไม่สำเร็จ */
.ally-msg.ally-hearing { opacity: 0.85; animation: ally-hearing 1.4s ease-in-out infinite; }
@keyframes ally-hearing { 50% { opacity: 0.55; } }
.ally-panel .ally-msg.ally-heard-fail { background: var(--red-soft); color: var(--ink); }

/* Second Brain: เลือกธุรกิจ · กรอง · แถบ "สร้างงานแล้ว" · หน้าต่างสร้างงาน */
.brain-picks { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.brain-brands .sl-opt span { white-space: nowrap; }
.brain-filter { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 4px; }
.brain-filter .chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: 0.86rem; text-decoration: none; }
.brain-filter .chip:hover { background: var(--hover); }
.brain-filter .chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.brain-filter .chip .count { opacity: 0.7; font-size: 0.8em; }
.brain-made { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-color: var(--green, #2e7d32); margin-bottom: 12px; }
.brain-made-btns { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.brain-made-btns form { margin: 0; }
.brain-task-form textarea { resize: vertical; }
.brain-task-btns { display: flex; justify-content: flex-end; gap: 8px; }
.brain-saved { font-size: 0.8rem; color: var(--green, #2e7d32); }

/* เมนูซ้าย: ลากเรียงใหม่ (nav-order.js) */
.sidenav [data-nav-list] > *, .sidenav > .sidenav-group > .sidenav-label { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.nav-sorting, .nav-sorting * { cursor: grabbing !important; }
.sidenav .nav-dragging { background: var(--surface) !important; box-shadow: var(--shadow-lg); border-radius: 8px; opacity: 0.95; position: relative; z-index: 2; outline: 1.5px dashed var(--line-strong); }
.menu-pop .linklike.menu-plain { color: var(--ink); text-align: left; }

/* เลือกช่วงเวลา (views/period.tsx) — หน้า Sales / Analytics */
.period { margin: 8px 0 12px; }
.period .period-head { margin: 0 0 8px; }
.period-quick { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.period-quick .chip, .an-chips .chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: 0.86rem; text-decoration: none; }
.period-quick .chip:hover, .an-chips .chip:hover { background: var(--hover); }
.period-quick .chip.on, .an-chips .chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.period-custom { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.period-custom label { flex: 1 1 140px; font-size: 0.8rem; }
.period-custom .btn { flex: 0 0 auto; }

/* ---------- Analytics (routes/analytics.tsx) ---------- */
.an-delta { font-size: 0.78rem; font-weight: 600; margin-left: 4px; white-space: nowrap; }
.an-delta.up { color: var(--green); }
.an-delta.down { color: var(--red); }
.an-vs { margin: -4px 0 10px; }
.an-notes ul { margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; line-height: 1.5; }
.an-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px 28px; }
.an-rank h3, .an-trend h3 { margin: 0 0 4px; font-size: 1rem; }
.an-rank ol { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.an-rank li { display: grid; grid-template-columns: 22px minmax(70px, 1fr) minmax(60px, 1.1fr) auto; gap: 8px; align-items: center; font-size: 0.88rem; }
.an-rank-no { color: var(--muted); font-size: 0.78rem; text-align: center; }
.an-rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-rank-bar { height: 10px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.an-rank-bar i { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.an-rank li.is-best .an-rank-name { font-weight: 600; }
.an-rank-num { text-align: right; white-space: nowrap; }
.an-trend-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.an-bars { display: flex; align-items: stretch; gap: 2px; height: 180px; margin-top: 12px; padding-bottom: 20px; border-bottom: 1px solid var(--line); position: relative; }
.an-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; position: relative; outline: none; }
.an-bar { display: block; width: 100%; max-width: 36px; margin: 0 auto; background: var(--accent); border-radius: 4px 4px 0 0; opacity: 0.8; }
.an-col.is-best .an-bar { opacity: 1; }
.an-col:hover .an-bar, .an-col:focus .an-bar { opacity: 1; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--accent); }
.an-col.is-future .an-bar { opacity: 0.25; }
.an-x { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-size: 0.7rem; color: var(--muted); white-space: nowrap; }
.an-col:hover::after, .an-col:focus::after {
  content: attr(data-tip); white-space: pre; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); z-index: 5;
  background: var(--ink); color: var(--bg); font-size: 0.78rem; line-height: 1.4; padding: 6px 9px; border-radius: 8px; pointer-events: none; box-shadow: var(--shadow-lg);
}
.an-col:first-child:hover::after, .an-col:first-child:focus::after { left: 0; transform: none; }
.an-col:last-child:hover::after, .an-col:last-child:focus::after { left: auto; right: 0; transform: none; }
.an-months td a { white-space: nowrap; }
@media (max-width: 640px) { .an-rank li { grid-template-columns: 20px minmax(60px, 1fr) 50px auto; } .an-bars { height: 150px; } }

/* Payroll: ตั้งค่าเงินเดือนทุกคนในตารางเดียว */
.pay-how p { margin: 4px 0; line-height: 1.55; }
.pay-setup-table select, .pay-setup-table input[type=number] { min-width: 110px; }
.pay-setup-table td { vertical-align: middle; }
.pay-setup-table tr.pay-unset td:first-child { font-weight: 600; }
.pay-setup-table label.check { flex-direction: row; align-items: center; gap: 6px; white-space: nowrap; }

/* ---------- เมนูคลิกขวา (ctxmenu.js) ---------- */
.ctx-menu {
  position: fixed; z-index: 200; width: 260px; max-height: min(480px, 80vh); display: flex; flex-direction: column;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px;
  animation: pop-in 0.1s ease-out; font-size: 0.9rem;
}
.ctx-search { margin: 0 0 4px; padding: 7px 10px !important; font-size: 0.88rem !important; border-radius: 8px !important; background: var(--surface-2) !important; }
.ctx-list { overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.ctx-head { font-size: 0.74rem; color: var(--muted); padding: 6px 8px 2px; }
.ctx-sep { height: 1px; background: var(--line); margin: 4px 2px; }
.ctx-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border: 0; border-radius: 7px; background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.ctx-item.on { background: var(--hover); }
.ctx-item.danger { color: var(--red); }
.ctx-ico { width: 18px; text-align: center; flex-shrink: 0; opacity: 0.85; }
.ctx-l { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-none { padding: 8px; color: var(--muted); font-size: 0.85rem; }
.ctx-meta { border-top: 1px solid var(--line); margin-top: 4px; padding: 6px 8px 2px; font-size: 0.75rem; color: var(--muted); white-space: pre-line; }

/* ข้อความที่ใส่ของผ่านเมนู "/" (views/richtext.tsx) */
.rt .rt-h { display: inline-block; font-weight: 700; color: var(--ink); }
.rt .rt-h1 { font-size: 1.25em; }
.rt .rt-h2 { font-size: 1.12em; }
.rt .rt-hr { border: 0; border-top: 1px solid var(--line-strong); margin: 6px 0; }
.rt .rt-imgwrap { display: inline-block; margin: 4px 0; }
.rt .rt-img { display: block; max-width: min(100%, 480px); max-height: 360px; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
.rt a { overflow-wrap: anywhere; }
.brain-title { font-weight: 600; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; line-height: 1.45; }
.brain-title:hover { text-decoration: underline; }
.brain-rest { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; color: var(--ink-2); font-size: 0.92rem; }
.brain-page { display: flex; flex-direction: column; gap: 10px; }
.brain-page-title { margin: 0; font-size: 1.4rem; overflow-wrap: anywhere; }
.brain-page-actions { margin: 4px 0 12px; }

/* ---------- แถบแจ้งเตือนใต้กระดิ่ง + หน้าต่างเด้ง (notif.js) ---------- */
.notif-pop { position: fixed; inset: auto; margin: 0; width: min(400px, calc(100vw - 16px)); max-height: min(560px, 75vh); padding: 0; overflow: hidden; display: none;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--shadow-lg); }
.notif-pop:popover-open { display: flex; flex-direction: column; animation: pop-in 0.12s ease-out; }
.notif-pop .np { display: flex; flex-direction: column; min-height: 0; max-height: inherit; }
.np-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 10px; border-bottom: 1px solid var(--line); }
.np-gap { flex: 1; }
.np-body { overflow-y: auto; min-height: 0; flex: 1; }
.np-body .notif-list { border: 0; border-radius: 0; }
.np-body .notif-list li a { padding: 10px 14px; }
.np-body .empty { margin: 16px; }
.np-all { display: block; text-align: center; padding: 10px; border-top: 1px solid var(--line); color: var(--accent-ink); text-decoration: none; }
.np-all:hover { background: var(--hover); }
.notif-peek { width: min(760px, 96vw); max-height: 88vh; padding: 0; border: 1px solid var(--line-strong); border-radius: 18px; background: var(--bg); color: var(--ink); box-shadow: var(--shadow-lg); overflow: hidden; }
.notif-peek[open] { display: flex; flex-direction: column; }
.notif-peek::backdrop { background: rgba(20, 20, 22, 0.4); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.npk-top { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.npk-body { overflow-y: auto; padding: 8px 20px 24px; }
@media (max-width: 640px) {
  .notif-pop { left: 8px !important; right: 8px !important; width: auto; }
  .notif-peek { width: 100%; max-width: 100%; max-height: 92vh; margin: auto 0 0; border-radius: 18px 18px 0 0; }
  .npk-body { padding: 6px 14px 20px; }
}
.brain-doc { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.brain-doc-title { font-size: 1.4rem !important; font-weight: 700; border: 0 !important; padding: 4px 0 !important; background: transparent !important; box-shadow: none !important; }
.brain-doc-title:focus { outline: none; }
.brain-doc-body { min-height: 160px; resize: vertical; line-height: 1.6; }
.brain-doc-foot { display: flex; justify-content: space-between; align-items: center; }
.brain-preview summary { cursor: pointer; }
.nt-save[hidden] { display: none !important; }

/* ---------- Classes: มุมมองปฏิทิน / บอร์ด · รับเงินตอนเพิ่มชื่อ · ย้ายรอบ ---------- */
.ws-viewbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0 12px; }
.ws-views a { padding: 5px 14px; border-radius: 6px; color: var(--ink-2); text-decoration: none; font-size: 0.88rem; }
.ws-views a.on { background: var(--surface); color: var(--accent-ink); font-weight: 600; box-shadow: var(--shadow-xs), 0 0 0 1px var(--line); }
.ws-when { margin: 0; }
.ws-cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.ws-cal-dow { text-align: center; font-size: 0.75rem; color: var(--muted); }
.ws-cal-day { min-height: 92px; border: 1px solid var(--line); border-radius: 8px; padding: 4px; display: flex; flex-direction: column; gap: 3px; background: var(--surface); min-width: 0; }
.ws-cal-day.is-past { background: var(--surface-2); }
.ws-cal-day.is-today { outline: 2px solid var(--accent); }
.ws-cal-num { display: flex; justify-content: space-between; align-items: center; font-size: 0.78rem; font-weight: 600; color: var(--ink-2); }
.ws-cal-add { text-decoration: none; color: var(--muted); width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; opacity: 0; }
.ws-cal-day:hover .ws-cal-add, .ws-cal-add:focus { opacity: 1; background: var(--hover); }
.ws-cal-item { display: flex; flex-direction: column; text-decoration: none; color: var(--ink); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-left: 3px solid var(--accent); border-radius: 5px; padding: 3px 5px; font-size: 0.72rem; line-height: 1.3; min-width: 0; }
.ws-cal-item b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.ws-cal-item span { color: var(--ink-2); }
.ws-cal-item.is-full { border-left-color: var(--red); }
.ws-cal-item:hover { background: color-mix(in srgb, var(--accent) 20%, var(--surface)); }
@media (max-width: 640px) {
  .ws-cal-day { min-height: 56px; padding: 3px; }
  .ws-cal-item span { display: none; }
  .ws-cal-item { font-size: 0.66rem; padding: 2px 3px; }
}
.ws-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; align-items: start; }
.ws-col { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.ws-col h3 { margin: 2px 4px 4px; font-size: 0.95rem; }
.ws-col .ws-round { margin: 0; }
.ws-col-full h3 { color: var(--red); }
.ws-pay-in { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.ws-pay-in legend { font-weight: 600; font-size: 0.9rem; padding: 0 4px; }
.student-move > summary { list-style: none; }
.student-move > summary::-webkit-details-marker { display: none; }
.student-move[open] { flex-basis: 100%; }
.student-move .ws-move { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.ws-cal-list-h { margin: 16px 0 8px; font-size: 1rem; }
.ws-chip.att-present { background: var(--green-soft); color: var(--green); }
.ws-chip.att-absent { background: var(--red-soft); color: var(--red-ink); }
.nt-peek .ws-roster { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; box-shadow: none; }
/* หน้างานเต็มแบบแก้ได้ทันที: ช่องต่างๆ ดูเหมือนข้อความธรรมดา ชี้แล้วค่อยเห็นกรอบ */
.task-inline { margin: 0; }
.task-inline .task-detail-head { display: flex; align-items: center; gap: 8px; }
.task-save { margin-left: auto; }
.task-title-in { width: 100%; font-size: 1.6rem !important; font-weight: 700; border: 0 !important; padding: 4px 0 !important; margin: 6px 0 4px; background: transparent !important; box-shadow: none !important; color: var(--ink); }
.task-title-in:focus { outline: none; }
.props-inline .inl { border: 1px solid transparent !important; background: transparent !important; box-shadow: none !important; padding: 2px 6px !important; margin-left: -7px; min-height: 0; width: auto; max-width: 100%; font: inherit; color: inherit; border-radius: 8px; cursor: pointer; }
.props-inline .inl:hover { background: var(--surface-2) !important; }
.props-inline .inl:focus { border-color: var(--line-strong) !important; background: var(--surface) !important; outline: none; cursor: text; }
.props-inline .inl-link { display: flex; gap: 8px; align-items: center; }
.props-inline .inl-link .inl { flex: 1; min-width: 0; }
.task-inline .prop-fields { margin: 8px 0; }
.task-note-in { width: 100%; min-height: 96px; margin-top: 10px; border: 1px solid transparent !important; background: transparent !important; box-shadow: none !important; padding: 8px !important; margin-left: -8px; line-height: 1.6; resize: none; border-radius: 10px; }
.task-note-in:hover { background: var(--surface-2) !important; }
.task-note-in:focus { border-color: var(--line-strong) !important; background: var(--surface) !important; outline: none; }
.task-del { text-align: right; margin: -4px 4px 12px; }

/* รีวิวไฟล์งาน: ดู + คอมเมนต์ + วงบนงาน (review.js) */
.frv { padding: 12px 0; border-top: 1px solid var(--line); }
.frv:first-of-type { border-top: 0; }
.frv-head { display: flex; align-items: center; gap: 10px; }
.frv-head .file-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.frv-viewer { position: relative; }
.frv-stage { position: relative; display: flex; justify-content: center; width: 100%; }
.frv-stage .frv-media { width: auto; max-width: 100%; height: auto; max-height: 72vh; object-fit: contain; display: block; }
.frv-stage video.frv-media { width: 100%; }
.frv-compact .frv-stage .frv-media { max-height: 56vh; }
.frv-canvas { position: absolute; left: 0; top: 0; pointer-events: none; touch-action: none; }
.frv.is-drawing .frv-canvas { pointer-events: auto; cursor: crosshair; }
.frv.is-drawing .frv-viewer { outline: 3px solid var(--accent, #2a9d8f); outline-offset: -3px; }
.frv-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.frv-tools[hidden] { display: none; }
.frv-tgroup { display: inline-flex; gap: 4px; align-items: center; }
.frv-tgroup + .frv-tgroup { padding-left: 8px; border-left: 1px solid var(--line); }
.frv-tools button { min-width: 34px; min-height: 34px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--ink); font: inherit; cursor: pointer; }
.frv-tools button:hover { background: var(--surface-3); }
.frv-tools button.on { border-color: var(--line-strong); background: var(--surface); }
.frv-tools .frv-color { min-width: 26px; min-height: 26px; width: 26px; height: 26px; border-radius: 50%; background: var(--c); border: 2px solid var(--line-strong); }
.frv-tools .frv-color.on { outline: 2px solid var(--ink); outline-offset: 2px; }
.frv-h { font-size: 0.95rem; margin: 10px 0 6px; }
.frv-comments .comments li.on { background: var(--amber-soft); border-radius: 10px; }
.frv-comments .comments li.has-markup { cursor: default; }
.frv-show { border: 0; background: var(--surface-3); border-radius: 999px; padding: 1px 8px; margin-right: 6px; font-size: 0.75rem; cursor: pointer; color: var(--ink); }
.frv-form { margin-top: 6px; }
.frv-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.frv-actions .frv-drawn { margin-right: auto; }
/* หน้าต่างงาน = เนื้อหาเต็มหน้า → กว้างขึ้น */
.tpanel { width: min(860px, 100vw); }
.tp-full-body > .card { box-shadow: none; border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 14px 0; margin: 0; background: transparent; }
.tp-full-body > .card:first-child { border-top: 0; padding-top: 0; }
.tp-full-body .task-title-in { font-size: 1.35rem !important; }
/* ===== โหมดคุย (คุยโต้ตอบด้วยเสียง ไม่ต้องกด) ===== */
.ally-convo { display: none; }
.ally-panel.convo .ally-convo {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px;
  position: absolute; inset: 0; z-index: 4; color: var(--ink); text-align: center;
  background: color-mix(in srgb, var(--surface) 86%, transparent); -webkit-backdrop-filter: blur(16px) saturate(150%); backdrop-filter: blur(16px) saturate(150%);
  animation: pop-in 0.15s ease-out;
}
.ally-convo-mark { width: 150px; height: 150px; color: var(--ink); transition: opacity 0.2s; }
.ally-convo-mark circle { fill: var(--accent); transform-box: fill-box; transform-origin: center; }
.ally-convo[data-state="listen"] .ally-convo-mark circle { animation: ally-listen 1.6s ease-in-out infinite; }
.ally-convo[data-state="capture"] .ally-convo-mark circle { animation: ally-listen 0.5s ease-in-out infinite; }
.ally-convo[data-state="think"] .ally-convo-mark { animation: ally-blink 1.1s ease-in-out infinite; }
.ally-convo[data-state="speak"] .ally-convo-mark circle { animation: ally-listen 0.8s ease-in-out infinite; }
.ally-convo-state { font-size: 1.6rem; font-weight: 700; min-height: 1.4em; }
.ally-convo-hint { font-size: 0.95rem; color: var(--muted); max-width: 300px; line-height: 1.6; }
.ally-convo-end { margin-top: 10px; font: inherit; font-size: 1.1rem; font-weight: 600; padding: 14px 34px; border-radius: 999px; border: 0; cursor: pointer; background: var(--red-soft); color: var(--red-ink); }
.ally-convo-btn.on { background: var(--accent); color: var(--on-accent); border-radius: 999px; }

/* ===== พิมพ์ด้วยเสียง (พูดแล้วคัดลอก) ===== */
.ally-msg.ally-dict { align-self: stretch; max-width: 100%; display: grid; gap: 8px; background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink); }
.ally-dict-head { font-weight: 600; font-size: 0.85rem; color: var(--muted); }
.ally-dict-head small { font-weight: 400; }
.ally-dict-head { display: flex; align-items: center; gap: 6px; }
.ally-dict-close { margin-left: auto; width: 28px; height: 28px; border-radius: 999px; border: 0; background: transparent; color: var(--muted); font: inherit; cursor: pointer; }
.ally-dict-close:hover { background: var(--line); color: var(--ink); }
.ally-msg.ally-dict { transition: opacity 0.25s, transform 0.25s; }
.ally-msg.ally-dict.ally-dict-gone { opacity: 0; transform: scale(0.97); }
.ally-dict-wait { color: var(--muted); animation: ally-hearing 1.4s ease-in-out infinite; }
.ally-dict-text { width: 100%; font: inherit; font-size: 1rem; line-height: 1.6; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--bg); color: var(--ink); resize: vertical; box-sizing: border-box; }
.ally-dict-copy { justify-self: end; font: inherit; font-weight: 600; padding: 8px 22px; border-radius: 999px; border: 0; cursor: pointer; background: var(--accent); color: var(--on-accent); }
.ally-panel.dictating .ally-dict-btn { background: var(--accent); border-radius: 999px; }

/* ‹ Today › (views/navstep.tsx) */
.navstep-bar { justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.navstep-label { font-size: 1.05rem; }
.navstep { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.navstep a { display: inline-flex; align-items: center; justify-content: center; min-height: 32px; border-radius: 9px; color: var(--ink); text-decoration: none; font-weight: 600; }
.navstep-btn { width: 34px; font-size: 1.25rem; line-height: 1; }
.navstep-today { padding: 0 14px; font-size: 0.9rem; }
.navstep a:hover { background: var(--surface-3); }
.navstep-today.is-on { color: var(--muted); }
.monthpicker.navstep-bar { background: transparent; border: 0; padding: 0 2px; }
/* Publish หน้า */
.pg-publish { position: relative; margin-left: auto; }
.pg-publish > summary { list-style: none; cursor: pointer; }
.pg-publish > summary::-webkit-details-marker { display: none; }
.pg-publish summary.is-live { color: var(--green); border-color: var(--green); }
.pg-publish-pop { position: absolute; right: 0; top: calc(100% + 6px); width: min(380px, 90vw); padding: 12px; z-index: 30; display: flex; flex-direction: column; gap: 8px; }
.pub-page { max-width: 860px; margin: 0 auto; padding: 24px 16px 48px; }
.pub-foot { text-align: center; margin-top: 32px; }
.frv-tools button.frv-color, .frv-tools button.frv-color.on, .frv-tools button.frv-color:hover { background: var(--c); }
.task-props > summary { cursor: pointer; list-style: none; padding: 4px 0; } .task-props > summary::-webkit-details-marker { display: none; } .task-props[open] > summary { margin-bottom: 4px; }

/* ถังขยะ */
.trash-list { list-style: none; padding: 0; }
.trash-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line, rgba(0,0,0,.08)); }
.trash-item:last-child { border-bottom: 0; }
.trash-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.trash-acts { display: flex; gap: 6px; flex-shrink: 0; }
@media (max-width: 600px) { .trash-item { flex-direction: column; align-items: stretch; } }
/* ---------- วันของฉัน (บนสุดของหน้าแรก): ด่วน/เลยกำหนด → วันนี้ → พรุ่งนี้ (details พับไว้) ---------- */
.myday-sec { border-radius: 12px; padding: 10px 12px; margin-top: 10px; }
.myday-sec[hidden] { display: none; }
.myday-sh { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; font-size: 0.95rem; font-weight: 700; color: var(--ink); }
.myday-sh .muted { font-weight: 400; margin-left: auto; }
.myday-hot { background: var(--red-soft); border: 1px solid color-mix(in srgb, var(--red) 25%, transparent); }
.myday-hot .myday-sh { color: var(--red); }
.myday-hot .myday-sh .count { background: var(--red); color: #fff; }
.myday-today { background: transparent; border: 1px solid var(--line-strong); }
.myday-today > .myday-sh .count { background: var(--accent); color: var(--on-accent); }
.myday-next { background: var(--surface-2); }
/* หมวดในวัน: แถบสีซ้าย + หัวข้อสีเดียวกัน (สีข้อความผสมสีตัวอักษรให้อ่านออกทั้งโหมดสว่าง/มืด) */
.myday-grp { --g: var(--muted); border-left: 3px solid var(--g); padding: 8px 10px 8px 12px; margin-top: 10px; border-radius: 4px 10px 10px 4px; background: color-mix(in srgb, var(--g) 7%, var(--surface)); }
.myday-grp > .myday-h { margin: 0 0 6px; font-size: 0.82rem; font-weight: 700; color: color-mix(in srgb, var(--g) 65%, var(--ink)); }
.myday-grp > .myday-h .count { background: color-mix(in srgb, var(--g) 18%, transparent); color: inherit; }
.myday-grp .task:last-child { margin-bottom: 0; }
.g-send { --g: #ff9f0a; }
.g-review { --g: var(--purple); }
.g-event { --g: var(--blue); }
.g-self { --g: var(--green); }
/* งานส่วนตัว: เลือกหมวดปฏิทิน + จุดสีหมวดหน้าข้อความ */
.myday-add select.myday-cat { width: 132px; flex: none; }
.myday-todo .dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }
@media (max-width: 480px) { .myday-add select.myday-cat { flex: 1; width: auto; } }
.myday-next > summary { cursor: pointer; list-style: none; margin: 0; }
.myday-next > summary::-webkit-details-marker { display: none; }
.myday-next > summary::after { content: '›'; color: var(--muted); transition: transform 0.15s; }
.myday-next[open] > summary::after { transform: rotate(90deg); }
.myday-next[open] > summary { margin-bottom: 4px; }
.myday-date { margin: 4px 0 2px; }
.myday-h { font-size: 0.78rem; font-weight: 600; color: var(--muted); text-transform: none; margin: 14px 0 6px; }
.myday-events, .myday-todos { list-style: none; margin: 0 0 6px; padding: 0; }
.myday-events a { display: flex; gap: 10px; align-items: baseline; padding: 7px 8px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.myday-events a:hover { background: var(--surface-2); }
.myday-time { min-width: 72px; font-variant-numeric: tabular-nums; }
.myday-todo { display: flex; align-items: center; gap: 6px; padding: 2px 4px; border-radius: 8px; }
.myday-todo:hover { background: var(--surface-2); }
.myday-todo form { margin: 0; }
.myday-todo.is-done .grow { color: var(--muted); text-decoration: line-through; }
.myday .link-btn { border: 0; background: transparent; font: inherit; color: var(--accent-ink); cursor: pointer; padding: 4px 6px; border-radius: 6px; white-space: nowrap; }
.myday .link-btn.muted { color: var(--faint); }
.myday .link-btn:hover { background: var(--surface-3); color: var(--ink); }
.myday-add { display: flex; gap: 6px; margin-top: 6px; }
.myday-add input[name="text"] { flex: 1; min-width: 0; }
.myday-add input[type="date"] { width: 140px; flex: none; }
@media (max-width: 480px) { .myday-add { flex-wrap: wrap; } .myday-add input[name="text"] { flex-basis: 100%; } .myday-add input[type="date"] { flex: 1; } }
/* ---------- Private (ที่จดส่วนตัวของเจ้าของ) ---------- */
.private-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.private-head form { margin: 0; }
.private-tools { display: flex; gap: 8px; margin-bottom: 10px; }
.private-search { flex: 1; min-width: 0; }
.private-list { list-style: none; margin: 0; padding: 0; }
.private-list a { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 8px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.private-list a:hover { background: var(--surface-2); }
.private-list strong { overflow-wrap: anywhere; }
.private-list .small { flex: none; }
.private-body { font-family: inherit; min-height: 260px; }
.private-actions { display: flex; gap: 8px; }
.private-delete { margin: 16px 0 0; text-align: right; }

/* เบิกเงิน: ปุ่มอนุมัติ/ไม่อนุมัติในรายการ */
.row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.row-actions form { margin: 0; }

/* แป้นพิมพ์มือถือขึ้นระหว่างพิมพ์ในหน้าต่างงาน: nav.js ปรับกรอบให้พอดีพื้นที่ที่เห็น → เนื้อในต้องยืดตามกรอบ แล้วเลื่อนในตัวได้ */
.tpanel[data-kb] .tp { height: 100%; max-height: none; }

/* จอมือถือแคบ (≤360px): ไอคอนบนแถบบนเกินจอ ทำให้ทั้งหน้ากว้างเกินและหน้าต่างลงยอด/รายจ่ายโดนตัดขอบ → บีบระยะ/ขนาดไอคอนให้พอดี */
@media (max-width: 360px) {
  .topbar { gap: 6px; padding-left: 10px; padding-right: 8px; }
  .topbar-right { gap: 2px; }
  .topbar-right .icon-btn, .topbar-right .bell { width: 32px; height: 32px; }
  .topbar .brand { gap: 6px; font-size: 0.9rem; min-width: 0; }
}
/* กันแถบบนดันหน้ากว้างเกินจอในทุกกรณี (เมนูที่เด้งลงมายังแสดงได้) */
.topbar { overflow-x: clip; }
/* แท็บ (เช่น บอสน้อยสอนถ่ายรูป / Thebossnoi) บนจอแคบ: ห้ามดันหน้ากว้างเกินจอ — ลดระยะในปุ่ม และถ้ายังไม่พอให้เลื่อนในแถบเอง */
@media (max-width: 400px) {
  .tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { padding: 6px 8px; font-size: 0.84rem; }
}

/* Ally: แนบรูป (สลิป ใบเสร็จ) */
.ally-input { flex-wrap: wrap; }
.ally-thumbs { flex-basis: 100%; display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; }
.ally-thumb { position: relative; flex: none; }
.ally-thumb img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block; }
.ally-thumb-x { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--ink); color: var(--surface); font-size: 0.9rem; line-height: 1; cursor: pointer; }
.ally-attach { width: 40px; height: 40px; flex: none; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); cursor: pointer; display: grid; place-items: center; padding: 0; }
.ally-attach svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ally-attach:active { transform: scale(0.94); }
body.ally-app .ally-input.has-images .ally-send { display: inline-block; }
.ally-msg-imgs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.ally-msg-imgs img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; display: block; }

/* ---------- หน้าต่างดูไฟล์ (แบบ Google Drive) — public/file-viewer.js ---------- */
html.fv-open { overflow: hidden; }
.fv {
  position: fixed; inset: 0; z-index: 900; display: none; flex-direction: column;
  background: rgba(12, 12, 14, 0.96); color: #f2f2f2; -webkit-user-select: none; user-select: none;
}
.fv.on { display: flex; animation: pop-in 0.12s ease-out; }
.fv .ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fv-top {
  display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: linear-gradient(rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0)); position: relative; z-index: 3;
}
.fv-btn, .fv-pct, .fv-menu > * {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 40px; height: 40px; padding: 0 9px;
  border: 0; border-radius: 999px; background: transparent; color: inherit; font: inherit; cursor: pointer; text-decoration: none;
}
.fv-btn:hover, .fv-pct:hover { background: rgba(255, 255, 255, 0.12); }
.fv-btn[hidden] { display: none; }
.fv-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.fv-title strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fv-title span { font-size: 0.78rem; color: rgba(255, 255, 255, 0.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fv-zoom { display: flex; align-items: center; background: rgba(255, 255, 255, 0.08); border-radius: 999px; }
.fv-zoom[hidden] { display: none; }
.fv-pct { min-width: 58px; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.fv-acts { display: flex; align-items: center; gap: 2px; }
.fv-share { background: #fff; color: #111; padding: 0 16px; font-weight: 600; margin: 0 4px; }
.fv-share:hover { background: #e9e9e9; }
.fv-share .ico { width: 18px; height: 18px; }
.fv-share-wrap { position: relative; }
.fv-menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 250px; padding: 6px; border-radius: 14px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
}
.fv-menu[hidden] { display: none; }
.fv-menu > * { justify-content: flex-start; border-radius: 10px; width: 100%; font-size: 0.92rem; }
.fv-menu > *:hover { background: var(--surface-2); }
.fv-stage { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; margin-top: -56px; padding: 56px 72px 40px; }
.fv-media { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 2px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); }
img.fv-media { cursor: zoom-in; transform-origin: center; will-change: transform; -webkit-user-drag: none; }
img.fv-media.zoomed { cursor: grab; box-shadow: none; }
img.fv-media.zoomed:active { cursor: grabbing; }
video.fv-media { width: min(100%, 1280px); background: #000; touch-action: auto; }
audio.fv-media { width: min(100%, 520px); box-shadow: none; }
.fv-pdf { width: min(100%, 1000px); height: 100%; border: 0; background: #fff; border-radius: 4px; }
.fv-stage.loading::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; margin: -17px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.25); border-top-color: #fff; animation: fv-spin 0.8s linear infinite;
}
@keyframes fv-spin { to { transform: rotate(360deg); } }
.fv-none { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 28px; border-radius: 16px; background: rgba(255, 255, 255, 0.06); max-width: 420px; }
.fv-none strong { word-break: break-word; }
.fv-none p { margin: 0; color: rgba(255, 255, 255, 0.7); }
.fv-none .ico { width: 18px; height: 18px; }
.fv-nav {
  position: absolute; top: 50%; z-index: 2; width: 48px; height: 48px; margin-top: -24px; border-radius: 50%; display: grid; place-items: center;
  border: 0; background: rgba(40, 40, 44, 0.85); color: #fff; cursor: pointer; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}
.fv-nav:hover { background: rgba(70, 70, 76, 0.95); }
.fv-nav[hidden] { display: none; }
.fv-prev { left: 14px; }
.fv-next { right: 14px; }
.fv-count {
  position: absolute; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 2;
  font-size: 0.8rem; color: rgba(255, 255, 255, 0.75); background: rgba(0, 0, 0, 0.45); padding: 3px 10px; border-radius: 999px;
}
.fv-count:empty { display: none; }
@media (max-width: 720px) {
  .fv-top { flex-wrap: wrap; padding-left: 6px; padding-right: 6px; gap: 2px; }
  .fv-title { order: 0; }
  .fv-acts { order: 1; }
  .fv-zoom { display: none; } /* มือถือ = ใช้สองนิ้วซูม / แตะสองครั้ง */
  .fv-share span { display: none; }
  .fv-share { padding: 0 10px; background: transparent; color: inherit; margin: 0; }
  .fv-stage { padding: 56px 0 36px; }
  .fv-nav { width: 40px; height: 40px; margin-top: -20px; background: rgba(40, 40, 44, 0.6); }
  .fv-prev { left: 6px; }
  .fv-next { right: 6px; }
}

/* แผงดาวน์โหลดโฟลเดอร์ (.zip) — ใช้หน้าตาเดียวกับแผงอัปโหลด */
.zip-panel { z-index: 51; }
.zip-body { padding: 12px 16px 14px; display: flex; flex-direction: column; gap: 8px; }
.zip-bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.zip-bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width 0.25s; }

/* ส่งงาน (ล่างสุดของหน้างาน): รอบที่ส่งแล้ว + เลือกส่งไฟล์/ลิงก์ */
.submit-box .sub-round { border-top: 1px solid var(--line); padding: 10px 0; }
.submit-box .sub-round:first-of-type { border-top: 0; }
.submit-box .sub-round > summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.submit-box .sub-round > summary::-webkit-details-marker { display: none; }
.submit-box .sub-round > summary::before { content: '›'; display: inline-block; width: 1em; color: var(--muted); transition: transform 0.15s; }
.submit-box .sub-round[open] > summary::before { transform: rotate(90deg); }
.submit-box .sub-round > :not(summary) { margin-top: 10px; }
.sub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.sub-item { position: relative; }
.sub-item > .sub-thumb { width: 100%; }
.sub-del { position: absolute; top: 4px; right: 4px; margin: 0; }
.sub-del button { width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 0.75rem; cursor: pointer; display: grid; place-items: center; opacity: 0; transition: opacity 0.15s; }
.sub-item:hover .sub-del button, .sub-del button:focus-visible { opacity: 1; }
.sub-del button:hover { background: var(--red); }
@media (hover: none) { .sub-del button { opacity: 1; } }
.sub-thumb { aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); display: grid; place-items: center; border: 1px solid var(--line); }
.sub-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sub-thumb .sub-name { padding: 6px; text-align: center; word-break: break-all; color: var(--muted); }
/* ---------- วันของฉัน: งานส่วนตัวบนสุด + แถบ "ทีมวันนี้" (บล็อกรูปพนักงาน + ป้ายสถานะ) ---------- */
.myday-h .count { margin-left: 6px; }
.g-self .myday-add { margin: 0 0 6px; }
.myday-pev { padding: 6px 8px; }
.myday-pev a { color: var(--ink); text-decoration: none; }
.myday-pev a:hover { text-decoration: underline; }
.myday-pev-ic { display: inline-flex; width: 22px; justify-content: center; color: var(--muted); flex: none; }
.myday-time-r { white-space: nowrap; font-variant-numeric: tabular-nums; }
.teamstrip { margin: 4px 0 2px; }
.teamstrip-ok { margin: 0 0 4px; }
.teamstrip-row { list-style: none; margin: 0; padding: 2px 0 6px; display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.tsb { --tone: var(--muted); --tone-soft: var(--gray-soft); display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 12px 8px 10px; border-radius: 14px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); text-align: center; min-width: 0; position: relative; overflow: hidden; }
.tsb::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--tone); opacity: 0.85; }
.tsb .avatar.lg { width: 56px; height: 56px; border-radius: 14px; font-size: 1.3rem; margin: 0 0 4px; box-shadow: 0 0 0 2px var(--surface-2), 0 0 0 4px var(--tone-soft); }
.tsb-off .avatar.lg { filter: grayscale(0.55); opacity: 0.85; }
.tsb-name { font-weight: 600; font-size: 0.86rem; color: var(--ink); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tsb-tag { font-size: 0.74rem; font-weight: 600; color: var(--tone); background: var(--tone-soft); padding: 2px 8px; border-radius: 999px; line-height: 1.5; max-width: 100%; }
.tsb-detail { font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; line-height: 1.3; }
.tsb-off { --tone: var(--blue); --tone-soft: var(--blue-soft); }
.tsb-plan { --tone: var(--accent-ink); --tone-soft: var(--accent-soft); }
.tsb-notin { --tone: var(--red-ink, var(--red)); --tone-soft: var(--red-soft); }
.tsb-late { --tone: #f5a524; --tone-soft: rgba(245, 165, 36, 0.15); }
.tsb-early, .tsb-tag-early { --tone: var(--purple); --tone-soft: var(--purple-soft); }
.tsb-tag { border-radius: 8px; }
:root[data-theme="light"] .tsb-late { --tone: #b86e00; }
:root[data-theme="light"] .tsb { background: var(--surface); }
/* งานส่วนตัวที่เสร็จแล้วในปฏิทิน: หน้าตาเหมือนนัดในหมวด แค่จางลง + ขีดฆ่าชื่อ */
.cal-chip.is-done, .day-item.is-done { opacity: 0.55; }
.cal-chip.is-done, .day-item.is-done .day-item-title { text-decoration: line-through; }
.mine .page-head h2 .count { margin-left: 8px; }
.mine-group { margin-top: 6px; }
.mine-late > .myday-h { color: var(--red-ink, var(--red)); }

/* หน้างาน: ช่องข้อมูลมีสี (สีเดียวกับบอร์ด) — data-v = ค่าที่เลือก */
.props-color .chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px !important; padding: 3px 12px !important; font-weight: 600; font-size: 0.88rem; border: 0 !important; background: var(--gray-soft) !important; color: var(--muted) !important; width: auto; min-height: 0; line-height: 1.6; }
.props-color select.chip { padding-right: 26px !important; margin-left: 0; }
.props-color [data-v=todo] { background: var(--gray-soft) !important; color: var(--muted) !important; }
.props-color [data-v=doing] { background: var(--blue-soft) !important; color: var(--blue) !important; }
.props-color [data-v=review] { background: var(--purple-soft) !important; color: var(--purple) !important; }
.props-color [data-v=revise] { background: var(--amber-soft) !important; color: var(--amber) !important; }
.props-color [data-v=done] { background: var(--green-soft) !important; color: var(--green) !important; }
.props-color [name=assignee_id]:not([data-v='']), .props-color [data-f=assignee_id]:not([data-v='']) { background: var(--accent-soft) !important; color: var(--accent-ink) !important; }
.props-color [data-v=urgent] { background: var(--red-soft) !important; color: var(--red) !important; }
.props-color [name=kind][data-v=task] { background: var(--blue-soft) !important; color: var(--blue) !important; }
.props-color [name=project_id]:not([data-v='']), .props-color [data-f=project_id] { background: var(--purple-soft) !important; color: var(--purple) !important; }
.props-color .due-late .chip-due, .props-color .due-late .due-lbl { background: var(--red-soft) !important; color: var(--red) !important; }
.props-color .due-soon .chip-due, .props-color .due-soon .due-lbl { background: var(--amber-soft) !important; color: var(--amber) !important; }
.props-color .due-later .chip-due { background: var(--blue-soft) !important; color: var(--blue) !important; }
.props-color .due-lbl { border-radius: 999px; padding: 2px 8px; font-weight: 600; }
.props-color .due-later .due-lbl, .props-color .due-none .due-lbl { padding: 0; }
.props-color select.chip option { color: var(--ink); background: var(--surface); }

/* แถบ 1 บรรทัด (ส่งงาน / บรีฟ): [📎] [พิมพ์ หรือวางลิงก์ ➤] [ปุ่ม] */
.sub-new { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 12px; }
.sub-new.over, .brief-bar.over { outline: 2px dashed var(--accent); outline-offset: 4px; border-radius: var(--radius-sm); }
.sub-new.is-busy { opacity: 0.85; pointer-events: none; position: relative; }
.sub-new.is-busy::before { content: ''; position: absolute; top: -1px; left: 0; height: 3px; width: var(--up, 0%); border-radius: 3px; background: var(--accent); transition: width 0.3s; }
.one-line { display: flex; align-items: center; gap: 6px; }
.one-line-form { flex: 1; min-width: 0; display: flex; align-items: center; gap: 0; position: relative; margin: 0; }
.one-line-form input { flex: 1; min-width: 0; min-height: 40px; padding: 8px 42px 8px 14px; border-radius: 999px; }
.one-line-send { position: absolute; right: 4px; width: 32px; height: 32px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); cursor: pointer; padding: 0; }
.one-line-send .ico, .one-line-btn .ico { width: 18px; height: 18px; }
.one-line-btn { flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--ink); cursor: pointer; border: 1px solid var(--line); text-decoration: none; font-size: 1.05rem; }
.one-line-btn:hover { background: var(--accent-soft); color: var(--accent-ink); }
.one-line-act { margin: 0; flex-shrink: 0; }
.one-line-act .btn { min-height: 40px; white-space: nowrap; }
.one-line-empty { flex: 1; }
.sub-notes { list-style: none; margin: 8px 0 0; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface-2); display: grid; gap: 4px; }
.sub-notes li { font-size: 0.92rem; }
.inline-rt, .inline-rt p { display: inline; margin: 0; }
.brief-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 2px; }
.brief-list li { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.brief-list li:last-child { border-bottom: 0; }
.brief-list li > :first-child { flex: 1; min-width: 0; }
.brief-file { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; }
.brief-file .file-ico { width: 22px; height: 22px; flex-shrink: 0; display: grid; place-items: center; }
.brief-file .file-ico svg { width: 22px; height: 22px; }
.brief-del { margin: 0; }
@media (max-width: 520px) { .one-line { flex-wrap: wrap; } .one-line-form { flex: 1 1 calc(100% - 100px); } .one-line-act { flex: 1 1 calc(50% - 6px); } .one-line-act .btn { width: 100%; } }

/* ตัวเลือกแบบ Notion (public/tagpick.js): ป้ายพื้นสี · กดได้ทั้งบรรทัด · รายการเด้งลงมา */
.tp-tag { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 2px 9px; border-radius: 6px; font-size: 0.9rem; font-weight: 500; line-height: 1.6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: color-mix(in srgb, var(--nt, #9aa0a3) 42%, var(--surface)); color: var(--ink); }
.tp-tag > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.tp-tag.tp-person { padding-left: 3px; border-radius: 999px; }
.tp-tag .avatar.xs { width: 20px; height: 20px; font-size: 0.7rem; flex-shrink: 0; }
select.tp-hidden { position: absolute !important; width: 1px !important; height: 1px !important; opacity: 0 !important; pointer-events: none !important; overflow: hidden; }
.tp-btn { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; min-height: 32px; padding: 2px 6px 2px 2px; margin-left: -2px; border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; cursor: pointer; text-align: left; }
.tp-caret { width: 14px; height: 14px; fill: none; stroke: var(--faint); stroke-width: 2; flex-shrink: 0; opacity: 0; transition: opacity 0.12s; }
.tp-row { cursor: pointer; border-radius: 8px; transition: background 0.12s; }
dd.tp-row:hover, dt.tp-row:hover + dd.tp-row, dd.tp-row:has(.tp-btn[aria-expanded=true]) { background: var(--surface-2); }
.tp-row:hover .tp-caret, .tp-btn:focus-visible .tp-caret { opacity: 1; }
.tp-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.props-color dd.tp-row { padding-left: 6px; margin-left: -6px; }
.tp-pop { position: absolute; z-index: 80; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; max-height: min(360px, 60vh); display: flex; flex-direction: column; animation: pop-in 0.12s ease-out; }
.tp-find { margin: 2px 2px 6px; min-height: 34px; }
.tp-head { padding: 4px 8px 6px; }
.tp-list { overflow-y: auto; overscroll-behavior: contain; min-height: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 1px; }
.tp-opt { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 36px; padding: 4px 8px; border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; cursor: pointer; text-align: left; }
.tp-opt:hover, .tp-opt:focus-visible { background: var(--surface-2); outline: none; }
.tp-check { color: var(--accent-ink); font-weight: 700; }
/* ช่องวันที่: กดตรงไหนของช่องก็เปิดปฏิทิน */
input[type=date], input[type=datetime-local], input[type=month], input[type=time] { cursor: pointer; }

/* แถบส่งงาน = สีเขียว (แยกจากแถบบรีฟสีเทา) */
.submit-box { border: 1.5px solid color-mix(in srgb, var(--green) 45%, transparent); background: linear-gradient(180deg, color-mix(in srgb, var(--green) 9%, var(--surface)), var(--surface) 70%); }
.submit-box > .page-head h2 { color: var(--green); }
.submit-box .one-line-form input { border-color: color-mix(in srgb, var(--green) 45%, var(--line-strong)); }
.submit-box .one-line-send { background: var(--green); color: #fff; }
.submit-box .one-line-btn { background: color-mix(in srgb, var(--green) 14%, var(--surface)); color: var(--green); border-color: color-mix(in srgb, var(--green) 35%, transparent); }
.submit-box .one-line-act .btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
/* Whiteboard ในบรีฟ: ไฮไลต์สีเหลือง ให้เห็นว่ามีบรีฟที่ต้องเปิดอ่าน */
.brief-list li.brief-board { background: color-mix(in srgb, var(--amber) 16%, var(--surface)); border: 1px solid color-mix(in srgb, var(--amber) 45%, transparent); border-radius: var(--radius-sm); padding: 8px 10px; margin: 4px 0; }
.brief-board-hint { color: var(--amber); font-weight: 600; }
.brief-board-flag { background: color-mix(in srgb, var(--amber) 20%, var(--surface)); color: var(--ink); font-weight: 600; }
.brief-list li[data-menu] { cursor: context-menu; }
.brief-list li[data-menu] a { cursor: pointer; }
.sub-thumb { cursor: zoom-in; }
.ally-devices { scroll-margin-top: 84px; }

/* คอมเมนต์แก้งาน (ต่อจากส่งงาน) = สีม่วง (สีเดียวกับสถานะส่งตรวจ) */
.revise-box { border: 1.5px solid color-mix(in srgb, var(--purple) 40%, transparent); }
.revise-box > .page-head h2 { color: var(--purple); }
.revise-box .one-line-send { background: var(--purple); color: #fff; }
.revise-box .one-line-form input { border-color: color-mix(in srgb, var(--purple) 40%, var(--line-strong)); }
.revise-box .frv { margin-top: 4px; }
.rv-strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 6px; }
.rv-pick { flex: 0 0 64px; width: 64px; height: 64px; padding: 0; border-radius: var(--radius-sm); overflow: hidden; border: 2px solid transparent; background: var(--surface-2); cursor: pointer; display: grid; place-items: center; }
.rv-pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rv-pick.on { border-color: var(--purple); }
.sub-thumb { position: relative; }
.sub-play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 1.4rem; text-shadow: 0 1px 6px rgba(0,0,0,0.6); pointer-events: none; }
/* การ์ดงาน: คนรับผิดชอบเป็นป้ายรูป + ชื่อ */
.task-meta .meta-who.tp-tag { font-size: 0.8rem; line-height: 1.5; padding-right: 8px; }
.task-meta .meta-who.tp-tag::before { display: none; }
.task-meta .meta-who.tp-tag .avatar.xs { width: 18px; height: 18px; }

/* ช่องวันส่ง: แถบสีสั้นเท่าตัวอักษร + ไอคอนปฏิทิน (ไม่ยืดเต็มบรรทัด) · ป้าย "วันนี้/เลย…" อยู่ข้างๆ บรรทัดเดียวกัน */
.props-color dd[class*='due-'] { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.props-color .field-due { display: inline-flex; align-items: center; gap: 6px; }
.props-color input.chip-due { width: auto !important; max-width: max-content; flex: 0 0 auto; padding: 3px 10px !important; min-height: 0; }

/* เงินเดือน: คำขอเพิ่มรายการเงินรออนุมัติ */
.payreq-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 10px; }
.payreq { display: flex; align-items: center; gap: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.payreq-info { flex: 1; min-width: 0; display: grid; gap: 4px; }
.payreq-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.payreq-item { display: inline-block; padding: 3px 10px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-ink); border-left: 4px solid var(--accent); font-weight: 600; }
.payreq-amt { font-size: 1.15em; color: var(--green); white-space: nowrap; }
.payreq-amt small { font-weight: 400; color: var(--muted); }
.payreq-actions { display: flex; align-items: flex-end; gap: 8px; flex-shrink: 0; }
.payreq-approve { display: flex; align-items: flex-end; gap: 8px; margin: 0; }
.payreq-approve label { display: grid; gap: 2px; margin: 0; color: var(--muted); }
.payreq-approve input { width: 150px; padding: 6px 10px; min-height: 0; }
.payreq-actions form { margin: 0; }
@media (max-width: 640px) {
  .payreq { flex-direction: column; align-items: stretch; }
  .payreq-actions { justify-content: space-between; }
  .payreq-approve { flex: 1; }
  .payreq-approve label { flex: 1; }
  .payreq-approve input { width: 100%; }
}

/* ลากการ์ดงานข้ามกลุ่ม (task-drag.js): กลุ่มว่างโผล่ตอนลาก ให้มีที่วาง */
.task-group.is-empty, .mine-group.is-empty, .myday-grp.is-empty { display: none; }
body.task-dragging .task-group.is-empty, body.task-dragging .mine-group.is-empty, body.task-dragging .myday-grp.is-empty { display: block; }
.drop-zone { min-height: 4px; border-radius: var(--radius-sm); transition: background 0.15s, outline-color 0.15s; }
body.task-dragging .drop-zone[data-drop-due], body.task-dragging .drop-zone[data-drop-status] { min-height: 52px; outline: 2px dashed var(--line); outline-offset: 2px; background: var(--accent-soft); }
.drop-zone .task.has-check { cursor: grab; }
.task.is-moving { pointer-events: none; }

/* คลังงานรอจ่าย (Backlog) */
.bl-load-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 8px 0 10px; }
.bl-person { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.bl-person.low { border-color: var(--red, #d33); background: color-mix(in srgb, var(--red, #d33) 7%, var(--surface)); }
.bl-person-name { font-weight: 600; }
.bl-person-open b { font-size: 1.3rem; }
.bl-person.low .bl-person-open b { color: var(--red, #d33); }
.bl-person input { width: 56px; padding: 3px 6px; font-size: 0.9rem; }
.bl-alert { color: var(--red, #d33); font-weight: 600; margin: 4px 0; }
.bl-form { margin-top: 10px; }
.bl-bulk { margin-top: 10px; }
.bl-pick { align-self: flex-start; cursor: pointer; }
.bl-progress li { padding: 2px 0; word-break: break-all; }
.bl-list { display: grid; gap: 10px; }
.bl-item.urgent { border-left: 4px solid var(--red, #d33); }
.bl-item-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.bl-item-head h3 { margin: 0; font-size: 1.02rem; }
.bl-meta { margin: 6px 0; }
.bl-brief { white-space: pre-wrap; color: var(--ink-2); }
.bl-assign { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.bl-assign select { flex: 1 1 160px; min-width: 0; }
.bl-assign input[type=date] { flex: 0 1 150px; }
.bl-actions { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; margin-top: 8px; }
.bl-actions details[open] { flex-basis: 100%; }

/* ---------- สีประจำตัวของแต่ละคน (คนที่ยังไม่มีรูป) — 8 สี คิดจากชื่อ (views/avatar.tsx) ---------- */
:root[data-theme] .avatar[class*="av-"], :root[data-theme] .pp-av-txt[class*="av-"] { background: linear-gradient(145deg, var(--av-a), var(--av-b)); color: var(--av-ink); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12); }
/* โหมดมืด (ค่าเริ่มต้น) */
.av-0 { --av-a: #6b3a1f; --av-b: #4d2914; --av-ink: #ffd9c2; }
.av-1 { --av-a: #1f5a45; --av-b: #153f31; --av-ink: #c9f3e1; }
.av-2 { --av-a: #1d4f6e; --av-b: #14384f; --av-ink: #cfe8fb; }
.av-3 { --av-a: #4b3a78; --av-b: #352957; --av-ink: #e2d9ff; }
.av-4 { --av-a: #6e2742; --av-b: #4f1c2f; --av-ink: #ffd1e0; }
.av-5 { --av-a: #6b5617; --av-b: #4d3e10; --av-ink: #fff0bf; }
.av-6 { --av-a: #1b5c63; --av-b: #134247; --av-ink: #c6f1f5; }
.av-7 { --av-a: #4a5a17; --av-b: #35410f; --av-ink: #e6f5bf; }
/* โหมดสว่าง */
:root[data-theme="light"] .av-0 { --av-a: #ffe3d1; --av-b: #ffd0b3; --av-ink: #9a3a0c; }
:root[data-theme="light"] .av-1 { --av-a: #d9f5e6; --av-b: #bfedd5; --av-ink: #1d6b45; }
:root[data-theme="light"] .av-2 { --av-a: #dcefff; --av-b: #c3e2fc; --av-ink: #1d5a8a; }
:root[data-theme="light"] .av-3 { --av-a: #e9e3ff; --av-b: #d8ceff; --av-ink: #4e3a9c; }
:root[data-theme="light"] .av-4 { --av-a: #ffe0ea; --av-b: #ffc9da; --av-ink: #9c2a54; }
:root[data-theme="light"] .av-5 { --av-a: #fff3c9; --av-b: #ffe79d; --av-ink: #7d5a00; }
:root[data-theme="light"] .av-6 { --av-a: #d6f4f6; --av-b: #b9ebef; --av-ink: #16656d; }
:root[data-theme="light"] .av-7 { --av-a: #eef8d2; --av-b: #ddf0a8; --av-ink: #4f6510; }
/* ชื่อคน + รูปเล็ก (views/avatar.tsx → Who) */
.who { display: inline-flex; align-items: center; gap: 0; white-space: nowrap; vertical-align: middle; }
.who .avatar.xs { margin-right: 6px; vertical-align: 0; }
.who .avatar.sm { margin: 0 7px 0 0; border: 0; }

/* ---------- ปุ่มรอง: ใส่สีอ่อนของแบรนด์ (เดิมเทาจืด) ---------- */
.btn:not(.btn-primary):not(.btn-danger):not(.btn-ghost) {
  background: var(--accent-soft); color: var(--accent-ink, var(--accent)); border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}
.btn:not(.btn-primary):not(.btn-danger):not(.btn-ghost):hover { background: color-mix(in srgb, var(--accent) 22%, transparent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.btn-danger { background: var(--red-soft, rgba(255, 69, 58, 0.1)); }
.btn-danger:hover { background: color-mix(in srgb, var(--red) 20%, transparent); }
/* ปุ่มยืนยัน/ผ่าน/อนุมัติ = เขียว */
.btn-ok { background: var(--green-soft) !important; color: var(--green) !important; border-color: color-mix(in srgb, var(--green) 40%, transparent) !important; }
/* รายการรอตรวจในวันของฉัน: ชื่องานตัดบรรทัดตามคำ ไม่ตัดกลางคำ (มีรูปคนขวามือแล้วที่แคบลง) */
.myday-events .grow.break { word-break: normal; overflow-wrap: anywhere; }

/* ---------- ไอคอนในปุ่ม (ใส่อัตโนมัติตามคำบนปุ่ม — public/btn-icons.js) ---------- */
.bi { display: inline-block; width: 1.05em; height: 1.05em; margin-right: 6px; vertical-align: -0.16em; flex-shrink: 0; background: currentColor; -webkit-mask: var(--bi) center/contain no-repeat; mask: var(--bi) center/contain no-repeat; }
.btn:has(> .bi) { display: inline-flex; align-items: center; gap: 0; }
.bi-check { --bi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7'/%3E%3C/svg%3E"); }
.bi-plus { --bi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E"); }
.bi-search { --bi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='M20 20l-4-4'/%3E%3C/svg%3E"); }
.bi-x { --bi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E"); }
.bi-trash { --bi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 7h16M10 11v6M14 11v6M6 7l1 13h10l1-13M9 7V4h6v3'/%3E%3C/svg%3E"); }
.bi-undo { --bi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 14L4 9l5-5'/%3E%3Cpath d='M4 9h10a6 6 0 0 1 0 12h-3'/%3E%3C/svg%3E"); }
.bi-send { --bi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 3L10 14M21 3l-7 18-4-7-7-4z'/%3E%3C/svg%3E"); }
.bi-upload { --bi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 16V4M7 9l5-5 5 5M5 20h14'/%3E%3C/svg%3E"); }
.bi-download { --bi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4v12M7 11l5 5 5-5M5 20h14'/%3E%3C/svg%3E"); }
.bi-calendar { --bi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='5' width='16' height='15' rx='2'/%3E%3Cpath d='M4 10h16M9 3v4M15 3v4'/%3E%3C/svg%3E"); }
/* ---------- 3 อย่างวันนี้ / โหมดโฟกัส / ทบทวน / เคลียร์ Inbox / ไทม์ไลน์รายวัน (เจ้าของ) ---------- */
.focus3 .focus-list { list-style: none; margin: 8px 0 6px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.focus-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.focus-item.is-top { padding: 14px; border-color: rgba(var(--accent-rgb), 0.45); background: var(--accent-soft); }
.focus-item.is-top .focus-text { font-size: 1.12rem; font-weight: 600; }
.focus-item.is-done .focus-text { text-decoration: line-through; color: var(--muted); }
.focus-check { margin: 0; }
.focus-box { width: 26px; height: 26px; min-height: 0; padding: 0; border-radius: 8px; border: 2px solid var(--line-strong); background: transparent; color: var(--on-accent); font-weight: 700; line-height: 1; cursor: pointer; }
.is-done .focus-box { background: var(--green); border-color: var(--green); }
.focus-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.focus-text a { color: inherit; }
.focus-badge { font-size: 0.72rem; font-weight: 600; color: var(--accent-ink); letter-spacing: 0.02em; }
.focus-acts { display: flex; gap: 4px; align-items: center; flex: none; }
.focus-acts form { margin: 0; }
.focus-win { margin: 6px 0; padding: 10px 12px; border-radius: 12px; background: var(--green-soft); font-weight: 600; }
.focus-live { display: block; margin: 6px 0 4px; padding: 10px 12px; border-radius: 12px; background: var(--amber-soft); color: var(--ink); text-decoration: none; }
.focus-sugg { margin: 6px 0; }
.focus-sugg ul { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.focus-sugg form { margin: 0; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.focus-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; margin-top: 10px; }
.focus-foot .chip, .focus-wait > summary.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: 0.86rem; text-decoration: none; cursor: pointer; list-style: none; }
.focus-wait > summary::-webkit-details-marker { display: none; }
.focus-foot .chip-hot { border-color: rgba(var(--accent-rgb), 0.5); color: var(--accent-ink); }
.focus-wait { flex: 1 1 100%; }
.focus-wait[open] > summary { margin-bottom: 6px; }

body.focus-app .topbar, body.focus-app .sidenav, body.focus-app .bottomnav, body.focus-app .ally-fab { display: none !important; }
body.focus-app main.page { max-width: 720px; margin: 0 auto; padding: max(20px, env(safe-area-inset-top)) 16px 40px; }
.focus-wrap { display: flex; flex-direction: column; gap: 16px; }
.focus-exit { color: var(--muted); }
.focus-run { text-align: center; padding: 6vh 0 0; }
.focus-label { color: var(--muted); font-size: 0.9rem; }
.focus-title { font-size: clamp(1.6rem, 5vw, 2.4rem); line-height: 1.25; margin: 8px 0 18px; overflow-wrap: anywhere; }
.focus-timer { font-size: clamp(3.6rem, 16vw, 6.5rem); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.focus-run.is-over .focus-timer { color: var(--green); }
.focus-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 22px 0; }
.focus-btns form { margin: 0; }
.focus-capture { text-align: left; margin-top: 28px; opacity: 0.85; }
.focus-setup .stack { gap: 14px; }
.focus-pickrow, .focus-mins { display: flex; flex-wrap: wrap; gap: 8px; }
.sl-opt input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }

.review-step { padding: 0; }
.review-step > summary { padding: 14px 16px; cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 10px; list-style: none; }
.review-step > summary::-webkit-details-marker { display: none; }
.review-n { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); flex: none; font-size: 0.9rem; }
.review-step.is-ok .review-n { background: var(--green-soft); color: var(--green); }
.review-body { padding: 0 16px 16px; }

.brain-hub { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.brain-hub a { display: inline-flex; align-items: center; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: 0.9rem; text-decoration: none; white-space: nowrap; }
.brain-hub a:hover { background: var(--hover); }
.brain-hub a.on { background: var(--accent-soft); border-color: rgba(var(--accent-rgb), 0.5); color: var(--ink); font-weight: 600; }
.clear-card { padding: 22px; }
.clear-title { font-size: 1.35rem; line-height: 1.35; margin: 6px 0 10px; overflow-wrap: anywhere; }
.clear-q { margin: 18px 0 10px; font-weight: 600; }
.clear-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-bottom: 14px; }
.clear-grid form { margin: 0; }
.clear-btn { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 14px; text-align: left; white-space: normal; }
.clear-btn b { font-size: 0.98rem; }
.clear-btn span { font-size: 0.8rem; color: var(--muted); font-weight: 400; }
.clear-date { display: flex; flex-direction: column; gap: 6px; }
.clear-date input { min-height: 36px; }
.clear-drop:hover { border-color: var(--red); }
.clear-done { text-align: center; padding: 30px 16px; }
.clear-win { font-size: 1.2rem; font-weight: 600; }

.tl { width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; margin-top: 6px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
/* แถว "ทั้งวัน" (แบบ Google Calendar): ป้ายซ้าย + แถบเล็กเรียงต่อกัน */
.tl-untimed { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line-strong); background: var(--surface-2); }
.tl-gut { flex: none; width: 52px; text-align: right; font-size: 0.74rem; color: var(--muted); padding-top: 5px; }
.tl-chips { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.tl-none { padding-top: 4px; }
.tl-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 3px 9px; border-radius: 6px; background: var(--nt-soft, var(--gray-soft)); border-left: 3px solid var(--nt, var(--faint)); color: var(--ink); font-size: 0.84rem; line-height: 1.35; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-chip:hover { text-decoration: none; filter: brightness(0.97); }
.tl-chip.is-done { opacity: 0.55; text-decoration: line-through; }
.tl-chip-sub { color: var(--muted); font-size: 0.78rem; }
.tl-chip .who { font-size: 0.78rem; color: var(--muted); }
.tl-task-chip { background: var(--blue-soft); border-left-color: var(--blue); }
.tl-task-chip.tone-red { background: var(--red-soft); border-left-color: var(--red); }
.tl-task-chip.tone-gray { background: var(--gray-soft); border-left-color: var(--faint); }
/* ตารางชั่วโมง */
.tl-grid { position: relative; margin: 10px 8px 12px 62px; border-left: 1px solid var(--line); }
.tl-hour { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
.tl-hour span { position: absolute; left: -58px; top: -0.62em; width: 50px; text-align: right; font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-now { position: absolute; left: -5px; right: 0; border-top: 2px solid var(--red); z-index: 3; pointer-events: none; }
.tl-now::before { content: ''; position: absolute; left: 0; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--red); }
.tl-lane { position: absolute; inset: 0 0 0 4px; }
.tl-block { position: absolute; padding: 1px 0; z-index: 2; }
.tl-ev { display: flex; flex-direction: column; gap: 1px; height: 100%; overflow: hidden; padding: 4px 8px; border-radius: 6px; background: var(--nt-soft); border-left: 3px solid var(--nt); color: var(--ink); text-decoration: none; font-size: 0.82rem; line-height: 1.3; }
.tl-ev:hover { text-decoration: none; filter: brightness(0.97); }
.tl-ev strong { font-size: 0.86rem; overflow-wrap: anywhere; line-height: 1.25; }
.tl-ev span { color: var(--muted); font-size: 0.76rem; overflow-wrap: anywhere; }
.tl-empty { position: absolute; top: 40%; left: 0; right: 0; text-align: center; }
.brain-howto { margin: 4px 2px 10px; }
.brain-back { margin: 4px 0 12px; }
.brain-more { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: 18px 2px 8px; }
.brain-find { flex: 1 1 100%; }
.brain-find > summary { cursor: pointer; color: var(--accent-ink); }
.brain-find[open] > summary { margin-bottom: 8px; }
.brain-actions .btn-ok { white-space: nowrap; }
[data-calview="day"] { min-width: 0; max-width: 100%; }
