/* =========================================================================
   SmartDoc — design tokens, base, app shell (sidebar / topbar / content), dashboard
   ========================================================================= */
/* Thai numerals everywhere, like the original (TH Sarabun IT๙ draws 0-9 as ๐-๙): only the digits come from
   it (unicode-range), letters stay in the UI fonts, and the values typed and stored stay 0-9.
   size-adjust makes its digits as tall as the Thai digits of Noto Sans Thai (126%) / Prompt (150%). */
@font-face { font-family: "ThaiDigits"; src: url(/public/font/THSarabunIT.ttf); unicode-range: U+0030-0039; font-weight: 100 500; size-adjust: 126%; }
@font-face { font-family: "ThaiDigits"; src: url(/public/font/THSarabunITBold.ttf); unicode-range: U+0030-0039; font-weight: 600 900; size-adjust: 126%; }
@font-face { font-family: "ThaiDigitsDisplay"; src: url(/public/font/THSarabunIT.ttf); unicode-range: U+0030-0039; font-weight: 100 500; size-adjust: 150%; }
@font-face { font-family: "ThaiDigitsDisplay"; src: url(/public/font/THSarabunITBold.ttf); unicode-range: U+0030-0039; font-weight: 600 900; size-adjust: 150%; }
/* register pages (ทะเบียน…): the Thai digits 2pt larger, letters unchanged (owner, 10 ต.ค. 2569). size-adjust is a ratio,
   so it is set for the main sizes there: 126% × 12.5pt/10.5pt for the 14px table text, 150% × 21.5pt/19.5pt for the
   26px stat numbers. Line height comes from the letter font, so rows keep their height. */
@font-face { font-family: "ThaiDigitsRegister"; src: url(/public/font/THSarabunIT.ttf); unicode-range: U+0030-0039; font-weight: 100 500; size-adjust: 150%; }
@font-face { font-family: "ThaiDigitsRegister"; src: url(/public/font/THSarabunITBold.ttf); unicode-range: U+0030-0039; font-weight: 600 900; size-adjust: 150%; }
@font-face { font-family: "ThaiDigitsRegisterDisplay"; src: url(/public/font/THSarabunIT.ttf); unicode-range: U+0030-0039; font-weight: 100 500; size-adjust: 165%; }
@font-face { font-family: "ThaiDigitsRegisterDisplay"; src: url(/public/font/THSarabunITBold.ttf); unicode-range: U+0030-0039; font-weight: 600 900; size-adjust: 165%; }

#receive_display, #send_display, #directive_display, #announce_display, #internal_display, #approved_display {
  --font-ui: "ThaiDigitsRegister", "Noto Sans Thai", "Leelawadee UI", "Thonburi", system-ui, sans-serif;
  --font-display: "ThaiDigitsRegisterDisplay", "Prompt", "Noto Sans Thai", "Leelawadee UI", system-ui, sans-serif;
  font-family: var(--font-ui);
}

