/* ==========================================================================
   🌿 STYLE.CSS - EEF ACTIVITY TRACKING SYSTEM PREMIUM REDESIGN
   ========================================================================== */

/* ── 1. CORE VARIABLES & VARIABLES SYSTEM ──────────────────────────────── */
:root {
  /* EEF Colors (Light Mode default) */
  --primary: #029b53; /* EEF Brand Green */
  --primary-light: #e6f6ee;
  --primary-hover: #027a41;
  
  --secondary: #ebb814; /* EEF Brand Yellow/Gold */
  --secondary-light: #fefbeb;
  --secondary-hover: #d29e0f;
  
  --dark: #0f172a; /* Slate 900 (Sidebar background) */
  --dark-accent: #1e293b; /* Slate 800 */
  --dark-border: #334155;
  
  --bg-main: #f4f6f8; /* Soft light gray for glassy look */
  --bg-panel: #ffffff;
  
  --text-main: #111827; /* Near black */
  --text-sub: #6b7280; /* Neutral gray */
  --text-white: #ffffff;
  
  --bdr: #e5e7eb; /* Gray 200 */
  --bdr-focus: #029b53; /* EEF Brand Green */
  --surface-muted: #f8fafc;
  --focus-ring: 0 0 0 3px rgba(2, 155, 83, 0.18);
  --overlay-gallery: rgba(0, 0, 0, 0.95);
  --danger-surface: #fee2e2;
  --danger-strong: #b33a3a;
  --z-dropdown: 1000;
  --z-modal: 2000;
  --z-modal-nested: 2100;
  --z-modal-deep: 2200;
  --z-alert: 3000;
  --z-lightbox: 4000;
  --radius-compact: 6px;
  --radius-control: 8px;
  --radius-card: 12px;
  --radius-panel: 16px;
  --radius-pill: 99px;
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --spacing-xl: 20px;
  --motion-fast: 180ms;
  --motion-standard: 220ms;
  --ease-standard: cubic-bezier(0.16, 1, 0.3, 1);
  
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 4px 15px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.04);
  
  /* Status Colors */
  --done-bg: #e6f6ee;
  --done-ring: #029b53;
  --done-tx: #027a41;
  
  --progress-bg: #fefbeb;
  --progress-ring: #ebb814;
  --progress-tx: #a17d09;

  --calendar-multiday-done-bg: #027a41;
  --calendar-upcoming-bg: #dbeafe;
  --calendar-upcoming-text: #1e40af;
  --calendar-upcoming-outline: #60a5fa;
  --calendar-multiday-progress-bg: #1d4ed8;
  --calendar-multiday-text: #ffffff;
  
  --todo-bg: #f8fafc;
  --todo-ring: #94a3b8;
  --todo-tx: #475569;
  
  --late-bg: #fef2f2;
  --late-ring: #ef4444;
  --late-tx: #991b1b;
}

/* Full-page activity report workspace */
.report-editor-page {
  width: 100%;
  padding-top: 16px;
  padding-bottom: 24px;
}

.report-editor-shell {
  min-width: 0;
  overflow: clip;
  border: 1px solid var(--bdr);
  border-radius: var(--radius-panel);
  background: var(--bg-panel);
  box-shadow: var(--shadow-lg);
}

.report-editor-header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--bdr);
  background: var(--bg-panel);
}

[class~="report-editor-body"] {
  min-width: 0;
  padding: 28px;
  overflow: visible;
}

.report-field-hint {
  margin: 0 0 4px;
  color: var(--text-sub);
  font-size: 12px;
  line-height: 1.6;
}

.report-score-input {
  max-width: 180px;
}

.report-required-note {
  display: inline-block;
  margin-left: 6px;
  color: var(--danger-strong);
  font-size: 11px;
  font-weight: 600;
}

.report-editor-footer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  padding: 16px 28px;
  border-top: 1px solid var(--bdr);
  background: var(--bg-panel);
}

.report-editor-footer > div {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 768px) {
  .report-editor-header,
  .report-editor-footer {
    position: static;
  }

  .report-editor-header {
    align-items: stretch;
    flex-direction: column;
    padding: 18px 16px;
  }

  [class~="report-editor-body"] {
    padding: 20px 16px;
  }

  .report-editor-footer {
    padding: 14px 16px;
  }

  .report-editor-footer > div,
  .report-editor-footer button {
    width: 100%;
  }
}

/* Report PDF export is rendered outside the visible workspace. */
.report-pdf-export {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 794px;
  min-height: 1123px;
  padding: 32px;
  box-sizing: border-box;
  background: #ffffff;
  color: #111827;
  font-family: 'Noto Sans Thai Looped', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.65;
}

.report-pdf-export h1,
.report-pdf-export h2,
.report-pdf-export p {
  margin: 0;
}

.report-pdf-export h1 {
  color: #0f172a;
  font-size: 26px;
  line-height: 1.3;
}

.report-pdf-export__brand {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-bottom: 24px;
  text-align: center;
}

.report-pdf-export__brand img {
  width: 96px;
  height: 72px;
  object-fit: contain;
}

.report-pdf-export__brand p {
  color: #475569;
  font-size: 16px;
  font-weight: 600;
}

.report-pdf-export__meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 20px;
  margin: 24px 0;
  padding: 16px;
  border: 1px solid #d1d5db;
  background: #f8fafc;
}

.report-pdf-export__meta div {
  display: grid;
  gap: 2px;
}

.report-pdf-export__meta strong {
  color: #475569;
  font-size: 12px;
}

.report-pdf-export__content > section,
.report-pdf-export__image-section {
  margin-top: 16px;
  break-inside: avoid;
}

.report-pdf-export h2 {
  margin-bottom: 6px;
  color: #027a41;
  font-size: 16px;
  line-height: 1.4;
}

.report-pdf-export__section-title {
  margin: 20px 0 12px;
  padding: 8px 12px;
  border-radius: 6px;
  background: #eef2f5;
  color: #0f172a;
  font-size: 15px;
}

.report-pdf-export p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.report-pdf-export table {
  width: 100%;
  border-collapse: collapse;
}

.report-pdf-export th,
.report-pdf-export td {
  padding: 9px 10px;
  border: 1px solid #cbd5e1;
  text-align: left;
  vertical-align: top;
}

.report-pdf-export th {
  background: #e6f6ee;
  color: #0f172a;
  font-weight: 700;
}

.report-pdf-export--image-grid {
  min-height: 1123px;
}

.report-pdf-export__image-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.report-pdf-export__image-grid img {
  display: block;
  width: 100%;
  height: 430px;
  object-fit: contain;
  background: #f8fafc;
}

.report-pdf-export__qr {
  display: grid;
  justify-items: center;
  gap: 16px;
  padding-top: 180px;
  text-align: center;
}

.report-pdf-export__qr-code {
  display: grid;
  place-items: center;
  min-width: 168px;
  min-height: 168px;
  padding: 12px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
}

.report-pdf-export__qr-link {
  max-width: 560px;
  color: #475569;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.form-section-title {
  margin: 20px 0 12px;
  color: var(--text-main);
  font-size: 15px;
  font-weight: 700;
}

#reportPrintStage {
  display: none;
}

