:root {
  --blue-900: #0a2540;
  --blue-800: #0f3460;
  --blue-700: #15509e;
  --blue-600: #1d6fd6;
  --blue-500: #2b86f0;
  --blue-400: #5aa6f7;
  --blue-300: #9ccbfb;
  --cyan: #27c3d6;

  --ink: #0c1b2e;
  --ink-soft: #3a4a5e;
  --muted: #6b7c92;

  --bg-grad-1: #eaf3ff;
  --bg-grad-2: #dcebff;
  --bg-grad-3: #e7f6ff;

  --glass-bg: rgba(255, 255, 255, 0.68);
  --glass-bg-strong: rgba(255, 255, 255, 0.82);
  --glass-soft: rgba(255, 255, 255, 0.5);
  --glass-border: rgba(255, 255, 255, 0.65);
  --glass-shadow: 0 8px 32px rgba(16, 52, 96, 0.14);

  --ok: #16a37b;
  --ok-bg: rgba(22, 163, 123, 0.12);
  --warn: #e59b1b;
  --warn-bg: rgba(229, 155, 27, 0.14);
  --danger: #e14b4b;
  --danger-bg: rgba(225, 75, 75, 0.12);
  --wait: #8a7be0;
  --wait-bg: rgba(138, 123, 224, 0.14);
  --info: var(--blue-600);
  --info-bg: rgba(29, 111, 214, 0.12);

  --radius: 20px;
  --radius-sm: 14px;
  --sidebar-w: 268px;
  --topbar-h: 70px;

  --font: "IBM Plex Sans Thai", "Prompt", "Sarabun", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body, button, input, select, textarea, optgroup, table {
  font-family: var(--font) !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html, body { height: 100%; margin: 0; }

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 85% -5%, var(--bg-grad-3), transparent 60%),
    radial-gradient(1000px 650px at -5% 10%, var(--bg-grad-2), transparent 55%),
    linear-gradient(135deg, var(--bg-grad-1), #f3f8ff 60%, #eef4ff);
  background-attachment: fixed;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}
.glass-soft {
  background: var(--glass-soft);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.icon { width: 20px; height: 20px; display: block; color: inherit; }

/* ---------- Layout ---------- */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas: "brand topbar" "sidebar content";
  min-height: 100vh;
}

.topbar {
  grid-area: topbar;
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  max-height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 0 22px;
  box-sizing: border-box;
  border-radius: 0;
  border-left: none; border-top: none; border-right: none;
  border-bottom: 1px solid rgba(16, 52, 96, 0.08);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 2px 14px rgba(16, 52, 96, 0.04);
}
.topbar .brand { display: none; }
.topbar .menu-toggle { display: none; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, var(--blue-600), var(--cyan));
  color: #fff;
  flex: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; overflow: hidden; }