:root {
  color-scheme: light;
  --font-ui: "ThaiDigits", "Noto Sans Thai", "Leelawadee UI", "Thonburi", system-ui, sans-serif;
  --font-display: "ThaiDigitsDisplay", "Prompt", "Noto Sans Thai", "Leelawadee UI", system-ui, sans-serif;
  --font-doc: "THSarabunIT", "Sarabun", sans-serif;
  --font-icon: "Material Symbols Outlined";

  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-2: #f6f9f7;
  --surface-3: #ecf2ee;
  --border: #e2e9e4;
  --border-strong: #cdd8d1;
  --text: #15211a;
  --text-2: #4a5a51;
  --muted: #84938a;
  --primary: #1b8a4c;
  --primary-hover: #157340;
  --primary-soft: rgba(27, 138, 76, 0.10);
  --primary-ring: rgba(27, 138, 76, 0.26);
  --grad: linear-gradient(135deg, #22a35b 0%, #18803f 100%);
  --accent: #f59e0b;
  --accent-soft: rgba(245, 158, 11, 0.14);
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.12);
  --warning: #ea8a0c;
  --warning-soft: rgba(245, 158, 11, 0.14);
  --danger: #e5383b;
  --danger-soft: rgba(229, 56, 59, 0.11);
  --info: #2f6fe0;
  --info-soft: rgba(47, 111, 224, 0.11);
  --cancel: #7c3aed;
  --cancel-soft: rgba(124, 58, 237, 0.11);
  --brand-accent: #f08a24;
  --overlay: rgba(10, 24, 16, 0.45);
  --sidebar-bg: #ffffff;
  --sidebar-text: #3d4b43;
  --sidebar-hover: #f1f6f3;
  --sidebar-border: #e6ece8;
  --shadow-sm: 0 1px 2px rgba(16, 40, 26, 0.05);
  --shadow: 0 1px 2px rgba(16, 40, 26, 0.04), 0 8px 24px -16px rgba(16, 40, 26, 0.16);
  --shadow-lg: 0 30px 60px -20px rgba(16, 40, 26, 0.30);
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --navbar_size: 76px;
  --menu_size: 280px;
  --menu_collapse_size: 84px;
  --child_size: 240px;
  --control-h: 44px;

  /* legacy names — still referenced by server-side operator colours and module scripts */
  --main_color: var(--primary);
  --second_color: var(--accent);
  --third_color: var(--success);
  --forth_color: var(--danger);
  --white_color: var(--surface);
  --bg_color: var(--bg);
  --light_color: var(--text-2);
  --dark_color: var(--text);
  --gap_size: 8px;
  --p_size: 28px; /* only used by server-defined column widths: calc(var(--p_size)*N) */
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c1310;
    --surface: #131c17;
    --surface-2: #17221c;
    --surface-3: #1e2b24;
    --border: #24332b;
    --border-strong: #33463b;
    --text: #e6efe9;
    --text-2: #b0c1b6;
    --muted: #7c8f83;
    --primary: #3cc47f;
    --primary-hover: #5fd497;
    --primary-soft: rgba(60, 196, 127, 0.14);
    --primary-ring: rgba(60, 196, 127, 0.32);
    --grad: linear-gradient(135deg, #2fae68 0%, #1e8a4c 100%);
    --success: #4ade80;
    --success-soft: rgba(74, 222, 128, 0.13);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.13);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.14);
    --info: #7aa7ff;
    --info-soft: rgba(122, 167, 255, 0.14);
    --cancel: #b794f6;
    --cancel-soft: rgba(183, 148, 246, 0.14);
    --overlay: rgba(0, 6, 3, 0.65);
    --sidebar-bg: #111915;
    --sidebar-text: #b0c1b6;
    --sidebar-hover: rgba(255, 255, 255, 0.05);
    --sidebar-border: #213028;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px -18px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 30px 60px -20px rgba(0, 0, 0, 0.7);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c1310;
  --surface: #131c17;
  --surface-2: #17221c;
  --surface-3: #1e2b24;
  --border: #24332b;
  --border-strong: #33463b;
  --text: #e6efe9;
  --text-2: #b0c1b6;
  --muted: #7c8f83;
  --primary: #3cc47f;
  --primary-hover: #5fd497;
  --primary-soft: rgba(60, 196, 127, 0.14);
  --primary-ring: rgba(60, 196, 127, 0.32);
  --grad: linear-gradient(135deg, #2fae68 0%, #1e8a4c 100%);
  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.13);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.13);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --info: #7aa7ff;
  --info-soft: rgba(122, 167, 255, 0.14);
  --cancel: #b794f6;
  --cancel-soft: rgba(183, 148, 246, 0.14);
  --overlay: rgba(0, 6, 3, 0.65);
  --sidebar-bg: #111915;
  --sidebar-text: #b0c1b6;
  --sidebar-hover: rgba(255, 255, 255, 0.05);
  --sidebar-border: #213028;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px -18px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 30px 60px -20px rgba(0, 0, 0, 0.7);
}

/* menu animations — names are referenced from common.js */
@keyframes animated_menubar_show { from { left: calc(-1*var(--menu_size)); } to { left: 0; } }
@keyframes animated_menubar_hide { from { left: 0; } to { left: calc(-1*var(--menu_size)); } }
@keyframes animated_menubar_expand { from { width: var(--menu_collapse_size); } to { width: var(--menu_size); } }
@keyframes animated_menubar_collapse { from { width: var(--menu_size); } to { width: var(--menu_collapse_size); } }
@keyframes animated_pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); } 50% { box-shadow: 0 0 0 5px rgba(239, 68, 68, 0); } }
@keyframes animated_spin { to { transform: rotate(360deg); } }
@keyframes animated_fade_in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

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

html, body { height: 100%; }

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background-color: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

input, select, textarea, button { font-family: inherit; font-size: inherit; color: inherit; }

::selection { background: var(--primary-ring); }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

.material-symbols-outlined, .icon {
  font-family: var(--font-icon);
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

.hidden {
  content-visibility: hidden !important;
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  visibility: hidden !important;
}

/* ---------------------------------------------------------- shell / layout */
#container {
  position: relative;
  width: calc(100vw + var(--menu_size));
  height: 100dvh;
  left: calc(-1*var(--menu_size));
  display: flex;
  flex-direction: row;
  overflow: hidden;
}

.main_column {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ----------------------------------------------------------------- sidebar */
#menubar {
  position: relative;
  width: var(--menu_size);
  height: 100%;
  padding: 18px 14px 16px 14px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--sidebar-text);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  overflow-x: hidden;
  overflow-y: auto;
  container-type: inline-size;
  container-name: menubar;
  z-index: 4;
}