@media print {
  @page {
    size: A4;
    margin: 14mm 15mm;
  }

  body > * {
    display: none !important;
  }

  #reportPrintStage {
    display: block !important;
    color: #111827;
    font-family: 'Noto Sans Thai Looped', Arial, sans-serif;
    font-size: 12px;
    line-height: 1.55;
  }

  .report-print-header {
    margin-bottom: 18px;
    text-align: center;
  }

  .report-print-header img {
    display: block;
    width: 320px;
    height: auto;
    margin: 0 auto 10px;
    object-fit: contain;
  }

  .report-print-header p,
  .report-print-header h1,
  .report-print-header h2,
  .report-print-section h2,
  .report-print-section h3,
  .report-print-section p {
    margin: 0;
  }

  .report-print-header > p:first-of-type {
    font-size: 14px;
    font-weight: 700;
  }

  .report-print-header h1 {
    margin: 3px 0;
    font-size: 16px;
    line-height: 1.35;
  }

  .report-print-header h2 {
    margin-bottom: 6px;
    font-size: 14px;
    line-height: 1.35;
  }

  .report-print-header > p:last-of-type {
    white-space: pre-line;
    color: #374151;
    font-size: 10px;
    line-height: 1.55;
  }

  .report-print-section {
    margin-top: 16px;
  }

  .report-print-section > h2 {
    margin-bottom: 12px;
    padding: 7px 10px;
    border-left: 3px solid #059669;
    background: #f1f5f9;
    color: #111827;
    font-size: 13px;
    line-height: 1.35;
  }

  .report-print-page-break {
    break-before: page;
    page-break-before: always;
  }

  .report-print-field {
    margin: 0 0 11px;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .report-print-field h3 {
    margin-bottom: 3px;
    color: #111827;
    font-size: 11px;
    font-weight: 700;
  }

  .report-print-field p {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  .report-print-section table {
    width: 100%;
    margin: 0 0 16px;
    border-collapse: collapse;
  }

  .report-print-section th,
  .report-print-section td {
    padding: 7px 8px;
    border: 1px solid #94a3b8;
    text-align: left;
    vertical-align: top;
  }

  .report-print-section th {
    background: #e6f6ee;
    font-size: 11px;
  }

  .report-print-section tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .report-print-image-group {
    margin-bottom: 18px;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .report-print-image-group h3 {
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid #94a3b8;
    font-size: 12px;
  }

  .report-print-image-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .report-print-image-card {
    margin: 0;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .report-print-image-card img {
    display: block;
    width: 100%;
    max-height: 112mm;
    object-fit: contain;
  }

  .report-print-qr {
    display: block;
    text-align: left;
  }

  .report-print-qr-code {
    display: block;
    min-width: 128px;
    min-height: 128px;
    margin: 8px 0;
  }

  .report-print-qr > p {
    max-width: 130mm;
    overflow-wrap: anywhere;
    font-size: 10px;
  }

  .report-print-pdf-page {
    margin: 0;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .report-print-pdf-page + .report-print-pdf-page {
    break-before: page;
    page-break-before: always;
  }

  .report-print-pdf-page figcaption {
    margin-bottom: 4mm;
    color: #374151;
    font-size: 9px;
    overflow-wrap: anywhere;
  }

  .report-print-pdf-page img {
    display: block;
    width: 100%;
    max-height: 238mm;
    object-fit: contain;
  }
}

/* Dark Theme Overrides */
body.dark-theme {
  --bg-main: #0f172a; /* Slate 900 */
  --bg-panel: #1e293b; /* Slate 800 */
  --dark: #0f172a;
  --dark-accent: #334155;
  --dark-border: #334155;
  
  --text-main: #f8fafc; /* Slate 50 */
  --text-sub: #94a3b8; /* Slate 400 */
  
  --bdr: #334155; /* Slate 700 */
  --bdr-focus: #10b981; /* Emerald 500 / Green */
  --surface-muted: #1f2937;
  --focus-ring: 0 0 0 3px rgba(16, 185, 129, 0.28);
  --danger-surface: rgba(239, 68, 68, 0.15);
  --danger-strong: #f87171;
  
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 15px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.4);
  
  /* Dark Status Colors */
  --done-bg: rgba(2, 155, 83, 0.15);
  --done-ring: #10b981;
  --done-tx: #4ade80;
  
  --progress-bg: rgba(235, 184, 20, 0.15);
  --progress-ring: #fbbf24;
  --progress-tx: #fcd34d;

  --calendar-multiday-done-bg: #4ade80;
  --calendar-upcoming-bg: #1e3a5f;
  --calendar-upcoming-text: #bfdbfe;
  --calendar-upcoming-outline: #60a5fa;
  --calendar-multiday-progress-bg: #93c5fd;
  --calendar-multiday-text: #0f172a;
  
  --todo-bg: #1f2937;
  --todo-ring: #4b5563;
  --todo-tx: #9ca3af;
  
  --late-bg: rgba(239, 68, 68, 0.15);
  --late-ring: #f87171;
  --late-tx: #fca5a5;
}

/* Additional Dark Mode refinements for specific elements */
body.dark-theme .pm-table th,
body.dark-theme .issues-table th,
body.dark-theme .bi-table th {
  background-color: #1f2937 !important;
  color: var(--text-main) !important;
}

body.dark-theme .pm-table tbody tr:hover {
  background-color: #1f2937 !important;
}

body.dark-theme .cal-day {
  background-color: #111827;
  border-color: #1f2937;
}

body.dark-theme .cal-day.today {
  border-color: var(--secondary) !important;
  background-color: #1e293b !important;
}

body.dark-theme .kanban-column {
  background-color: #1f2937;
}

body.dark-theme .modal-footer {
  background-color: #1f2937;
}

/* ── 2.1 ICON STYLES ──────────────────────────────────────────────────────── */
.icon-inline {
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.15em;
  display: inline-block;
  stroke-width: 2.2px;
}

/* ── 3. BUTTONS ──────────────────────────────────────────────────────────── */

/* ── 2. GLOBAL RESET ────────────────────────────────────────────────────── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Noto Sans Thai Looped', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: hidden;
}

/* Scrollbar Style */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ── 3. LOGIN SCREEN (Premium Glassmorphism & Moving Gradient) ──────────── */
@keyframes gradientBG {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.login-container {
  display: flex;
  flex-direction: row;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  width: 100vw;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(2, 155, 83, 0.4) 0%, rgba(15, 23, 42, 0.75) 100%), url('./Picture/login-bg.jpg') no-repeat center center;
  background-size: cover;
}

/* วงกลมเรืองแสงสไตล์ 3D Glassmorphism */
.glow-sphere {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  z-index: 1;
  opacity: 0.35;
}

.sphere-1 {
  width: 300px;
  height: 300px;
  background: #029b53;
  top: 15%;
  left: 25%;
  animation: float1 10s ease-in-out infinite alternate;
}

.sphere-2 {
  width: 450px;
  height: 450px;
  background: #8fa015; /* เขียวแกมเหลืองทอง */
  bottom: 10%;
  right: 20%;
  animation: float2 14s ease-in-out infinite alternate;
}

@keyframes float1 {
  0% { transform: translateY(0px) scale(1); }
  100% { transform: translateY(-40px) scale(1.1); }
}

@keyframes float2 {
  0% { transform: translateY(0px) scale(1); }
  100% { transform: translateY(50px) scale(0.9); }
}

/* Left login sidebar */
.login-sidebar-panel {
  position: relative;
  z-index: 100;
  width: 380px;
  min-width: 380px;
  height: 100%;
  flex: 0 0 380px;
  overflow: visible;
  background: rgba(15, 23, 42, 0.78);
  border-right: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 10px 0 30px rgba(15, 23, 42, 0.2);
  transition: margin-left var(--motion-standard) var(--ease-standard),
              transform var(--motion-standard) var(--ease-standard);
}

.login-sidebar-panel.collapsed {
  margin-left: -380px;
}

.login-sidebar-scrollable {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 30px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  width: 100%;
  max-width: 320px;
}

.login-sidebar-panel.collapsed .login-box {
  opacity: 0;
  pointer-events: none;
}

.login-sidebar-toggle {
  position: absolute;
  left: 100%;
  top: 50%;
  z-index: 101;
  width: 28px;
  height: 80px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform: translateY(-50%);
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-left: 0;
  border-radius: 0 12px 12px 0;
  background: var(--primary);
  color: var(--text-white);
  font: inherit;
  cursor: pointer;
  box-shadow: 4px 0 10px rgba(15, 23, 42, 0.18);
  transition: background-color var(--motion-fast) ease,
              transform var(--motion-fast) ease;
}

.login-sidebar-toggle:hover {
  background: var(--primary-hover);
  transform: translateY(-50%) translateX(3px);
}

.login-sidebar-toggle:focus-visible,
.login-forgot-link:focus-visible,
.login-account-links a:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.82);
  outline-offset: 3px;
}

.login-field-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.login-field-heading .form-label {
  margin-bottom: 0;
}

.login-forgot-link,
.login-account-links a {
  color: var(--primary-light);
  font-size: 12px;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.login-password-field {
  position: relative;
}

.login-password-field .form-input {
  padding-right: 44px;
}

.login-password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  width: 36px;
  height: 36px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  border: 0;
  border-radius: var(--radius-compact);
  cursor: pointer;
}

.login-password-toggle:hover {
  color: var(--text-white);
  background: rgba(255, 255, 255, 0.1);
}

.login-account-links {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 7px;
  margin-top: 15px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  text-align: center;
}

.login-first-run-copy {
  margin-top: 15px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

/* Main Content: Public Calendar */
.login-main-content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 24px 32px;
  box-sizing: border-box;
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.public-calendar-wrapper {
  width: 100%;
  max-width: 1440px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 24px 30px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  margin-top: 10px;
  margin-bottom: 30px;
}

body.dark-theme .public-calendar-wrapper {
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.public-calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.public-calendar-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
  font-family: 'Noto Sans Thai Looped', Arial, sans-serif;
}

body.dark-theme .public-calendar-title {
  color: #6ee7b7;
}

.public-calendar-active-filters {
  margin: -8px 0 16px;
}

.public-calendar-wrapper .calendar-layout {
  grid-template-columns: minmax(0, 1fr) 280px;
}

/* Search Container for Autocomplete */
.pub-search-container {
  position: relative;
  width: 320px;
  min-width: 250px;
}

.pub-search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.pub-search-input {
  width: 100%;
  padding: 10px 35px 10px 15px;
  border-radius: 8px;
  border: 1px solid var(--bdr);
  font-size: 14px;
  background: var(--bg-panel);
  color: var(--text-main);
  font-family: 'Noto Sans Thai Looped', Arial, sans-serif;
  transition: all 0.2s;
}

.pub-search-input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(2, 155, 83, 0.15);
}

.pub-search-clear {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-sub);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pub-autocomplete-box {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-panel);
  border: 1px solid var(--bdr);
  border-radius: 8px;
  max-height: 250px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0 4px 15px rgba(0,0,0,0.15);
  margin-top: 4px;
}

.pub-autocomplete-box.hidden {
  display: none;
}

.pub-autocomplete-item {
  padding: 10px 15px;
  cursor: pointer;
  border-bottom: 1px solid var(--bdr);
  font-size: 13px;
  color: var(--text-main);
  text-align: left;
  transition: background 0.15s;
}

.pub-autocomplete-item:last-child {
  border-bottom: none;
}

.pub-autocomplete-item:hover {
  background-color: var(--bg-main);
  color: var(--primary);
}

/* Filters Grid */
.public-filters-grid {
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  margin-bottom: 20px;
  background: rgba(0, 0, 0, 0.02);
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--bdr);
  align-items: flex-end;
}

.public-filters-grid > .filter-field {
  flex: 1;
  min-width: 150px;
}

.public-filters-grid > .filter-btn-container {
  flex-shrink: 0;
}

body.dark-theme .public-filters-grid {
  background: rgba(255, 255, 255, 0.02);
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-field select {
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--bdr);
  font-size: 13px;
  background: var(--bg-panel);
  color: var(--text-main);
  font-family: 'Noto Sans Thai Looped', Arial, sans-serif;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  box-sizing: border-box;
}

.filter-field select:focus {
  border-color: var(--primary);
  outline: none;
}

.pub-btn-reset {
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--bdr);
  background: var(--bg-panel);
  color: var(--text-main);
  font-size: 13px;
  font-family: 'Noto Sans Thai Looped', Arial, sans-serif;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.pub-btn-reset:hover {
  background: var(--bg-main);
  border-color: var(--text-sub);
}

.public-cal-panel {
  box-shadow: none;
  border: 1px solid var(--bdr);
  background: var(--bg-panel);
}

.cal-day.highlight-event {
  border: 2px dashed var(--primary) !important;
  background-color: rgba(2, 155, 83, 0.15) !important;
  box-shadow: 0 0 10px rgba(2, 155, 83, 0.3);
  animation: pulseHighlight 1.5s infinite alternate;
}

@keyframes pulseHighlight {
  0% { box-shadow: 0 0 5px rgba(2, 155, 83, 0.2); }
  100% { box-shadow: 0 0 15px rgba(2, 155, 83, 0.5); }
}

.login-logo-img {
  width: min(250px, 100%);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}

.login-logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}

.login-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-white);
  margin: 0 0 8px;
  line-height: 1.3;
  text-align: center;
}

.login-sub {
  margin: 0 0 32px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

/* ปรับแต่งฟอร์มในหน้าล็อกอินให้เข้ากับดีไซน์กระจก */
.login-container .form-label {
  display: block;
  color: var(--text-white);
  font-weight: 500;
  opacity: 0.9;
  margin-bottom: 5px;
  font-size: 12px;
}

.login-container .form-input {
  background-color: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: var(--text-white);
  transition: all 0.3s ease;
}

.login-container .form-input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.login-container .form-input:focus {
  background-color: rgba(255, 255, 255, 0.25);
  border-color: var(--text-white);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

.login-container .btn-login {
  min-height: 44px;
  width: 100%;
  background-color: var(--text-white);
  color: var(--primary);
  font-weight: 700;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.login-container .btn-login:hover {
  background-color: #f8fafc;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

body.dark-theme .login-container .btn-login {
  background-color: var(--primary);
  color: var(--text-white);
}

body.dark-theme .login-container .btn-login:hover {
  background-color: var(--primary-hover);
}

.login-container .login-err {
  color: #fca5a5;
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
  font-size: 12px;
  line-height: 1.35;
}

.login-err:empty {
  display: none;
}

@media (max-width: 1180px) {
  .public-filters-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .login-sidebar-panel {
    position: absolute;
    inset: 0 auto 0 0;
    width: min(380px, calc(100vw - 32px));
    min-width: 0;
    height: 100%;
    flex-basis: auto;
    margin-left: 0;
  }

  .login-sidebar-panel.collapsed {
    margin-left: 0;
    transform: translateX(-100%);
  }

  .login-main-content {
    padding: 16px;
  }

  .public-filters-grid {
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .login-sidebar-scrollable {
    align-items: flex-start;
    padding: 24px 20px;
  }
}

/* ── 4. APP SHELL LAYOUT (SIDEBAR + MAIN) ────────────────────────────────── */
.app-container {
  display: flex;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  width: 100vw;
  overflow: hidden;
}

/* Sidebar Navigation */
.sidebar {
  width: 280px;
  background-color: transparent;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: none;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: visible;
  position: relative;
}

/* Sidebar collapsed state */
.sidebar.collapsed {
  width: 78px;
}

/* Smooth text collapsing transition */
.sidebar-logo-text,
.sidebar-subtitle,
.menu-text,
.user-info,
.btn-logout-text {
  display: inline-block;
  vertical-align: middle;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), max-width 0.25s cubic-bezier(0.4, 0, 0.2, 1), padding 0.25s ease, margin 0.25s ease;
  opacity: 1;
  max-width: 220px;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-logo-text, .user-info {
  display: flex;
  flex-direction: column;
}

.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .sidebar-subtitle,
.sidebar.collapsed .menu-text,
.sidebar.collapsed .user-info,
.sidebar.collapsed .btn-logout-text {
  opacity: 0;
  max-width: 0;
  pointer-events: none;
  padding: 0 !important;
  margin: 0 !important;
}

.sidebar.collapsed .sidebar-header {
  padding: 24px 16px;
  justify-content: center;
}

.sidebar.collapsed .menu-item {
  justify-content: center;
  padding: 12px;
  gap: 0; /* Remove gap so icon isn't pushed left by hidden text */
}

.sidebar.collapsed .sidebar-footer {
  padding: 16px 12px;
  align-items: center;
}

.sidebar.collapsed .user-profile {
  justify-content: center;
}

.sidebar.collapsed .btn-logout {
  display: none !important;
}

.sidebar-logo-btn {
  background-color: transparent;
  color: var(--primary);
  border: 1px solid transparent;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 4px;
}

.sidebar-logo-btn:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

body.dark-theme .sidebar-logo-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.btn-theme-toggle {
  background: none;
  border: 1px solid var(--bdr);
  color: var(--text-main);
  font-size: 14px;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  width: 36px;
  height: 36px;
}

.btn-theme-toggle:hover {
  background-color: var(--bdr);
  transform: scale(1.05);
}

body.dark-theme .btn-theme-toggle {
  border-color: #374151;
  color: #fbbf24;
}

.sidebar-header {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: none;
  position: relative;
  overflow: visible;
}

.sidebar-logo {
  font-size: 32px;
}

.sidebar-title-group {
  display: flex;
  flex-direction: column;
}

.sidebar-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
  line-height: 1.25;
  color: var(--text-main);
}

.sidebar-subtitle {
  font-size: 11px;
  color: var(--text-sub);
  font-weight: 500;
}

.sidebar-menu {
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px; /* Slightly more gap */
  flex-grow: 1;
}

.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.25s ease;
}

.menu-item:hover {
  background-color: rgba(0,0,0,0.03);
  color: var(--text-main);
}

.menu-item.active {
  background-color: var(--bg-panel);
  color: var(--text-main);
  border-left: none;
  border-radius: 16px;
  padding-left: 16px;
  box-shadow: var(--shadow-md);
}

.sidebar.collapsed .menu-item.active {
  padding: 12px; /* Force symmetrical padding when collapsed */
}

body.dark-theme .menu-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

body.dark-theme .menu-item.active {
  background-color: var(--bg-panel);
  color: var(--text-main);
  box-shadow: var(--shadow-md);
}

.menu-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background-color: var(--primary);
  color: var(--text-white);
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 700;
  font-size: 16px;
}

.user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 9px;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background-color: var(--primary-light);
  padding: 2px 6.5px;
  border-radius: 4px;
  margin-top: 2px;
  font-weight: 700;
  align-self: flex-start;
}

body.dark-theme .user-role {
  background-color: rgba(2, 155, 83, 0.2);
  color: #4ade80;
}

/* Main Content Area */
.main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow-y: hidden;
}

