/* =========================================================
   WPL Workplace Learning System — UI v3.1
   Mobile-First Enhancement — ตารางไม่ล้น, รองรับสมาร์ทโฟน
   Compatible: PHP 5.6 / Modern Browsers
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700;800&display=swap');

/* ── TOKENS ── */
:root {
  --primary:        #2563eb;
  --primary-dark:   #1e40af;
  --primary-light:  #eff6ff;
  --primary-mid:    #bfdbfe;
  --success:        #16a34a;
  --success-bg:     #f0fdf4;
  --success-mid:    #bbf7d0;
  --warning:        #d97706;
  --warning-bg:     #fffbeb;
  --warning-mid:    #fde68a;
  --danger:         #dc2626;
  --danger-bg:      #fef2f2;
  --danger-mid:     #fecaca;
  --info:           #0891b2;
  --info-bg:        #ecfeff;
  --purple:         #7c3aed;
  --purple-bg:      #f5f3ff;
  --sidebar-w:      260px;
  --topbar-h:       56px;
  --bg:             #f4f6fb;
  --surface:        #ffffff;
  --border:         #e2e8f0;
  --text:           #1e293b;
  --text-muted:     #64748b;
  --text-light:     #94a3b8;
  --radius:         16px;
  --radius-sm:      10px;
  --radius-xs:      6px;
  --shadow:         0 2px 8px rgba(15,23,42,.07), 0 8px 24px rgba(15,23,42,.05);
  --shadow-md:      0 8px 28px rgba(15,23,42,.10);
  --shadow-lg:      0 18px 48px rgba(15,23,42,.13);
  --font:           'Sarabun', 'TH Sarabun New', system-ui, sans-serif;
  --transition:     all .18s ease;
  --content-pad:    20px;
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }

/* ── LAYOUT ── */
.layout { display: -webkit-flex; display: flex; min-height: 100vh; }

/* ── SIDEBAR OVERLAY (mobile) ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(15,23,42,.55);
  z-index: 198;
}
.sidebar-overlay.open { display: block; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: #0f172a;
  color: #e2e8f0;
  display: -webkit-flex; display: flex;
  -webkit-flex-direction: column; flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  -webkit-transition: -webkit-transform .25s ease;
  transition: transform .25s ease;
  overflow: hidden;
}
.sidebar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #06b6d4);
}
.sidebar-brand {
  padding: 0 18px;
  height: var(--topbar-h);
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  -webkit-flex-shrink: 0; flex-shrink: 0;
}
.sidebar-brand .brand-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary), #06b6d4);
  border-radius: 10px;
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  -webkit-justify-content: center; justify-content: center;
  font-size: 17px; -webkit-flex-shrink: 0; flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(37,99,235,.35);
}
.sidebar-brand .brand-name { font-weight: 800; font-size: 13.5px; color: #fff; line-height: 1.2; }
.sidebar-brand .brand-sub  { font-size: 10px; color: #64748b; margin-top: 2px; letter-spacing: .04em; }
.sidebar-user {
  padding: 12px 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  -webkit-flex-shrink: 0; flex-shrink: 0;
}
.sidebar-user .su-name {
  font-weight: 700; font-size: 13px; color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-user .su-role { margin-top: 5px; }
.role-badge {
  display: inline-block;
  padding: 2px 10px; border-radius: 99px;
  font-size: 10px; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase;
}
.role-badge.student  { background: rgba(22,163,74,.2);   color: #86efac; }
.role-badge.advisor  { background: rgba(37,99,235,.25);  color: #93c5fd; }
.role-badge.teacher  { background: rgba(124,58,237,.25); color: #c4b5fd; }
.role-badge.trainer  { background: rgba(217,119,6,.25);  color: #fcd34d; }
.role-badge.company  { background: rgba(8,145,178,.25);  color: #67e8f9; }
.role-badge.admin    { background: rgba(220,38,38,.2);   color: #fca5a5; }
.sidebar-nav {
  -webkit-flex: 1; flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  -webkit-overflow-scrolling: touch;
}
.nav-section {
  padding: 12px 18px 4px;
  font-size: 10px; letter-spacing: .08em;
  text-transform: uppercase; color: #475569; font-weight: 700;
}
.nav-item {
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  gap: 10px;
  padding: 10px 18px; margin: 2px 10px;
  border-radius: 10px;
  color: #94a3b8; text-decoration: none;
  font-size: 13.5px; font-weight: 600;
  -webkit-transition: var(--transition); transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.nav-item .nav-icon { width: 20px; text-align: center; font-size: 16px; -webkit-flex-shrink: 0; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #e2e8f0; text-decoration: none; }
.nav-item.active { background: rgba(37,99,235,.22); color: #93c5fd; font-weight: 700; }
.nav-item .badge-count {
  margin-left: auto;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 1px 7px; border-radius: 99px;
}
.sidebar-footer { padding: 12px 18px; border-top: 1px solid rgba(255,255,255,.07); -webkit-flex-shrink: 0; flex-shrink: 0; }
.sidebar-footer a {
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  gap: 8px; padding: 9px 10px; border-radius: 10px;
  color: #94a3b8; text-decoration: none;
  font-size: 13px; font-weight: 600;
  -webkit-transition: var(--transition); transition: var(--transition);
}
.sidebar-footer a:hover { background: rgba(239,68,68,.12); color: #fca5a5; text-decoration: none; }

/* ── MAIN ── */
.main {
  margin-left: var(--sidebar-w);
  -webkit-flex: 1; flex: 1;
  display: -webkit-flex; display: flex;
  -webkit-flex-direction: column; flex-direction: column;
  min-height: 100vh; min-width: 0;
  overflow-x: hidden;
}