.sidebar_brand {
  order: -2;
  margin: 0 0 10px 0;
  padding: 2px 6px 6px 6px;
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 12px;
}

.sidebar_mark {
  width: 46px;
  height: 46px;
  display: flex;
  flex-shrink: 0;
  justify-content: center;
  align-items: center;
  color: var(--primary);
  font-family: var(--font-icon);
  font-size: 26px;
  background: var(--primary-soft);
  border-radius: 50%;
  user-select: none;
}

.sidebar_name { min-width: 0; line-height: 1.15; }

/* the Smart Doc logo when the menu is open; the round mark only when it is collapsed (container query below) */
.sidebar_brand > .sidebar_mark { display: none; }

.sidebar_logo { display: block; width: 224px; max-width: 100%; height: auto; }

.sidebar_title {
  color: var(--primary);
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: .01em;
  white-space: nowrap;
}

.sidebar_title > span { color: var(--brand-accent); }

.sidebar_subtitle { margin-top: 2px; color: var(--muted); font-size: 12px; white-space: nowrap; }

.sidebar_section {
  order: -1;
  padding: 10px 12px 6px 12px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .06em;
  white-space: nowrap;
}

.menubar_list {
  position: relative;
  min-height: 48px;
  padding: 0 14px;
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 14px;
  color: var(--sidebar-text);
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  overflow: hidden;
  transition: background-color .15s, color .15s;
}

.menubar_list:hover { color: var(--text); background-color: var(--sidebar-hover); }

.menubar_list.active {
  color: var(--primary);
  font-weight: 600;
  background: var(--primary-soft);
  box-shadow: inset -4px 0 0 var(--primary);
}

/* separate the administration modules from the document registers */
.menubar_list:is(#structure_menu, #office_menu, #member_menu, #position_menu, #authority_menu):not(:is(#structure_menu, #office_menu, #member_menu, #position_menu, #authority_menu) ~ .menubar_list) {
  margin-top: 34px;
  overflow: visible;
}

.menubar_list:is(#structure_menu, #office_menu, #member_menu, #position_menu, #authority_menu):not(:is(#structure_menu, #office_menu, #member_menu, #position_menu, #authority_menu) ~ .menubar_list)::after {
  content: "การตั้งค่าระบบ";
  position: absolute;
  top: -26px;
  left: 12px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .06em;
  white-space: nowrap;
}

.menubar_symbol {
  width: 24px;
  flex-shrink: 0;
  font-family: var(--font-icon);
  font-size: 23px;
  line-height: 1;
}

.menubar_list.active .menubar_symbol { font-variation-settings: "FILL" 1; }

.menubar_label {
  overflow-x: clip;
  overflow-y: visible;
  min-width: 0;
  font-size: 15px;
  white-space: nowrap;
  text-overflow: ellipsis;
  user-select: none;
  pointer-events: none;
}

.menubar_amount {
  margin-left: auto;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  display: flex;
  flex-shrink: 0;
  justify-content: center;
  align-items: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background-color: var(--danger);
  border-radius: 999px;
  animation: animated_pulse 2.4s ease-in-out infinite;
}

.menubar_list.active .menubar_amount { animation: none; }

/* main.js appends a fresh badge on every refresh — only the newest one is meaningful */
.menubar_amount:not(:last-child) { display: none; }

.sidebar_storage {
  order: 2;
  margin-top: auto;
  padding: 14px;
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 12px;
  background: var(--primary-soft);
  border-radius: 16px;
}

.sidebar_storage.hidden { display: none; }

.sidebar_storage_icon {
  flex-shrink: 0;
  color: var(--primary);
  font-family: var(--font-icon);
  font-size: 30px;
}

.sidebar_storage_body { flex: 1 1 auto; min-width: 0; }

.sidebar_storage_title { color: var(--text); font-size: 13.5px; font-weight: 600; white-space: nowrap; }

.sidebar_storage_text { margin: 2px 0 8px 0; color: var(--text-2); font-size: 12.5px; font-variant-numeric: tabular-nums; }

.sidebar_storage_bar { height: 7px; background: var(--surface); border-radius: 999px; overflow: hidden; }

.sidebar_storage_bar > div { height: 100%; background: var(--primary); border-radius: 999px; }