.top-bar {
  height: 80px;
  background-color: transparent;
  border-bottom: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  flex-shrink: 0;
}

.page-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-main);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.top-bar-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 20px;
  border-left: 1.5px solid var(--bdr);
}

.top-bar-filter .filter-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
}

.top-bar-filter .filter-select {
  padding: 8px 16px;
  border: 1px solid var(--bdr);
  border-radius: 50px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  background-color: var(--bg-panel);
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.top-bar-filter .filter-select:hover {
  border-color: var(--bdr-focus);
}

.top-bar-filter .filter-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(10, 191, 115, 0.15);
}

.session-timer {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
  background-color: var(--bg-main);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--bdr);
}

.page-container {
  flex-grow: 1;
  min-height: 0;
  padding: 0 32px;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

.page-section {
  display: none;
  padding: 32px 0 0;
}

.page-section > :last-child {
  margin-bottom: 0;
}

.settings-grid > :last-child {
  margin-bottom: 0;
}

.page-section.active {
  display: block;
  animation: pageFadeIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

#pageDashboard {
  padding-top: 16px;
  padding-bottom: 0;
}

@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── 5. FORM ELEMENTS ────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group-inline {
  display: flex;
  gap: 16px;
  align-items: center;
}

.form-row {
  display: flex;
  gap: 16px;
  margin-bottom: 4px;
}

.flex-1 {
  flex: 1;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--bdr);
  border-radius: 8px;
  font-size: 14px;
  background-color: var(--bg-panel);
  color: var(--text-main);
  transition: border-color 0.2s ease;
  outline: none;
}

.form-input:focus {
  border-color: var(--bdr-focus);
}

.form-input.text-area {
  min-height: 80px;
  resize: vertical;
  line-height: 1.5;
}

/* Buttons */
.btn-login, .btn-primary, .btn-secondary, .btn-danger, .btn-action {
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-login {
  width: 100%;
  padding: 12px;
  background-color: var(--primary);
  color: var(--text-white);
  font-size: 15px;
}
.btn-login:hover {
  background-color: var(--primary-hover);
}

.btn-primary {
  padding: 10px 16px;
  background-color: var(--primary);
  color: var(--text-white);
  font-size: 14px;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  padding: 10px 16px;
  background-color: var(--bg-panel);
  color: var(--text-main);
  border: 1.5px solid var(--bdr) !important;
  font-size: 14px;
}
.btn-secondary:hover {
  background-color: var(--bg-main);
}

.btn-danger {
  padding: 10px 16px;
  background-color: #ef4444;
  color: var(--text-white);
  font-size: 14px;
}
.btn-danger:hover {
  background-color: #dc2626;
}

.btn-action {
  padding: 6px 12px;
  background-color: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  border-radius: 6px;
}
.btn-action:hover {
  background-color: #d1fae5;
}

.btn-logout {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.btn-logout:hover {
  color: var(--text-white);
}

.login-err {
  color: #ef4444;
  font-size: 12px;
  margin-top: 10px;
  text-align: center;
}

/* ── 6. KPI DASHBOARD METRICS ────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  padding: 16px 20px;
  border-radius: 12px;
  background-color: var(--bg-panel) !important;
  color: var(--text-main) !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 1px solid var(--bdr);
}

body.dark-theme .kpi-card {
  border-color: var(--bdr);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kpi-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
}

.kpi-icon {
  font-size: 18px;
  width: 36px;
  height: 36px;
  background-color: var(--bg-main);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.1;
}

/* Override old legacy gradient classes to prevent breaking the new white theme */
.bg-kpi-blue, .bg-kpi-green, .bg-kpi-orange, .bg-kpi-purple, .bg-kpi-teal, .bg-kpi-red { 
  background: var(--bg-panel);
  box-shadow: var(--shadow-lg);
}

/* Progress Summary */
.progress-section {
  background-color: var(--bg-panel);
  border: 1px solid transparent;
  border-radius: 24px;
  padding: 32px;
  margin-bottom: 32px;
  box-shadow: var(--shadow-lg);
}

body.dark-theme .progress-section {
  border-color: var(--bdr);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.progress-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--dark);
}

.progress-percent {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
}

.progress-bar-track {
  height: 8px;
  background-color: #f1f5f9;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background-color: var(--primary);
  border-radius: 4px;
  transition: width 0.5s ease-out;
}

/* Dashboard layouts (grid 2 cols) */
.dashboard-layouts {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 24px;
}

.dashboard-col-left,
.dashboard-col-right {
  display: flex;
  flex-direction: column;
}

.dashboard-col-left > .panel,
.dashboard-col-right > .panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-bottom: 0; /* เอา margin-bottom ออกเมื่ออยู่ใน Grid เพื่อให้ส่วนล่างเสมอกัน */
}

.dashboard-col-left > .panel > .panel-body,
.dashboard-col-right > .panel > .panel-body {
  flex: 1;
}

/* ปรับให้แสดงผลแถวเดียวเมื่ออยู่บนหน้าจอมือถือและแท็บเล็ต */
@media (max-width: 1024px) {
  .dashboard-layouts {
    grid-template-columns: 1fr;
  }
  .dashboard-col-left > .panel,
  .dashboard-col-right > .panel {
    margin-bottom: 24px; /* คืนค่า margin-bottom เมื่อวางซ้อนกันแนวตั้ง */
  }
}

.panel {
  background-color: var(--bg-panel);
  border: 1px solid transparent;
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-bottom: 24px;
}

body.dark-theme .panel {
  border-color: var(--bdr);
}

.panel-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--bdr);
}

.panel-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--dark);
}

.panel-body {
  padding: 24px;
}

/* ── 7. BUDGET REMAINING GRID ───────────────────────────────────────────── */
.bgt-remain-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.bgt-card {
  padding: 16px;
  border: 1px solid var(--bdr);
  border-radius: 8px;
  background-color: var(--bg-main);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bgt-card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-sub);
}

.bgt-card-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--dark);
}

.bgt-card-label {
  font-size: 11px;
  color: var(--text-sub);
}

/* ── 8. WORKSPACE FILTERS & KANBAN BOARD ───────────────────────────────── */
.workspace-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
  background-color: var(--bg-panel);
  padding: 20px;
  border-radius: 12px;
  border: 1px solid var(--bdr);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.filter-select, .filter-search {
  padding: 8px 12px;
  border: 1.5px solid var(--bdr);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-main);
  outline: none;
  background-color: var(--bg-panel);
}

.filter-select:focus, .filter-search:focus {
  border-color: var(--bdr-focus);
}

.filter-search {
  flex-grow: 1;
  min-width: 200px;
}

.mode-toggles {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--spacing-md);
  border-top: 1px solid var(--bdr);
  padding-top: 16px;
}

.workspace-primary-actions {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-left: auto;
}

@media (max-width: 640px) {
  .mode-toggles {
    align-items: stretch;
  }

  .workspace-primary-actions {
    width: 100%;
    margin-left: 0;
  }

  .workspace-primary-actions > .btn-primary,
  .workspace-primary-actions > .btn-secondary {
    flex: 1 1 0;
    min-width: 0;
    min-height: 44px;
    justify-content: center;
    white-space: normal;
  }
}

/* กลุ่มปุ่ม Kanban + List ให้อยู่ติดกันแบบ segmented control */
.view-toggle-group {
  display: flex;
  border: 1.5px solid var(--bdr);
  border-radius: 8px;
  overflow: hidden;
}

.view-toggle-group .btn-toggle {
  border: none;
  border-radius: 0;
  margin-right: 0;
  border-right: 1px solid var(--bdr);
}

.view-toggle-group .btn-toggle:last-child {
  border-right: none;
}

.btn-toggle {
  padding: 8px 14px;
  background: none;
  border: 1.5px solid var(--bdr);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-right: 6px;
  border-radius: 6px;
}

.btn-toggle:hover {
  background-color: var(--bg-main);
}

.btn-toggle.active {
  background-color: var(--dark-accent);
  color: var(--text-white);
  border-color: var(--dark-accent);
}

/* Kanban System */
.kanban-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  height: calc(100vh - 290px);
  min-height: 400px;
}

.kanban-column {
  background-color: var(--bg-panel);
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid transparent;
}

body.dark-theme .kanban-column {
  border-color: var(--bdr);
}

.kanban-col-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-white);
}

.kanban-count {
  background-color: rgba(255, 255, 255, 0.2);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
}

.bg-col-todo { background-color: #475569; }
.bg-col-progress { background-color: #2563eb; }
.bg-col-done { background-color: #059669; }

.kanban-cards-wrapper {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  flex-grow: 1;
}

.kanban-card {
  background-color: var(--bg-panel);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--bdr);
  box-shadow: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.kanban-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.workspace-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.workspace-card-action {
  flex: 1;
  padding: 5px 8px;
  font-size: 12px;
}

.workspace-card-actions--single .workspace-card-action { width: 100%; }

#kanbanTodo .kanban-card {
  border-left: 4px solid var(--todo-ring);
}
#kanbanProgress .kanban-card {
  border-left: 4px solid var(--progress-ring);
}
#kanbanDone .kanban-card {
  border-left: 4px solid var(--done-ring);
}

#kanbanTodo .kanban-card:hover {
  transform: translateY(-4px);
  border-color: var(--todo-ring);
  box-shadow: 0 8px 16px -4px rgba(148, 163, 184, 0.35);
}
#kanbanProgress .kanban-card:hover {
  transform: translateY(-4px);
  border-color: var(--progress-ring);
  box-shadow: 0 8px 16px -4px rgba(235, 184, 20, 0.35);
}
#kanbanDone .kanban-card:hover {
  transform: translateY(-4px);
  border-color: var(--done-ring);
  box-shadow: 0 8px 16px -4px rgba(2, 155, 83, 0.35);
}

.card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 8px;
  line-height: 1.4;
}

.card-meta {
  font-size: 11px;
  color: var(--text-sub);
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
}

.pill {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.pill-frame {
  background-color: #f1f5f9;
  color: #475569;
}

/* ── 9. TABLES DESIGN ────────────────────────────────────────────────────── */
.table-container {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--bdr);
  background-color: var(--bg-panel);
}

.workspace-list-surface,
.finance-list-surface {
  overflow: hidden;
  border: 1px solid var(--bdr);
  border-radius: 8px;
  background-color: var(--bg-panel);
}

.workspace-table-container,
.finance-table-container {
  border: 0;
  border-radius: 0;
}

.workspace-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--bdr);
  color: var(--text-sub);
  font-size: 12px;
}

.workspace-pagination__size,
.workspace-pagination__pages {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.workspace-pagination__size .filter-select {
  min-width: 68px;
  padding: 6px 8px;
}

.workspace-pagination__pages {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.workspace-pagination__button.active {
  background-color: var(--dark-accent);
  border-color: var(--dark-accent);
  color: var(--text-white);
}

.pm-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.pm-table th {
  background-color: #f8fafc;
  padding: 14px 18px;
  font-weight: 700;
  color: var(--dark);
  border-bottom: 1px solid var(--bdr);
}

.pm-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--bdr);
  color: var(--text-main);
}