/* ── TOPBAR ── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  padding: 0 18px; gap: 10px;
  position: -webkit-sticky; position: sticky;
  top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(15,23,42,.04);
}
.topbar-hamburger {
  display: none;
  background: var(--primary-light); border: none;
  border-radius: 8px; cursor: pointer;
  color: var(--primary); font-size: 18px;
  padding: 6px 10px; line-height: 1;
  -webkit-flex-shrink: 0; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.topbar-title { font-weight: 800; font-size: 14.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.topbar-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), #06b6d4);
  border-radius: 10px;
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  -webkit-justify-content: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 14px;
  -webkit-flex-shrink: 0; flex-shrink: 0;
}
.term-strip {
  background: var(--primary-light);
  border-bottom: 1px solid var(--primary-mid);
  padding: 6px 18px; font-size: 12px;
  color: var(--primary-dark);
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  gap: 8px; -webkit-flex-wrap: wrap; flex-wrap: wrap;
}

/* ── CONTENT ── */
.content { padding: var(--content-pad); -webkit-flex: 1; flex: 1; }

/* ── PAGE HEADER ── */
.page-header {
  background: linear-gradient(135deg, #0f172a 0%, var(--primary) 60%, #06b6d4 100%);
  border-radius: var(--radius); padding: 20px 24px;
  color: #fff; margin-bottom: 18px;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-md);
}
.page-header::after {
  content: ''; position: absolute;
  right: -50px; top: -60px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  pointer-events: none;
}
.page-header h1 { font-size: 20px; font-weight: 800; margin: 6px 0 4px; position: relative; }
.page-header .sub { font-size: 12.5px; color: rgba(255,255,255,.8); position: relative; }
.page-header .enterprise-mark {
  display: inline-block;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 99px; padding: 3px 11px;
  font-size: 11px; font-weight: 700;
  letter-spacing: .05em; margin-bottom: 5px; position: relative;
}

/* ── GRID ── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

/* ── CARD ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 18px;
  -webkit-transition: var(--transition); transition: var(--transition);
  min-width: 0; overflow: hidden;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  -webkit-justify-content: space-between; justify-content: space-between;
  margin-bottom: 14px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border); gap: 8px;
  -webkit-flex-wrap: wrap; flex-wrap: wrap;
}
.card-header h2 { font-size: 14.5px; font-weight: 800; margin: 0; color: var(--text); }
.card-header .card-actions { display: -webkit-flex; display: flex; gap: 8px; -webkit-flex-shrink: 0; flex-shrink: 0; }
.card h2, .card h3 { margin-top: 0; }

/* ── STAT / KPI CARDS ── */
.enterprise-kpi-row, .stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 14px; margin-bottom: 16px;
}
.enterprise-kpi, .stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  -webkit-transition: var(--transition); transition: var(--transition);
  position: relative; overflow: hidden; min-width: 0;
}
.enterprise-kpi:hover, .stat-card:hover { box-shadow: var(--shadow-md); -webkit-transform: translateY(-2px); transform: translateY(-2px); }
.kpi-top, .stat-header {
  display: -webkit-flex; display: flex;
  -webkit-justify-content: space-between; justify-content: space-between;
  -webkit-align-items: center; align-items: center;
}
.kpi-icon, .stat-icon {
  width: 42px; height: 42px; border-radius: 12px;
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  -webkit-justify-content: center; justify-content: center;
  font-size: 19px; -webkit-flex-shrink: 0; flex-shrink: 0;
}
.stat-icon.blue   { background: var(--primary-light); }
.stat-icon.green  { background: var(--success-bg); }
.stat-icon.orange { background: var(--warning-bg); }
.stat-icon.red    { background: var(--danger-bg); }
.stat-icon.purple { background: var(--purple-bg); }
.kpi-value, .stat-value { font-size: 28px; font-weight: 800; line-height: 1; margin-top: 10px; color: var(--text); }
.kpi-label, .stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-weight: 500; }
.stat-body { -webkit-flex: 1; flex: 1; min-width: 0; }