@container menubar (max-width: 130px) {
  .sidebar_brand { justify-content: center; padding-left: 0; padding-right: 0; }
  .sidebar_brand > .sidebar_mark { display: flex; }
  .sidebar_name, .menubar_label, .sidebar_storage_body { display: none; }
  .sidebar_section { padding: 10px 0 2px 0; color: transparent; font-size: 0; border-top: 1px solid var(--sidebar-border); margin: 6px 10px 0 10px; }
  .menubar_list { justify-content: center; padding: 0; }
  .menubar_amount { position: absolute; top: 3px; right: 8px; min-width: 18px; height: 18px; padding: 0 5px; font-size: 10.5px; }
  .menubar_list:is(#structure_menu, #office_menu, #member_menu, #position_menu, #authority_menu)::after { content: ""; left: 10px; right: 10px; top: -17px; height: 1px; background: var(--sidebar-border); }
  .sidebar_storage { justify-content: center; padding: 10px 0; }
}

/* ------------------------------------------------------------------ topbar */
.navbar {
  position: relative;
  height: var(--navbar_size);
  padding: 0 16px;
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 3;
}

#navbar_burger, #navbar_expand, .navbar_icon {
  position: relative;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--text-2);
  font-family: var(--font-icon);
  font-size: 24px;
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  user-select: none;
  transition: background-color .15s, color .15s;
}

#navbar_burger:hover, #navbar_expand:hover, .navbar_icon:hover { color: var(--primary); background: var(--primary-soft); }

.navbar_icon.hidden { display: none; }

#navbar_expand { display: none; }

.navbar_badge {
  position: absolute;
  top: 3px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  color: #fff;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  background: var(--danger);
  border: 2px solid var(--surface);
  border-radius: 999px;
  box-sizing: content-box;
}

/* the bell's list (main.js toggleNotice) */
.notice_panel {
  position: fixed;
  width: 380px;
  max-width: calc(100vw - 16px);
  max-height: min(70vh, 560px);
  display: flex;
  flex-direction: column;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 40;
  overflow: hidden;
  animation: animated_fade_in .18s ease;
}
.notice_head { padding: 14px 16px 10px; font-family: var(--font-display); font-size: 16px; font-weight: 700; border-bottom: 1px solid var(--border); }
.notice_list { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; }
.notice_item {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 16px;
  color: inherit;
  font: inherit;
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.notice_item:hover, .notice_item:focus-visible { background: var(--primary-soft); outline: none; }
.notice_topic { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-weight: 600; line-height: 1.45; overflow-wrap: anywhere; }
.notice_meta, .notice_time, .notice_more, .notice_empty { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.notice_tag { display: inline-block; margin-right: 6px; padding: 0 7px; font-size: 12px; font-weight: 700; line-height: 20px; vertical-align: 1px; border-radius: 999px; }
.notice_tag.overdue { color: var(--danger); background: var(--danger-soft); }
.notice_tag.urgent { color: var(--warning); background: var(--warning-soft); }
.notice_empty, .notice_more { padding: 16px; text-align: center; }
.notice_all {
  padding: 12px 16px;
  color: var(--primary);
  font: inherit;
  font-weight: 600;
  background: var(--surface-2);
  border: none;
  border-top: 1px solid var(--border);
  cursor: pointer;
}
.notice_all:hover { background: var(--primary-soft); }

.navbar_search {
  position: relative;
  flex: 1 1 auto;
  max-width: 760px;
  min-width: 0;
}

.navbar_search::before {
  content: "search";
  position: absolute;
  top: 50%;
  left: 16px;
  transform: translateY(-50%);
  color: var(--muted);
  font-family: var(--font-icon);
  font-size: 22px;
  pointer-events: none;
}

#navbar_search {
  width: 100%;
  height: 46px;
  padding: 0 60px 0 48px;
  color: var(--text);
  font-size: 14.5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}

#navbar_search:focus { background: var(--surface); border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-ring); }

.navbar_kbd {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  padding: 2px 8px;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 12px;
  background: var(--surface-3);
  border-radius: 7px;
  pointer-events: none;
}

.navbar_user {
  margin-left: auto;
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 4px;
}

.navbar_date { display: none !important; }

.navbar_account {
  margin-left: 8px;
  padding: 4px 6px 4px 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 1px solid var(--border);
  padding-left: 14px;
  cursor: pointer;
}

#navbar_avatar {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  object-fit: cover;
  object-position: center top;
  background-color: var(--surface-3);
  border: 2px solid var(--primary-soft);
  border-radius: 50%;
  user-select: none;
}

.navbar_profile {
  display: none;
  min-width: 0;
  max-width: 180px;
  flex-direction: column;
  line-height: 1.3;
}

#navbar_username {
  overflow-x: clip;
  overflow-y: visible;
  min-width: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#navbar_position {
  overflow-x: clip;
  overflow-y: visible;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.navbar_account_more { display: none; color: var(--text-2); font-family: var(--font-icon); font-size: 22px; }

.help_content p { margin: 0 0 10px 0; line-height: 1.6; }

/* ----------------------------------------------------------------- content */
#display {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  padding: 20px 16px 48px 16px;
  overflow-x: hidden;
  overflow-y: auto;
}