.pm-table tbody tr {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.pm-table tbody tr:hover {
  background-color: #f8fafc;
}

.workspace-list-table {
  min-width: 980px;
  table-layout: fixed;
}

.workspace-list-table th,
.workspace-list-table td {
  padding: 12px 14px;
  vertical-align: middle;
}

.workspace-list-table th:nth-child(1) { width: 32%; }
.workspace-list-table th:nth-child(2) { width: 15%; }
.workspace-list-table th:nth-child(3) { width: 14%; }
.workspace-list-table th:nth-child(4) { width: 11%; }
.workspace-list-table th:nth-child(5) { width: 17%; }
.workspace-list-table th:nth-child(6) { width: 11%; }

.workspace-list-table__activity {
  overflow-wrap: anywhere;
  white-space: normal;
}

.workspace-list-table__activity-content {
  min-width: 0;
}

.workspace-list-table__metadata {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.workspace-activity-code,
.workspace-activity-frame {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border: 1px solid var(--bdr);
  border-radius: var(--radius-compact);
  background: var(--surface-muted);
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}

.workspace-activity-code {
  border-color: var(--done-ring);
  background: var(--done-bg);
  color: var(--done-tx);
  font-variant-numeric: tabular-nums;
}

.workspace-activity-name {
  color: var(--dark);
  font-weight: 700;
  line-height: 1.45;
}

.workspace-activity-unit {
  margin-top: 3px;
  color: var(--text-sub);
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
}

.report-table {
  min-width: 980px;
  table-layout: fixed;
}

.report-table__activity {
  width: 28%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.report-table__meta {
  white-space: nowrap;
}

.finance-table {
  min-width: 1120px;
  table-layout: fixed;
}

.finance-table__activity {
  width: 28%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.finance-table__meta {
  white-space: nowrap;
}

.finance-table__plan-meta {
  color: var(--text-sub);
  font-size: 12px;
}

.finance-table__money {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.finance-list-table th:nth-child(1) { width: 28%; }
.finance-list-table th:nth-child(2) { width: 14%; }
.finance-list-table th:nth-child(3) { width: 13%; }
.finance-list-table th:nth-child(4) { width: 13%; }
.finance-list-table th:nth-child(5) { width: 12%; text-align: right; }
.finance-list-table th:nth-child(6) { width: 10%; text-align: right; }
.finance-list-table th:nth-child(7) { width: 10%; }

.finance-list-table .btn-action {
  min-height: 44px;
}

.report-table th:nth-child(2) { width: 17%; }
.report-table th:nth-child(3) { width: 14%; }
.report-table th:nth-child(4) { width: 16%; }
.report-table th:nth-child(5) { width: 12%; }
.report-table th:nth-child(6) { width: 13%; }

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
}

.status-badge.done { background-color: var(--done-bg); color: var(--done-tx); border: 1px solid var(--done-ring); }
.status-badge.progress { background-color: var(--progress-bg); color: var(--progress-tx); border: 1px solid var(--progress-ring); }
.status-badge.todo { background-color: var(--todo-bg); color: var(--todo-tx); border: 1px solid var(--todo-ring); }
.status-badge.late { background-color: var(--late-bg); color: var(--late-tx); border: 1px solid var(--late-ring); }

@media (max-width: 768px) {
  #workspaceList {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .workspace-table-container {
    overflow: visible;
  }

  .workspace-list-table,
  .workspace-list-table tbody,
  .workspace-list-table tr,
  .workspace-list-table td {
    display: block;
    width: 100%;
  }

  .workspace-list-table {
    min-width: 0;
  }

  .workspace-list-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .workspace-list-table tbody {
    display: grid;
    gap: 12px;
  }

  .workspace-list-table tbody tr {
    padding: 8px 0;
    border: 1px solid var(--bdr);
    border-radius: var(--radius-card);
    background: var(--bg-panel);
    overflow: hidden;
  }

  .workspace-list-table td {
    display: grid;
    grid-template-columns: minmax(112px, 38%) minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    padding: 8px 12px;
    border-bottom: 0;
  }

  .workspace-list-table td::before {
    content: attr(data-label);
    color: var(--text-sub);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.4;
  }

  .workspace-list-table .workspace-list-empty td {
    display: block;
  }

  .workspace-list-table .workspace-list-empty td::before {
    content: none;
  }

  #workspacePagination,
  #financePagination {
    margin-top: 12px;
    border: 1px solid var(--bdr);
    border-radius: var(--radius-card);
    background: var(--bg-panel);
  }

  .finance-list-surface,
  .finance-table-container {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .finance-list-table .finance-table__money {
    text-align: left;
  }

  .finance-list-table .btn-action {
    width: 100%;
  }
}

/* ── 10. CALENDAR PANEL ──────────────────────────────────────────────────── */
.calendar-toolbar {
  margin-bottom: 16px;
}

.calendar-toolbar .filter-bar--scoped {
  margin-bottom: 0;
}

.calendar-search-field {
  grid-column: span 2;
}

.calendar-active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 0;
  margin-top: 10px;
}

.calendar-active-filters:empty {
  display: none;
}

.calendar-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--bdr);
  border-radius: var(--radius-pill);
  background: var(--bg-panel);
  color: var(--text-main);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.calendar-filter-chip:hover {
  border-color: var(--primary);
  color: var(--primary-hover);
}

.calendar-filter-chip svg {
  width: 14px;
  height: 14px;
}

.calendar-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px solid var(--bdr);
  border-radius: var(--radius-card);
  background: var(--bg-panel);
}

.calendar-summary-item {
  display: flex;
  min-width: 0;
  min-height: 78px;
  padding: 14px 18px;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  border-right: 1px solid var(--bdr);
}

.calendar-summary-item:last-child {
  border-right: 0;
}

.calendar-summary-item--attention {
  background: var(--secondary-light);
}

.calendar-summary-label {
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 600;
}

.calendar-summary-item strong {
  overflow: hidden;
  color: var(--dark);
  font-size: 20px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.calendar-summary-item--attention strong {
  color: var(--progress-tx);
}

.cal-panel {
  background-color: var(--bg-panel);
  border: 1px solid var(--bdr);
  border-radius: var(--radius-panel);
  padding: 24px;
}

.cal-hdr {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 20px;
}

.cal-hdr-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--dark);
}

.cal-hdr-description {
  margin: 5px 0 0;
  color: var(--text-sub);
  font-size: 12px;
}

.cal-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.cal-nav button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 36px;
  background: var(--bg-panel);
  border: 1px solid var(--bdr);
  padding: 7px 11px;
  border-radius: var(--radius-control);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-main);
  transition: all 0.2s ease;
}

.cal-nav button:hover {
  background-color: var(--bg-main);
  border-color: var(--primary);
  color: var(--primary-hover);
}

.cal-nav button:focus-visible,
.cal-day:focus-visible,
.cal-ev:focus-visible,
.cal-more:focus-visible,
.calendar-day-item:focus-visible,
.calendar-filter-chip:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.cal-nav svg {
  width: 15px;
  height: 15px;
}

.calMonth {
  font-size: 16px;
  font-weight: 700;
  min-width: 142px;
  text-align: center;
}

.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--bdr);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
}

.cal-leg-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cal-leg-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.cal-leg-dot.bg-done { background-color: var(--primary); }
.cal-leg-dot.bg-progress { background-color: var(--calendar-multiday-progress-bg); }
.cal-leg-dot.bg-overlap { border: 1px solid var(--secondary); background-color: var(--secondary-light); }

.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  align-items: start;
  gap: 18px;
}

.cal-wds {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  margin-bottom: 7px;
}

.cal-wd {
  text-align: center;
  font-weight: 700;
  font-size: 12px;
  color: var(--text-sub);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  min-height: 520px;
  overflow: hidden;
  border: 1px solid var(--bdr);
  border-radius: var(--radius-control);
  background: var(--bdr);
}

.cal-day {
  position: relative;
  border: 0;
  border-radius: 0;
  padding: 8px;
  min-height: 104px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
  background: var(--bg-panel);
  cursor: pointer;
  transition: background-color var(--motion-fast) var(--ease-standard), box-shadow var(--motion-fast) var(--ease-standard);
}

.cal-day.other {
  opacity: 0.42;
  cursor: default;
}

.cal-day.today {
  background-color: var(--primary-light);
}

.cal-day.density-busy {
  background-color: var(--secondary-light);
}

.cal-day.density-packed {
  box-shadow: inset 0 0 0 1px var(--secondary);
}

.cal-day.selected {
  z-index: 1;
  box-shadow: inset 0 0 0 2px var(--primary);
}

.cal-day:hover:not(.other) {
  box-shadow: inset 0 0 0 1px var(--primary);
}

.cal-day-header {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.cal-day-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.cal-day.today .cal-day-num {
  background: var(--primary);
  color: var(--text-white);
}

.cal-day-weekday {
  display: none;
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 600;
}

.cal-density-badge {
  margin-left: auto;
  padding: 2px 6px;
  border-radius: var(--radius-compact);
  background: var(--progress-bg);
  color: var(--progress-tx);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.cal-evs {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cal-ev {
  display: block;
  width: auto;
  min-width: 0;
  min-height: 26px;
  border: 0;
  padding: 5px 7px;
  border-radius: var(--radius-compact);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.cal-ev.ev-done { background-color: var(--done-bg); color: var(--done-tx); }
.cal-ev.ev-progress {
  background-color: var(--calendar-upcoming-bg);
  color: var(--calendar-upcoming-text);
  outline: 1px solid var(--calendar-upcoming-outline);
  outline-offset: -1px;
}

.cal-ev.ev-done:not(.segment-single) { background-color: var(--calendar-multiday-done-bg); color: var(--calendar-multiday-text); }
.cal-ev.ev-progress:not(.segment-single) {
  background-color: var(--calendar-multiday-progress-bg);
  color: var(--calendar-multiday-text);
  outline: none;
}

.cal-ev.segment-start { margin-right: -9px; border-radius: var(--radius-compact) 0 0 var(--radius-compact); }
.cal-ev.segment-middle { margin-right: -9px; margin-left: -9px; border-radius: 0; }
.cal-ev.segment-end { margin-left: -9px; border-radius: 0 var(--radius-compact) var(--radius-compact) 0; }
.cal-day:nth-child(7n) .cal-ev.segment-start,
.cal-day:nth-child(7n) .cal-ev.segment-middle { margin-right: 0; border-radius: 0 var(--radius-compact) var(--radius-compact) 0; }
.cal-day:nth-child(7n + 1) .cal-ev.segment-middle,
.cal-day:nth-child(7n + 1) .cal-ev.segment-end { margin-left: 0; border-radius: var(--radius-compact) 0 0 var(--radius-compact); }

.cal-event-label--continuation {
  visibility: hidden;
}

.cal-more {
  min-height: 26px;
  border: 0;
  padding: 4px 6px;
  background: transparent;
  color: var(--text-sub);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.cal-more:hover {
  color: var(--primary-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.calendar-day-panel {
  position: sticky;
  top: 16px;
  min-width: 0;
  min-height: 360px;
  overflow: hidden;
  border: 1px solid var(--bdr);
  border-radius: var(--radius-card);
  background: var(--surface-muted);
}

.calendar-day-panel-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 16px;
  border-bottom: 1px solid var(--bdr);
  background: var(--bg-panel);
}

.calendar-day-panel-header h3 {
  margin: 0;
  color: var(--dark);
  font-size: 14px;
  line-height: 1.5;
}

.calendar-day-count {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: var(--todo-bg);
  color: var(--todo-tx);
  font-size: 12px;
  font-weight: 700;
}

.calendar-day-count.is-overlap {
  background: var(--progress-bg);
  color: var(--progress-tx);
}

.calendar-day-list {
  display: flex;
  flex-direction: column;
  max-height: 590px;
  overflow-y: auto;
  padding: 8px;
}

#pageCalendar .calendar-layout {
  align-items: stretch;
}

#pageCalendar .calendar-day-panel {
  display: flex;
  height: 100%;
  flex-direction: column;
}

#pageCalendar .calendar-day-list {
  min-height: 0;
  max-height: none;
  flex: 1 1 auto;
}

#pageCalendar .calendar-day-empty {
  flex: 1 1 auto;
}

.calendar-day-item {
  display: flex;
  width: 100%;
  padding: 12px 10px;
  flex-direction: column;
  gap: 7px;
  border: 0;
  border-bottom: 1px solid var(--bdr);
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.calendar-day-item:last-child {
  border-bottom: 0;
}

.calendar-day-item:hover {
  background: var(--bg-panel);
}

.calendar-day-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.calendar-day-item-code {
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 600;
}

.calendar-day-item-status {
  padding: 2px 6px;
  border-radius: var(--radius-compact);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.calendar-day-item-status.is-done { background: var(--done-bg); color: var(--done-tx); }
.calendar-day-item-status.is-progress { background: var(--progress-bg); color: var(--progress-tx); }

.calendar-day-item strong {
  color: var(--dark);
  font-size: 14px;
  line-height: 1.45;
}

.calendar-day-item-meta {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  color: var(--text-sub);
  font-size: 12px;
  line-height: 1.45;
}

.calendar-day-item-meta svg {
  width: 13px;
  height: 13px;
  margin-top: 1px;
  flex: 0 0 auto;
}

.calendar-day-empty {
  display: flex;
  min-height: 280px;
  padding: 24px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-sub);
  text-align: center;
}

.calendar-day-empty svg {
  width: 28px;
  height: 28px;
  margin-bottom: 10px;
  color: var(--primary);
}

.calendar-day-empty p {
  margin: 0;
  color: var(--dark);
  font-size: 14px;
  font-weight: 700;
}

.calendar-day-empty span {
  margin-top: 3px;
  font-size: 12px;
}

body.dark-theme .calendar-summary-item--attention,
body.dark-theme .cal-day.density-busy {
  background: var(--progress-bg);
}

body.dark-theme .cal-day.today {
  border-color: transparent !important;
  background: var(--done-bg) !important;
}

@media (max-width: 1180px) {
  .calendar-layout {
    grid-template-columns: minmax(0, 1fr) 260px;
  }

  .cal-day {
    padding: 6px;
  }

  .cal-density-badge {
    display: none;
  }

  .cal-ev.segment-start { margin-right: -7px; }
  .cal-ev.segment-middle { margin-right: -7px; margin-left: -7px; }
  .cal-ev.segment-end { margin-left: -7px; }
}

@media (max-width: 900px) {
  .calendar-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .public-calendar-wrapper .calendar-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .calendar-day-panel {
    position: static;
    min-height: 0;
  }

  #pageCalendar .calendar-day-panel {
    height: auto;
  }

  .calendar-day-list {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .calendar-search-field {
    grid-column: auto;
  }

  .calendar-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .cal-panel {
    padding: 16px;
  }

  .cal-hdr {
    flex-direction: column;
  }

  .cal-nav {
    width: 100%;
    justify-content: space-between;
  }

  .cal-nav button span {
    display: none;
  }

  .cal-nav button:first-child {
    padding-inline: 12px;
  }

  .calMonth {
    min-width: 0;
  }

  .cal-wds {
    display: none;
  }

  .cal-days {
    display: flex;
    min-height: 0;
    flex-direction: column;
    gap: 8px;
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .cal-day {
    display: grid;
    grid-template-columns: 70px minmax(0, 1fr);
    min-height: 0;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--bdr);
    border-radius: var(--radius-control);
  }

  .cal-day.other,
  .cal-day:not(.has-events):not(.today) {
    display: none;
  }

  .cal-day-header {
    align-self: start;
  }

  .cal-day-weekday {
    display: inline;
  }

  .cal-density-badge {
    display: none;
  }

  .cal-ev,
  .cal-ev.segment-start,
  .cal-ev.segment-middle,
  .cal-ev.segment-end,
  .cal-day:nth-child(7n) .cal-ev.segment-start,
  .cal-day:nth-child(7n) .cal-ev.segment-middle,
  .cal-day:nth-child(7n + 1) .cal-ev.segment-middle,
  .cal-day:nth-child(7n + 1) .cal-ev.segment-end {
    margin: 0;
    border-radius: var(--radius-compact);
  }

  .cal-event-label--continuation {
    visibility: visible;
  }
}

/* ── 11. MODAL BOXES DESIGN ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: var(--z-modal);
  opacity: 1;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hidden, .modal-overlay.hidden {
  display: none !important;
}

.modal-box {
  background-color: var(--bg-panel);
  border-radius: 20px; /* More rounded corners */
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.05);
  border: 1px solid var(--bdr);
  width: 90%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalScaleIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); /* Elastic zoom curve */
}

