/* =============================================================
   Smart TAS License — Branding overrides for Metronic v9 demo10
   - Tailwind CSS variable overrides (HSL format)
   - Sarabun font for Thai
   - Status pills (12 variants)
   - Form section pattern
   - Sidebar TAS navy active state
   - Watermark
   ============================================================= */

/* === Anchor scroll offset (accounts for sticky header ~72px) === */
html { scroll-behavior: smooth; }
section[id] { scroll-margin-top: 88px; }

/* === EA-style government palette === */
:root {
  --c-bg:        #f6f7fb;
  --c-surface:   #ffffff;
  --c-ink:       #0f172a;
  --c-ink-2:     #475569;
  --c-line:      #e2e8f0;
  --c-primary:   #1e3a8a;
  --c-primary-2: #2547b3;
  --c-accent:    #c8a951;   /* TAS gold accent */
  --c-accent-2:  #a98c3d;
  --c-success:   #15803d;
  --c-warn:      #b45309;
  --c-danger:    #b91c1c;
}

body { background: var(--c-bg); color: var(--c-ink); }

/* === Brand color tokens (override Metronic Tailwind HSL vars) === */
:root {
  --primary: 222 65% 33%;            /* TAS Navy #1e3a8a */
  --primary-foreground: 0 0% 100%;
  --primary-light: 218 92% 92%;      /* #dbeafe */
  --primary-active: 222 60% 42%;     /* #2547b3 */

  --success: 142 71% 30%;            /* Agriculture green #15803d */
  --success-foreground: 0 0% 100%;
  --success-light: 138 76% 91%;      /* #dcfce7 */

  --warning: 38 92% 50%;             /* #f59e0b */
  --destructive: 0 72% 41%;          /* #b91c1c */
  --info: 201 96% 32%;               /* #0369a1 */

  /* TAS direct values (for non-HSL use) */
  --tas-brand-blue: #1e3a8a;
  --tas-brand-green: #15803d;
  --tas-gradient-header: linear-gradient(135deg, #1e3a8a 0%, #2547b3 100%);
}

.dark {
  --primary: 218 70% 60%;
  --primary-light: 222 30% 18%;
}

/* === Thai font (IBM Plex Sans Thai — government standard) === */
html, body, button, input, textarea, select,
.kt-btn, .kt-menu-link, .kt-menu-title, .kt-card-title,
.kt-modal-title, .kt-input, .kt-form-label {
  font-family: 'IBM Plex Sans Thai', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
}

body { line-height: 1.65; }  /* Thai readability */

/* Numbers + license codes use Inter for clarity */
.t-mono, code, .text-mono {
  font-family: 'Inter', ui-monospace, monospace !important;
}

/* === EA-style utility classes (government look) === */
.tas-mark {
  background: linear-gradient(135deg, #1e3a8a 0%, #2547b3 60%, #c8a951 100%);
}
.tas-chip {
  background: rgba(200, 169, 81, 0.30);
  color: #fef3c7;
  border: 1px solid rgba(254, 243, 199, 0.55);
  font-weight: 600;
  letter-spacing: 0.5px;
}
.tas-link {
  color: var(--c-primary);
}
.tas-link:hover {
  color: var(--c-accent-2);
  text-decoration: underline;
}

/* Top nav item (replaces chunky header buttons) */
.nav-item {
  position: relative;
  padding: 8px 12px;
  border-radius: 8px;
  color: #334155;
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover {
  background: #eef2ff;
  color: var(--c-primary);
}
.nav-item.active {
  background: var(--c-primary);
  color: #fff;
}

/* Pill (status/category badge — small, subtle pastels) */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.pill-info    { background: #e0e7ff; color: #3730a3; }
.pill-success { background: #dcfce7; color: #166534; }
.pill-warn    { background: #fef3c7; color: #854d0e; }
.pill-danger  { background: #fee2e2; color: #991b1b; }
.pill-grey    { background: #f1f5f9; color: #475569; }
.pill-gold    { background: #fef3c7; color: #92400e; }

/* Card (replaces chunky card-flush) */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: 14px;
}

/* Buttons */
.btn-primary {
  background: var(--c-primary);
  color: #fff;
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--c-primary-2); color: #fff; }
.btn-ghost {
  background: #fff;
  border: 1px solid var(--c-line);
  color: #334155;
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s;
}
.btn-ghost:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn-gold {
  background: var(--c-accent);
  color: #fff;
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
}
.btn-gold:hover { background: var(--c-accent-2); color: #fff; }

/* Hero gradient (government navy with subtle gold radial highlight) */
.tas-hero {
  background:
    radial-gradient(circle at 20% 20%, rgba(200, 169, 81, 0.18), transparent 40%),
    radial-gradient(circle at 80% 60%, rgba(255, 255, 255, 0.08), transparent 50%),
    linear-gradient(135deg, #0f1f4d 0%, #1e3a8a 60%, #2547b3 100%);
  color: #fff;
}

/* Category icon circle (replaces emoji) */
.cat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.cat-icon-plant   { background: #dcfce7; color: #15803d; }
.cat-icon-livestock { background: #fef3c7; color: #b45309; }
.cat-icon-fishery { background: #dbeafe; color: #0369a1; }

/* === Status pills (17 workflow states → 12 colors) === */
.tas-status {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  gap: 0.25rem;
  white-space: nowrap;
}
.tas-status-draft       { background: #f1f5f9; color: #475569; }   /* แบบร่าง */
.tas-status-review      { background: #e0f2fe; color: #0369a1; }   /* อยู่ระหว่างการตรวจสอบ */
.tas-status-pending     { background: #fef3c7; color: #b45309; }   /* ขอเอกสารเพิ่มเติม */
.tas-status-incomplete  { background: #fef3c7; color: #b45309; }   /* เอกสารไม่ครบถ้วน */
.tas-status-recheck     { background: #ddd6fe; color: #5b21b6; }   /* รอตรวจสอบเอกสารเพิ่มเติม */
.tas-status-forward     { background: #e0e7ff; color: #4338ca; }   /* ส่งต่อหัวหน้าฝ่าย */
.tas-status-revise      { background: #fed7aa; color: #9a3412; }   /* เห็นควรแก้ไขแบบ */
.tas-status-approved    { background: #dcfce7; color: #15803d; }   /* ผ่านการอนุมัติ (level 1) */
.tas-status-waitsign    { background: #fef9c3; color: #a16207; }   /* รอลงนาม */
.tas-status-issued      { background: #15803d; color: #fff; font-weight: 600; }  /* ออกใบอนุญาตแล้ว */
.tas-status-rejected    { background: #fee2e2; color: #b91c1c; }   /* ไม่ผ่านการอนุมัติ */
.tas-status-expired     { background: #e5e7eb; color: #4b5563; }   /* ใบอนุญาตหมดอายุ */
.tas-status-suspended   { background: #f3e8ff; color: #9333ea; }   /* พักใช้ใบอนุญาต */
.tas-status-cancelled   { background: #fee2e2; color: #7f1d1d; }   /* ยกเลิกใบอนุญาต */
.tas-status-cancelled-req { background: #fafafa; color: #525252; } /* ยกเลิกคำขอแล้ว */

/* === Watermark === */
.proto-tag {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1060;
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 11px;
  letter-spacing: 0.5px;
  font-weight: 500;
  pointer-events: none;
  font-family: 'Inter', sans-serif;
}

/* === Form section (ส่วนที่ ๑, ๒, ๓ — TAS-specific, extends kt-card) === */
.tas-form-section {
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: 0.5rem;
  margin-bottom: 1.25rem;
  overflow: hidden;
}
.tas-form-section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid hsl(var(--border));
  background: linear-gradient(to right, #dbeafe, transparent);
}
.tas-form-section-num {
  width: 30px;
  height: 30px;
  border-radius: 9999px;
  background: var(--tas-brand-blue);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
  font-size: 0.875rem;
}
.tas-form-section-body {
  padding: 1.25rem;
}

/* === Sidebar TAS navy active state (override demo10 default) === */
#sidebar .kt-menu-item.active > .kt-menu-link,
#sidebar .kt-menu-item.kt-menu-item-active > .kt-menu-link {
  background: var(--tas-brand-blue) !important;
  color: #fff !important;
}
#sidebar .kt-menu-item.active > .kt-menu-link .kt-menu-icon i,
#sidebar .kt-menu-item.kt-menu-item-active > .kt-menu-link .kt-menu-icon i {
  color: #fff !important;
}

/* Sidebar section heading */
#sidebar .kt-menu-section {
  text-transform: uppercase;
  font-size: 0.6875rem;
  letter-spacing: 0.05em;
  color: #64748b;
  padding: 0.875rem 0.875rem 0.375rem;
  font-weight: 600;
}

/* === Cookie banner === */
.tas-cookie-banner {
  position: fixed;
  bottom: 12px;
  left: 12px;
  right: 12px;
  z-index: 1050;
  background: #fff;
  border: 1px solid hsl(var(--border));
  border-radius: 0.5rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  padding: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}
@media (min-width: 768px) {
  .tas-cookie-banner {
    bottom: 20px;
    left: 20px;
    right: 20px;
    flex-wrap: nowrap;
  }
}

/* === Workflow timeline (TAS-specific custom — uses Tailwind) === */
.tas-timeline {
  position: relative;
  border-left: 2px solid hsl(var(--border));
  margin-left: 0.75rem;
  padding-left: 0;
}
.tas-timeline-item {
  position: relative;
  padding-left: 1.5rem;
  padding-bottom: 1.5rem;
}
.tas-timeline-dot {
  position: absolute;
  left: -0.8125rem;
  top: 0;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  border: 2px solid hsl(var(--background));
}
.tas-timeline-dot-success { background: #15803d; color: #fff; }
.tas-timeline-dot-pending { background: #f59e0b; color: #fff; }
.tas-timeline-dot-current { background: var(--tas-brand-blue); color: #fff; }
.tas-timeline-dot-muted { background: #e5e7eb; color: #6b7280; }

/* === Form inputs (login) === */
.kt-input {
  display: block;
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: #0f172a;
  background-color: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  transition: border-color .15s, box-shadow .15s;
}
.kt-input::placeholder { color: #94a3b8; }
.kt-input:focus {
  outline: none;
  border-color: var(--tas-brand-blue);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.15);
}
.kt-input:disabled { background-color: #f1f5f9; color: #64748b; cursor: not-allowed; }
.kt-input-error {
  border-color: #f43f5e !important;
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.12) !important;
}

/* === Canonical form field sizing (project-wide) ===
   Single source of truth so <input> and <select> always share the same height.
   Pages must NOT redefine `.form-input` box-model inline — extend states only. */
:root { --tas-field-h: 38px; }
.form-input {
  box-sizing: border-box;
  display: block;
  width: 100%;
  height: var(--tas-field-h);
  padding: 0 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.2;
  color: #1e293b;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.form-input:focus {
  outline: none;
  border-color: var(--tas-brand-blue);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.12);
}
/* NOTE: :read-only matches <select> by default in Chromium → scope to input/textarea
   only, else every <select class="form-input"> renders greyed even when enabled.
   .is-picker = readonly input ที่ใช้เป็น "ปุ่มเลือก" (เปิด modal เลือกค่า เช่น ชื่อสินค้า) —
   ยกเว้นจากสไตล์ greyed/not-allowed ให้ดูคลิกได้ (ดู .form-input.is-picker ด้านล่าง). */
.form-input[readonly]:not(.is-picker),
input.form-input:read-only:not(.is-picker), textarea.form-input:read-only,
.form-input.ro,
.form-input:disabled, select.form-input:disabled {
  background: #f8fafc; color: #475569; cursor: not-allowed; opacity: 1;
}
/* Readonly "picker" input (เปิด modal เลือกค่า) — clickable look: พื้นขาว + cursor pointer */
.form-input.is-picker {
  background: #fff; color: #0f172a; cursor: pointer;
}
.form-input.is-error { border-color: #e11d48; }
/* form-input / kt-input selects: no built-in chevron → keep the native arrow */
select.form-input, select.kt-input {
  box-sizing: border-box;
  height: var(--tas-field-h);
  padding-right: 30px;
  appearance: auto;
}
/* kt-select ships its own chevron (background-image SVG) → hide the native arrow
   to avoid the double "v" chevron. */
select.kt-select {
  box-sizing: border-box;
  height: var(--tas-field-h);
  padding-right: 30px;
  appearance: none;
  -webkit-appearance: none;
}
/* kt-input single-line fields share the same height (textarea excluded) */
input.kt-input, select.kt-input {
  box-sizing: border-box;
  height: var(--tas-field-h);
  padding-top: 0;
  padding-bottom: 0;
  line-height: calc(var(--tas-field-h) - 2px);
}
/* Multi-line fields opt out of the fixed height */
textarea.form-input, textarea.kt-input {
  height: auto;
  min-height: 80px;
  padding: 8px 12px;
  line-height: 1.6;
}

.kt-checkbox {
  width: 1rem;
  height: 1rem;
  border-radius: 0.25rem;
  border: 1.5px solid #cbd5e1;
  accent-color: var(--tas-brand-blue);
  cursor: pointer;
}

/* OTP input squares */
.otp-input {
  width: 100%;
  padding: 0.875rem 0.5rem;
  font-size: 1.5rem;
  text-align: center;
  font-weight: 600;
  font-family: 'Inter', ui-monospace, monospace;
  border: 1.5px solid #cbd5e1;
  border-radius: 0.625rem;
  background: #fff;
  color: #0f172a;
  transition: border-color .15s, box-shadow .15s;
}
.otp-input:focus {
  outline: none;
  border-color: var(--tas-brand-blue);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.15);
}

/* === App shell (post-login layout) === */
.tas-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas:
    "sidebar header"
    "sidebar main";
  height: 100vh;
  transition: grid-template-columns .25s ease;
}
@media (max-width: 1023px) {
  .tas-shell { grid-template-columns: 1fr; grid-template-areas: "header" "main"; }
  .tas-shell > #sidebar { display: none; }
  .tas-shell.sidebar-open > #sidebar {
    display: flex; position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 60; box-shadow: 0 10px 40px rgba(15,23,42,0.25);
  }
  .tas-shell.sidebar-open::after {
    content: ''; position: fixed; inset: 0; background: rgba(15,23,42,0.45); z-index: 55;
  }
}
/* Desktop collapse — mini sidebar (icons only, 68px) — keeps white theme */
@media (min-width: 1024px) {
  .tas-shell.sidebar-collapsed {
    grid-template-columns: 68px 1fr;
  }
  .tas-shell.sidebar-collapsed > #sidebar {
    width: 68px;
  }
  /* Brand: center logo, hide text — keep same height/size as expanded */
  .tas-shell.sidebar-collapsed .side-brand {
    justify-content: center;
    padding: 0.6rem 0;       /* same vertical padding as expanded */
  }
  .tas-shell.sidebar-collapsed .side-brand img { height: 36px; }   /* same logo size */
  .tas-shell.sidebar-collapsed .side-brand-text { display: none; }

  /* Nav: center icons, hide labels + section headers */
  .tas-shell.sidebar-collapsed .side-nav { padding: 0.625rem 0.375rem; }
  .tas-shell.sidebar-collapsed .side-section { display: none; }
  .tas-shell.sidebar-collapsed .side-link {
    justify-content: center;
    padding: 0;
    margin-bottom: 0.125rem;
  }
  .tas-shell.sidebar-collapsed .side-link i { font-size: 18px; }
  .tas-shell.sidebar-collapsed .side-link > span { display: none; }

  /* Groups: collapse to single icon, hide caret + children */
  .tas-shell.sidebar-collapsed .side-group > summary {
    justify-content: center;
    padding: 0;
    margin-bottom: 0.125rem;
  }
  .tas-shell.sidebar-collapsed .side-group > summary > i:first-child { font-size: 18px; }
  .tas-shell.sidebar-collapsed .side-group > summary > span,
  .tas-shell.sidebar-collapsed .side-group > summary > .side-caret {
    display: none;
  }
  .tas-shell.sidebar-collapsed .side-group .side-children { display: none; }

  /* Foot: hide */
  .tas-shell.sidebar-collapsed .side-foot { display: none; }

  /* Rotate arrow to point right (= "expand") */
  .tas-shell.sidebar-collapsed .side-toggle i {
    transform: rotate(180deg);
  }
}

/* Animations */
.side-toggle i { transition: transform .25s ease; display: inline-block; }
.side-brand,
.side-link,
.side-group > summary { transition: padding .2s ease, background-color .15s ease, color .15s ease; }
.side-brand-text,
.side-link > span,
.side-group > summary > span,
.side-group > summary > .side-caret { transition: opacity .15s ease; }
.tas-shell > #sidebar { grid-area: sidebar; }
.tas-shell > #header  { grid-area: header; }
.tas-shell > #main    { grid-area: main; overflow: auto; }

/* === Sidebar === */
#sidebar {
  background: #fff;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  overflow: visible;
  position: relative;
  transition: width .25s ease;
}

/* Floating toggle button at sidebar's right edge */
.side-toggle {
  position: absolute;
  top: 14px;
  right: -14px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: #475569;
  border: 1px solid #e5e7eb;
  border-radius: 9999px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
  z-index: 30;
  cursor: pointer;
  transition: background-color .15s, color .15s, transform .15s;
}
.side-toggle:hover {
  background: var(--tas-brand-blue);
  color: #fff;
  border-color: var(--tas-brand-blue);
}
.side-toggle:focus-visible {
  outline: 2px solid var(--tas-brand-blue);
  outline-offset: 2px;
}
.side-brand {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  flex-shrink: 0;
}
.side-brand img { height: 36px; width: auto; }
.side-brand .side-brand-text { line-height: 1.2; }
.side-brand .side-brand-text .t1 { font-size: 14px; font-weight: 600; color: #0f172a; }
.side-brand .side-brand-text .t2 { font-size: 11px; color: #64748b; }

.side-nav { flex: 1; overflow-y: auto; padding: 0.75rem 0.5rem; }
.side-section {
  padding: 1rem 0.75rem 0.25rem;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0;
  color: #0f172a;
}
.side-link {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0 0.75rem;
  height: 34px;
  border-radius: 0.5rem;
  color: #475569;
  font-size: 13px;
  font-weight: 400;
  text-decoration: none;
  transition: background-color .15s, color .15s;
}
.side-link > span {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-link:hover { background: #f1f5f9; color: #0f172a; }
.side-link.is-active { background: rgba(30, 58, 138, 0.08); color: var(--tas-brand-blue); font-weight: 600; }
.side-link.is-active i { color: var(--tas-brand-blue); }
.side-link i { font-size: 16px; color: #94a3b8; flex-shrink: 0; }

.side-group { margin: 0; }
.side-group > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0 0.75rem;
  height: 34px;
  border-radius: 0.5rem;
  color: #475569; font-size: 13px; font-weight: 400;
}
.side-group > summary > span {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-group > summary::-webkit-details-marker { display: none; }
.side-group > summary:hover { background: #f1f5f9; color: #0f172a; }
.side-group > summary > i:first-child { font-size: 16px; color: #94a3b8; flex-shrink: 0; }
.side-group > summary > .side-caret { margin-left: auto; font-size: 12px; color: #cbd5e1; transition: transform .15s; }
.side-group[open] > summary > .side-caret { transform: rotate(90deg); }
.side-group .side-children { padding: 0.125rem 0 0.25rem 1.875rem; display: flex; flex-direction: column; gap: 1px; }
.side-group .side-children .side-link { font-size: 12px; font-weight: 400; padding: 0 0.625rem; height: 30px; }

/* "ยังไม่ได้พัฒนา" — muted look + dashed underline tooltip cue */
.side-link.side-todo { color: #94a3b8; }
.side-link.side-todo::after {
  content: '·';
  margin-left: auto;
  color: #cbd5e1;
  font-size: 16px;
  line-height: 1;
}
.side-link.side-todo:hover { color: #475569; background: #f8fafc; }

.side-foot {
  padding: 0.625rem 0.875rem;
  border-top: 1px solid #f1f5f9;
  font-size: 11px;
  color: #94a3b8;
  flex-shrink: 0;
}

/* === Topbar === */
#header {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  display: flex; align-items: center;
  padding: 0 1rem;
  gap: 0.75rem;
  flex-shrink: 0;
}
.topbar-burger {
  display: none;
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  border-radius: 0.5rem;
  color: #475569;
}
.topbar-burger:hover { background: #f1f5f9; }
/* Mobile only — desktop uses .side-toggle that stays visible even when collapsed */
@media (max-width: 1023px) {
  .topbar-burger { display: inline-flex; }
  .side-toggle { display: none; }
}
.topbar-search {
  flex: 1; max-width: 420px;
  position: relative;
}
.topbar-search input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  font-size: 13px;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  background: #f8fafc;
}
.topbar-search input:focus { outline: none; border-color: var(--tas-brand-blue); background: #fff; }
.topbar-search > i {
  position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%);
  color: #94a3b8;
}
.topbar-icon-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 0.5rem; color: #475569;
  position: relative;
  cursor: pointer;
}
.topbar-icon-btn:hover { background: #f1f5f9; }

/* ===== Org switcher (header chip) ===== */
.topbar-org-switch {
  display: inline-flex; align-items: center; gap: 0.5rem;
  height: 36px; padding: 0 0.75rem;
  border-radius: 0.5rem;
  background: #eef4ff;
  border: 1px solid #d8e4ff;
  color: var(--tas-brand-blue, #1e3a8a);
  font-family: inherit; font-size: 13px; line-height: 1.1;
  margin-right: 0.25rem;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  max-width: 320px;
}
.topbar-org-switch:hover { background: #e0eaff; border-color: #b9cdff; }
.topbar-org-switch.is-hidden { display: none; }
.topbar-org-switch.is-single { cursor: default; background: #f1f5f9; border-color: #e2e8f0; color: #475569; }
.topbar-org-switch.is-single:hover { background: #f1f5f9; }
.topbar-org-switch .org-switch-icon { font-size: 16px; color: var(--tas-brand-blue, #1e3a8a); }
.topbar-org-switch.is-single .org-switch-icon { color: #64748b; }
.topbar-org-switch .org-switch-text {
  display: flex; flex-direction: column; align-items: flex-start;
  min-width: 0; line-height: 1.15;
}
.topbar-org-switch .org-switch-name {
  font-weight: 600; font-size: 13px; color: inherit;
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-org-switch .org-switch-sub {
  font-size: 11px; color: #64748b; font-weight: 400;
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-org-switch .org-switch-caret { font-size: 12px; color: #94a3b8; margin-left: 0.25rem; }
@media (max-width: 640px) {
  .topbar-org-switch .org-switch-sub { display: none; }
  .topbar-org-switch .org-switch-name { max-width: 120px; }
}

/* ===== Org switcher modal cards ===== */
.org-card-list { display: flex; flex-direction: column; gap: 0.5rem; }
.org-card {
  display: flex; align-items: stretch; gap: 0.75rem;
  padding: 0.75rem 0.875rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 0.625rem;
  background: #fff;
  text-align: left; width: 100%;
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
  font-family: inherit;
}
.org-card:hover { border-color: var(--tas-brand-blue, #1e3a8a); background: #f8fbff; }
.org-card.is-active {
  border-color: var(--tas-brand-blue, #1e3a8a);
  background: #eef4ff;
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.08);
}
.org-card-icon {
  width: 40px; height: 40px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 0.5rem;
  background: #eef4ff; color: var(--tas-brand-blue, #1e3a8a);
  font-size: 18px;
}
.org-card.is-active .org-card-icon { background: var(--tas-brand-blue, #1e3a8a); color: #fff; }
.org-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.org-card-name { font-weight: 600; font-size: 14px; color: #0f172a; }
.org-card-branch { font-weight: 400; color: #64748b; font-size: 12px; }
.org-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem; font-size: 11.5px; }
.org-pill {
  display: inline-flex; align-items: center;
  padding: 1px 0.5rem;
  border-radius: 999px;
  font-size: 11px; font-weight: 500;
  background: #f1f5f9; color: #475569;
}
.org-pill-operator { background: #dcfce7; color: #166534; }
.org-pill-agent    { background: #fef3c7; color: #92400e; }
.org-pill-type     { background: #e0e7ff; color: #3730a3; }
.org-card-role { color: #64748b; font-size: 11.5px; }
.org-card-check {
  font-size: 22px; color: #cbd5e1;
  display: inline-flex; align-items: center;
  flex-shrink: 0;
}
.org-card.is-active .org-card-check { color: var(--tas-brand-blue, #1e3a8a); }

.topbar-badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 16px; height: 16px;
  background: #ef4444; color: #fff;
  font-size: 10px; font-weight: 700;
  border-radius: 9999px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 4px;
  pointer-events: none;
}
.topbar-user {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.25rem 0.5rem 0.25rem 0.25rem;
  border-radius: 9999px;
  cursor: pointer;
}
.topbar-user:hover { background: #f1f5f9; }
.topbar-user .avatar {
  width: 32px; height: 32px;
  border-radius: 9999px;
  background: linear-gradient(135deg, #1e3a8a, #2547b3);
  color: #fff; font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
}
.topbar-user .meta { line-height: 1.15; }
.topbar-user .meta .t1 { font-size: 13px; font-weight: 600; color: #0f172a; }
.topbar-user .meta .t2 { font-size: 11px; color: #64748b; }

.topbar-user-wrap { position: relative; }
.topbar-user-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 240px; background: #fff;
  border: 1px solid #e2e8f0; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15,23,42,0.12);
  padding: 6px; z-index: 200;
  display: none;
}
.topbar-user-wrap.is-open .topbar-user-dropdown { display: block; }
.topbar-user-dropdown .tud-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px;
  font-size: 13px; color: #0f172a; text-decoration: none;
  cursor: pointer;
  width: 100%; background: none; border: 0; text-align: left;
  font-family: inherit;
}
.topbar-user-dropdown .tud-item:hover { background: #f1f5f9; }
.topbar-user-dropdown .tud-item i { font-size: 16px; color: #64748b; }
.topbar-user-dropdown .tud-item.tud-danger { color: #b91c1c; }
.topbar-user-dropdown .tud-item.tud-danger i { color: #b91c1c; }
.topbar-user-dropdown .tud-sep {
  height: 1px; background: #e2e8f0; margin: 6px 4px;
}

/* === Notification dropdown === */
.topbar-notif-wrap { position: relative; }
.topbar-notif-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0;
  width: 380px; max-width: calc(100vw - 24px); background: #fff;
  border: 1px solid #e2e8f0; border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15,23,42,0.16);
  z-index: 200; display: none; overflow: hidden;
}
.topbar-notif-wrap.is-open .topbar-notif-dropdown { display: block; }
.topbar-notif-dropdown .tnd-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid #f1f5f9;
}
.topbar-notif-dropdown .tnd-title { font-size: 14px; font-weight: 600; color: #0f172a; }
.topbar-notif-dropdown .tnd-mark {
  font-size: 12px; color: #1e3a8a; background: none; border: 0; cursor: pointer;
}
.topbar-notif-dropdown .tnd-mark:hover { text-decoration: underline; }
.topbar-notif-dropdown .tnd-list {
  max-height: 420px; overflow-y: auto;
}
.topbar-notif-dropdown .tnd-empty {
  padding: 28px 14px; text-align: center; color: #94a3b8; font-size: 13px;
}
.topbar-notif-dropdown .tnd-row {
  display: flex; gap: 10px; padding: 11px 14px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer; transition: background-color .12s;
  text-decoration: none; color: inherit;
}
.topbar-notif-dropdown .tnd-row:last-child { border-bottom: 0; }
.topbar-notif-dropdown .tnd-row:hover { background: #f8fafc; }
.topbar-notif-dropdown .tnd-row.is-unread { background: #eff6ff; }
.topbar-notif-dropdown .tnd-row.is-unread:hover { background: #dbeafe; }
.topbar-notif-dropdown .tnd-icon {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.topbar-notif-dropdown .tnd-icon.t-blue   { background: #dbeafe; color: #1d4ed8; }
.topbar-notif-dropdown .tnd-icon.t-green  { background: #dcfce7; color: #047857; }
.topbar-notif-dropdown .tnd-icon.t-amber  { background: #fef3c7; color: #b45309; }
.topbar-notif-dropdown .tnd-icon.t-rose   { background: #fee2e2; color: #b91c1c; }
.topbar-notif-dropdown .tnd-icon.t-violet { background: #ede9fe; color: #6d28d9; }
.topbar-notif-dropdown .tnd-body { min-width: 0; flex: 1; }
.topbar-notif-dropdown .tnd-msg {
  font-size: 13px; color: #0f172a; line-height: 1.45;
}
.topbar-notif-dropdown .tnd-row.is-unread .tnd-msg { font-weight: 600; }
.topbar-notif-dropdown .tnd-meta {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: #94a3b8; margin-top: 3px;
}
.topbar-notif-dropdown .tnd-meta .tnd-ref { color: #1e3a8a; font-weight: 500; }
.topbar-notif-dropdown .tnd-dot {
  flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%;
  background: #2563eb; align-self: center;
}
.topbar-notif-dropdown .tnd-row:not(.is-unread) .tnd-dot { visibility: hidden; }
.topbar-notif-dropdown .tnd-foot {
  border-top: 1px solid #f1f5f9; padding: 10px 14px; text-align: center;
}
.topbar-notif-dropdown .tnd-foot a,
.topbar-notif-dropdown .tnd-foot button {
  font-size: 13px; color: #1e3a8a; font-weight: 500; text-decoration: none;
  background: none; border: 0; cursor: pointer; padding: 0; font-family: inherit;
}
.topbar-notif-dropdown .tnd-foot a:hover,
.topbar-notif-dropdown .tnd-foot button:hover { text-decoration: underline; }
.topbar-badge { cursor: default; }
.topbar-notif-wrap .topbar-badge.is-hidden { display: none; }

/* === kt-modal-backdrop global default (mirrors master-data.css for pages that don't load it) === */
.kt-modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,0.5);
  z-index: 50; display: none;
  align-items: flex-start; justify-content: center;
  padding: 2rem 1rem; overflow-y: auto;
}
.kt-modal-backdrop.is-open { display: flex; }
.kt-modal-panel {
  background: #fff; border-radius: 10px; width: 100%;
  max-width: 40rem; box-shadow: 0 20px 50px rgba(15,23,42,0.25);
  display: flex; flex-direction: column; max-height: calc(100vh - 4rem);
}
.kt-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid #f1f5f9;
}
.kt-modal-header h3 {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 600; margin: 0;
}
.kt-modal-body { padding: 18px; overflow-y: auto; flex: 1; }
.kt-modal-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 18px; border-top: 1px solid #f1f5f9;
}

/* === Notification all-list modal === */
.notif-tabs {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 8px 0 12px;
  border-bottom: 1px solid #f1f5f9; margin-bottom: 6px;
}
.notif-tab {
  padding: 5px 12px; font-size: 12px; color: #475569;
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 9999px;
  cursor: pointer; transition: background-color .12s, color .12s;
}
.notif-tab:hover { background: #f1f5f9; color: #0f172a; }
.notif-tab.is-active {
  background: #1e3a8a; color: #fff; border-color: #1e3a8a; font-weight: 500;
}

.notif-all-list { max-height: 480px; overflow-y: auto; }
.notif-all-row {
  display: flex; gap: 12px; padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer; transition: background-color .12s;
  text-decoration: none; color: inherit;
}
.notif-all-row:last-child { border-bottom: 0; }
.notif-all-row:hover { background: #f8fafc; }
.notif-all-row.is-unread { background: #eff6ff; }
.notif-all-row.is-unread:hover { background: #dbeafe; }
.notif-all-body { flex: 1; min-width: 0; }
.notif-all-msg { font-size: 13.5px; color: #0f172a; line-height: 1.5; }
.notif-all-row.is-unread .notif-all-msg { font-weight: 600; }
.notif-all-meta-row {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 11.5px; color: #94a3b8; margin-top: 4px;
}
.notif-all-meta-row .dot { color: #cbd5e1; }
.notif-all-meta-row .tnd-ref { color: #1e3a8a; font-weight: 500; }
.notif-type-pill {
  display: inline-block; padding: 1px 8px; border-radius: 9999px;
  font-size: 11px; font-weight: 500; border: 1px solid;
}
.notif-type-review   { background:#eff6ff; color:#1d4ed8; border-color:#bfdbfe; }
.notif-type-sla      { background:#fef3c7; color:#b45309; border-color:#fde68a; }
.notif-type-payment  { background:#ecfdf5; color:#047857; border-color:#a7f3d0; }
.notif-type-sign     { background:#ede9fe; color:#6d28d9; border-color:#ddd6fe; }
.notif-type-revise   { background:#fee2e2; color:#b91c1c; border-color:#fecaca; }
.notif-type-forward  { background:#eff6ff; color:#1d4ed8; border-color:#bfdbfe; }
.notif-type-cancel   { background:#fee2e2; color:#b91c1c; border-color:#fecaca; }
.notif-type-system   { background:#f1f5f9; color:#475569; border-color:#cbd5e1; }
.notif-type-approved { background:#ecfdf5; color:#047857; border-color:#a7f3d0; }
.notif-type-expire   { background:#fef3c7; color:#b45309; border-color:#fde68a; }

.notif-all-empty {
  padding: 60px 20px; text-align: center; color: #94a3b8;
}
.notif-all-empty i { font-size: 36px; display: block; margin-bottom: 8px; }

.notif-all-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 12px; margin-top: 8px; border-top: 1px solid #f1f5f9;
  flex-wrap: wrap; gap: 8px;
}
.notif-all-meta { font-size: 12px; color: #64748b; }
.notif-all-pager { display: flex; gap: 4px; flex-wrap: wrap; }
.notif-all-pager .pg-btn {
  min-width: 32px; padding: 4px 10px; font-size: 12px;
  background: #fff; border: 1px solid #e2e8f0; color: #475569;
  border-radius: 6px; cursor: pointer;
}
.notif-all-pager .pg-btn:hover:not([disabled]) { background: #f1f5f9; color: #0f172a; }
.notif-all-pager .pg-btn.is-active {
  background: #1e3a8a; color: #fff; border-color: #1e3a8a; font-weight: 500;
}
.notif-all-pager .pg-btn[disabled] { opacity: 0.4; cursor: not-allowed; }

/* === Notification inbox page (ศูนย์การแจ้งเตือน) === */
.nfi-tab {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 14px; font-size: 13px; color: #475569;
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 9999px;
  cursor: pointer; transition: background-color .12s, color .12s;
}
.nfi-tab:hover { background: #f1f5f9; color: #0f172a; }
.nfi-tab.is-active { background: #1e3a8a; color: #fff; border-color: #1e3a8a; font-weight: 500; }
.nfi-badge {
  display: inline-block; min-width: 18px; padding: 0 5px; text-align: center;
  font-size: 11px; line-height: 16px; border-radius: 9999px;
  background: #e11d48; color: #fff; font-weight: 600;
}
.nfi-tab.is-active .nfi-badge { background: #fff; color: #1e3a8a; }
[data-nfi-pager] .pg-btn {
  min-width: 32px; padding: 4px 10px; font-size: 12px;
  background: #fff; border: 1px solid #e2e8f0; color: #475569;
  border-radius: 6px; cursor: pointer;
}
[data-nfi-pager] .pg-btn:hover:not([disabled]) { background: #f1f5f9; color: #0f172a; }
[data-nfi-pager] .pg-btn.is-active { background: #1e3a8a; color: #fff; border-color: #1e3a8a; font-weight: 500; }
[data-nfi-pager] .pg-btn[disabled] { opacity: 0.4; cursor: not-allowed; }

/* === Page header (inside main) === */
.page-header {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid #f1f5f9;
  background: #fff;
}
.page-header h1 { font-size: 20px; font-weight: 600; color: #0f172a; margin: 0; line-height: 1.3; }
.page-header .crumbs {
  display: flex; align-items: center; gap: 0.375rem;
  font-size: 12px; color: #94a3b8; margin-bottom: 0.25rem;
}
.page-header .crumbs a { color: #64748b; }
.page-header .crumbs a:hover { color: var(--tas-brand-blue); }
.page-content { padding: 1rem 1.25rem; }

/* === Per-request font overrides === */
.text-xs { font-size: 0.85rem; line-height: 1rem; }
.text-xs.text-slate-500 { font-size: 0.85rem; line-height: 1rem; }
.px-3.py-2.text-xs.text-slate-700 { font-size: 0.85rem; line-height: 1rem; }
.text-\[10px\].text-slate-500.uppercase.tracking-wider { font-size: 12px; }

/* === Print styles === */
@media print {
  .proto-tag,
  .tas-cookie-banner,
  #sidebar,
  #header { display: none !important; }
}