.display {
  width: 100%;
  max-width: 1560px;
  margin: 0 auto;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 18px;
  animation: animated_fade_in .3s ease-out;
}

.card {
  position: relative;
  width: 100%;
  padding: 20px;
  flex-shrink: 0;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.card.quard, .card.triple, .card.double { width: 100%; }

.card_menu { margin-bottom: 16px; display: flex; gap: 24px; color: var(--text-2); overflow-x: auto; }
.card_menu::-webkit-scrollbar { display: none; }
.card_menu_item { padding: 8px 0; flex-shrink: 0; cursor: pointer; user-select: none; }
.card_menu_item.active { color: var(--primary); border-bottom: 2px solid var(--primary); }

#tooltip {
  visibility: hidden;
  position: absolute;
  padding: 6px 10px;
  color: #fff;
  font-size: 12.5px;
  background-color: #111433;
  border-radius: 8px;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
  z-index: 20;
}

#tooltip.show { visibility: visible; opacity: 1; }

/* ---------------------------------------------------------------- loading */
.loading_background {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: color-mix(in srgb, var(--bg) 50%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  touch-action: none;
  z-index: 30;
}

.loading_container {
  width: 72px;
  height: 72px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--surface);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
}

.loading_container img { display: none; }

.loading_container::after {
  content: "";
  width: 30px;
  height: 30px;
  border: 3px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-right-color: var(--primary-hover);
  border-radius: 50%;
  animation: animated_spin .8s linear infinite;
}

/* -------------------------------------------------------------- dashboard */
.dashboard_hero {
  position: relative;
  width: 100%;
  padding: 26px 24px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  color: #fff;
  background:
    radial-gradient(500px 260px at 92% 120%, rgba(255, 255, 255, 0.18), transparent 60%),
    radial-gradient(420px 240px at 10% -40%, rgba(255, 255, 255, 0.16), transparent 60%),
    linear-gradient(120deg, #157340 0%, #1b8a4c 45%, #2fae68 100%);
  border-radius: 24px;
  box-shadow: 0 24px 48px -24px rgba(27, 138, 76, 0.65);
  overflow: hidden;
}

.dashboard_hero::after {
  content: "mark_email_read";
  position: absolute;
  right: -18px;
  bottom: -70px;
  color: rgba(255, 255, 255, 0.09);
  font-family: var(--font-icon);
  font-size: 240px;
  transform: rotate(-12deg);
  pointer-events: none;
}

.dashboard_heading { position: relative; min-width: 0; z-index: 1; }

.dashboard_greeting { font-size: 14px; opacity: .85; }

.dashboard_greeting_name {
  margin: 2px 0 6px 0;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.25;
}

.dashboard_date { font-size: 14px; opacity: .85; }

.dashboard_hero #system_year.form_input_container { position: relative; width: 190px; margin: 0; z-index: 1; }

.dashboard_hero #system_year .form_input_label { color: rgba(255, 255, 255, 0.85); }

.dashboard_hero #system_year .form_input_extend {
  color: #fff;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(6px);
}

.dashboard_hero #system_year .form_input_extend > div:last-child { color: #fff; }

.dashboard_grid {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.dashboard_grid > .card { width: auto; }

.dashboard_chart_card {
  padding: 20px 20px 12px 20px;
  overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}

.dashboard_chart_card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.dashboard_chart_card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--chip-color, var(--primary));
}

.dashboard_chart_title {
  position: relative;
  margin-bottom: 12px;
  padding-left: 56px;
  display: flex;
  flex-direction: column;
  min-height: 46px;
  justify-content: center;
}

.dashboard_chart_title > span:first-child { color: var(--text-2); font-size: 13.5px; font-weight: 500; }