@keyframes modalScaleIn {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 20px 28px;
  border-bottom: 1px solid var(--bdr);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--dark);
}

.modal-subtitle {
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 2px;
}

.btn-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-sub);
  cursor: pointer;
}
.btn-close:hover {
  color: var(--dark);
}

.modal-body {
  padding: 28px;
  overflow-y: auto;
  flex-grow: 1;
}

.modal-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--bdr);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  background-color: #f8fafc;
  flex-shrink: 0;
}

/* Modal Tab Styles */
.modal-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 2px solid var(--bdr);
  margin-bottom: 24px;
  padding-bottom: 0px;
}

.modal-tab-btn {
  background: none;
  border: none;
  outline: none;
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal-tab-btn:hover {
  color: var(--primary);
  background-color: var(--primary-light);
}

body.dark-theme .modal-tab-btn:hover {
  background-color: rgba(16, 185, 129, 0.08);
  color: #10b981;
}

.modal-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background-color: var(--primary-light);
}

body.dark-theme .modal-tab-btn.active {
  background-color: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border-bottom-color: #10b981;
}

.modal-tab-content {
  animation: tabFadeIn 0.3s ease;
}

@keyframes tabFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-tab-content.hidden {
  display: none !important;
}

/* ── 12. ISSUES TABLE & KM UPLOADS ───────────────────────────────────────── */
.issues-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 8px;
  font-size: 13px;
  border: 1px solid var(--bdr);
  border-radius: 10px;
  overflow: hidden;
}

.issues-table th {
  background-color: #f1f5f9;
  padding: 10px 14px;
  font-weight: 700;
  color: var(--text-main);
  border-bottom: 1.5px solid var(--bdr);
  text-align: left;
}

body.dark-theme .issues-table th {
  background-color: #1f2937;
}

.issues-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--bdr);
}

.issues-table tr:last-child td {
  border-bottom: none;
}

.issues-input {
  width: 100%;
  border: 1.5px solid transparent;
  padding: 6px 10px;
  border-radius: 6px;
  outline: none;
  font-size: 13px;
  background: transparent;
  color: var(--text-main);
  transition: all 0.2s ease;
}

.issues-input:focus {
  border-color: var(--primary);
  background-color: var(--bg-main);
}

body.dark-theme .issues-input:focus {
  border-color: #10b981;
}

.btn-delete-row {
  background: none;
  border: none;
  color: #ef4444;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.btn-delete-row:hover {
  background-color: #fef2f2;
}

body.dark-theme .btn-delete-row:hover {
  background-color: rgba(239, 68, 68, 0.15);
}

/* Upload zone categories inside KM form */
.upload-categories {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.upload-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border: 1px solid var(--bdr);
  border-radius: 12px;
  background-color: var(--bg-panel);
  gap: 20px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.upload-row:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

body.dark-theme .upload-row:hover {
  border-color: #10b981;
}

.upload-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.upload-info strong {
  font-size: 13px;
  color: var(--dark);
}

body.dark-theme .upload-info strong {
  color: var(--text-main);
}

.upload-info p {
  font-size: 11px;
  color: var(--text-sub);
  margin: 4px 0 0 0;
}

.file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.file-chip {
  background-color: var(--bg-panel);
  border: 1px solid var(--bdr);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.file-chip a {
  color: var(--primary);
  text-decoration: none;
}
body.dark-theme .file-chip a {
  color: #10b981;
}
.file-chip a:hover {
  text-decoration: underline;
}

.file-del-btn {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-weight: 700;
}

/* Settings Grids */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

.settings-tab-content.hidden {
  display: none;
}

.telegram-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-lg);
}

.telegram-settings-heading {
  min-width: 0;
}

.telegram-settings-summary {
  margin-top: var(--spacing-xs);
  color: var(--text-sub);
  font-size: 14px;
  line-height: 1.5;
}

.telegram-config-status {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: 6px 10px;
  border: 1px solid var(--bdr);
  border-radius: var(--radius-pill);
  background: var(--bg-main);
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.telegram-config-status::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  content: '';
}

.telegram-config-status[data-state="ready"] {
  border-color: var(--done-ring);
  background: var(--done-bg);
  color: var(--done-tx);
}

.telegram-config-status[data-state="disabled"] {
  border-color: var(--progress-ring);
  background: var(--progress-bg);
  color: var(--progress-tx);
}

.telegram-config-status[data-state="incomplete"],
.telegram-config-status[data-state="error"] {
  border-color: var(--late-ring);
  background: var(--late-bg);
  color: var(--late-tx);
}

.telegram-enable-row {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-md);
  padding-bottom: var(--spacing-xl);
  margin-bottom: var(--spacing-xl);
  border-bottom: 1px solid var(--bdr);
  cursor: pointer;
}

.telegram-enable-row input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--primary);
}

.telegram-enable-row input:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.telegram-enable-row span {
  display: grid;
  gap: var(--spacing-xs);
  min-width: 0;
}

.telegram-enable-row strong {
  color: var(--text-main);
  font-size: 14px;
}

.telegram-enable-row small,
.telegram-field-hint {
  color: var(--text-sub);
  font-size: 12px;
  line-height: 1.5;
}

.telegram-settings-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--spacing-lg);
}

.telegram-config-message {
  min-height: 24px;
  margin-top: var(--spacing-xs);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.telegram-config-message[data-state="success"] { color: var(--done-tx); }
.telegram-config-message[data-state="error"] { color: var(--late-tx); }
.telegram-config-message[data-state="loading"] { color: var(--text-sub); }

.telegram-settings-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-md);
}

.telegram-settings-actions button:disabled {
  cursor: wait;
  opacity: 0.62;
}

@media (max-width: 640px) {
  .telegram-settings-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .telegram-settings-fields {
    grid-template-columns: 1fr;
  }

  .telegram-settings-fields .form-input {
    font-size: 16px;
  }

  .telegram-settings-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .telegram-settings-actions button {
    width: 100%;
  }
}

/* ── 13. SPINNER LOADING ANIMATION ──────────────────────────────────────── */
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
  z-index: 9999;
}

body.dark-theme .loading-overlay {
  background-color: rgba(17, 24, 39, 0.85);
}

.loading-txt {
  font-size: 14px;
  font-weight: 700;
  color: var(--dark);
}

/* ── 14. SKELETON LOADERS & MICRO-INTERACTIONS ────────────────────────────── */
@keyframes skeleton-loading {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 4px;
  color: transparent !important;
  pointer-events: none;
}

.dark-theme .skeleton {
  background: linear-gradient(90deg, #1f2937 25%, #374151 50%, #1f2937 75%);
  background-size: 200% 100%;
}

/* Micro-interactions */
.kanban-card, .kpi-card, .bgt-card {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, border-color 0.3s ease;
}

.kpi-card:hover {
  transform: translateY(-6px);
}

.bg-kpi-blue:hover { box-shadow: 0 14px 28px -5px rgba(59, 130, 246, 0.65); }
.bg-kpi-green:hover { box-shadow: 0 14px 28px -5px rgba(16, 185, 129, 0.65); }
.bg-kpi-orange:hover { box-shadow: 0 14px 28px -5px rgba(245, 158, 11, 0.65); }
.bg-kpi-purple:hover { box-shadow: 0 14px 28px -5px rgba(139, 92, 246, 0.65); }
.bg-kpi-teal:hover { box-shadow: 0 14px 28px -5px rgba(20, 184, 166, 0.65); }
.bg-kpi-red:hover { box-shadow: 0 14px 28px -5px rgba(239, 68, 68, 0.65); }

/* CSS Transition for Progress Indicators */
.progress-bar-fill {
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── 14. KM IMAGE GALLERY LIGHTBOX PREVIEWER ───────────────────────────────── */
#galleryLightbox {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.93);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: opacity 0.3s ease;
}

.lightbox-close-btn {
  position: absolute;
  top: 24px;
  right: 30px;
  color: #f1f5f9;
  font-size: 44px;
  font-weight: 300;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 10010;
  transition: transform 0.2s ease, color 0.2s ease;
}

.lightbox-close-btn:hover {
  color: var(--primary);
  transform: scale(1.1);
}

.lightbox-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: white;
  width: 56px;
  height: 56px;
  font-size: 24px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10005;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.lightbox-nav-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  transform: translateY(-50%) scale(1.1);
}

.lightbox-nav-btn.prev {
  left: 30px;
}

.lightbox-nav-btn.next {
  right: 30px;
}

.lightbox-content {
  max-width: 80%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  position: relative;
}

#lightboxImg {
  max-width: 100%;
  max-height: 72vh;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  object-fit: contain;
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: transform 0.3s ease;
}

.lightbox-caption {
  color: #f8fafc;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 6px 16px;
  border-radius: 20px;
  max-width: 90%;
  text-align: center;
  word-break: break-all;
}

