/* ═══════════════════════════════════════════════════════════
   TDH KPI System — Main Stylesheet
   Font: Prompt | Bootstrap 5.3 + Custom TDH Design
   อ้างอิง design จาก tdh_portal
   ═══════════════════════════════════════════════════════════ */

:root {
  --tdh-primary:     #0d47a1;
  --tdh-primary-dk:  #0a3880;
  --tdh-accent:      #1976d2;
  --tdh-light:       #e3f2fd;
  --tdh-bg:          #f0f4f8;
  --tdh-text:        #1a202c;
  --tdh-muted:       #64748b;
  --tdh-border:      rgba(0,0,0,.08);
  --tdh-card-shadow: 0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.04);

  --sidebar-width:   250px;
  --topbar-height:   54px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Prompt', sans-serif;
  background: var(--tdh-bg);
  color: var(--tdh-text);
  font-size: 14px;
  line-height: 1.6;
}

/* ── Sidebar ─────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  flex-shrink: 0;
  background: var(--tdh-primary);
  transition: width .25s ease;
  display: flex;
  flex-direction: column;
}
#sidebar.collapsed { width: 0; overflow: hidden; }

.sidebar-brand {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.12);
  display: flex;
  align-items: center;
  gap: .625rem;
}
.sidebar-brand-icon {
  width: 34px; height: 34px;
  background: rgba(255,255,255,.2);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #fff; flex-shrink: 0;
}
.sidebar-brand-text {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  letter-spacing: .3px;
}

.sidebar-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,.4);
  padding: 14px 20px 4px;
  white-space: nowrap;
}

#sidebar .nav-link {
  color: rgba(255,255,255,.72);
  border-radius: 8px;
  margin: 2px 10px;
  padding: 8px 12px;
  font-size: 13.5px;
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
#sidebar .nav-link i {
  font-size: 15px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
#sidebar .nav-link:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
}
#sidebar .nav-link.active {
  background: rgba(255,255,255,.18);
  color: #fff;
  font-weight: 500;
}

.sidebar-footer {
  padding: .875rem 1.125rem;
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: 12.5px;
  color: rgba(255,255,255,.55);
  white-space: nowrap;
}

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--tdh-border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: .75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  position: sticky;
  top: 0;
  z-index: 100;
}
#sidebarToggle {
  color: var(--tdh-muted);
  border: none;
  background: none;
  padding: .35rem;
  border-radius: 6px;
  line-height: 1;
  transition: background .15s;
}
#sidebarToggle:hover { background: var(--tdh-light); color: var(--tdh-primary); }
#sidebarToggle i { font-size: 20px; }

.topbar-breadcrumb { flex: 1; }
.topbar-breadcrumb .breadcrumb { margin: 0; }
.topbar-breadcrumb .breadcrumb-item { font-size: 13px; }
.topbar-breadcrumb .breadcrumb-item a { color: var(--tdh-accent); text-decoration: none; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: .625rem;
}
.user-avatar-sm {
  width: 30px; height: 30px;
  background: var(--tdh-light);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  color: var(--tdh-primary);
  font-weight: 600;
  flex-shrink: 0;
}
.topbar-username {
  font-size: 13px;
  font-weight: 500;
  color: var(--tdh-text);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Main content ────────────────────────────────────────── */
.main-content { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.page-content { flex: 1; padding: 1.5rem; }

/* ── Page header ─────────────────────────────────────────── */
.page-header { margin-bottom: 1.25rem; }
.page-header h5 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  color: var(--tdh-text);
}
.page-header .subtitle { font-size: 13px; color: var(--tdh-muted); margin: .2rem 0 0; }

/* ── Flash alert ─────────────────────────────────────────── */
.flash-area { padding: .75rem 1.5rem 0; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  border: 1px solid var(--tdh-border) !important;
  border-radius: 12px !important;
  box-shadow: var(--tdh-card-shadow) !important;
}
.card-header {
  background: #fff;
  border-bottom: 1px solid var(--tdh-border);
  padding: .875rem 1.125rem;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 12px 12px 0 0 !important;
}