.brand-text strong { font-size: 16.5px; font-weight: 700; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-search {
  position: relative;
  flex: 1 1 220px;
  min-width: 140px;
  max-width: 440px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px; height: 42px;
  background: var(--glass-soft);
  border: 1.5px solid rgba(21, 80, 158, 0.12);
  border-radius: 999px;
  color: var(--muted);
  transition: all .2s;
}
.topbar-search:focus-within {
  background: #fff;
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3.5px rgba(29, 111, 214, 0.12);
}
.topbar-search input,
.topbar-search input[type="text"],
.topbar-search input:hover,
.topbar-search input:focus {
  flex: 1 !important;
  min-width: 0 !important;
  width: 100% !important;
  border: none !important;
  background: transparent !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  border-radius: 0 !important;
  font-family: var(--font) !important;
  font-size: 14.5px !important;
  color: var(--ink) !important;
  line-height: 1.2 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
.search-results {
  position: absolute; top: 48px; left: 0; right: 0;
  border-radius: var(--radius-sm); padding: 8px; max-height: 420px; overflow: auto; z-index: 60;
  box-shadow: 0 12px 36px rgba(16, 52, 96, 0.18);
}
.search-results .sr-group { font-size: 11px; color: var(--muted); padding: 8px 10px 4px; text-transform: uppercase; letter-spacing: .5px; }
.search-results .sr-item { padding: 9px 10px; border-radius: 9px; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.search-results .sr-item:hover { background: rgba(29,111,214,.1); }
.search-results .sr-item small { color: var(--muted); }

.table-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 38px;
  background: #fff;
  border: 1px solid rgba(16, 52, 96, 0.16);
  border-radius: var(--radius-sm);
  color: var(--muted);
}
.table-search:focus-within {
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgba(29, 111, 214, 0.12);
}
.table-search input,
.table-search input[type="text"],
.table-search input:hover,
.table-search input:focus {
  flex: 1 !important;
  min-width: 0 !important;
  width: 100% !important;
  border: none !important;
  background: transparent !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  border-radius: 0 !important;
  font-family: var(--font) !important;
  font-size: 13.5px !important;
  color: var(--ink) !important;
}

.topbar-actions {
  display: flex; align-items: center; gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

.icon-btn {
  position: relative;
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 11px;
  border: 1px solid rgba(21, 80, 158, 0.14);
  background: var(--glass-soft); color: var(--blue-800);
  cursor: pointer; transition: .15s;
  flex: none;
}
.icon-btn:hover { background: #fff; color: var(--blue-600); box-shadow: 0 2px 8px rgba(16, 52, 96, 0.08); }
.badge-dot { position: absolute; top: 7px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); border: 2px solid #fff; }

.role-switch { display: flex; align-items: center; gap: 6px; padding: 0 10px 0 12px; height: 40px; border-radius: 11px; color: var(--blue-800); }
.role-switch select { border: none; background: transparent; font-family: var(--font); font-size: 13px; color: var(--ink); outline: none; cursor: pointer; }

/* The brand block sits above the sidebar visually */
.sidebar {
  grid-area: sidebar / sidebar / sidebar / sidebar;
  position: sticky; top: var(--topbar-h);
  align-self: start;
  height: calc(100vh - var(--topbar-h));
  display: flex; flex-direction: column;
  padding: 14px 12px;
  border-radius: 0; border-left: none; border-bottom: none;
  overflow-y: auto;
}
.sidebar .brand { padding: 4px 10px 14px; }

#nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-group-label { font-size: 12px; color: var(--muted); letter-spacing: .6px; text-transform: uppercase; padding: 14px 12px 6px; font-weight: 700; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 12px;
  color: var(--ink-soft); cursor: pointer; font-weight: 500; font-size: 15.5px;
  border: 1px solid transparent; transition: all .14s ease;
}
.nav-item:hover { background: rgba(29,111,214,.08); color: var(--blue-700); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(29,111,214,.16), rgba(39,195,214,.12));
  color: var(--blue-700); border-color: rgba(29,111,214,.25);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.4);
  font-weight: 600;
}
.nav-item .count { margin-left: auto; font-size: 12px; font-weight: 700; background: rgba(29,111,214,.14); color: var(--blue-700); padding: 2px 9px; border-radius: 999px; }
.nav-item.sub { padding-left: 42px; font-size: 14px; font-weight: 400; }

.sidebar-foot { padding-top: 12px; }
.me-card { padding: 12px 14px; border-radius: 14px; display:flex; gap:12px; align-items:center; }
.me-card .avatar { width: 40px; height: 40px; font-size: 15px; }
.me-card .me-name { font-weight: 600; font-size: 15.5px; }
.me-card .me-role { font-size: 12px; color: var(--muted); }

/* The topbar overlaps the brand corner; create a brand cell background */
/* Branded header occupying the top-left cell above the sidebar */
.brandbar {
  grid-area: brand; position: sticky; top: 0; z-index: 41;
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px;
  height: var(--topbar-h);
  max-height: var(--topbar-h);
  box-sizing: border-box;
  border-radius: 0; border-left: none; border-top: none;
  border-bottom: 1px solid rgba(16, 52, 96, 0.08);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 2px 14px rgba(16, 52, 96, 0.04);
  white-space: nowrap; overflow: hidden;
}
.brandbar .brand-mark { width: 40px; height: 40px; border-radius: 12px; flex: none; }
.brandbar .brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; overflow: hidden; }
.brandbar .brand-text strong { font-size: 16px; font-weight: 700; color: var(--blue-800); letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brandbar .brand-text small { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.customer-mode .brandbar { display: none; }
@media (max-width: 820px) { .brandbar { display: none; } }

.content {
  grid-area: content;
  min-width: 0;
  padding: 26px 32px 64px;
  overflow-x: hidden;
}

/* ---------- Typography helpers ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; margin: 0 0 3px; font-weight: 700; color: var(--ink); }
.page-head p { margin: 0; color: var(--muted); font-size: 15px; }
.page-head .sub { font-size: 13.5px; color: var(--muted); }

h2.section-title { font-size: 18.5px; margin: 28px 0 14px; font-weight: 700; display:flex; align-items:center; gap:8px; color: var(--ink); }
h2.section-title .icon { color: var(--blue-600); }

/* ---------- Cards & grid ---------- */
.grid { display: grid; gap: 18px; }
.cards-5 { grid-template-columns: repeat(5, 1fr); }
.cards-4 { grid-template-columns: repeat(4, 1fr); }
.cards-3 { grid-template-columns: repeat(3, 1fr); }
.cards-2 { grid-template-columns: repeat(2, 1fr); }

.card { background: var(--glass-bg); backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%); border: 1px solid var(--glass-border); border-radius: var(--radius); box-shadow: var(--glass-shadow); padding: 22px; }
.card.pad-lg { padding: 26px; }

.stat {
  display: flex; flex-direction: column; gap: 8px; position: relative; overflow: hidden;
}
.stat .stat-top { display:flex; align-items:center; justify-content: space-between; }
.stat .stat-ico { width: 38px; height: 38px; border-radius: 12px; display:grid; place-items:center; color:#fff; }
.stat .stat-val { font-size: 32px; font-weight: 800; line-height: 1; }
.stat .stat-label { color: var(--muted); font-size: 13.5px; font-weight: 500; }
.stat.clickable { cursor: pointer; transition: transform .14s, box-shadow .14s; }
.stat.clickable:hover { transform: translateY(-2px); box-shadow: 0 16px 36px rgba(16,52,96,.2); }

.tone-blue  .stat-ico { background: linear-gradient(135deg, var(--blue-600), var(--blue-400)); }
.tone-cyan  .stat-ico { background: linear-gradient(135deg, var(--cyan), var(--blue-400)); }
.tone-ok    .stat-ico { background: linear-gradient(135deg, #19b386, #37d0a0); }
.tone-warn  .stat-ico { background: linear-gradient(135deg, #e5a51b, #f2c14e); }
.tone-danger .stat-ico { background: linear-gradient(135deg, #e14b4b, #f27272); }
.tone-wait  .stat-ico { background: linear-gradient(135deg, #8a7be0, #a99bf0); }

/* ---------- Badges / status ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.b-ok { color: var(--ok); background: var(--ok-bg); }
.b-warn { color: var(--warn); background: var(--warn-bg); }
.b-danger { color: var(--danger); background: var(--danger-bg); }
.b-wait { color: var(--wait); background: var(--wait-bg); }
.b-info { color: var(--info); background: var(--info-bg); }
.b-muted { color: var(--muted); background: rgba(107,124,146,.12); }

/* priority pills */
.pri { font-size: 12.5px; font-weight: 700; padding: 3px 10px; border-radius: 8px; }
.pri-low { color: var(--muted); background: rgba(107,124,146,.14); }
.pri-medium { color: var(--blue-700); background: var(--info-bg); }
.pri-high { color: var(--warn); background: var(--warn-bg); }
.pri-critical { color: var(--danger); background: var(--danger-bg); }

/* ---------- Lists / tables ---------- */
.list { display: flex; flex-direction: column; gap: 12px; }
.row-item { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: 14px; background: var(--glass-soft); border: 1px solid rgba(255,255,255,.55); transition: all .16s ease; cursor: pointer; }
.row-item:hover { background: #fff; transform: translateY(-1px); box-shadow: 0 10px 26px rgba(16,52,96,.12); }
.row-item .ri-main { flex: 1; min-width: 0; }
.row-item .ri-title { font-weight: 600; font-size: 16px; color: var(--ink); }
.row-item .ri-meta { font-size: 13.5px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; margin-top: 4px; }
.row-item .ri-right { display: flex; align-items: center; gap: 10px; }
.row-accent { width: 5px; align-self: stretch; border-radius: 4px; }
.a-danger { background: var(--danger); } .a-warn { background: var(--warn); } .a-wait { background: var(--wait); } .a-ok { background: var(--ok); } .a-info { background: var(--blue-500); }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; padding: 12px 14px; }
.table td { padding: 13px 14px; border-top: 1px solid rgba(16,52,96,.08); font-size: 15.5px; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: rgba(29,111,214,.06); }

/* ---------- Progress ---------- */
.progress { height: 10px; border-radius: 999px; background: rgba(16,52,96,.1); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--blue-600), var(--cyan)); }
.progress.sm { height: 7px; }
.ring { --p: 0; width: 68px; height: 68px; border-radius: 50%; display:grid; place-items:center; background: conic-gradient(var(--blue-600) calc(var(--p)*1%), rgba(16,52,96,.12) 0); }
.ring > span { width: 52px; height: 52px; border-radius: 50%; background: #fff; display:grid; place-items:center; font-weight:700; font-size:15px; color: var(--blue-800); }

/* ---------- Avatar ---------- */
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; font-weight: 700; color: #fff; flex: none; background: linear-gradient(135deg, var(--blue-600), var(--cyan)); box-shadow: 0 2px 6px rgba(16,52,96,.15); }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -10px; border: 2px solid #fff; }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 12px; font-family: var(--font); font-weight: 600; font-size: 15px; cursor: pointer; border: 1px solid transparent; transition: all .16s ease; line-height: 1.4; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: linear-gradient(135deg, var(--blue-600), var(--blue-500)); color: #fff; box-shadow: 0 4px 14px rgba(29,111,214,.32); border-color: rgba(255,255,255,.2); }
.btn-primary:hover { filter: brightness(1.06); box-shadow: 0 6px 20px rgba(29,111,214,.42); }
.btn-ghost { background: var(--glass-soft); border-color: rgba(255,255,255,.65); color: var(--blue-700); box-shadow: 0 2px 8px rgba(16,52,96,.04); }
.btn-ghost:hover { background: #fff; border-color: var(--blue-300); }
.btn-sm { padding: 7px 14px; font-size: 13.5px; border-radius: 10px; }

/* chips / filters */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip { padding: 8px 16px; border-radius: 999px; font-size: 14px; font-weight: 500; cursor: pointer; background: var(--glass-soft); border: 1px solid rgba(255,255,255,.6); color: var(--ink-soft); transition: all .16s ease; }
.chip:hover { background: #fff; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(16,52,96,.08); }
.chip.active { background: linear-gradient(135deg, var(--blue-600), var(--blue-500)); color: #fff; border-color: transparent; box-shadow: 0 4px 14px rgba(29,111,214,.3); }

/* ============================================================
   UNIVERSAL FORM CONTROLS & INPUTS
   ============================================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label.form-label,
label.muted,
.modal-body label {
  display: inline-block;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

.form-input,
.login-field input,
.form-group input,
.form-group select,
.form-group textarea,
.chat-input:not(div),
input[type="text"]:not(#globalSearch):not(#adminSearch),
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  display: block;
  width: 100%;
  font-family: var(--font) !important;
  font-size: 15.5px;
  font-weight: 400;
  line-height: 1.45;
  color: var(--ink);
  background: #ffffff;
  border: 1.5px solid rgba(21, 80, 158, 0.2);
  border-radius: 12px;
  padding: 10px 14px;
  outline: none;
  box-shadow: 0 1px 3px rgba(10, 37, 64, 0.04);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-input:hover,
.login-field input:hover,
.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover,
.chat-input:not(div):hover,
input[type="text"]:not(#globalSearch):not(#adminSearch):hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="number"]:hover,
input[type="date"]:hover,
select:hover,
textarea:hover {
  border-color: rgba(29, 111, 214, 0.45);
}

.form-input:focus,
.login-field input:focus,
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.chat-input:not(div):focus,
input[type="text"]:not(#globalSearch):not(#adminSearch):focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
  border-color: var(--blue-600);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(29, 111, 214, 0.16), 0 2px 6px rgba(10, 37, 64, 0.06);
}

.form-input::placeholder,
.chat-input::placeholder,
input::placeholder,
textarea::placeholder {
  color: #94a3b8;
  font-weight: 400;
}

select,
.form-select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2315509e' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 40px !important;
}

textarea,
.form-textarea {
  min-height: 80px;
  resize: vertical;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 22px;
}

/* ---------- Modal ---------- */
.modal-host, .drawer-host { position: fixed; inset: 0; z-index: 100; display: grid; }
.modal-host[hidden], .drawer-host[hidden] { display: none; }
.modal-host { place-items: center; background: rgba(10, 37, 64, 0.45); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); padding: 24px; }
.modal { width: min(780px, 100%); max-height: 88vh; overflow: auto; border-radius: 24px; padding: 0; background: linear-gradient(165deg, rgba(255,255,255,0.96), rgba(248,251,255,0.94)); border: 1px solid rgba(255,255,255,0.9); box-shadow: 0 24px 60px rgba(10,37,64,0.22), 0 4px 16px rgba(10,37,64,0.08); animation: pop .18s ease; }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
.modal-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 20px 26px; background: rgba(255,255,255,0.92); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-bottom: 1px solid rgba(16,52,96,.08); z-index: 10; }
.modal-head h3 { margin: 0; font-size: 20px; font-weight: 700; color: var(--ink); }
.modal-head .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.modal-body { padding: 24px 26px 28px; }

.drawer-host { justify-items: end; background: rgba(10,37,64,.3); backdrop-filter: blur(2px); }
.drawer { width: min(420px, 100%); height: 100%; overflow: auto; border-radius: 0; animation: slide .2s ease; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer-head { display:flex; align-items:center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid rgba(16,52,96,.08); position: sticky; top: 0; background: var(--glass-bg-strong); backdrop-filter: blur(18px); }

/* detail layout */
.detail-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; font-size: 14px; font-weight: 500; }
.subcard { background: var(--glass-soft); border: 1px solid rgba(255,255,255,.5); border-radius: 14px; padding: 16px; }
.subcard h4 { margin: 0 0 12px; font-size: 14px; display:flex; align-items:center; gap:7px; }
.subcard h4 .icon { color: var(--blue-600); width:17px; height:17px; }

/* timeline / activity */
.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: rgba(29,111,214,.2); }
.timeline li { list-style: none; position: relative; margin-bottom: 14px; }
.timeline li::before { content: ""; position: absolute; left: -16px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--blue-500); border: 2px solid #fff; }
.timeline .t-when { font-size: 13px; color: var(--muted); }
.timeline .t-what { font-size: 15px; line-height: 1.45; }

/* ---------- Calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; width: 100%; }
.cal .cal-dow { text-align: center; font-size: 13px; color: var(--muted); font-weight: 600; padding-bottom: 4px; min-width: 0; }
.cal .cal-cell { min-width: 0; min-height: 96px; border-radius: 12px; background: var(--glass-soft); border: 1px solid rgba(255,255,255,.5); padding: 8px; display: flex; flex-direction: column; gap: 5px; overflow: hidden; }
.cal .cal-cell.other { opacity: .4; }
.cal .cal-cell.today { outline: 2px solid var(--blue-500); }
.cal .cal-date { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.cal-ev { max-width: 100%; font-size: 11.5px; padding: 3px 7px; border-radius: 7px; color: #fff; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-unit { background: var(--blue-600); } .ev-task { background: var(--warn); } .ev-meet { background: var(--wait); } .ev-leave { background: var(--danger); } .ev-done { background: var(--ok); }

/* ---------- AI Assistant ---------- */
.ai-wrap { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
.chat { display: flex; flex-direction: column; height: calc(100vh - var(--topbar-h) - 150px); min-height: 480px; }
.chat-stream { flex: 1; overflow-y: auto; padding: 6px 4px 12px; display: flex; flex-direction: column; gap: 16px; }
.msg { display: flex; gap: 12px; max-width: 92%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg .bubble { padding: 14px 18px; border-radius: 16px; font-size: 15.5px; line-height: 1.55; }
.msg.ai .bubble { background: var(--glass-bg-strong); border: 1px solid var(--glass-border); border-top-left-radius: 4px; }
.msg.user .bubble { background: linear-gradient(135deg, var(--blue-600), var(--blue-500)); color: #fff; border-top-right-radius: 4px; }
.msg .ai-ico { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--blue-700), var(--cyan)); flex: none; }
.source-ref { margin-top: 10px; padding-top: 10px; border-top: 1px dashed rgba(16,52,96,.18); font-size: 13px; color: var(--muted); }
.source-ref .src-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.source-link { color: var(--blue-600); cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.source-link:hover { text-decoration: underline; }
.chat-input { display: flex; gap: 10px; padding-top: 12px; }
.chat-input input { flex: 1; padding: 12px 18px; border-radius: 13px; border: 1px solid rgba(255,255,255,.6); background: var(--glass-soft); font-family: var(--font); font-size: 15.5px; outline: none; }
.chat-input input:focus { background: #fff; border-color: var(--blue-400); }
.suggest { display: flex; flex-direction: column; gap: 8px; }
.suggest .s-q { text-align: left; padding: 12px 15px; border-radius: 12px; background: var(--glass-soft); border: 1px solid rgba(255,255,255,.5); font-size: 14px; cursor: pointer; color: var(--ink-soft); font-family: var(--font); transition: .14s; }
.suggest .s-q:hover { background: #fff; color: var(--blue-700); }
.ai-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 14.5px; }
.ai-table th { text-align: left; padding: 7px 10px; color: var(--muted); font-size: 13px; border-bottom: 1px solid rgba(16,52,96,.12); }
.ai-table td { padding: 8px 10px; border-bottom: 1px solid rgba(16,52,96,.07); }

/* AI Action Execution Cards */
.ai-action-card {
  margin-top: 12px; padding: 16px 18px; border-radius: 14px;
  background: #fff; border: 1.5px solid rgba(22, 163, 123, 0.28);
  box-shadow: 0 4px 16px rgba(22, 163, 123, 0.09);
}
.ai-action-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px;
  background: var(--ok-bg); color: var(--ok);
  font-weight: 700; font-size: 13.5px; margin-bottom: 10px;
}
.ai-action-badge .icon { width: 16px; height: 16px; }
.ai-action-title { font-size: 16px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.ai-action-grid { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 14px; margin: 10px 0 14px; }
.ai-action-grid dt { color: var(--muted); font-size: 13px; }
.ai-action-grid dd { margin: 0; font-weight: 500; color: var(--ink); }
.ai-action-footer { display: flex; gap: 10px; align-items: center; padding-top: 10px; border-top: 1px solid rgba(16, 52, 96, 0.08); }

.briefing { background: linear-gradient(135deg, rgba(29,111,214,.1), rgba(39,195,214,.08)); }

/* empty / helpers */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 15.5px; }
.empty .icon { width: 44px; height: 44px; margin: 0 auto 10px; color: var(--blue-300); }
.muted { color: var(--muted); }
.hl { color: var(--blue-700); font-weight: 600; }
.spacer { flex: 1; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-col { display: flex; flex-direction: column; gap: 6px; }
.wrap-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 13px; padding: 3px 10px; border-radius: 999px; background: rgba(29,111,214,.1); color: var(--blue-700); font-weight: 500; }
.notice { padding: 14px 18px; border-radius: 14px; font-size: 14.5px; display:flex; gap:10px; align-items:flex-start; line-height: 1.5; }
.notice.warn { background: var(--warn-bg); color: #9a6a09; }
.notice.danger { background: var(--danger-bg); color: #a62f2f; }
.notice.info { background: var(--info-bg); color: var(--blue-800); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .cards-5 { grid-template-columns: repeat(3, 1fr); }
  .cards-4 { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
  .ai-wrap { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  #app { grid-template-columns: 1fr; grid-template-areas: "topbar" "content"; }
  .sidebar { position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: 270px; z-index: 50; transform: translateX(-100%); transition: transform .22s; }
  #app.nav-open .sidebar { transform: translateX(0); }
  .topbar .brand { display: flex; }
  .topbar .menu-toggle { display: grid; }
  .cards-5, .cards-4, .cards-3, .cards-2 { grid-template-columns: 1fr 1fr; }
  .topbar-search { display: none; }
}
@media (max-width: 560px) {
  .cards-5, .cards-4, .cards-3, .cards-2 { grid-template-columns: 1fr; }
  .content { padding: 18px 14px 50px; }
  .role-switch .icon { display: none; }
}

/* ============================================================
   LANDING (หน้าแรก เลือกบทบาท) — พรีเมียม สง่างาม เข้าธีม Royal Blue
   ============================================================ */
.landing {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  overflow-y: auto; padding: 24px;
  background:
    radial-gradient(1000px 650px at 80% -10%, rgba(39, 195, 214, 0.22), transparent 60%),
    radial-gradient(900px 600px at 10% 110%, rgba(29, 111, 214, 0.28), transparent 55%),
    linear-gradient(135deg, #071e3d 0%, #0c2b55 42%, #144e99 100%);
  animation: landingFade .4s ease;
}
@keyframes landingFade { from { opacity: 0; } }
.landing[hidden] { display: none; }

.landing-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(550px 550px at 85% 15%, rgba(39,195,214,.16), transparent 60%),
    radial-gradient(450px 450px at 15% 85%, rgba(90,166,247,.14), transparent 60%);
  pointer-events: none;
}
.landing-bg::before, .landing-bg::after {
  content: ""; position: absolute; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.07); pointer-events: none;
}
.landing-bg::before { width: 760px; height: 760px; right: -220px; top: -220px; }
.landing-bg::after { width: 520px; height: 520px; left: -160px; bottom: -160px; }

.landing-inner {
  position: relative; z-index: 2;
  text-align: center; padding: 46px 40px 42px;
  max-width: 720px; width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 32px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  animation: landingRise .5s cubic-bezier(.2,.7,.3,1);
}
@keyframes landingRise { from { transform: translateY(16px); opacity: 0; } }

.landing-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 18px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #cfe3fa; font-size: 13.5px; font-weight: 500;
  margin-bottom: 22px;
  backdrop-filter: blur(10px);
}
.landing-badge .icon { width: 16px; height: 16px; color: var(--cyan); }

.landing-title {
  color: #fff; font-weight: 700; letter-spacing: .5px;
  font-size: clamp(32px, 6vw, 56px); margin: 0 0 12px; line-height: 1.1;
  text-shadow: 0 4px 30px rgba(0,0,0,.25);
}
.landing-sub {
  color: rgba(255,255,255,.78); font-size: 14.5px;
  margin: 0 auto 38px; max-width: 540px; font-weight: 400; line-height: 1.5;
}

.landing-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px; max-width: 580px; margin: 0 auto;
}
.landing-btn {
  display: flex; align-items: center; gap: 16px; text-align: left;
  padding: 20px 22px; border-radius: 20px; cursor: pointer;
  background: rgba(255, 255, 255, 0.12);
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(12px);
  color: #fff; font-family: var(--font) !important;
  transition: all .2s cubic-bezier(.2,.7,.3,1);
}
.landing-btn:hover {
  transform: translateY(-3px);
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
}
.landing-btn.primary {
  background: linear-gradient(135deg, rgba(39,195,214,.28), rgba(29,111,214,.35));
  border-color: rgba(39, 195, 214, 0.45);
}
.landing-btn.primary:hover {
  background: linear-gradient(135deg, rgba(39,195,214,.42), rgba(29,111,214,.5));
  border-color: rgba(39, 195, 214, 0.7);
}
.landing-btn .lb-ico {
  flex: none; width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.28);
  color: #fff;
}
.landing-btn .lb-ico .icon { width: 24px; height: 24px; }
.landing-btn .lb-text { display: flex; flex-direction: column; gap: 4px; }
.landing-btn .lb-text strong { font-size: 18px; font-weight: 700; letter-spacing: .2px; }
.landing-btn .lb-text small { font-size: 12.5px; color: rgba(255,255,255,.78); font-weight: 400; line-height: 1.35; }

@media (max-width: 560px) {
  .landing-actions { grid-template-columns: 1fr; }
  .landing-inner { padding: 34px 22px 30px; }
}

/* back-to-landing button in topbar */
.home-btn { }

/* ============================================================
   CUSTOMER PORTAL (ผู้รับบริการ) — ค้นหาชื่อองค์กร + ป๊อปอัปยืนยันสิทธิ์
   ============================================================ */
.cust-wrap { max-width: 820px; margin: 0 auto; }
.cust-hero {
  text-align: center; padding: 36px 20px 24px;
}
.cust-hero .mark {
  width: 58px; height: 58px; border-radius: 18px; margin: 0 auto 16px;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--blue-600), var(--cyan));
  box-shadow: 0 10px 30px rgba(29,111,214,.3);
}
.cust-hero h1 { font-size: 26px; font-weight: 700; margin: 0 0 8px; color: var(--ink); }
.cust-hero p { color: var(--muted); margin: 0; font-size: 15.5px; }

.cust-search-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 20px; padding: 22px 24px;
  box-shadow: var(--glass-shadow);
  margin-top: 10px;
}
.cust-search {
  display: flex; gap: 10px; align-items: center;
  position: relative;
}
.cust-search-icon { position: absolute; left: 18px; color: var(--muted); pointer-events: none; }
.cust-search input {
  flex: 1; padding: 14px 18px 14px 48px; border-radius: 14px;
  border: 1.5px solid rgba(21, 80, 158, 0.18); background: #fff;
  font-family: var(--font) !important; font-size: 15.5px; outline: none;
  transition: all .2s;
}
.cust-search input:focus {
  border-color: var(--blue-600);
  box-shadow: 0 0 0 4px rgba(29, 111, 214, 0.14);
}
.cust-search-btn {
  padding: 14px 22px; border-radius: 14px; border: none;
  background: linear-gradient(135deg, var(--blue-600), var(--cyan));
  color: #fff; font-family: var(--font) !important; font-weight: 600; font-size: 15px;
  cursor: pointer; transition: all .15s;
}
.cust-search-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }

.cust-company-list { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.cust-unit-item {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 16px 20px; border-radius: 16px; background: #fff;
  border: 1.5px solid rgba(21, 80, 158, 0.12);
  cursor: pointer; transition: all .18s;
  box-shadow: 0 2px 8px rgba(16, 52, 96, 0.04);
}
.cust-unit-item:hover {
  transform: translateY(-2px);
  border-color: var(--blue-600);
  box-shadow: 0 8px 24px rgba(29, 111, 214, 0.12);
}
.cust-unit-item .cui-title { font-size: 16.5px; font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.cust-unit-item .cui-meta { font-size: 13.5px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }
.cust-unit-item .cui-action {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 10px; font-weight: 600; font-size: 13.5px;
  background: rgba(29, 111, 214, 0.1); color: var(--blue-700); flex: none;
}
.cust-unit-item:hover .cui-action {
  background: var(--blue-600); color: #fff;
}

/* Modal ยืนยันสิทธิ์เข้าดูข้อมูลองค์กร */
.confirm-box {
  padding: 10px 4px 6px; text-align: center;
}
.confirm-icon-ring {
  width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 16px;
  display: grid; place-items: center; color: var(--blue-600);
  background: rgba(29, 111, 214, 0.12); border: 1px solid rgba(29, 111, 214, 0.22);
}
.confirm-icon-ring .icon { width: 32px; height: 32px; }
.confirm-box h3 { font-size: 20px; font-weight: 700; margin: 0 0 8px; color: var(--ink); }
.confirm-box p { font-size: 15px; color: var(--muted); line-height: 1.55; margin: 0 0 20px; }
.confirm-company-badge {
  display: inline-block; padding: 10px 18px; border-radius: 12px;
  background: rgba(29, 111, 214, 0.08); border: 1px solid rgba(29, 111, 214, 0.2);
  color: var(--blue-800); font-weight: 700; font-size: 16px; margin-bottom: 22px;
}

/* steps timeline (ขั้นตอนหลังออกหน่วย) */
.steps { position: relative; margin: 10px 0; }
.step {
  display: flex; gap: 16px; align-items: flex-start; padding: 4px 0; position: relative;
}
.step .step-rail { display: flex; flex-direction: column; align-items: center; flex: none; }
.step .step-dot {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: #fff; border: 2px solid rgba(16,52,96,.15); color: var(--muted); font-weight: 700; z-index: 1;
  transition: .2s;
}
.step .step-line { width: 2px; flex: 1; min-height: 26px; background: rgba(16,52,96,.14); }
.step:last-child .step-line { display: none; }
.step.done .step-dot { background: linear-gradient(135deg, var(--ok), #37d0a0); border-color: transparent; color: #fff; }
.step.done .step-line { background: linear-gradient(var(--ok), rgba(22,163,123,.3)); }
.step.current .step-dot { background: linear-gradient(135deg, var(--blue-600), var(--cyan)); border-color: transparent; color: #fff; box-shadow: 0 0 0 5px rgba(29,111,214,.15); animation: pulseDot 1.6s infinite; }
@keyframes pulseDot { 50% { box-shadow: 0 0 0 9px rgba(29,111,214,.05); } }
.step .step-body { padding: 7px 0 20px; }
.step .step-title { font-weight: 600; font-size: 15px; }
.step.pending .step-title { color: var(--muted); font-weight: 500; }
.step .step-meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.step .step-badge { margin-top: 6px; }

/* checklist (เจ้าหน้าที่ติ๊ก) */
.checklist { display: flex; flex-direction: column; gap: 8px; }
.chk-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px;
  background: var(--glass-soft); border: 1px solid rgba(255,255,255,.5); cursor: pointer; transition: .14s; user-select: none;
}
.chk-item:hover { background: #fff; }
.chk-item .chk-box {
  flex: none; width: 24px; height: 24px; border-radius: 7px; border: 2px solid rgba(16,52,96,.25);
  display: grid; place-items: center; color: #fff; transition: .15s; background: transparent;
}
.chk-item.on .chk-box { background: linear-gradient(135deg, var(--blue-600), var(--cyan)); border-color: transparent; }
.chk-item .chk-box .icon { width: 15px; height: 15px; opacity: 0; }
.chk-item.on .chk-box .icon { opacity: 1; }
.chk-item .chk-label { font-size: 14px; }
.chk-item.on .chk-label { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(107,124,146,.5); }
.chk-item .chk-when { margin-left: auto; font-size: 11.5px; color: var(--muted); }

.phase-head { display: flex; align-items: center; justify-content: space-between; margin: 2px 0 10px; }
.phase-head .ph-left { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.phase-head .ph-left .icon { color: var(--blue-600); }
.phase-pct { font-size: 13px; color: var(--blue-700); font-weight: 700; }

/* ============================================================
   CUSTOMER MODE — ซ่อน chrome ที่ไม่เกี่ยวกับลูกค้า
   ============================================================ */
body.customer-mode .sidebar { display: none; }
body.customer-mode #nav { display: none; }
body.customer-mode .topbar-search,
body.customer-mode #notifBtn,
body.customer-mode .role-switch,
body.customer-mode .menu-toggle { display: none; }
body.customer-mode #app {
  grid-template-columns: 1fr;
  grid-template-areas: "topbar" "content";
}
body.customer-mode .topbar .brand { display: flex; }

/* ============================================================
   BRAND WORDMARK (ตาม–หน่วย–งาน) — อลังการบนหน้าแรก
   ============================================================ */
.brand-wordmark { font-size: clamp(40px, 8vw, 82px); font-weight: 700; letter-spacing: 1px; background: linear-gradient(100deg, #FFFFFF 0%, #CFE3FA 40%, #2FD3A5 100%); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: none; margin: 0 0 8px; }
.brand-wordmark .dash { color: #2FD3A5; -webkit-text-fill-color: #2FD3A5; margin: 0 2px; font-weight: 300; }
.landing-tagline { color: #CFE3FA; font-size: clamp(15px, 2.6vw, 20px); font-weight: 300; letter-spacing: 2px; margin: 0 0 20px; }

/* ============================================================
   LOGIN CARD
   ============================================================ */
.login-card { position: relative; z-index: 2; width: min(420px, 92vw); padding: 40px 38px 34px; border-radius: 24px; text-align: center; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.22); animation: landingRise .5s cubic-bezier(.2,.7,.3,1); }
.login-back { position: absolute; top: 18px; left: 18px; display: inline-flex; align-items: center; gap: 4px; background: none; border: none; color: rgba(255,255,255,.7); font-family: var(--font); font-size: 13px; cursor: pointer; }
.login-back:hover { color: #fff; }
.login-back .icon { width: 16px; height: 16px; transform: rotate(180deg); }
.login-mark { width: 54px; height: 54px; border-radius: 16px; margin: 0 auto 18px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, rgba(255,255,255,.2), rgba(255,255,255,.05)); border: 1px solid rgba(255,255,255,.25); }
.login-mark .icon { width: 28px; height: 28px; }
.login-title { color: #fff; font-size: 26px; font-weight: 700; margin: 0 0 4px; }
.login-sub { color: #9CCBFB; font-size: 14px; margin: 0 0 24px; }
.login-form { display: flex; flex-direction: column; gap: 16px; text-align: left; }
.login-field { display: flex; flex-direction: column; gap: 6px; }
.login-field span { font-size: 13.5px; color: rgba(255,255,255,.82); font-weight: 500; }
.login-field input { padding: 12px 16px; border-radius: 12px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.1); color: #fff; font-family: var(--font) !important; font-size: 15.5px; outline: none; transition: .15s; }
.login-field input::placeholder { color: rgba(255,255,255,.45); }
.login-field input:focus { border-color: #2FD3A5; background: rgba(255,255,255,.18); box-shadow: 0 0 0 3px rgba(47,211,165,.2); }
.login-error { background: rgba(225,75,75,.2); border: 1px solid rgba(225,75,75,.4); color: #FFD7D7; font-size: 13.5px; padding: 10px 14px; border-radius: 10px; }
.login-submit { margin-top: 8px; padding: 14px; border-radius: 12px; border: none; cursor: pointer; font-family: var(--font) !important; font-weight: 700; font-size: 16px; color: #06243f; background: linear-gradient(135deg, #2FD3A5, #14B8C4); transition: .15s; box-shadow: 0 6px 18px rgba(47,211,165,.3); }
.login-submit:hover { filter: brightness(1.07); transform: translateY(-1px); }
.login-submit:disabled { opacity: .6; cursor: default; }

/* ============================================================
   UNIT BADGE (มุมบนขวา) + USER CHIP
   ============================================================ */
.unit-badge {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px; border-radius: 11px;
  background: linear-gradient(135deg, rgba(29,111,214,.10), rgba(39,195,214,.08));
  border: 1px solid rgba(29,111,214,.18);
  white-space: nowrap; flex-shrink: 1; min-width: 0; max-width: 270px;
}
.unit-badge .ub-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-600), var(--cyan));
  flex: none; box-shadow: 0 0 0 3px rgba(29,111,214,.14);
}
.unit-badge .ub-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; overflow: hidden; }
.unit-badge .ub-text strong {
  font-size: 13px; font-weight: 700; color: var(--blue-800);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.unit-badge .ub-text small {
  font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 8px 4px 6px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(21, 80, 158, 0.12);
  flex-shrink: 0; white-space: nowrap; cursor: pointer;
  transition: all .15s ease;
}
.user-chip:hover {
  background: #ffffff;
  border-color: rgba(29, 111, 214, 0.3);
  box-shadow: 0 2px 8px rgba(16, 52, 96, 0.08);
}
.user-chip .uc-avatar {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; font-size: 14px; font-weight: 700;
  color: #fff; background: linear-gradient(135deg, var(--blue-600), var(--cyan));
  flex: none;
}
.user-chip .uc-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; overflow: hidden; }
.user-chip .uc-text strong {
  font-size: 13.5px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 140px; display: block;
}
.user-chip .uc-text small {
  font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 140px; display: block;
}
.user-chip .uc-logout {
  width: 28px; height: 28px; border-radius: 8px; border: none;
  background: transparent; color: var(--muted); cursor: pointer;
  display: grid; place-items: center; flex: none; transition: all .15s;
}
.user-chip .uc-logout:hover { background: var(--danger-bg); color: var(--danger); }
.user-chip .uc-logout .icon { width: 16px; height: 16px; }

@media (max-width: 1360px) { .unit-badge .ub-text small { display: none; } }
@media (max-width: 1100px) { .unit-badge { display: none; } }
@media (max-width: 760px) { .unit-badge, .user-chip .uc-text { display: none; } }
body.customer-mode .unit-badge, body.customer-mode .user-chip { display: none; }

/* loading overlay */
.loading-splash { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; background: var(--bg-grad-1); }
.loading-splash .spinner { width: 42px; height: 42px; border-radius: 50%; border: 3px solid rgba(29,111,214,.2); border-top-color: var(--blue-600); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   DASHBOARD v2 — command center (hero + focus feed + pulse rail)
   ============================================================ */
.dash-hero {
  position: relative; overflow: hidden;
  border-radius: 26px; padding: 30px 34px;
  background: linear-gradient(135deg, #071e3d 0%, #0c2b55 42%, #144e99 100%);
  box-shadow: 0 20px 50px rgba(10, 37, 64, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  color: #fff; margin-bottom: 24px;
}
.dash-hero::before {
  content: ""; position: absolute; left: -100px; bottom: -100px; width: 340px; height: 340px; border-radius: 50%;
  background: radial-gradient(circle, rgba(29, 111, 214, 0.35), transparent 70%); pointer-events: none;
}
.dash-hero::after {
  content: ""; position: absolute; right: -80px; top: -80px; width: 360px; height: 360px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(39, 195, 214, 0.38), transparent 70%); pointer-events: none;
}
.dash-hero-top {
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.dash-hero-avatar .avatar.hero-av {
  width: 58px; height: 58px; border-radius: 18px;
  font-size: 22px; font-weight: 800;
  background: linear-gradient(135deg, #27c3d6, #1d6fd6);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25), 0 0 0 3px rgba(255, 255, 255, 0.3);
}
.dash-hero-info { flex: 1; min-width: 220px; }
.dash-hero-greet { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.greet-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  padding: 3px 12px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; color: #bde0fe;
}
.greet-badge .icon { width: 15px; height: 15px; }
.dash-hero-title {
  font-size: 32px; font-weight: 800; margin: 4px 0 6px; line-height: 1.2;
  letter-spacing: -0.3px; color: #ffffff;
}
.dash-hero-sub {
  font-size: 14.5px; color: rgba(255, 255, 255, 0.82); font-weight: 400;
}
.hero-date-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 13.5px; font-weight: 500; color: rgba(255, 255, 255, 0.88);
}
.dash-hero-summary-box {
  position: relative; z-index: 2;
  margin-top: 20px; padding: 16px 20px; border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex; flex-direction: column; gap: 10px;
}
.hero-summary-text {
  font-size: 16px; color: #eaf3ff; line-height: 1.6;
}
.hero-summary-text b { color: #ffffff; font-weight: 700; }
.hero-summary-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.dash-hero .pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
}
.dash-hero .pill-danger { background: rgba(225, 75, 75, 0.28); color: #ffd8d8; border: 1px solid rgba(225, 75, 75, 0.4); }
.dash-hero .pill-warn { background: rgba(229, 155, 27, 0.28); color: #ffe6ba; border: 1px solid rgba(229, 155, 27, 0.4); }
.dash-hero .pill-ok { background: rgba(39, 195, 214, 0.25); color: #c3f9f3; border: 1px solid rgba(39, 195, 214, 0.35); }
.dash-hero .hero-actions {
  position: relative; z-index: 2;
  margin-top: 20px; display: flex; gap: 12px; flex-wrap: wrap;
}
.dash-hero .hero-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: 13px;
  font-family: var(--font); font-weight: 600; font-size: 14.5px;
  cursor: pointer; border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.12); color: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.dash-hero .hero-btn:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}
.dash-hero .hero-btn.solid {
  background: linear-gradient(135deg, #27c3d6, #2fd3a5);
  color: #06243f; border-color: transparent; font-weight: 700;
  box-shadow: 0 6px 20px rgba(39, 195, 214, 0.35);
}
.dash-hero .hero-btn.solid:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(39, 195, 214, 0.5);
  filter: brightness(1.05);
}

/* 2-column asymmetric */
.dash-grid { display: grid; grid-template-columns: 1.7fr 1fr; gap: 22px; align-items: start; }
@media (max-width: 1000px) { .dash-grid { grid-template-columns: 1fr; } }

.panel { background: var(--glass-bg); backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%); border: 1px solid var(--glass-border); border-radius: var(--radius); box-shadow: var(--glass-shadow); padding: 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-head .ph-title { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17.5px; color: var(--ink); }
.panel-head .ph-title .icon { color: var(--blue-600); }
.panel-head .ph-count { font-size: 13px; font-weight: 700; background: rgba(29,111,214,.14); color: var(--blue-700); padding: 2px 11px; border-radius: 999px; }

/* focus feed item — priority dot + info, no edge stripe */
.focus-item { display: flex; gap: 14px; align-items: center; padding: 14px 10px; border-bottom: 1px solid rgba(16,52,96,.07); cursor: pointer; transition: all .16s ease; border-radius: 12px; }
.focus-item:last-child { border-bottom: none; }
.focus-item:hover { background: rgba(29,111,214,.06); padding-left: 14px; padding-right: 14px; }
.focus-item .pr-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; margin-top: 3px; align-self: flex-start; }
.pr-dot.d-danger { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-bg); }
.pr-dot.d-warn { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-bg); }
.pr-dot.d-wait { background: var(--wait); box-shadow: 0 0 0 4px var(--wait-bg); }
.pr-dot.d-info { background: var(--blue-500); box-shadow: 0 0 0 4px var(--info-bg); }
.focus-item .fi-main { flex: 1; min-width: 0; }
.focus-item .fi-title { font-weight: 600; font-size: 15.5px; color: var(--ink); }
.focus-item .fi-meta { font-size: 13.5px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; margin-top: 4px; }
.focus-item .fi-when { font-size: 13px; font-weight: 700; white-space: nowrap; }
.fi-when.w-danger { color: var(--danger); } .fi-when.w-warn { color: var(--warn); } .fi-when.w-info { color: var(--blue-600); } .fi-when.w-wait { color: var(--wait); }

/* focus empty card */
.focus-empty-card {
  padding: 32px 24px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.focus-empty-card .fec-ico {
  width: 54px; height: 54px; border-radius: 16px;
  background: rgba(22, 163, 123, 0.14); color: var(--ok);
  display: grid; place-items: center;
}
.focus-empty-card .fec-ico .icon { width: 28px; height: 28px; }
.focus-empty-card strong { font-size: 17px; color: var(--ink); font-weight: 700; }
.focus-empty-card p { font-size: 14.5px; color: var(--muted); margin: 0; max-width: 440px; line-height: 1.5; }
.focus-empty-card .fec-acts { display: flex; gap: 10px; margin-top: 8px; }

/* pulse rail tiles — asymmetric: alert tiles prominent, mini-stats compact */
.pulse-stack { display: flex; flex-direction: column; gap: 16px; }
.alert-tile { display: flex; align-items: center; gap: 16px; padding: 18px 20px; border-radius: 18px; cursor: pointer; transition: all .16s ease; }
.alert-tile:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(16,52,96,.12); }
.alert-tile .at-num { font-size: 32px; font-weight: 800; line-height: 1; }
.alert-tile .at-label { font-size: 14px; font-weight: 600; }
.alert-tile.t-danger { background: linear-gradient(135deg, rgba(225,75,75,.15), rgba(225,75,75,.06)); border: 1px solid rgba(225,75,75,.28); color: var(--danger); }
.alert-tile.t-warn { background: linear-gradient(135deg, rgba(229,155,27,.15), rgba(229,155,27,.06)); border: 1px solid rgba(229,155,27,.25); color: #b4790a; }
.alert-tile .at-ico { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: #fff; flex: none; box-shadow: 0 4px 12px rgba(0,0,0,.08); }

.mini-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mini-stat { background: var(--glass-soft); border: 1px solid rgba(255,255,255,.55); border-radius: 16px; padding: 16px; cursor: pointer; transition: all .16s ease; }
.mini-stat:hover { background: #fff; transform: translateY(-2px); box-shadow: 0 10px 24px rgba(16,52,96,.12); }
.mini-stat .ms-top { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.mini-stat .ms-top .icon { width: 17px; height: 17px; color: var(--blue-600); }
.mini-stat .ms-num { font-size: 28px; font-weight: 800; color: var(--ink); margin-top: 6px; line-height: 1; }
.mini-stat .ms-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* staff-today donut */
.donut-wrap { display: flex; align-items: center; gap: 20px; }
.donut { width: 104px; height: 104px; border-radius: 50%; flex: none; display: grid; place-items: center; box-shadow: 0 4px 16px rgba(16,52,96,.1); }
.donut > .donut-hole { width: 72px; height: 72px; border-radius: 50%; background: var(--glass-bg-strong); display: grid; place-items: center; text-align: center; }
.donut-hole .dh-num { font-size: 24px; font-weight: 800; color: var(--ink); line-height: 1; }
.donut-hole .dh-lbl { font-size: 11px; color: var(--muted); font-weight: 600; }
.donut-legend { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.donut-legend .dl-row { display: flex; align-items: center; gap: 9px; }
.donut-legend .dl-sw { width: 12px; height: 12px; border-radius: 4px; }
.donut-legend .dl-n { margin-left: auto; font-weight: 700; color: var(--ink); font-size: 14.5px; }

/* upcoming unit — richer horizontal card */
.up-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.up-card { background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: 20px; padding: 20px; box-shadow: var(--glass-shadow); cursor: pointer; transition: all .16s ease; }
.up-card:hover { transform: translateY(-3px); box-shadow: 0 18px 40px rgba(16,52,96,.18); background: #fff; }
.up-card .uc-day { display: flex; align-items: baseline; gap: 8px; }
.up-card .uc-d { font-size: 32px; font-weight: 800; color: var(--blue-700); line-height: 1; }
.up-card .uc-mo { font-size: 14px; color: var(--muted); font-weight: 600; }
.up-card .uc-co { font-weight: 700; font-size: 16.5px; margin: 10px 0 3px; color: var(--ink); }
.up-card .uc-meta { font-size: 13.5px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }
.up-card .uc-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }

/* Shared staff unavailability calendar */
.busy-scroll { overflow-x:auto; }
.busy-grid { display:grid; grid-template-columns:repeat(7,minmax(0,1fr)); gap:8px; min-width:620px; margin-top:16px; }
.busy-grid > strong { text-align:center; padding:8px; }
.busy-day { min-height:100px; padding:10px; border:1px solid var(--border,#d8e2ee); border-radius:12px; background:rgba(255,255,255,.8); color:inherit; font:inherit; text-align:left; cursor:pointer; display:flex; flex-direction:column; gap:5px; }
.busy-day span { font-size:12px; overflow-wrap:anywhere; background:#eaf1ff; border-radius:5px; padding:3px; }
.busy-day:hover,.busy-today { border-color:#1d6fd6; box-shadow:inset 0 0 0 1px #1d6fd6; }

/* Respect hidden for empty validation messages and all hidden panels. */
[hidden] { display: none !important; }

/* Separate unit date and participant count, including on narrow cards. */
.unit-meta { display:flex; flex-wrap:wrap; gap:8px 18px; margin:8px 0; color:var(--muted); font-size:13.5px; }
.unit-meta > span { display:inline-flex; align-items:center; gap:6px; white-space:nowrap; }