.lightbox-counter {
  color: rgba(241, 245, 249, 0.65);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* Image preview cards style in upload lists */
.image-preview-card {
  position: relative;
  width: 95px;
  height: 95px;
  border-radius: 8px;
  overflow: hidden;
  border: 1.5px solid var(--bdr);
  background-color: var(--bg-panel);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.image-preview-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.image-preview-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview-card .img-del-overlay {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(239, 68, 68, 0.95);
  color: white;
  border: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: bold;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 10;
}

.image-preview-card:hover .img-del-overlay {
  opacity: 1;
}

.image-preview-card .img-del-overlay:hover {
  background: #dc2626;
  transform: scale(1.15);
}

.image-preview-card .img-name-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(15, 23, 42, 0.95), rgba(15, 23, 42, 0));
  color: #f1f5f9;
  font-size: 8.5px;
  padding: 8px 6px 4px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  font-weight: 500;
}

/* ─────────────────────────────────────────────────────────────────
   UX/UI Redesign: Activity Details & Finance Modal (actModal)
───────────────────────────────────────────────────────────────── */
.info-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.info-card {
  background-color: var(--bg-main);
  border: 1px solid var(--bdr);
  border-radius: 10px;
  padding: 16px;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.info-card:hover {
  border-color: var(--bdr-focus);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

body.dark-theme .info-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.info-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1.5px solid var(--bdr);
  display: flex;
  align-items: center;
  gap: 6px;
}

.info-card-body p {
  margin: 6px 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-main);
}

/* ตารางงบประมาณย่อยในรายละเอียดโครงการ */
.bi-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.bi-table th {
  background-color: #f8fafc;
  font-weight: 700;
  color: var(--dark);
  border-bottom: 1.5px solid var(--bdr);
}

body.dark-theme .bi-table th {
  background-color: #1f2937 !important;
  color: var(--text-main) !important;
}

.bi-table tr {
  transition: background-color 0.15s ease;
}

.bi-table tbody tr:nth-child(even) {
  background-color: rgba(248, 250, 252, 0.4);
}

body.dark-theme .bi-table tbody tr:nth-child(even) {
  background-color: rgba(31, 41, 55, 0.2);
}

.bi-table tbody tr:hover {
  background-color: #f8fafc;
}

body.dark-theme .bi-table tbody tr:hover {
  background-color: #1f2937 !important;
}

.bi-table td {
  border-bottom: 1px solid var(--bdr);
  color: var(--text-main);
}

.workspace-budget-progress {
  height: 10px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--bdr);
}

.workspace-budget-progress-group { margin-bottom: 20px; }

.workspace-budget-progress-heading,
.workspace-budget-toolbar,
.workspace-budget-actions {
  display: flex;
  align-items: center;
}

.workspace-budget-progress-heading {
  justify-content: space-between;
  margin-bottom: 6px;
}

.workspace-budget-heading {
  color: var(--dark);
  font-size: 14px;
  font-weight: 700;
}

.workspace-budget-progress-meta {
  color: var(--text-sub);
  font-size: 12px;
}

.workspace-budget-toolbar {
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.workspace-budget-actions {
  gap: 8px;
  flex-wrap: wrap;
}

.workspace-budget-table {
  overflow-x: auto;
  margin-bottom: 16px;
  border: 1px solid var(--bdr);
  border-radius: var(--radius-card);
}

.workspace-budget-cell {
  padding: 6px 10px;
  font-size: 14px;
}

.workspace-budget-cell--number {
  width: 140px;
  text-align: right;
}

.workspace-budget-cell--remain {
  width: 120px;
  padding: 10px 14px;
  text-align: right;
  font-weight: 700;
}

.workspace-budget-cell-value {
  padding: 4px 8px;
  font-weight: 600;
}

.workspace-budget-cell--number .workspace-budget-cell-value,
.workspace-budget-input { text-align: right; }

.workspace-budget-cell-value.is-actual,
.workspace-budget-input.bgt-input-act { color: var(--primary); }

.workspace-budget-input {
  width: 100%;
  padding: 4px 8px;
  border: 0;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
}

.workspace-budget-input--name {
  color: var(--text-main);
  text-align: left;
  font-weight: 400;
}

.workspace-budget-progress__bar {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  transform: scaleX(var(--budget-progress));
  transform-origin: left center;
  transition: transform var(--motion-standard) var(--ease-standard);
}

.workspace-budget-progress__bar.is-success { background-color: var(--done-ring); }
.workspace-budget-progress__bar.is-warning { background-color: var(--progress-ring); }
.workspace-budget-progress__bar.is-danger { background-color: var(--late-ring); }
.bgt-row-remain.is-positive { color: var(--done-tx); }
.bgt-row-remain.is-neutral { color: var(--text-sub); }
.bgt-row-remain.is-negative { color: var(--late-tx); }

@media (prefers-reduced-motion: reduce) {
  .workspace-budget-progress__bar { transition: none; }
}

/* กล่องกรอกข้อมูลเพิ่มเติมงบย่อย */
.budget-add-box {
  background-color: var(--bg-main);
  border: 1.5px dashed var(--bdr);
  border-radius: 10px;
  padding: 16px;
  margin-top: 16px;
}

.budget-add-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 10px;
}


/* ── 14. INTERACTIVE DASHBOARD COMPONENTS ───────────────────────────────── */

/* Dashboard Filter Bar */
.db-filter-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--bg-main);
  border: 1px solid var(--bdr);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-md);
  padding: 12px 16px;
  margin-bottom: 24px;
}

#dbProjectTableSection {
  margin-bottom: 0;
}

.db-filter-select {
  border-radius: 50px !important;
  background-color: var(--bg-panel) !important;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--bdr) !important;
  padding: 8px 16px !important;
}

.db-filter-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
  white-space: nowrap;
  margin-right: 4px;
}

.db-filter-select {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
}

.db-filter-reset {
  font-size: 12px;
  padding: 6px 14px;
}

.db-filter-search {
  flex: 1 1 220px;
  min-width: 220px;
  max-width: 360px;
  font-size: 12px;
}

/* Reach Metric Cards */
.reach-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 768px) {
  .reach-grid { grid-template-columns: 1fr; }

  .db-filter-search {
    flex-basis: 100%;
    max-width: none;
  }
}

.reach-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border-radius: 14px;
  border: 1.5px solid transparent;
  transition: transform 0.2s, box-shadow 0.2s;
}

.reach-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}

.reach-total  { background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%); border-color: #bfdbfe; }
.reach-students { background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%); border-color: #bbf7d0; }
.reach-staff  { background: linear-gradient(135deg, #fefce8 0%, #fef9c3 100%); border-color: #fde68a; }

body.dark-theme .reach-total    { background: linear-gradient(135deg, #1e3a5f 0%, #172554 100%); border-color: #1d4ed8; }
body.dark-theme .reach-students { background: linear-gradient(135deg, #14532d 0%, #052e16 100%); border-color: #15803d; }
body.dark-theme .reach-staff    { background: linear-gradient(135deg, #713f12 0%, #451a03 100%); border-color: #b45309; }

.reach-icon {
  font-size: 32px;
  flex-shrink: 0;
}

.reach-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.reach-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.reach-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--dark);
  line-height: 1;
}

.reach-unit {
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 2px;
}

/* Budget Progress Mini Bar */
.bgt-bar-track {
  width: 100%;
  height: 5px;
  background: var(--bdr);
  border-radius: 99px;
  margin-top: 8px;
  overflow: hidden;
}

.bgt-bar-fill {
  height: 5px;
  border-radius: 99px;
  transition: width 0.4s ease;
}

/* Activity Budget Table */
.db-act-table {
  min-width: 1120px;
  table-layout: auto;
}

.db-act-table th {
  white-space: nowrap;
  font-size: 12px;
}

.db-act-table th:first-child,
.db-act-table td:first-child {
  min-width: 360px;
  max-width: 520px;
}

.db-act-table td:first-child {
  white-space: normal;
  line-height: 1.45;
}

.db-act-table th:nth-child(n+2),
.db-act-table td:nth-child(n+2) {
  white-space: nowrap;
}

.db-act-table th:nth-child(2),
.db-act-table td:nth-child(2) {
  min-width: 160px;
}

.db-act-table th:nth-child(3),
.db-act-table td:nth-child(3),
.db-act-table th:nth-child(4),
.db-act-table td:nth-child(4),
.db-act-table th:nth-child(5),
.db-act-table td:nth-child(5) {
  min-width: 118px;
}

.db-act-table th:nth-child(6),
.db-act-table td:nth-child(6) {
  min-width: 118px;
}

.db-act-table th:nth-child(7),
.db-act-table td:nth-child(7) {
  min-width: 104px;
}

.db-act-table tr:hover td {
  background: var(--bg-hover, rgba(2,155,83,0.04));
}

.db-mobile-activity-list { display: none; }

@media (max-width: 767px) {
  #dbProjectTableSection .table-container { display: none; }
  .db-act-table { display: none; }
  .db-mobile-activity-list { display: grid; gap: 12px; }
  .db-mobile-activity, .db-mobile-empty {
    width: 100%; min-height: 44px; padding: 16px; border: 1px solid var(--bdr);
    border-radius: var(--radius-card); background: var(--bg-panel); color: var(--text-main); text-align: left;
  }
  .db-mobile-activity { cursor: pointer; }
  .db-mobile-activity__heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
  .db-mobile-activity__title { font-size: 14px; font-weight: 700; line-height: 1.45; }
  .db-mobile-activity__identity, .db-mobile-activity__department { display: block; margin-top: 6px; color: var(--text-sub); font-size: 12px; }
  .db-mobile-activity__budget { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
  .db-mobile-activity__budget small, .db-mobile-activity__budget strong { display: block; }
  .db-mobile-activity__budget small { color: var(--text-sub); font-size: 11px; }
  .db-mobile-activity__budget strong { margin-top: 2px; font-size: 12px; }
  .db-mobile-activity .bgt-bar-track { display: block; margin-top: 12px; }
  .db-mobile-activity:focus-visible { outline: none; box-shadow: var(--focus-ring); }
  .db-mobile-activity:active { background: var(--primary-light); border-color: var(--primary); }
}

/* Budget Remaining Badge */
.db-remain-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}

/* Reach Badge in Table */
.db-reach-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 600;
  cursor: help;
  border: 1px solid #bfdbfe;
}

.activity-import-modal-box { max-width: 680px; }
.activity-import-body { display: grid; gap: 14px; }
.activity-import-help {
  padding: 12px 14px; border: 1px solid var(--bdr); border-radius: var(--radius-control);
  background: var(--surface-muted); color: var(--text-sub); font-size: 12px; line-height: 1.6;
}
.activity-import-dropzone {
  display: grid; place-items: center; gap: 6px; min-height: 150px; padding: 20px;
  border: 2px dashed var(--bdr-focus); border-radius: var(--radius-card); cursor: pointer;
  color: var(--text-main); text-align: center; background: var(--bg-panel);
}
.activity-import-dropzone:hover, .activity-import-dropzone:focus-within { background: var(--primary-light); }
.activity-import-dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.activity-import-dropzone__icon { width: 30px; height: 30px; color: var(--primary); }
.activity-import-dropzone small, .activity-import-file-name { color: var(--text-sub); font-size: 12px; }
.activity-import-file-name { min-height: 18px; }
.activity-import-status { min-height: 20px; color: var(--text-main); font-size: 13px; }
.activity-import-result { padding: 14px; border: 1px solid var(--bdr); border-radius: var(--radius-control); background: var(--surface-muted); }
.activity-import-result__summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }
.activity-import-result__errors { display: grid; gap: 6px; margin: 12px 0 0; max-height: 180px; overflow: auto; font-size: 12px; }
.activity-import-result__error { padding: 8px 10px; border-radius: var(--radius-compact); background: var(--danger-surface); color: var(--danger-strong); }
@media (max-width: 640px) {
  .activity-import-result__summary { grid-template-columns: 1fr; }
  .activity-import-modal-box { width: calc(100vw - 24px); }
}

body.dark-theme .db-reach-badge {
  background: #1e3a5f;
  color: #93c5fd;
  border-color: #1d4ed8;
}

/* ═══════════════════════════════════════════════════════════════════
   DOCUMENT MANAGEMENT PAGE STYLES
   ═══════════════════════════════════════════════════════════════════ */

/* Header */
.doc-page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.doc-page-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--dark);
  margin: 0;
}
.doc-page-subtitle {
  font-size: 13px;
  color: var(--text-sub);
  margin: 4px 0 0;
}
.doc-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.doc-upload-btn {
  white-space: nowrap;
  padding: 10px 20px;
  font-size: 14px;
}

.document-category-add {
  display: flex;
  gap: 8px;
}
.document-category-add .form-input {
  min-width: 0;
  flex: 1;
}
.document-category-message {
  min-height: 20px;
  margin-top: 8px;
  color: var(--text-sub);
  font-size: 12px;
}
.document-category-list {
  display: grid;
  gap: 6px;
  max-height: 300px;
  margin-top: 8px;
  overflow-y: auto;
}
.document-category-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border: 1px solid var(--bdr);
  border-radius: 8px;
  background: var(--card-bg);
}
.document-category-row.is-dragging {
  opacity: 0.45;
}
.document-category-row.is-drop-target {
  border-color: var(--primary);
  background: var(--secondary-light);
}
.document-category-label {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 7px;
}
.doc-category-drag-handle {
  display: inline-flex;
  align-items: center;
  color: var(--text-sub);
  cursor: grab;
  touch-action: none;
}
.doc-category-drag-handle:active {
  cursor: grabbing;
}
.document-category-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Category Tab Bar */
.doc-category-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.doc-cat-tab {
  padding: 7px 14px;
  border-radius: 99px;
  border: 1.5px solid var(--bdr);
  background: var(--card-bg);
  color: var(--text-sub);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.doc-cat-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.doc-cat-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99,102,241,0.35);
}