/* Stat cards */
.stat-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--tdh-border);
  box-shadow: var(--tdh-card-shadow);
  padding: 1.1rem 1.25rem;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.stat-icon {
  width: 46px; height: 46px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-icon.primary  { background: #e8eeff; color: var(--tdh-primary); }
.stat-icon.success  { background: #d1fae5; color: #065f46; }
.stat-icon.info     { background: #dbeafe; color: #1e40af; }
.stat-icon.warning  { background: #fef3c7; color: #92400e; }
.stat-label { font-size: 11px; color: var(--tdh-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--tdh-primary); line-height: 1.2; }

/* ── Tables ──────────────────────────────────────────────── */
.table {
  font-size: 13.5px;
}
.table thead th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--tdh-muted);
  padding: .65rem 1rem;
  background: #f8fafc;
  border-bottom: 2px solid var(--tdh-border) !important;
  white-space: nowrap;
}
.table tbody td {
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--tdh-border);
  vertical-align: middle;
  font-size: 13.5px;
}
.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover td { background: #f8fafc; }
.card > .table-responsive { padding: 0 1rem 1rem; }

/* ── Forms ───────────────────────────────────────────────── */
.form-label {
  font-size: 12.5px;
  font-weight: 500;
  color: #374151;
  margin-bottom: .3rem;
}
.form-control, .form-select {
  font-size: 13.5px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: .45rem .75rem;
  font-family: 'Prompt', sans-serif;
  transition: border-color .15s, box-shadow .15s;
  min-width: 90px;
 /* text-align: center;*/
}

.form-control:focus, .form-select:focus {
  border-color: var(--tdh-accent);
  box-shadow: 0 0 0 3px rgba(25,118,210,.12);
}
.form-control::placeholder { color: #9ca3af; font-size: 13px; }
.input-group-text {
  font-size: 13.5px;
  background: #f8fafc;
  border-color: #d1d5db;
  font-family: 'Prompt', sans-serif;
}
.input-group .form-control:focus { z-index: 3; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  font-family: 'Prompt', sans-serif;
  font-weight: 500;
  border-radius: 8px;
}
.btn-primary {
  background: var(--tdh-primary);
  border-color: var(--tdh-primary);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--tdh-primary-dk);
  border-color: var(--tdh-primary-dk);
}
.btn-sm {
  font-size: 12px;
  padding: .3rem .7rem;
  border-radius: 6px;
}
.btn-outline-primary  { color: var(--tdh-primary); border-color: var(--tdh-primary); }
.btn-outline-primary:hover { background: var(--tdh-primary); border-color: var(--tdh-primary); }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  font-family: 'Prompt', sans-serif;
  font-weight: 500;
  font-size: 11px;
  border-radius: 5px;
  padding: 3px 8px;
}
.badge-dept {
  background: var(--tdh-light);
  color: var(--tdh-primary);
  border-radius: 5px;
  padding: 2px 9px;
  font-size: 11.5px;
  font-weight: 500;
}

/* Grade badges */
.badge-grade-a { background: #d1fae5; color: #065f46; }
.badge-grade-b { background: #dbeafe; color: #1e40af; }
.badge-grade-c { background: #fef3c7; color: #92400e; }
.badge-grade-d { background: #fee2e2; color: #991b1b; }

/* Status badges */
.badge-open   { background: #d1fae5; color: #065f46; }
.badge-draft  { background: #fef3c7; color: #92400e; }
.badge-closed { background: #f3f4f6; color: #374151; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-content {
  border: none !important;
  border-radius: 12px !important;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-header {
  background: var(--tdh-primary);
  color: #fff;
  border-radius: 12px 12px 0 0 !important;
  padding: .875rem 1.125rem;
  border-bottom: none !important;
}
.modal-header .modal-title { font-size: 15px; font-weight: 600; }
.modal-header .btn-close { filter: invert(1) brightness(2); opacity: .8; }
.modal-footer {
  border-top: 1px solid var(--tdh-border);
  padding: .875rem 1.125rem;
  border-radius: 0 0 12px 12px !important;
}

/* ── Alert ───────────────────────────────────────────────── */
.alert { border: none; border-radius: 10px; font-size: 13.5px; }

/* ── Login page ──────────────────────────────────────────── */
.login-page {
  background: linear-gradient(135deg, var(--tdh-primary) 0%, var(--tdh-accent) 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  border-radius: 16px !important;
  border: none !important;
  box-shadow: 0 24px 80px rgba(0,0,0,.25) !important;
  overflow: hidden;
  width: 100%;
  max-width: 420px;
}
.login-logo-icon {
  width: 60px; height: 60px;
  background: rgba(255,255,255,.18);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: #fff;
  margin: 0 auto .875rem;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,.25);
}
.login-header {
  background: linear-gradient(135deg, var(--tdh-primary), var(--tdh-accent));
  padding: 2rem 1.75rem 1.5rem;
  text-align: center;
}
.login-header h4 { color: #fff; font-weight: 700; font-size: 20px; margin: 0; }
.login-header p  { color: rgba(255,255,255,.75); font-size: 13px; margin: .3rem 0 0; }
.login-body { padding: 1.75rem; }
.login-footer { background: #f8fafc; padding: .875rem; text-align: center; font-size: 12px; color: var(--tdh-muted); }

/* ── Progress bar mini ───────────────────────────────────── */
.progress { border-radius: 4px; }
.progress-bar { border-radius: 4px; }

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

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — Mobile First
   ══════════════════════════════════════════════════════════ */

/* Sidebar overlay (mobile) */
#sidebarOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 998;
}
#sidebarOverlay.show { display: block; }

/* ── Mobile (< 768px) ────────────────────────────────────── */
@media (max-width: 767.98px) {
  /* Sidebar slides in from left as overlay */
  #sidebar {
    position: fixed;
    z-index: 999;
    height: 100dvh;
    top: 0; left: 0;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform .25s ease;
    overflow-y: auto;
    overflow-x: hidden;
  }
  #sidebar.open {
    transform: translateX(0);
  }
  /* Main always full-width on mobile */
  .main-content { width: 100%; }

  .page-content { padding: .875rem .75rem; }
  .topbar { padding: 0 .75rem; gap: .5rem; }

  /* Topbar breadcrumb smaller */
  .topbar-breadcrumb .breadcrumb-item { font-size: 12px; }

  /* Stat cards: 2 per row */
  .stat-card { padding: .875rem 1rem; }
  .stat-icon { width: 38px; height: 38px; font-size: 17px; }
  .stat-value { font-size: 22px; }
  .stat-label { font-size: 10px; }

  /* Tables: horizontal scroll + compact */
  .table { font-size: 12.5px; }
  .table thead th { padding: .5rem .75rem; font-size: 10px; }
  .table tbody td { padding: .55rem .75rem; font-size: 12.5px; }

  /* Cards */
  .card-header { padding: .75rem 1rem; font-size: 13px; }

  /* Modal full-screen on small */
  .modal-dialog { margin: 0; max-width: 100%; }
  .modal-content { border-radius: 0 !important; min-height: 100dvh; }
  .modal-header { border-radius: 0 !important; }
  .modal-footer { border-radius: 0 !important; position: sticky; bottom: 0; background: #fff; }

  /* Flash */
  .flash-area { padding: .5rem .75rem 0; }

  /* Hide topbar username text */
  .topbar-username { display: none; }

  /* Tab nav scroll horizontally */
  .nav-tabs { flex-wrap: nowrap; overflow-x: auto; }
  .nav-tabs .nav-link { white-space: nowrap; }

  /* Buttons in card headers stack if needed */
  .card-header .d-flex { flex-wrap: wrap; gap: .375rem !important; }
}

/* ── Small mobile (< 480px) ──────────────────────────────── */
@media (max-width: 479.98px) {
  .page-content { padding: .625rem .5rem; }
  .stat-value { font-size: 20px; }
  /* 1 column stat cards */
  .col-sm-6 { width: 50%; }
  /* Breadcrumb — show only active */
  .breadcrumb-item:not(.active) { display: none; }
  .breadcrumb-item.active::before { display: none; }
}

/* ── Tablet (768px – 991px) ──────────────────────────────── */
@media (min-width: 768px) and (max-width: 991.98px) {
  :root { --sidebar-width: 210px; }
  .page-content { padding: 1.25rem 1rem; }
  .stat-value { font-size: 24px; }
}

/* ── Desktop (≥ 992px) — sidebar always visible ──────────── */
@media (min-width: 992px) {
  #sidebar {
    transform: none !important;
    position: sticky;
    top: 0;
    height: 100vh;
    align-self: flex-start;
  }
  #sidebar.collapsed { width: 0; overflow: hidden; }
}

/* ── SweetAlert2 overrides ───────────────────────────────── */
.tdh-swal-popup { font-family: 'Prompt', sans-serif !important; border-radius: 14px !important; }
.swal2-title    { font-family: 'Prompt', sans-serif !important; font-size: 18px !important; font-weight: 600 !important; }
.swal2-html-container, .swal2-content { font-family: 'Prompt', sans-serif !important; font-size: 14px !important; }
.swal2-confirm, .swal2-cancel { font-family: 'Prompt', sans-serif !important; border-radius: 8px !important; font-weight: 500 !important; }

/* ── KPI Result page ─────────────────────────────────────── */
.result-stat-card {
  background: #fff;
  border: 1px solid var(--tdh-border);
  border-radius: 10px;
  padding: .875rem 1rem;
  text-align: center;
}
.result-stat-icon {
  width: 38px; height: 38px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  margin: 0 auto .5rem;
}
.result-stat-val  { font-size: 22px; font-weight: 700; line-height: 1.2; }
.result-stat-lbl  { font-size: 11px; color: var(--tdh-muted); margin-top: .2rem; }

.grade-mini-bar   { display: flex; gap: .375rem; justify-content: center; flex-wrap: wrap; min-height: 32px; align-items: center; }
.grade-mini-item  { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.grade-mini-count { font-size: 11px; font-weight: 600; color: var(--tdh-text); }

.dept-header-row td { background: #f8fafc !important; padding: .5rem 1rem; }

.user-avatar-lg {
  width: 48px; height: 48px;
  background: var(--tdh-light);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--tdh-primary); font-weight: 700;
  flex-shrink: 0;
}

/* ── Rating Scale Grid ───────────────────────────────────── */
.scale-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .625rem;
}
.scale-item {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid transparent;
}
.scale-header {
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  padding: .5rem .75rem;
  line-height: 1.4;
}
.scale-value {
  text-align: center;
  padding: .375rem .5rem;
  font-size: 13px;
  font-weight: 500;
 /* font-family: monospace;*/
  background: rgba(255,255,255,.6);
}
.scale-hint {
  text-align: center;
  font-size: 11px;
  padding: .3rem .5rem .5rem;
  opacity: .85;
}
.scale-1 { background: #fff5f5; border-color: #fecaca; }
.scale-1 .scale-header { background: #dc3545; color: #fff; }
.scale-1 .scale-hint   { color: #991b1b; }
.scale-2 { background: #fffbeb; border-color: #fde68a; }
.scale-2 .scale-header { background: #f59e0b; color: #fff; }
.scale-2 .scale-hint   { color: #92400e; }
.scale-3 { background: #eff6ff; border-color: #bfdbfe; }
.scale-3 .scale-header { background: #0dcaf0; color: #fff; }
.scale-3 .scale-hint   { color: #075985; }
.scale-4 { background: #eff6ff; border-color: #bfdbfe; }
.scale-4 .scale-header { background: #0d6efd; color: #fff; }
.scale-4 .scale-hint   { color: #1e40af; }
.scale-5 { background: #f0fdf4; border-color: #bbf7d0; }
.scale-5 .scale-header { background: #198754; color: #fff; }
.scale-5 .scale-hint   { color: #065f46; }

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

/* ── Role & Permission Page ───────────────────────────────── */
.role-overview-card { transition: box-shadow .2s; }
.role-overview-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.10) !important; }

/* Row accent by role */
.role-row-admin    td:first-child { border-left: 3px solid #ef4444; }
.role-row-manager  td:first-child { border-left: 3px solid #f59e0b; }
.role-row-employee td:first-child { border-left: 3px solid #3b82f6; }
.role-row-none     td:first-child { border-left: 3px solid transparent; }

/* Action buttons */
.role-action-btn {
  width: 30px; height: 30px;
  border-radius: 8px; border: 1px solid transparent;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 13px;
  transition: background .15s, color .15s, border-color .15s;
  background: transparent; padding: 0;
  flex-shrink: 0;
}
.role-action-edit  { color: #3b82f6; border-color: #bfdbfe; background: #eff6ff; }
.role-action-edit:hover  { background: #3b82f6; color: #fff; border-color: #3b82f6; }
.role-action-reset { color: #ef4444; border-color: #fecaca; background: #fef2f2; }
.role-action-reset:hover { background: #ef4444; color: #fff; border-color: #ef4444; }
.role-action-placeholder { visibility: hidden; pointer-events: none; }

.role-icon-circle {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}

.perm-dot {
  font-size: 13px;
  opacity: .85;
  cursor: default;
}

/* Role select cards in modal */
.role-select-card { cursor: pointer; }
.role-select-inner {
  border-color: #e2e8f0 !important;
  background: #f8fafc;
  transition: all .15s;
}
.role-select-inner:hover { background: #f1f5f9; border-color: #cbd5e1 !important; }
.role-select-inner.role-card-active {
  background: #eff6ff;
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 2px #bfdbfe;
}

/* Permission row in modal */
.perm-row { background: #f8fafc; }
.perm-row:hover { background: #f1f5f9; }
.perm-row-icon { font-size: 15px; width: 20px; text-align: center; }

/* ── KPI Detail Modal Cards ───────────────────────────────── */
.kpi-detail-card {
  border: 1px solid #f1f5f9;
  border-radius: 12px;
  padding: 1rem;
  background: #fff;
}
.kpi-seq {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #475569;
  font-size: 11px;
  font-weight: 700;
  margin-right: .4rem;
  flex-shrink: 0;
}
.kpi-detail-name {
  font-weight: 600;
  font-size: .875rem;
  color: #1e293b;
  line-height: 1.5;
}
.kpi-stat-cell {
  background: #f8fafc;
  border-radius: 8px;
  padding: .625rem .5rem;
  text-align: center;
}
.kpi-stat-cell .kv {
  font-weight: 700;
  font-size: .875rem;
  color: #334155;
}
.kpi-stat-cell .kl {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
}
.kpi-status-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  padding: .2rem .65rem;
  border-radius: 999px;
  border: 1px solid;
  white-space: nowrap;
}
.kpi-status-none { background:#f8fafc; color:#94a3b8; border-color:#e2e8f0; }
.kpi-status-1    { background:#fff5f5; color:#dc3545; border-color:#fca5a5; }
.kpi-status-2    { background:#fffbeb; color:#d97706; border-color:#fcd34d; }
.kpi-status-3    { background:#eff6ff; color:#0284c7; border-color:#bae6fd; }
.kpi-status-4    { background:#eef2ff; color:#4f46e5; border-color:#c7d2fe; }
.kpi-status-5    { background:#f0fdf4; color:#16a34a; border-color:#bbf7d0; }

/* ── Completion Ring (Dashboard) ─────────────────────────── */
.completion-ring {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: conic-gradient(#198754 var(--pct), #e9ecef 0);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.completion-ring-inner {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* ── Pending section card (Dashboard) ────────────────────── */
.dash-pending-card {
  border-left: 3px solid #ffc107 !important;
  transition: box-shadow .15s;
}
.dash-pending-card:hover {
  box-shadow: 0 4px 16px rgba(255,193,7,.15) !important;
}
.dash-pending-border {
  border-left: 3px solid #ffc107 !important;
}

/* ── Period Cards (Assessment index) ─────────────────────── */
.period-card {
  display: block;
  background: #fff;
  border: 2px solid var(--tdh-border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  cursor: pointer;
  transition: border-color .18s, box-shadow .18s, transform .12s;
  color: var(--tdh-text);
}
.period-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 4px 16px rgba(13,71,161,.10);
  transform: translateY(-2px);
  color: var(--tdh-text);
}
.period-card.selected {
  border-color: var(--tdh-primary);
  box-shadow: 0 0 0 3px rgba(13,71,161,.12), 0 4px 16px rgba(13,71,161,.10);
}
.period-card.open .period-card-title { color: var(--tdh-primary); }
.period-card.draft { background: #fffdf5; border-color: #fcd34d; opacity: .85; }
.period-card.draft:hover { border-color: #f59e0b; opacity: 1; }
.period-card.closed { background: #f9fafb; opacity: .75; }
.period-card.closed:hover { opacity: .9; }
.period-card-title { font-size: .9rem; line-height: 1.3; }
.period-dates { margin-top: .25rem; font-size: 11px; }

/* ── Report Cards (reports landing page) ─────────────────── */
.report-card {
  transition: box-shadow .18s, transform .12s;
  cursor: pointer;
}
.report-card:hover {
  box-shadow: 0 6px 24px rgba(0,0,0,.12) !important;
  transform: translateY(-3px);
}
.report-card-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

/* ── Report Document ──────────────────────────────────────── */
.report-wrapper {
  background: #fff;
  border-radius: 12px;
  padding: 2rem;
  box-shadow: var(--tdh-card-shadow);
}
.report-org-name {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--tdh-muted);
  font-weight: 600;
}
.report-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--tdh-text);
  margin-top: .25rem;
}
.report-divider {
  border-color: var(--tdh-border);
}
.report-info-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--tdh-muted);
  margin-bottom: 2px;
}
.report-info-value {
  font-weight: 600;
  font-size: .9rem;
}
.report-card-section {
  border: 1px solid var(--tdh-border) !important;
}
.report-table th, .report-table td {
  font-size: 12px;
  padding: .5rem .75rem;
}
.report-signature {
  margin-top: 3rem;
}
.report-sig-line {
  height: 1px;
  background: #dee2e6;
  margin-bottom: .5rem;
  margin-left: auto;
  margin-right: auto;
  width: 80%;
}

/* ── ช่องเลือกวันที่ (.fp-date) — ไอคอนปฏิทินในช่อง ────────── */
input.fp-date {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%237a8699'%3E%3Cpath d='M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5zM1 4v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4H1z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  background-size: 15px 15px;
  padding-right: 2.25rem;
  cursor: pointer;
}
input.fp-date:focus { background-image: none; }
/* ── Flatpickr — Prompt font + TDH theme ────────────────── */
.flatpickr-calendar,
.flatpickr-calendar *,
.flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year,
.flatpickr-day,
.flatpickr-weekday {
  font-family: 'Prompt', sans-serif !important;
}
.flatpickr-calendar {
  border: none;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.14);
  padding: 4px;
}
.flatpickr-months {
  background: var(--tdh-primary);
  border-radius: 10px 10px 0 0;
  padding: 4px 0;
}
.flatpickr-months .flatpickr-month { background: transparent; }
.flatpickr-current-month,
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year { color: #fff; fill: #fff; font-size: 14px; font-weight: 500; }
.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month { color: #fff; fill: #fff; padding: 6px 10px; }
.flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-months .flatpickr-next-month:hover { background: rgba(255,255,255,.15); border-radius: 6px; }
.flatpickr-months .flatpickr-prev-month svg,
.flatpickr-months .flatpickr-next-month svg { fill: #fff; }
.flatpickr-weekdays { background: var(--tdh-primary); }
span.flatpickr-weekday { color: rgba(255,255,255,.75); font-size: 11px; font-weight: 500; }
.flatpickr-day {
  border-radius: 8px; font-size: 13px;
  height: 34px; line-height: 34px; max-width: 34px;
  font-weight: 400; color: var(--tdh-text);
}
.flatpickr-day:hover { background: var(--tdh-light); border-color: transparent; }
.flatpickr-day.today { border-color: var(--tdh-primary); color: var(--tdh-primary); font-weight: 600; }
.flatpickr-day.today:hover { background: var(--tdh-light); }
.flatpickr-day.selected,
.flatpickr-day.selected:hover,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
  background: var(--tdh-primary); border-color: var(--tdh-primary); color: #fff; font-weight: 500;
}
.flatpickr-day.inRange {
  background: var(--tdh-light); border-color: var(--tdh-light); color: var(--tdh-primary);
  box-shadow: -5px 0 0 var(--tdh-light), 5px 0 0 var(--tdh-light);
}
.flatpickr-day.flatpickr-disabled,
.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay { color: #c0c8d2; }
.flatpickr-monthDropdown-months { background: var(--tdh-primary); border: none; outline: none; font-size: 14px; }
.flatpickr-monthDropdown-months option { background: var(--tdh-primary); color: #fff; }
.flatpickr-time { border-top: 1px solid #e8edf2; }
.flatpickr-time input,
.flatpickr-time .flatpickr-am-pm { font-size: 14px !important; font-weight: 500; color: var(--tdh-text); }
.flatpickr-time input:hover,
.flatpickr-time .flatpickr-am-pm:hover,
.flatpickr-time input:focus { background: var(--tdh-light); }

/* ── Print styles ─────────────────────────────────────────── */
@media print {
  #sidebar, #sidebarOverlay, .topbar, .btn, .alert,
  .no-print { display: none !important; }
  .main-content { margin: 0 !important; padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
  .report-wrapper { box-shadow: none !important; padding: 0 !important; }
  .report-card-section { border: 1px solid #ccc !important; }
  body { font-size: 12px; }
  .badge { border: 1px solid #ccc !important; }
}

/* ── Dashboard: performers / insight rows ─────────────────── */
.perf-row { border-radius: 8px; transition: background .12s ease; }
.perf-row:hover { background: var(--tdh-light); }
.perf-rank {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; background: var(--tdh-accent);
}
.perf-rank-low { background: #dc3545; }

/* ── Dashboard: sortable table + sticky header ────────────── */
.dash-scroll { max-height: 620px; overflow: auto; }
#resultsTable thead th {
  position: sticky; top: 0; z-index: 2; background: var(--tdh-bg);
}
.sortable-th { cursor: pointer; user-select: none; white-space: nowrap; }
.sortable-th:hover { color: var(--tdh-primary); }
.sortable-th::after { content: '\2195'; opacity: .3; margin-left: 4px; font-size: 10px; }
.sortable-th[data-sorted="asc"]::after  { content: '\2191'; opacity: 1; }
.sortable-th[data-sorted="desc"]::after { content: '\2193'; opacity: 1; }