.enterprise-hero {
  display: grid; grid-template-columns: 1.4fr .85fr;
  gap: 16px; margin-bottom: 16px;
}
.enterprise-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  min-width: 0;
}
.enterprise-panel h2 { font-size: 17px; font-weight: 800; margin-bottom: 8px; color: var(--text); }
.enterprise-panel p  { color: var(--text-muted); line-height: 1.7; }
.enterprise-actions  { display: -webkit-flex; display: flex; gap: 10px; -webkit-flex-wrap: wrap; flex-wrap: wrap; margin-top: 14px; }

/* ── CHIPS / BADGES ── */
.enterprise-chip, .badge {
  display: inline-block;
  padding: 3px 10px; border-radius: 99px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
}
.enterprise-chip        { background: var(--primary-light); color: var(--primary); border: 1px solid var(--primary-mid); }
.enterprise-chip.green  { background: var(--success-bg);   color: var(--success);  border-color: var(--success-mid); }
.enterprise-chip.orange { background: var(--warning-bg);   color: var(--warning);  border-color: var(--warning-mid); }
.enterprise-chip.red    { background: var(--danger-bg);    color: var(--danger);   border-color: var(--danger-mid);  }
.enterprise-chip.dark   { background: #1e293b; color: #e2e8f0; border-color: #334155; }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success, .badge-green  { background: var(--success-bg); color: var(--success); }
.badge-warning, .badge-orange { background: var(--warning-bg); color: var(--warning); }
.badge-danger,  .badge-red    { background: var(--danger-bg);  color: var(--danger);  }
.badge-blue   { background: var(--primary-light); color: var(--primary); }
.badge-gray   { background: #f1f5f9; color: var(--text-muted); }

/* ── STATUS PILL ── */
.status-pill { display: inline-block; padding: 3px 12px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.status-pill.present { background: var(--success-bg); color: var(--success); }
.status-pill.leave   { background: var(--warning-bg); color: var(--warning); }
.status-pill.absent  { background: var(--danger-bg);  color: var(--danger);  }
.status-pill.pending { background: #f1f5f9; color: var(--text-muted); }

/* ── BUTTONS ── */
.btn {
  display: inline-block;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 700;
  cursor: pointer; border: none;
  text-decoration: none;
  -webkit-transition: var(--transition); transition: var(--transition);
  font-family: var(--font);
  white-space: nowrap; text-align: center;
  vertical-align: middle; line-height: 1.4;
  max-width: 100%;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { text-decoration: none; -webkit-transform: translateY(-1px); transform: translateY(-1px); }
.btn-sm { padding: 5px 13px; font-size: 12px; border-radius: 7px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(37,99,235,.28); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 6px 18px rgba(37,99,235,.38); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; color: #fff; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-danger:hover  { background: #b91c1c; color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--border); color: var(--text); }
.btn-white { background: rgba(255,255,255,.2); color: #fff; border: 1px solid rgba(255,255,255,.35); }
.btn-white:hover { background: rgba(255,255,255,.32); color: #fff; }
.btn-block { display: block; width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; -webkit-transform: none; transform: none; }

/* ── FORMS ── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px; font-family: var(--font);
  color: var(--text); background: #fff;
  -webkit-transition: border-color .15s, box-shadow .15s;
  transition: border-color .15s, box-shadow .15s;
  outline: none; -webkit-appearance: none; appearance: none;
  max-width: 100%;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.14); }
.form-control:disabled { background: #f8fafc; color: var(--text-muted); cursor: not-allowed; }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { cursor: pointer; }
.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.location-box {
  background: #f8fafc; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center; gap: 10px;
}
.location-box .loc-icon { font-size: 20px; -webkit-flex-shrink: 0; flex-shrink: 0; }
.location-box .loc-coords { font-size: 12px; color: var(--text-muted); }

/* ── ALERTS ── */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm);
  margin-bottom: 14px; font-size: 13.5px;
  display: -webkit-flex; display: flex;
  -webkit-align-items: flex-start; align-items: flex-start;
  gap: 10px; border: 1px solid transparent;
}
.alert-success { background: var(--success-bg); border-color: var(--success-mid); color: #14532d; }
.alert-danger  { background: var(--danger-bg);  border-color: var(--danger-mid);  color: #7f1d1d; }
.alert-warning { background: var(--warning-bg); border-color: var(--warning-mid); color: #78350f; }
.alert-info    { background: var(--info-bg);    border-color: #a5f3fc;            color: #164e63; }

/* ═══════════════════════════════════════════════════════════
   TABLES — Mobile-Safe
   ตาราง scroll แนวนอนภายใน wrapper ไม่ล้นออกนอก card/หน้า
   ═══════════════════════════════════════════════════════════ */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  max-width: 100%;
  /* แสดง scrollbar บาง ๆ บน WebKit */
}
.table-wrap::-webkit-scrollbar { height: 4px; }
.table-wrap::-webkit-scrollbar-track { background: #f1f5f9; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--primary-mid); border-radius: 99px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th {
  background: #f8fafc; padding: 10px 13px;
  text-align: left; font-weight: 800;
  font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1.5px solid var(--border); white-space: nowrap;
}
td { padding: 10px 13px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { -webkit-transition: background .12s; transition: background .12s; }
tbody tr:hover td { background: #f8fafc; }

/* ── TABS ── */
.tabs {
  display: -webkit-flex; display: flex;
  gap: 0; border-bottom: 2px solid var(--border);
  margin-bottom: 18px; overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 9px 18px; font-size: 13.5px; font-weight: 700;
  color: var(--text-muted); text-decoration: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px; cursor: pointer;
  -webkit-transition: var(--transition); transition: var(--transition);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── PROGRESS ── */
.progress-shell { height: 9px; background: #e2e8f0; border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--primary), #06b6d4); border-radius: 99px; -webkit-transition: width .4s ease; transition: width .4s ease; }

/* ── TIMELINE ── */
.enterprise-timeline { position: relative; padding-left: 20px; }
.etl-item { position: relative; padding-bottom: 14px; }
.etl-item:before { content: ''; position: absolute; left: -13px; top: 14px; bottom: -6px; width: 2px; background: var(--primary-mid); }
.etl-item:last-child:before { display: none; }
.etl-dot { position: absolute; left: -19px; top: 4px; width: 13px; height: 13px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 4px var(--primary-light); }
.etl-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.etl-card b { display: block; color: var(--text); font-size: 13.5px; }
.etl-card span { font-size: 12.5px; color: var(--text-muted); }

/* ── RISK LIST ── */
.risk-list { display: -webkit-flex; display: flex; -webkit-flex-direction: column; flex-direction: column; gap: 10px; }
.risk-item {
  display: -webkit-flex; display: flex; gap: 12px;
  -webkit-align-items: flex-start; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 13px;
  -webkit-transition: var(--transition); transition: var(--transition);
}
.risk-item:hover { border-color: var(--primary-mid); background: var(--primary-light); }
.risk-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--warning-bg);
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  -webkit-justify-content: center; justify-content: center;
  font-size: 17px; -webkit-flex-shrink: 0; flex-shrink: 0;
}

/* ── SIGNATURE BOX ── */
.signature-box {
  border: 2px dashed var(--border); border-radius: var(--radius-sm);
  padding: 16px; text-align: center; min-height: 100px;
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  -webkit-justify-content: center; justify-content: center;
  -webkit-flex-direction: column; flex-direction: column; gap: 8px;
}
.signature-box img { max-height: 80px; }

/* ── TODAY CARD ── */
.today-card {
  background: linear-gradient(135deg, var(--primary) 0%, #1e40af 100%);
  border-radius: var(--radius); padding: 20px;
  color: #fff; position: relative; overflow: hidden;
}
.today-card::after { content: ''; position: absolute; top: -30px; right: -30px; width: 130px; height: 130px; border-radius: 50%; background: rgba(255,255,255,.08); pointer-events: none; }
.today-card .tc-date   { font-size: 12px; opacity: .78; font-weight: 600; }
.today-card .tc-status { font-size: 24px; font-weight: 800; margin: 5px 0 2px; }
.today-card .tc-time   { font-size: 13px; opacity: .82; }
.today-card .tc-actions { display: -webkit-flex; display: flex; gap: 10px; margin-top: 14px; -webkit-flex-wrap: wrap; flex-wrap: wrap; }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); border: 1.5px dashed var(--border); border-radius: var(--radius); background: #f8fafc; }
.empty-state .empty-icon { font-size: 44px; margin-bottom: 10px; }
.empty-state p { font-size: 14px; }

/* ── ENTERPRISE SECTION TITLE ── */
.enterprise-section-title { display: -webkit-flex; display: flex; -webkit-justify-content: space-between; justify-content: space-between; -webkit-align-items: center; align-items: center; margin: 18px 0 10px; -webkit-flex-wrap: wrap; flex-wrap: wrap; gap: 8px; }
.enterprise-section-title h2 { font-size: 17px; font-weight: 800; color: var(--text); }

/* ── SPINNER ── */
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; -webkit-animation: spin .7s linear infinite; animation: spin .7s linear infinite; }
@-webkit-keyframes spin { to { -webkit-transform: rotate(360deg); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── FOOTER ── */
.footer-credit { padding: 14px 20px; text-align: center; font-size: 11.5px; color: var(--text-light); border-top: 1px solid var(--border); margin-top: auto; }

/* ── UTILS ── */
.mt-0{margin-top:0} .mt-1{margin-top:8px} .mt-2{margin-top:16px} .mt-3{margin-top:24px}
.mb-0{margin-bottom:0} .mb-1{margin-bottom:8px} .mb-2{margin-bottom:16px} .mb-3{margin-bottom:24px}
.text-muted{color:var(--text-muted)} .text-small{font-size:12px} .text-center{text-align:center} .text-right{text-align:right}
.fw-bold{font-weight:800}
.d-none{display:none} .hidden{display:none} .block{display:block}
.flex{display:-webkit-flex;display:flex}
.flex-center{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center}
.flex-between{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:space-between;justify-content:space-between}
.flex-wrap{-webkit-flex-wrap:wrap;flex-wrap:wrap}
.gap-1{gap:8px} .gap-2{gap:14px} .gap-3{gap:20px}
.items-center{-webkit-align-items:center;align-items:center}
.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.w-full{width:100%}
.min-w-0{min-width:0}
.overflow-x-auto{overflow-x:auto;-webkit-overflow-scrolling:touch}
.break-word{word-break:break-word;overflow-wrap:anywhere}

/* ── PRINT ── */
@media print {
  .sidebar, .topbar, .term-strip, .no-print { display: none !important; }
  .main { margin: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; }
  body { background: #fff !important; font-size: 12px !important; }
  .print-header { display: block !important; }
  .table-wrap { overflow: visible !important; }
}
.print-header { display: none; }

/* ═══════════════════════════════
   RESPONSIVE
   ═══════════════════════════════ */

/* Tablet ≤1024px */
@media (max-width: 1024px) {
  .enterprise-hero { grid-template-columns: 1fr; }
  .enterprise-kpi-row, .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* Sidebar collapse ≤900px */
@media (max-width: 900px) {
  .sidebar { -webkit-transform: translateX(-100%); transform: translateX(-100%); box-shadow: none; }
  .sidebar.open { -webkit-transform: translateX(0); transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .topbar-hamburger { display: block; }
}

/* Mobile ≤640px */
@media (max-width: 640px) {
  :root { --content-pad: 12px; }

  .content { padding: var(--content-pad); }

  /* KPI ยังคง 2 คอลัมน์ อ่านง่าย */
  .enterprise-kpi-row, .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; gap: 10px; }

  .form-row { grid-template-columns: 1fr; }

  .page-header { padding: 16px 18px; }
  .page-header h1 { font-size: 17px; }
  .kpi-value, .stat-value { font-size: 24px; }
  .enterprise-kpi, .stat-card { padding: 12px 14px; }
  .kpi-icon, .stat-icon { width: 36px; height: 36px; font-size: 16px; }

  .enterprise-actions .btn { -webkit-flex: 1 1 auto; flex: 1 1 auto; }

  .topbar { padding: 0 12px; }
  .topbar-sub { display: none; }
  .term-strip { padding: 6px 12px; font-size: 11px; }
  .tab { padding: 8px 12px; font-size: 12.5px; }

  .card { padding: 14px; border-radius: 12px; }
  .card-header { padding-bottom: 10px; margin-bottom: 10px; }

  /* ตาราง font เล็กลงเล็กน้อย padding แน่นขึ้น */
  table { font-size: 12.5px; }
  th { padding: 8px 10px; font-size: 10.5px; }
  td { padding: 9px 10px; }

  /* teacher-review-box: ยกเลิก min-width คงที่ */
  .teacher-review-box { min-width: 0 !important; width: 100%; }
  /* reply-text: ไม่จำกัด max-width */
  .reply-text { max-width: none !important; }
}

/* Small mobile ≤400px */
@media (max-width: 400px) {
  .enterprise-kpi-row, .stats-grid { gap: 8px; }
  .kpi-value, .stat-value { font-size: 22px; }
  .kpi-label, .stat-label { font-size: 11px; }
  .btn { padding: 8px 14px; font-size: 13px; }
  .btn-sm { padding: 5px 10px; font-size: 11.5px; }
}