/* Document Grid */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

/* Document Card */
.doc-card {
  background: var(--card-bg);
  border-radius: 14px;
  border: 1.5px solid var(--bdr);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

.doc-card--pinned {
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--secondary) 32%, transparent);
}
.doc-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 14px 14px 0 0;
}
.doc-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

/* Card color variants */
.doc-card-blue::before  { background: #3b82f6; }
.doc-card-green::before { background: #10b981; }
.doc-card-purple::before{ background: #8b5cf6; }
.doc-card-orange::before{ background: #f59e0b; }
.doc-card-teal::before  { background: #14b8a6; }
.doc-card-indigo::before{ background: #6366f1; }
.doc-card-red::before   { background: #ef4444; }
.doc-card-gray::before  { background: #6b7280; }

.doc-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
}
.doc-card-icon {
  font-size: 32px;
  line-height: 1;
}
.doc-cat-badge {
  flex: 1;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-delete-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 0.2s;
  padding: 2px 4px;
  border-radius: 6px;
}
.doc-card-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.doc-pin-btn {
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.6;
  padding: 0;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-sub);
}
.doc-pin-btn:hover {
  opacity: 1;
  background: var(--bg-main);
}
.doc-pin-btn.active,
.doc-pin-indicator {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #16803c;
  color: #fff;
  opacity: 1;
}
.doc-pin-btn.active:hover {
  background: #106b31;
}
.doc-pin-indicator {
  margin-left: auto;
  pointer-events: none;
}
.doc-edit-btn {
  background: none;
  border: none;
  color: var(--text-sub);
  cursor: pointer;
  opacity: 0.6;
  padding: 2px 4px;
  border-radius: 6px;
}
.doc-edit-btn:hover {
  color: var(--text-main);
  opacity: 1;
  background: var(--bg-main);
}
.doc-delete-btn:hover {
  opacity: 1;
  background: #fee2e2;
}

.doc-card-body { flex: 1; }
.doc-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--dark);
  margin: 0 0 5px;
  line-height: 1.4;
}
.doc-card-desc {
  font-size: 12px;
  color: var(--text-sub);
  margin: 0;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.doc-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--bdr);
  padding-top: 10px;
  margin-top: 4px;
}
.doc-card-meta {
  font-size: 11px;
  color: var(--text-sub);
}
.doc-dl-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  white-space: nowrap;
}
.doc-dl-btn:hover {
  background: var(--primary-dark, #4f46e5);
  transform: scale(1.03);
}

/* Empty State */
.doc-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-sub);
}
.doc-empty-icon {
  font-size: 56px;
  margin-bottom: 12px;
}
.doc-empty p {
  font-size: 16px;
  font-weight: 600;
}

/* ─── Upload Modal Drop Zone ─── */
.doc-dropzone {
  border: 2.5px dashed var(--bdr);
  border-radius: 14px;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s;
  background: var(--bg);
}
.doc-dropzone:hover, .doc-dropzone.dragover {
  border-color: var(--primary);
  background: rgba(99,102,241,0.06);
}
.doc-dropzone-icon { font-size: 40px; margin-bottom: 8px; }
.doc-dropzone-text { font-size: 15px; font-weight: 700; color: var(--dark); margin-bottom: 4px; }
.doc-dropzone-hint { font-size: 12px; color: var(--text-sub); }
.doc-dropzone-name {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 700;
  color: #10b981;
}

/* Dark mode adjustments */
body.dark-theme .doc-delete-btn:hover { background: #450a0a; }
body.dark-theme .doc-dropzone { background: var(--bg); }

/* ═══════════════════════════════════════════════════════════════════
   FINANCE MODAL REDESIGN — Summary Cards & Status Timeline
   ═══════════════════════════════════════════════════════════════════ */

.finance-status--pending {
  --finance-status-bg: var(--progress-bg);
  --finance-status-ring: var(--progress-ring);
  --finance-status-text: var(--progress-tx);
}

.finance-status--approved,
.finance-status--complete {
  --finance-status-bg: var(--done-bg);
  --finance-status-ring: var(--done-ring);
  --finance-status-text: var(--done-tx);
}

.finance-status--neutral {
  --finance-status-bg: var(--todo-bg);
  --finance-status-ring: var(--todo-ring);
  --finance-status-text: var(--todo-tx);
}

.fin-status-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 14px 18px;
  border: 1.5px solid var(--finance-status-ring);
  border-radius: var(--radius-card);
  background: var(--finance-status-bg);
  color: var(--finance-status-text);
}

.finance-status-icon { font-size: 26px; }

.finance-status-kicker {
  color: var(--finance-status-text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.finance-status-title {
  color: var(--finance-status-text);
  font-size: 20px;
  font-weight: 800;
}

.finance-timeline {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  margin-bottom: 24px;
  padding-bottom: 4px;
}

.finance-timeline-step {
  position: relative;
  flex: 1;
  min-width: 80px;
  text-align: center;
}

.finance-timeline-connector {
  position: absolute;
  top: 14px;
  width: 50%;
  height: 2px;
  background: var(--bdr);
}

.finance-timeline-connector--before { left: 0; }
.finance-timeline-connector--after { right: 0; }
.finance-timeline-connector.is-complete { background: var(--finance-status-ring); }

.finance-timeline-marker {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--bdr);
  color: var(--text-sub);
  font-size: 14px;
  font-weight: 700;
}

.finance-timeline-step.is-active .finance-timeline-marker,
.finance-timeline-step.is-past .finance-timeline-marker {
  background: var(--finance-status-ring);
  color: var(--text-white);
}

.finance-timeline-label {
  margin-top: 5px;
  color: var(--bdr);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
}

.finance-timeline-step.is-active .finance-timeline-label {
  color: var(--finance-status-text);
  font-weight: 700;
}

.finance-timeline-step.is-past .finance-timeline-label { color: var(--text-sub); }

.finance-edit-panel {
  margin-bottom: 16px;
  padding: 16px;
  border: 1.5px solid var(--bdr);
  border-radius: var(--radius-card);
  background: var(--bg);
}

.finance-edit-heading {
  margin-bottom: 14px;
  color: var(--dark);
  font-size: 14px;
  font-weight: 700;
}

.finance-note-input {
  min-height: 72px;
  resize: vertical;
  font-size: 14px;
}

.finance-update-meta {
  color: var(--text-sub);
  font-size: 12px;
  text-align: right;
}

@media (max-width: 768px) {
  .finance-timeline-label {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .workspace-budget-table { overflow-x: auto; }
}

.fin-summary-card {
  padding: 14px 16px;
  border-radius: 12px;
  border: 1.5px solid transparent;
  text-align: left;
}

.fin-summary-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
  opacity: 0.75;
}

.fin-summary-value {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 3px;
}

.fin-summary-sub {
  font-size: 11px;
  opacity: 0.65;
}

/* Color variants */
.fin-card-blue {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.fin-card-green {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #15803d;
}

.fin-card-purple {
  background: #f5f3ff;
  border-color: #ddd6fe;
  color: #7c3aed;
}

.fin-card-red {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
}

.fin-card-orange {
  background: #fffbeb;
  border-color: #fde68a;
  color: #d97706;
}

/* Dark mode */
body.dark-theme .fin-card-blue {
  background: #1e3a5f;
  border-color: #1d4ed8;
  color: #93c5fd;
}
body.dark-theme .fin-card-green {
  background: #14532d;
  border-color: #15803d;
  color: #86efac;
}
body.dark-theme .fin-card-purple {
  background: #2e1065;
  border-color: #7c3aed;
  color: #c4b5fd;
}
body.dark-theme .fin-card-red {
  background: #450a0a;
  border-color: #dc2626;
  color: #fca5a5;
}

/* ── X. CUSTOM SELECT UI (From Image Style) ────────────────────────────── */
.custom-select-wrapper {
  position: relative;
  display: inline-block;
  min-width: 150px;
  width: auto;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background-color: var(--bg-panel);
  border: 1px solid var(--bdr);
  border-radius: 12px;
  font-size: 13px;
  font-family: 'Noto Sans Thai Looped', Arial, sans-serif;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  height: 38px;
  box-sizing: border-box;
}

.custom-select-trigger:hover {
  background-color: var(--bg-main);
  border-color: var(--bdr-focus);
}

.custom-select-trigger.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 155, 83, 0.15);
}

.custom-select-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 8px;
}

.custom-select-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: max-content;
  min-width: 100%;
  background-color: var(--bg-panel);
  border-radius: 16px;
  border: 1px solid var(--bdr);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
  padding: 8px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 300px;
  overflow-y: auto;
}

body.dark-theme .custom-select-menu {
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.custom-select-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.custom-select-option {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-family: 'Noto Sans Thai Looped', Arial, sans-serif;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.custom-select-option:hover {
  background-color: var(--bg-main);
  color: var(--primary);
}

.custom-select-option.selected {
  background-color: rgba(2, 155, 83, 0.1);
  color: var(--primary);
  font-weight: 600;
}

/* ── Shared operational system polish ─────────────────────────────────── */
.btn-login, .btn-primary, .btn-secondary, .btn-danger, .btn-action {
  border-radius: var(--radius-control);
  transition: background-color var(--motion-fast) ease, border-color var(--motion-fast) ease,
              color var(--motion-fast) ease, box-shadow var(--motion-fast) ease,
              transform var(--motion-fast) ease;
}

.btn-primary:focus-visible, .btn-secondary:focus-visible, .btn-danger:focus-visible,
.btn-action:focus-visible, .btn-login:focus-visible, .form-input:focus-visible,
.filter-select:focus-visible, .filter-search:focus-visible, .menu-item:focus-visible,
.modal-tab-btn:focus-visible, .doc-cat-tab:focus-visible, .btn-close:focus-visible,
.btn-theme-toggle:focus-visible, .pub-btn-reset:focus-visible, .pub-search-clear:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.kpi-card { border-radius: var(--radius-card); }
.panel, .progress-section, .custom-select-menu { border-radius: var(--radius-panel); }
.modal-box { border-radius: var(--radius-panel); }
.status-badge, .db-remain-badge { border-radius: var(--radius-compact); }

#docUploadBar.upload-progress-bar {
  height: 6px;
  border-radius: 99px;
  background: var(--primary);
  transform: scaleX(var(--upload-progress, 0));
  transform-origin: left center;
  transition: transform var(--motion-standard) var(--ease-standard);
}

.icon-danger { color: var(--late-ring); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.filter-bar--scoped {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  align-items: end;
  gap: var(--spacing-lg, 16px);
  margin-bottom: var(--spacing-xl, 20px);
  padding: var(--spacing-lg, 16px);
  border: 1px solid var(--bdr);
  border-radius: var(--radius-card);
  background: var(--surface-muted);
}

.filter-bar--scoped .filter-field {
  min-width: 0;
}

.filter-bar--scoped .filter-select,
.filter-bar--scoped .filter-input {
  width: 100%;
  min-height: 38px;
  border-radius: var(--radius-control);
}

.filter-bar--scoped .filter-btn-container {
  display: flex;
  align-items: end;
}

.btn-reset {
  min-width: 38px;
  min-height: 38px;
  padding: 8px;
}

body.dark-theme .filter-bar--scoped {
  background: var(--surface-muted);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
.report-history-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

/* ── Admin action queue ──────────────────────────────────────────────── */
.admin-action-queue {
  margin-top: 24px;
  overflow: hidden;
}

.admin-action-queue[hidden] {
  display: none;
}

.admin-action-queue__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 24px 12px;
}

.admin-action-queue__header .panel-title {
  margin: 0;
  font-size: 16px;
}

.admin-action-queue__search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(380px, 100%);
  padding: 0 12px;
  border: 1px solid var(--bdr);
  border-radius: var(--radius-control);
  background: var(--bg-panel);
  color: var(--text-sub);
  transition: border-color var(--motion-fast) ease, box-shadow var(--motion-fast) ease;
}

.admin-action-queue__search:focus-within {
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

.admin-action-queue__search input {
  width: 100%;
  min-height: 44px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text-main);
  font: inherit;
}

.admin-action-queue__search input::placeholder {
  color: var(--text-sub);
}

.admin-action-queue__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 24px 16px;
}