.dashboard_chart_title > span:last-child {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.dashboard_chart_title > span:last-child::after {
  content: " วันนี้";
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 500;
}

.dashboard_chart_title::before {
  content: attr(data-icon);
  position: absolute;
  top: 2px;
  left: 0;
  width: 44px;
  height: 44px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
  font-family: var(--font-icon);
  font-size: 22px;
  background: var(--chip-color, var(--primary));
  border-radius: 14px;
  box-shadow: 0 10px 18px -10px var(--chip-color, var(--primary));
}

.dashboard_chart { width: 100% !important; max-height: 140px; }

.dashboard_hold_label { color: var(--text); font-family: var(--font-display); font-size: 17px; font-weight: 600; }

.dashboard_hold_hint { margin: 2px 0 16px 0; color: var(--muted); font-size: 13px; }

#dashboard_hold {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

/* 2 / 3 / 5 per row, same breakpoints as the original .dashboard_hold_item */
@media screen and (min-width: 768px) {
  #dashboard_hold { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media screen and (min-width: 1200px) {
  #dashboard_hold { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

#dashboard_hold:empty::before {
  content: "ไม่มีผู้ที่มีหนังสือค้างเกษียนเกิน 3 ฉบับ";
  grid-column: 1 / -1;
  padding: 20px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

.dashboard_hold_item {
  position: relative;
  min-width: 0;
  padding: 18px 12px 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.dashboard_hold_image {
  width: 64px;
  height: 64px;
  object-fit: cover;
  object-position: center top;
  background: var(--surface-3);
  border-radius: 50%;
}

.dashboard_hold_name {
  max-width: 100%;
  overflow-x: clip;
  overflow-y: visible;
  min-width: 0;
  color: var(--text);
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.dashboard_hold_amount {
  padding: 3px 10px;
  color: var(--danger);
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  background: var(--danger-soft);
  border-radius: 999px;
}

/* -------------------------------------------------------------- responsive */
@media screen and (min-width: 768px) {
  .dashboard_grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .navbar_date { display: block; }
  .card.quard, .card.triple { width: calc(50% - 9px); }
  .dashboard_hero { padding: 32px 36px; }
  .dashboard_greeting_name { font-size: 30px; }
}

@media screen and (min-width: 992px) {
  #navbar_burger { display: none; }
  #navbar_expand { display: flex; }
  #container { width: 100vw; left: 0; }
  #menubar { left: 0; }
  .navbar { padding: 0 32px 0 24px; }
  #display { padding: 28px 32px 56px 32px; }
  .display { gap: 22px; }
  .card { padding: 24px 26px; }
  .card.quard { width: calc(100%/3 - 44px/3); }
  .card.triple, .card.double { width: calc(50% - 11px); }
  .dashboard_grid { gap: 20px; }
}

/* charts: 1 / 2 / 3 per row, same breakpoints as the original .card.triple */
@media screen and (min-width: 1200px) {
  .dashboard_grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.password_toggle {
  position: absolute;
  right: 4px;
  bottom: 0;
  width: 38px;
  height: var(--control-h);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  color: var(--muted);
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.password_toggle:hover, .password_toggle:focus-visible { color: var(--primary); }

.password_toggle > .icon { font-size: 20px; }

:has(> .password_toggle) > input { padding-right: 44px; }

@media screen and (min-width: 1400px) {
  .card.quard { width: calc(25% - 16.5px); }
}

/* topbar: compact on phones, full account block on desktop */
@media screen and (max-width: 767px) {
  .navbar_kbd, .navbar_icon.optional { display: none; }
  .navbar_account { margin-left: 2px; padding-left: 6px; border-left: none; }
  #navbar_avatar { width: 38px; height: 38px; }
  #navbar_search { height: 42px; padding-right: 14px; }
}

@media screen and (min-width: 992px) {
  .navbar_profile { display: flex; }
  .navbar_account_more { display: block; }
  .navbar { padding: 0 32px 0 20px; gap: 16px; }
}

/* =========================================================================
   Home dashboard — Revise_Requirement 2026-10, slide 2 (module/home.js)
   ========================================================================= */
.home_hero {
  position: relative;
  width: 100%;
  min-height: 190px;
  padding: 26px 30px;
  display: flex;
  align-items: center;
  gap: 24px;
  color: #fff;
  background:
    radial-gradient(520px 260px at 62% 120%, rgba(134, 239, 172, .30), transparent 70%),
    linear-gradient(120deg, #0f3d22 0%, #17693a 55%, #23a25a 100%);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.home_hero_text { position: relative; flex: 1 1 auto; min-width: 0; z-index: 1; }
.home_hero_kicker { color: rgba(255, 255, 255, .8); font-size: 13px; letter-spacing: .08em; }
.home_hero h1 { margin: 6px 0 10px; font-family: var(--font-display); font-size: clamp(24px, 2.4vw, 34px); font-weight: 700; line-height: 1.3; }
.home_hero h1 > span { color: #f6d77a; }
.home_hero p { margin: 0; color: rgba(255, 255, 255, .88); font-size: 14.5px; }
/* the illustration cut from the Revise_Requirement mockup (slide 2): edges fade into the banner, and it sits on the
   banner's bottom edge like in the mockup, where the documents run off the bottom */
.home_hero_art { position: relative; flex: 0 1 400px; min-width: 0; align-self: flex-end; margin-bottom: -26px; display: none; }
.home_hero_art > img { display: block; width: 100%; height: auto; }
.home_hero_side { position: relative; width: 270px; flex-shrink: 0; display: flex; flex-direction: column; gap: 14px; z-index: 1; }
.home_hero_greeting { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.home_hero_greeting .dashboard_greeting { font-size: 14px; opacity: .85; }
.home_hero_greeting .dashboard_date { font-family: var(--font-display); font-size: 18px; font-weight: 600; }
.home_hero_greeting > .icon {
  width: 48px;
  height: 48px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 28px;
  background: rgba(255, 255, 255, .14);
  border-radius: 12px;
}
.home_hero #system_year.form_input_container { margin: 0; }
.home_hero #system_year .form_input_label { color: rgba(255, 255, 255, .85); }
.home_hero #system_year .form_input_extend { color: #fff; background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .35); }
.home_hero #system_year .form_input_extend > div:last-child { color: #fff; }

.home_cards { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.home_stat {
  min-width: 0;
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  color: var(--text);
  font: inherit;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .15s, border-color .15s;
}
.home_stat:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--tone); }
.home_stat:disabled { cursor: default; }
.home_stat_icon {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
  font-family: var(--font-icon);
  font-size: 24px;
  background: var(--tone);
  border-radius: 12px;
}
.home_stat_body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.home_stat_label { color: var(--text-2); font-size: 13.5px; font-weight: 600; }
.home_stat_value { font-family: var(--font-display); font-size: 28px; font-weight: 700; line-height: 1.15; }
.home_trend { display: inline-flex; align-items: center; gap: 2px; font-size: 12.5px; font-weight: 700; }
.home_trend .icon { font-size: 16px; }
.home_trend.up { color: var(--success); }
.home_trend.down { color: var(--danger); }
.home_trend.flat { color: var(--muted); font-weight: 500; }
.home_stat_sub { color: var(--muted); font-size: 11.5px; }

.home_row { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.home_card { width: 100%; padding: 18px 20px; }
.home_card.hidden { display: none; }
.home_card_head { margin-bottom: 14px; display: flex; align-items: center; gap: 12px; }
.home_card_head > h2 { margin: 0; flex: 1 1 auto; min-width: 0; color: var(--text); font-family: var(--font-display); font-size: 16.5px; font-weight: 600; }
.home_card_icon {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--primary);
  font-family: var(--font-icon);
  font-size: 22px;
  background: var(--primary-soft);
  border-radius: 10px;
}
.home_card_icon.warning { color: var(--warning); background: var(--warning-soft); }
.home_card_note { color: var(--muted); font-size: 13px; white-space: nowrap; }
.home_select {
  height: 38px;
  padding: 0 32px 0 12px;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%2384938a' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") no-repeat right 10px center / 18px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.home_series_legend { margin: -4px 0 8px; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; color: var(--text-2); font-size: 13px; }
.home_series_legend > span { display: inline-flex; align-items: center; gap: 6px; }
.home_series_legend i { width: 10px; height: 10px; background: var(--tone); border-radius: 50%; }
.home_chart_box { position: relative; height: 240px; }

.home_status_body { display: flex; align-items: center; gap: 22px; }
.home_donut { position: relative; width: 180px; height: 180px; flex-shrink: 0; }
.home_donut_center { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; pointer-events: none; }
.home_donut_center > b { color: var(--text); font-family: var(--font-display); font-size: 30px; line-height: 1.1; }
.home_donut_center > span { color: var(--muted); font-size: 12.5px; }
.home_legend { margin: 0; padding: 0; flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 12px; list-style: none; }
.home_legend > li { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto auto; align-items: center; gap: 10px; color: var(--text-2); font-size: 13.5px; }
.home_legend i { width: 12px; height: 12px; background: var(--tone); border-radius: 50%; }
.home_legend b { color: var(--tone); }
.home_legend > li > span:last-child { min-width: 44px; color: var(--text); text-align: right; }

.home_more { margin-left: auto; padding: 4px 6px; display: inline-flex; align-items: center; gap: 4px; color: var(--primary); font: inherit; font-size: 13.5px; font-weight: 600; background: none; border: 0; cursor: pointer; }
.home_more .icon { font-size: 18px; }
.home_more:hover { text-decoration: underline; }
.home_table_box { width: 100%; overflow-x: auto; }
.home_table { width: 100%; font-size: 13.5px; border-collapse: collapse; }
.home_table th { padding: 8px 10px; color: var(--muted); font-size: 12.5px; font-weight: 600; text-align: left; background: var(--surface-2); white-space: nowrap; }
.home_table td { padding: 10px; color: var(--text); border-bottom: 1px solid var(--border); white-space: nowrap; }
.home_table tbody tr { cursor: pointer; transition: background-color .15s; }
.home_table tbody tr:hover { background: var(--primary-soft); }
.home_table tr.home_empty { cursor: default; }
.home_table tr.home_empty td { padding: 22px; color: var(--muted); text-align: center; white-space: normal; }
.home_table .home_num { color: var(--info); font-weight: 600; }
.home_table .home_topic { max-width: 260px; overflow-x: clip; overflow-y: visible; min-width: 0; text-overflow: ellipsis; }
.home_table .home_from { max-width: 160px; overflow-x: clip; overflow-y: visible; min-width: 0; text-overflow: ellipsis; }
.home_table .status_pill { height: 26px; font-size: 12px; }
.home_due { display: flex; align-items: center; gap: 8px; }
.home_due_date { color: var(--text-2); }
.home_chip { padding: 2px 8px; font-size: 12px; font-weight: 700; border-radius: 6px; }
.home_chip.danger { color: #fff; background: var(--danger); }
.home_chip.warning { color: #fff; background: var(--warning); }
.home_chip.muted { color: var(--text-2); background: var(--surface-3); }
#home_hold #dashboard_hold { margin-top: 4px; }

@media screen and (min-width: 768px) {
  .home_cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .home_row.half { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* as tall as every page's banner (--hero-height, table.css); 24px top and bottom so its tallest content still fits */
@media screen and (min-width: 992px) {
  .home_hero { min-height: var(--hero-height); padding-top: 24px; padding-bottom: 24px; }
}
@media screen and (min-width: 1200px) {
  .home_hero_art { display: block; }
  /* 360px keeps "จัดการเอกสารราชการ" on one line in TH Sarabun at 1280px (320px broke it, and the banner grew) */
  .home_hero_text { flex: 1 0 360px; }
  .home_cards { grid-template-columns: repeat(6, minmax(0, 1fr)); }   /* six registers since ทะเบียนประกาศ (2026-10-19) */
  .home_row { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
}
@media screen and (max-width: 767.98px) {
  .home_hero { flex-direction: column; align-items: stretch; padding: 22px; }
  .home_hero_side { width: 100%; }
  .home_status_body { flex-direction: column; }
}
@media screen and (min-width: 768px) {
  .home_row:has(> .home_card.hidden) { grid-template-columns: minmax(0, 1fr); }
}
.home_cards_caption { width: 100%; margin: 2px 0 -8px; color: var(--muted); font-size: 13px; }
.home_legend > li > span:nth-child(2) { overflow-x: clip; overflow-y: visible; min-width: 0; white-space: nowrap; text-overflow: ellipsis; }
@media screen and (min-width: 1200px) {
  .home_row { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
}
@media screen and (max-width: 1599.98px) {
  .home_donut { width: 150px; height: 150px; }
  .home_status_body { gap: 16px; }
  .home_stat_icon { width: 40px; height: 40px; font-size: 22px; }
  .home_stat { padding: 14px; gap: 10px; }
}
@media screen and (max-width: 1599.98px) {
  .home_table .home_topic { max-width: 170px; }
  .home_table .home_from { max-width: 110px; }
  .home_table td, .home_table th { padding-left: 8px; padding-right: 8px; }
}

/* ------------------------------------------------------------ touch screens
   A finger needs 44px (Apple HIG, WCAG 2.5.5) — tests/ui_overlap.py checks it (small-target) on every screen. Only for
   coarse pointers, so the desktop look does not change; the other style files end with their own block like this. */
@media (pointer: coarse) {
  #navbar_burger, #navbar_expand, .navbar_icon { width: 44px; height: 44px; }
  #navbar_search { height: 44px; }
  .password_toggle { right: 1px; width: 44px; }
  .home_more { min-height: 44px; margin-right: -6px; }
  .home_select { height: 44px; }
}

/* phones: squeezed between the buttons, the search box showed two letters of its hint. It shrinks to its icon and
   spreads over the top bar while it is in use or still holds a word. */
@media screen and (max-width: 575.98px) {
  .navbar_search { flex: 0 0 44px; }
  #navbar_search { padding: 0; color: transparent; cursor: pointer; }
  #navbar_search::placeholder { color: transparent; }
  .navbar_search::before { left: 50%; transform: translate(-50%, -50%); }
  .navbar_search:is(:focus-within, :has(> #navbar_search:not(:placeholder-shown))) {
    position: absolute;
    top: 50%;
    left: 12px;
    right: 12px;
    transform: translateY(-50%);
    z-index: 4;
  }
  .navbar_search:is(:focus-within, :has(> #navbar_search:not(:placeholder-shown))) > #navbar_search { padding: 0 14px 0 46px; color: var(--text); cursor: text; }
  .navbar_search:is(:focus-within, :has(> #navbar_search:not(:placeholder-shown))) > #navbar_search::placeholder { color: var(--muted); }
  .navbar_search:is(:focus-within, :has(> #navbar_search:not(:placeholder-shown)))::before { left: 16px; transform: translateY(-50%); z-index: 1; }
}

/* six cards in a row leave no room for the icon below 1600px */
@media screen and (min-width: 1200px) and (max-width: 1599.98px) {
  .home_stat > .home_stat_icon { display: none; }
}