.admin-task-filter {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--bdr);
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  color: var(--text-sub);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: border-color var(--motion-fast) ease, background-color var(--motion-fast) ease,
              color var(--motion-fast) ease, box-shadow var(--motion-fast) ease;
}

.admin-task-filter strong {
  min-width: 24px;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--bg-panel);
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.admin-task-filter:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

.admin-task-filter[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-hover);
}

.admin-task-filter[aria-pressed="true"] strong {
  background: var(--primary);
  color: #ffffff;
}

.admin-task-filter:focus-visible,
.admin-task-action:focus-visible {
  outline: 0;
  box-shadow: var(--focus-ring);
}

.admin-action-queue__summary {
  margin: 0;
  padding: 0 24px 12px;
  color: var(--text-sub);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.admin-action-queue__table-wrap {
  overflow-x: auto;
}

.admin-action-queue__table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.admin-action-queue__table th,
.admin-action-queue__table td {
  padding: 14px 16px;
  border-top: 1px solid var(--bdr);
  text-align: left;
  vertical-align: top;
}

.admin-action-queue__table th {
  background: var(--surface-muted);
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.admin-action-queue__table th:nth-child(1) { width: 120px; }
.admin-action-queue__table th:nth-child(2) { width: 21%; }
.admin-action-queue__table th:nth-child(3) { width: 23%; }
.admin-action-queue__table th:nth-child(4) { width: 17%; }
.admin-action-queue__table th:nth-child(5) { width: 140px; }
.admin-action-queue__table th:nth-child(6) { width: 155px; }

.admin-action-queue__table tbody tr {
  transition: background-color var(--motion-fast) ease;
}

.admin-action-queue__table tbody tr:hover {
  background: var(--surface-muted);
}

.admin-task-priority {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}

.admin-task-priority--urgent { color: var(--late-tx); }
.admin-task-priority--upcoming { color: var(--progress-tx); }
.admin-task-priority--backlog { color: var(--todo-tx); }

.admin-task-type,
.admin-task-id,
.admin-task-department,
.admin-task-owner,
.admin-task-remaining {
  display: block;
}

.admin-task-type,
.admin-task-id,
.admin-task-department {
  margin-top: 4px;
  color: var(--text-sub);
  font-size: 12px;
}

.admin-task-name {
  display: block;
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.45;
}

.admin-task-reason {
  margin: 0;
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.5;
}

.admin-task-owner {
  color: var(--text-main);
  font-size: 12px;
}

.admin-task-deadline time,
.admin-task-deadline > span:first-child,
.admin-task-card__deadline time,
.admin-task-card__deadline > span:first-child {
  color: var(--text-main);
  font-size: 12px;
  white-space: nowrap;
}

.admin-task-remaining {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.admin-task-remaining--urgent { color: var(--late-tx); }
.admin-task-remaining--upcoming { color: var(--progress-tx); }
.admin-task-remaining--backlog { color: var(--text-sub); }

.admin-task-actions {
  display: grid;
  gap: 7px;
}

.admin-task-action {
  min-height: 44px;
  padding: 8px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.admin-task-action:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.admin-action-queue__mobile {
  display: none;
}

.admin-task-card {
  border: 1px solid var(--bdr);
  border-radius: var(--radius-card);
  background: var(--bg-panel);
}

.admin-action-queue__pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--bdr);
  color: var(--text-sub);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.admin-action-queue__empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 36px 24px;
  color: var(--text-sub);
  text-align: center;
}

.admin-action-queue__empty > svg {
  width: 28px;
  height: 28px;
  color: var(--primary);
}

.admin-action-queue__empty strong {
  color: var(--text-main);
}

.budget-revision-modal-box {
  width: min(960px, calc(100vw - 32px));
  max-width: 960px;
}

.budget-revision-editor {
  display: grid;
  gap: 18px;
}

.budget-revision-guidance,
.budget-revision-warning {
  padding: 12px 14px;
  border: 1px solid var(--bdr);
  border-radius: var(--radius-control);
  background: var(--surface-muted);
  color: var(--text-sub);
  font-size: 13px;
  line-height: 1.6;
}

.budget-revision-warning {
  border-color: var(--progress-ring);
  color: var(--text-main);
}

.budget-revision-rows {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.budget-revision-row {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(140px, 1fr) minmax(140px, 1fr) minmax(120px, auto);
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--bdr);
  border-radius: var(--radius-control);
  background: var(--bg-panel);
}

.budget-revision-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.budget-revision-field label,
.budget-revision-actual span {
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 600;
}

.budget-revision-actual {
  min-height: 44px;
  align-content: center;
  padding: 8px 10px;
  border-radius: var(--radius-control);
  background: var(--surface-muted);
}

.budget-revision-actual strong {
  color: var(--primary);
  font-size: 14px;
}

.budget-revision-delete {
  display: grid;
  gap: 4px;
}

.budget-revision-delete button,
.budget-revision-add,
.budget-revision-actions button {
  min-height: 44px;
}

.budget-revision-delete small {
  max-width: 150px;
  color: var(--danger-strong);
  font-size: 11px;
  line-height: 1.35;
}

.budget-revision-add {
  margin-top: 12px;
}

.budget-revision-empty {
  padding: 24px;
  border: 1px dashed var(--bdr);
  border-radius: var(--radius-control);
  color: var(--text-sub);
  text-align: center;
}

.budget-revision-validation {
  padding: 12px 14px;
  border: 1px solid var(--danger-strong);
  border-radius: var(--radius-control);
  background: var(--danger-surface);
  color: var(--danger-strong);
}

.budget-revision-validation:focus {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.budget-revision-validation ul {
  margin: 6px 0 0 20px;
}

.budget-revision-totals {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--bdr);
  border-radius: var(--radius-control);
  background: var(--bg-panel);
  box-shadow: var(--shadow-sm);
}

.budget-revision-totals > div {
  display: grid;
  gap: 4px;
}

.budget-revision-totals span {
  color: var(--text-sub);
  font-size: 12px;
}

.budget-revision-totals strong {
  color: var(--text-main);
  font-size: 16px;
}

#budgetRevisionDifference[data-state="increase"] {
  color: var(--danger-strong);
}

#budgetRevisionDifference[data-state="decrease"] {
  color: var(--primary);
}

.budget-revision-review h4 {
  margin: 0 0 12px;
  color: var(--text-main);
}

.budget-revision-review h4:focus {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

.budget-revision-change-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.budget-revision-change-list li {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-control);
  background: var(--surface-muted);
}

.budget-revision-change-list li span {
  color: var(--text-sub);
  font-size: 12px;
}

.budget-revision-change-list li strong {
  overflow-wrap: anywhere;
  color: var(--text-main);
  font-size: 13px;
}

.budget-revision-transfer {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.budget-history-modal-box,
.budget-snapshot-modal-box {
  width: min(820px, calc(100vw - 32px));
  max-width: 820px;
}

.budget-history-timeline {
  display: grid;
  gap: 14px;
}

.budget-history-card {
  padding: 16px;
  border: 1px solid var(--bdr);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-control);
  background: var(--bg-panel);
}

.budget-history-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.budget-history-card__header > div {
  display: grid;
  gap: 3px;
}

.budget-history-card__header strong {
  color: var(--text-main);
  font-size: 16px;
}

.budget-history-card__header span,
.budget-history-meta dt {
  color: var(--text-sub);
  font-size: 12px;
}

.budget-history-card__header button {
  min-height: 44px;
}

.budget-history-meta {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
}

.budget-history-meta > div {
  display: grid;
  grid-template-columns: 145px minmax(0, 1fr);
  gap: 12px;
}

.budget-history-meta dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text-main);
  font-size: 13px;
}

.budget-history-meta dd[data-state="increase"] {
  color: var(--danger-strong);
}

.budget-history-meta dd[data-state="decrease"] {
  color: var(--primary);
}

.budget-history-empty {
  padding: 28px 16px;
  color: var(--text-sub);
  text-align: center;
}

.budget-snapshot-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-control);
  background: var(--surface-muted);
}

.budget-snapshot-summary span {
  color: var(--text-sub);
}

.budget-snapshot-summary strong {
  color: var(--primary);
}

.budget-snapshot-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--bdr);
  border-radius: var(--radius-control);
}

.budget-snapshot-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 580px;
}

.budget-snapshot-table th,
.budget-snapshot-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--bdr);
  color: var(--text-main);
  text-align: left;
}

.budget-snapshot-table th {
  background: var(--surface-muted);
  color: var(--text-sub);
  font-size: 12px;
}

.budget-snapshot-table tr:last-child td {
  border-bottom: 0;
}

.budget-snapshot-table .number-cell {
  text-align: right;
  white-space: nowrap;
}

body.dark-theme .budget-revision-row,
body.dark-theme .budget-revision-totals {
  background: var(--bg-panel);
}

body.dark-theme .admin-action-queue__search,
body.dark-theme .admin-task-card {
  background: var(--bg-panel);
}

@media (max-width: 768px) {
  .budget-revision-modal-box {
    width: calc(100vw - 16px);
  }

  .budget-revision-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .budget-revision-delete small {
    max-width: none;
  }

  .budget-revision-totals {
    position: static;
    grid-template-columns: 1fr;
  }

  .budget-revision-change-list li {
    grid-template-columns: 1fr;
  }

  .budget-revision-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .budget-revision-actions button {
    width: 100%;
  }

  .budget-history-modal-box,
  .budget-snapshot-modal-box {
    width: calc(100vw - 16px);
  }

  .budget-history-card {
    padding: 14px;
  }

  .budget-history-card__header,
  .budget-snapshot-summary {
    align-items: stretch;
    flex-direction: column;
  }

  .budget-history-card__header button {
    width: 100%;
  }

  .budget-history-meta > div {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .admin-action-queue__header {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
    padding: 18px 16px 12px;
  }

  .admin-action-queue__search {
    width: 100%;
  }

  .admin-action-queue__filters {
    display: grid;
    grid-template-columns: 1fr;
    padding: 0 16px 14px;
  }

  .admin-task-filter {
    width: 100%;
    border-radius: var(--radius-control);
  }

  .admin-action-queue__summary {
    padding: 0 16px 12px;
  }

  .admin-action-queue__table-wrap {
    display: none;
  }

  .admin-action-queue__mobile {
    display: grid;
    gap: 12px;
    padding: 0 16px 16px;
  }

  .admin-task-card {
    display: grid;
    gap: 10px;
    padding: 16px;
  }

  .admin-task-card__top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
  }

  .admin-task-card__top .admin-task-type {
    margin: 0;
  }

  .admin-task-card__deadline {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-control);
    background: var(--surface-muted);
  }

  .admin-task-card__deadline .admin-task-remaining {
    margin: 0;
  }

  .admin-task-card__meta {
    display: grid;
    gap: 8px;
    margin: 0;
  }

  .admin-task-card__meta div {
    display: grid;
    grid-template-columns: 95px minmax(0, 1fr);
    gap: 8px;
  }

  .admin-task-card__meta dt {
    color: var(--text-sub);
    font-size: 12px;
  }

  .admin-task-card__meta dd {
    margin: 0;
    color: var(--text-main);
    font-size: 12px;
  }

  .admin-task-card .admin-task-actions {
    grid-template-columns: 1fr;
  }

  .admin-task-card .admin-task-action {
    width: 100%;
  }

  .admin-action-queue__pagination {
    justify-content: center;
    padding: 14px 16px;
  }
}
