/* ========================================================================
   iOS 17 / 18 design language
   - SF Pro typography (system fallback)
   - System colors theo Apple HIG
   - Bo tròn lớn, shadow rất nhẹ
   - Segmented control cho tabs
   - Pill buttons, soft inputs
   ======================================================================== */
:root {
  /* iOS system colors (light mode) */
  --bg:        #edf2ff;   /* nền xanh nhạt giống SaaS app tham chiếu */
  --bg-card:   #ffffff;   /* card trắng tinh, tương phản rõ với nền */
  --bg-input:  #f2f2f7;   /* tertiarySystemFill (cho input filled style) */
  --bg-hover:  #e5e5ea;
  --separator: #c6c6c8;   /* opaqueSeparator */
  --separator-soft: rgba(60, 60, 67, 0.12);

  --label:     #1c1c1e;
  --label-2:   #3c3c4399;
  --label-3:   #3c3c4366;
  --label-4:   #3c3c432e;

  /* === EVN brand palette (chính thức) === */
  --npc-navy:    #164397;   /* Xanh lam EVN — Pantone Blue 072C — R22 G67 B151 */
  --npc-navy-d:  #0e2d6b;   /* Xanh đậm hơn (hover/pressed) */
  --npc-navy-l:  #2c5db8;   /* Xanh sáng hơn */
  --npc-red:     #ed1c24;   /* Đỏ EVN — R237 G28 B36 */
  --npc-red-d:   #c41119;
  --npc-yellow:  #fff200;   /* Vàng EVN — R255 G242 B0 */
  --npc-orange:  #f58220;   /* Cam EVN — R245 G130 B32 (dùng thay xanh lá cho success states) */
  --npc-orange-d:#c66518;
  --npc-grey:    #939598;   /* Ghi EVN — R147 G149 B152 */

  --blue:      var(--npc-navy);     /* alias để các rule cũ không vỡ */
  --blue-d:    var(--npc-navy-d);
  /* Đã bỏ xanh lá — thay bằng cam EVN cho success/positive states */
  --green:     var(--npc-orange);
  --green-d:   var(--npc-orange-d);
  --red:       var(--npc-red);
  --orange:    var(--npc-orange);
  --yellow:    var(--npc-yellow);
  --purple:    #af52de;
  --pink:      #ff2d55;
  --indigo:    #5856d6;
  --teal:      #5ac8fa;

  --gray:      var(--npc-grey);
  --gray-2:    #b2b3b5;
  --gray-6:    #f2f2f7;

  --radius-xl: 20px;       /* card lớn */
  --radius-l:  14px;       /* card thường */
  --radius-m:  12px;       /* button, input */
  --radius-s:  8px;
  --radius-pill: 999px;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-2: 0 4px 16px rgba(0, 0, 0, .06);
  --shadow-3: 0 12px 32px rgba(0, 0, 0, .12);

  --tap: cubic-bezier(.32, .72, 0, 1);   /* Apple spring-like */
}

/* Force light mode — không theo system dark mode */
html { color-scheme: light; }

/* ============= RESET & BASE ============= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display',
               'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--label);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
  position: relative;
  min-height: 100vh;
  overflow-x: hidden;
}

/* (Đã bỏ trang trí ngôi sao theo yêu cầu) */
#main-app .container { position: relative; z-index: 1; }

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

/* ============= HEADER ============= */
/* Thiết kế hero-style như app tham chiếu: gradient stripe trên cùng,
   logo + title rõ ràng, shadow xanh thay cho border cứng.
   LƯU Ý: header KHÔNG sticky để tránh xung đột với user-bar (cũng sticky top:0).
   User-bar đã đóng vai trò "anchor" trên cùng + chứa nút logout cần luôn truy cập.
   Header chỉ là branding — không cần luôn nhìn thấy khi đã scroll xuống xem kết quả. */
header {
  background: var(--bg-card);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  color: var(--label);
  padding: 16px 28px;
  display: flex; align-items: center; gap: 16px;
  position: relative;
  /* Shadow xanh nhẹ thay cho border cứng */
  box-shadow: 0 1px 0 rgba(22, 67, 151, 0.1), 0 4px 24px rgba(22, 67, 151, 0.07);
}
/* Gradient stripe 3px ở trên cùng — giống app tham chiếu */
header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--npc-navy) 0%, var(--npc-red) 55%, var(--npc-orange) 100%);
}
header .logo-header {
  height: 48px; width: auto;
  object-fit: contain;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.08));
  flex-shrink: 0;
}
.header-content {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
/* Nhãn accent nhỏ "XÍ NGHIỆP TƯ VẤN" — giống label trên app tham chiếu */
.header-unit {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--npc-navy);
  opacity: 0.7;
}
header h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--label);
  line-height: 1.2;
}
header p  { font-size: 12px; color: var(--label-2); margin-top: 1px; }

.container { max-width: 980px; margin: 0 auto; padding: 24px 20px 60px; }

/* ============= AUTH SCREEN — NPC theme ============= */
.auth-screen {
  position: fixed; inset: 0;
  background:
    radial-gradient(110% 80% at 0% 0%,   rgba(237, 28, 36, 0.28) 0%, transparent 55%),
    radial-gradient(110% 80% at 100% 0%, rgba(255, 213, 0, 0.18) 0%, transparent 50%),
    radial-gradient(120% 80% at 50% 100%, rgba(0, 80, 179, 0.30) 0%, transparent 60%),
    linear-gradient(135deg, #001a4d 0%, var(--npc-navy-d) 50%, #001838 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; padding: 24px;
  overflow: hidden;
}

/* (Đã bỏ trang trí ngôi sao theo yêu cầu) */
.auth-box { position: relative; z-index: 1; }
.auth-box {
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 24px;
  padding: 32px 32px 36px;
  width: 400px; max-width: 100%;
  box-shadow: 0 24px 64px rgba(0, 30, 80, 0.35);
}
.auth-logo {
  display: flex; justify-content: center;
  margin-bottom: 14px;
}
.auth-logo img {
  height: 80px; width: auto; object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.08));
}
.auth-box h2 {
  text-align: center; color: var(--npc-navy);
  margin-bottom: 6px; font-size: 21px; font-weight: 700; letter-spacing: -0.02em;
}
.auth-sub {
  text-align: center; color: var(--label-2);
  font-size: 13px; margin-bottom: 24px;
}

/* iOS segmented control */
.auth-tabs {
  display: flex; padding: 2px; border-radius: 10px;
  background: var(--bg-input); margin-bottom: 22px;
}
.auth-tab {
  flex: 1; padding: 8px 12px; border: 0; background: transparent;
  color: var(--label); font-size: 13px; font-weight: 500;
  border-radius: 8px; cursor: pointer; transition: all .2s var(--tap);
}
.auth-tab.active {
  background: var(--bg-card);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.06);
  font-weight: 600;
}

.auth-form label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--label-2); margin: 14px 0 6px;
}
.auth-form input {
  width: 100%; padding: 12px 14px;
  background: var(--bg-input); border: 1px solid transparent;
  border-radius: var(--radius-m); font-size: 15px; outline: none;
  color: var(--label);
  transition: all .2s var(--tap);
}
.auth-form input:focus {
  background: var(--bg-card);
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(22, 67, 151, 0.12);
}

.auth-msg     { font-size: 12px; margin-top: 12px; min-height: 18px; text-align: center; color: var(--red); }
.auth-msg.ok  { color: var(--green); }

.auth-btn {
  width: 100%; padding: 13px; border: 0; border-radius: var(--radius-m);
  font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 22px;
  transition: all .15s var(--tap);
}
.auth-btn:active { transform: scale(.98); }
.auth-btn-primary { background: var(--blue); color: #fff; }
.auth-btn-primary:hover { background: var(--blue-d); }
.auth-btn-primary:disabled { opacity: .55; cursor: wait; }

/* ============= USER BAR ============= */
.user-bar {
  background: var(--bg-card);
  border-bottom: 0.5px solid var(--separator-soft);
  padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px;
  position: sticky; top: 0; z-index: 60;
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}
.user-bar .ub-left { display: flex; align-items: center; gap: 10px; color: var(--label); }
.user-bar .ub-name { font-weight: 600; }
.user-bar .ub-role {
  background: var(--bg-input); color: var(--label-2);
  padding: 3px 10px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 500;
}
.user-bar button {
  background: var(--bg-input); color: var(--label);
  border: 0; padding: 7px 14px; border-radius: var(--radius-pill);
  cursor: pointer; font-size: 12px; font-weight: 500; margin-left: 8px;
  transition: background .15s var(--tap);
}
.user-bar button:hover { background: var(--bg-hover); }
.user-bar button:active { transform: scale(.96); }

/* ============= ADMIN PANEL ============= */
.admin-section {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 24px 28px;
  margin-bottom: 16px;
  box-shadow: 0 2px 20px rgba(22, 67, 151, 0.07), 0 1px 4px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(22, 67, 151, 0.07);
}
.admin-section h3 {
  margin-bottom: 14px;
  color: var(--npc-navy);
  font-size: 17px;
  font-weight: 600; letter-spacing: -0.02em;
}
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th {
  background: transparent;
  padding: 10px 12px;
  text-align: left; font-weight: 600;
  color: var(--label-2); font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 0.5px solid var(--separator-soft);
}
.admin-table td {
  padding: 10px 12px; border-bottom: 0.5px solid var(--separator-soft);
  color: var(--label);
}
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table tr:hover td { background: var(--bg-input); }

.badge-pending  { background: rgba(255, 149, 0, 0.15);  color: #b56500; padding: 3px 9px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 600; }
.badge-active   { background: rgba(245, 130, 32, 0.15);  color: #a04e10; padding: 3px 9px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 600; }
.badge-rejected { background: rgba(255, 59, 48, 0.15);  color: #b22a23; padding: 3px 9px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 600; }
.badge-admin    { background: rgba(22, 67, 151, 0.15);  color: #0a4ca0; padding: 3px 9px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 600; }

.admin-btn {
  padding: 5px 11px; border: 0; border-radius: var(--radius-pill);
  font-size: 12px; cursor: pointer; font-weight: 500; margin-right: 6px;
  transition: all .12s var(--tap);
}
.admin-btn:active { transform: scale(.95); }
.admin-btn-ok    { background: rgba(245, 130, 32, 0.15);  color: #a04e10; }
.admin-btn-ok:hover    { background: rgba(245, 130, 32, 0.25); }
.admin-btn-del   { background: rgba(255, 59, 48, 0.15);  color: #b22a23; }
.admin-btn-del:hover   { background: rgba(255, 59, 48, 0.25); }
.admin-btn-reset { background: rgba(22, 67, 151, 0.15);  color: #0a4ca0; }
.admin-btn-reset:hover { background: rgba(22, 67, 151, 0.25); }

/* ============= CARDS ============= */
/* Dùng shadow xanh nhạt + border xanh mờ — tạo chiều sâu như app tham chiếu */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 24px 28px;
  margin-bottom: 16px;
  box-shadow: 0 2px 20px rgba(22, 67, 151, 0.07), 0 1px 4px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(22, 67, 151, 0.07);
}
.card-title {
  font-size: 16px; font-weight: 700; color: var(--label);
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 20px; padding-bottom: 16px;
  border-bottom: 0.5px solid var(--separator-soft);
  letter-spacing: -0.015em;
}

/* ============= FIX PANEL (HƯỚNG DẪN) ============= */
/* Nâng cấp: dùng white card giống các card khác, thêm border xanh trái làm accent */
.fix-panel {
  background: var(--bg-card);
  border: 1px solid rgba(22, 67, 151, 0.07);
  border-radius: var(--radius-xl);
  padding: 24px 28px;
  margin-bottom: 16px;
  box-shadow: 0 2px 20px rgba(22, 67, 151, 0.07), 0 1px 4px rgba(0, 0, 0, 0.04);
}
.fix-panel h2 {
  font-size: 16px; color: var(--label); font-weight: 700;
  margin-bottom: 16px; letter-spacing: -0.015em;
  display: flex; align-items: center; gap: 8px;
}
.fix-list { display: grid; gap: 10px; }
.fix-item {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 16px; border-radius: var(--radius-l);
  background: var(--bg); /* nền xanh nhạt để nổi bật trên card trắng */
  border: 1px solid rgba(22, 67, 151, 0.06);
  transition: background .15s var(--tap);
}
.fix-item:hover { background: rgba(22, 67, 151, 0.05); }
.fix-item .bnum {
  min-width: 26px; height: 26px; border-radius: 50%;
  /* Gradient xanh → navy giống indicator trên app tham chiếu */
  background: linear-gradient(135deg, var(--npc-navy-l), var(--npc-navy));
  color: #fff;
  font-weight: 700; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(22, 67, 151, 0.3);
}
.fix-item .btxt { font-size: 13px; color: var(--label-2); line-height: 1.55; }
.fix-item .btxt strong { color: var(--label); font-weight: 600; }

/* ============= PERIOD SELECT ============= */
.period-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.period-row label { font-size: 14px; font-weight: 500; color: var(--label); }
.period-row select, .period-row input {
  padding: 9px 14px; background: var(--bg-input);
  border: 0; border-radius: var(--radius-m);
  font-size: 14px; color: var(--label); outline: none; cursor: pointer;
  transition: background .15s var(--tap);
}
.period-row select:hover, .period-row input:hover { background: var(--bg-hover); }
.period-row select:focus, .period-row input:focus {
  background: var(--bg-card);
  box-shadow: 0 0 0 4px rgba(22, 67, 151, 0.15);
}
.period-row #report-year { width: 100px; }
.period-hint { color: var(--label-3); font-size: 13px; margin-left: 6px; }

/* ============= UPLOAD GRID ============= */
.upload-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
/* Drop zone nâng cấp: taller, shadow nhẹ, hover rõ hơn */
.drop-zone {
  border: 1.5px dashed rgba(22, 67, 151, 0.25);
  border-radius: var(--radius-l);
  padding: 22px 16px; text-align: center;
  cursor: pointer; transition: all .22s var(--tap);
  position: relative; min-height: 150px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px;
  background: var(--bg-card);
  box-shadow: 0 1px 6px rgba(22, 67, 151, 0.04);
}
.drop-zone:hover {
  border-color: var(--blue);
  border-style: solid;
  background: rgba(22, 67, 151, 0.04);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(22, 67, 151, 0.10);
}
.drop-zone.ok {
  border-color: var(--npc-orange);
  border-style: solid;
  background: rgba(245, 130, 32, 0.05);
  box-shadow: 0 2px 10px rgba(245, 130, 32, 0.12);
}
.drop-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-zone .dicon { font-size: 32px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.08)); }
.drop-zone .dlabel { font-size: 14px; font-weight: 700; color: var(--label); line-height: 1.3; }
.drop-zone .dsub   { font-size: 12px; color: var(--label-2); line-height: 1.4; }
.drop-zone .dfile  { font-size: 11px; color: var(--npc-orange); font-weight: 600; margin-top: 4px; word-break: break-all; }

.tag {
  font-size: 10px; padding: 2px 8px; border-radius: var(--radius-pill);
  font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase;
}
.tag.req { background: rgba(255, 59, 48, 0.15);  color: #b22a23; }
.tag.opt { background: rgba(22, 67, 151, 0.15);  color: #0a4ca0; }

/* ============= BUTTONS ============= */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 11px 22px; border-radius: var(--radius-pill);
  border: 0; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .15s var(--tap);
  letter-spacing: -0.01em;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--blue);  color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-d); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover:not(:disabled) { background: var(--green-d); }
.btn-gray    { background: var(--bg-input); color: var(--label); }
.btn-gray:hover { background: var(--bg-hover); }
.btn-row     { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* ============= PROGRESS ============= */
.prog-wrap {
  background: var(--bg-input); border-radius: var(--radius-pill);
  height: 6px; overflow: hidden; margin: 12px 0;
}
.prog-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--green));
  border-radius: var(--radius-pill);
  transition: width .4s var(--tap);
  width: 0;
}
#prog-label { font-size: 13px; color: var(--label-2); margin-bottom: 10px; }

#log {
  background: #1c1c1e; color: #d1f0d1;
  font-family: ui-monospace, 'SF Mono', Menlo, Monaco, 'Cascadia Code', monospace;
  font-size: 12px; padding: 14px 16px;
  border-radius: var(--radius-l);
  max-height: 260px; overflow-y: auto; line-height: 1.7;
  white-space: pre-wrap;
}
.li  { color: #76b9ff; }
.lok { color: #fdba74; }
.lw  { color: #ffd25d; }
.le  { color: #ff7a78; }

/* ============= STATS ============= */
/* Metric cards giống app tham chiếu: số to, shadow xanh, hover lift */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.stat {
  background: var(--bg);
  border-radius: var(--radius-l);
  padding: 18px 16px;
  text-align: center;
  border: 1px solid rgba(22, 67, 151, 0.08);
  transition: all .18s var(--tap);
  box-shadow: 0 1px 6px rgba(22, 67, 151, 0.05);
}
.stat:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(22, 67, 151, 0.12);
  background: var(--bg-card);
}
.stat .sv {
  font-size: 26px; font-weight: 800; color: var(--npc-navy);
  letter-spacing: -0.03em; line-height: 1;
}
.stat .sl { font-size: 11px; color: var(--label-2); margin-top: 6px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; }
/* Ô thống kê bấm được (nhảy tới tab tương ứng) — báo hiệu cho user bằng con trỏ + viền */
.stat.stat-link { cursor: pointer; }
.stat.stat-link:hover { border-color: rgba(22, 67, 151, 0.35); }
.stat.stat-link .sl::after { content: ' ›'; color: var(--npc-navy); font-weight: 800; }

/* ============= TABS (iOS segmented control) ============= */
/* Nâng cấp: border xanh mờ bên ngoài, active tab có shadow đẹp hơn */
.tabs {
  display: flex; gap: 3px;
  padding: 4px;
  background: var(--bg);
  border-radius: var(--radius-l);
  margin-bottom: 18px;
  flex-wrap: wrap;
  border: 1px solid rgba(22, 67, 151, 0.08);
}
.tab {
  flex: 1; min-width: max-content;
  padding: 9px 16px; border: 0; background: transparent;
  font-size: 13px; font-weight: 500; color: var(--label-2);
  cursor: pointer; border-radius: var(--radius-m);
  transition: all .2s var(--tap);
  letter-spacing: -0.01em;
}
.tab:hover:not(.active) { color: var(--label); background: rgba(22, 67, 151, 0.05); }
.tab.active {
  background: var(--bg-card);
  font-weight: 700;
  color: var(--npc-navy);
  box-shadow: 0 2px 10px rgba(22, 67, 151, 0.10), 0 1px 3px rgba(0, 0, 0, 0.06);
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ============= TABLE ============= */
.tbl-wrap {
  overflow: auto;
  max-height: 540px;
  border-radius: var(--radius-l);
  border: 0.5px solid var(--separator-soft);
}
table { border-collapse: collapse; width: 100%; font-size: 13px; }
thead th {
  background: var(--bg-input);
  color: var(--label-2);
  padding: 10px 12px;
  font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.04em;
  text-align: left; white-space: nowrap;
  position: sticky; top: 0; z-index: 2;
  border-bottom: 0.5px solid var(--separator-soft);
}
tbody tr:nth-child(even) { background: rgba(120, 120, 128, 0.04); }
tbody tr.g-row { background: rgba(22, 67, 151, 0.06); font-weight: 600; color: var(--label); }
tbody tr.t-row { background: rgba(245, 130, 32, 0.10); font-weight: 600; color: #a04e10; }
tbody tr.warn  { background: rgba(255, 204, 0, 0.10); }
tbody tr.err   { background: rgba(255, 59, 48, 0.08); }
td {
  padding: 9px 12px;
  border-bottom: 0.5px solid var(--separator-soft);
  white-space: nowrap;
  color: var(--label);
}
tr:last-child td { border-bottom: 0; }
td.txt { white-space: normal; max-width: 320px; word-break: break-word; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  letter-spacing: 0.01em;
}
.b-ok    { background: rgba(245, 130, 32, 0.15);  color: #a04e10; }
.b-warn  { background: rgba(255, 204, 0, 0.18);  color: #8a6500; }
.b-err   { background: rgba(255, 59, 48, 0.15);  color: #b22a23; }
.b-info  { background: rgba(22, 67, 151, 0.15);  color: #0a4ca0; }
.b-nb    { background: rgba(175, 82, 222, 0.15); color: #6b2da3; }
.b-ngoai { background: rgba(255, 45, 85, 0.15);  color: #a01740; }

/* ============= SCROLLBAR ============= */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--gray-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray); }
::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   RESPONSIVE — 4 breakpoint
   - 1024px : laptop nhỏ / tablet ngang — chỉ tweak nhẹ padding
   - 768px  : tablet dọc / mobile lớn   — thu gọn header, tabs scroll
   - 480px  : mobile thường              — single column, font nhỏ
   - 360px  : mobile nhỏ (iPhone SE)    — nén tối đa
   ============================================================ */

/* === Laptop nhỏ / tablet ngang === */
@media (max-width: 1024px) {
  .container { padding: 20px 16px 50px; }
}

/* === Tablet dọc / mobile lớn === */
@media (max-width: 768px) {
  /* Header: thu nhỏ logo + tiêu đề */
  header { padding: 12px 16px; gap: 12px; }
  header .logo-header { height: 40px; }
  header h1 { font-size: 16px; }
  header p  { font-size: 11px; }
  .header-unit { font-size: 9px; }

  /* User-bar: nhỏ gọn lại, ub-name không tràn */
  .user-bar { padding: 8px 14px; font-size: 12px; }
  .user-bar .ub-left { min-width: 0; flex: 1; }   /* min-width:0 cho ellipsis hoạt động */
  .user-bar .ub-name {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: 140px;
  }
  .user-bar button { padding: 6px 12px; font-size: 12px; margin-left: 6px; }
  .user-bar .ub-btns { flex-shrink: 0; }

  /* Container và card */
  .container { padding: 16px 14px 40px; }
  .card, .fix-panel, .admin-section { padding: 18px 16px; }
  .card-title { font-size: 15px; margin-bottom: 14px; padding-bottom: 12px; }

  /* Fix panel (hướng dẫn) */
  .fix-item { padding: 12px 14px; gap: 12px; }
  .fix-item .btxt { font-size: 12.5px; }

  /* Upload grid: 2 cột compact */
  .upload-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .drop-zone { padding: 16px 10px; min-height: 130px; gap: 5px; }
  .drop-zone .dicon { font-size: 26px; }
  .drop-zone .dlabel { font-size: 13px; }
  .drop-zone .dsub { font-size: 11px; }

  /* Tabs: scroll ngang để 7 tab không vỡ thành 2-3 dòng xấu */
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;          /* Firefox */
  }
  .tabs::-webkit-scrollbar { display: none; }   /* WebKit */
  .tab { flex: 0 0 auto; padding: 8px 14px; }

  /* Tables: cell nhỏ hơn, max-height thấp hơn để không chiếm hết màn */
  .tbl-wrap { max-height: 60vh; }
  thead th, td { padding: 8px 10px; font-size: 12px; }
  td.txt { max-width: 220px; }

  /* Stats: vẫn 2 cột, font nhỏ hơn */
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 14px 10px; }
  .stat .sv { font-size: 22px; }
  .stat .sl { font-size: 10px; }

  /* Period row */
  .period-row { gap: 8px; }
  .period-row #report-year { width: 90px; }
  .period-hint { width: 100%; margin-left: 0; }

  /* Log compact */
  #log { max-height: 200px; font-size: 11.5px; padding: 12px 14px; }

  /* Admin table */
  .admin-table { font-size: 12px; }
  .admin-table th, .admin-table td { padding: 8px 10px; }

  /* Auth box */
  .auth-screen { padding: 18px; }
  .auth-box { padding: 28px 24px 30px; }
  .auth-box h2 { font-size: 19px; }
}

/* === Mobile thường (iPhone 12-15 dọc, Galaxy S) === */
@media (max-width: 480px) {
  /* Header: cực nhỏ — logo 32px, h1 14px */
  header { padding: 10px 12px; gap: 10px; }
  header .logo-header { height: 32px; }
  header h1 { font-size: 14px; line-height: 1.25; }
  header p  { font-size: 10.5px; }
  .header-unit { font-size: 9px; letter-spacing: 0.08em; }

  /* User-bar: ẩn badge role, name có ellipsis */
  .user-bar { padding: 7px 12px; font-size: 11.5px; }
  .user-bar .ub-role { display: none; }   /* ẩn badge role để tiết kiệm space */
  .user-bar .ub-name { max-width: 100px; }
  .user-bar button { padding: 5px 10px; font-size: 11px; margin-left: 4px; }

  /* Container, card padding tối thiểu */
  .container { padding: 12px 10px 32px; }
  .card, .fix-panel, .admin-section {
    padding: 14px 14px;
    border-radius: var(--radius-l);   /* radius nhỏ hơn cho cảm giác compact */
  }
  .card-title { font-size: 14.5px; padding-bottom: 10px; margin-bottom: 12px; gap: 8px; }

  /* Hướng dẫn: text wrap đẹp hơn, button-num nhỏ lại */
  .fix-item { padding: 10px 12px; gap: 10px; }
  .fix-item .bnum { min-width: 22px; height: 22px; font-size: 11px; }
  .fix-item .btxt { font-size: 12px; line-height: 1.5; }

  /* Upload: 1 cột, card thấp gọn */
  .upload-grid { grid-template-columns: 1fr; gap: 10px; }
  .drop-zone { min-height: 100px; padding: 14px 12px; gap: 4px; }
  .drop-zone .dicon { font-size: 26px; }

  /* Period row: stack vertical, control full width */
  .period-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .period-row label { font-size: 13px; }
  .period-row select, .period-row input {
    padding: 11px 14px; font-size: 15px; width: 100%;
  }
  .period-row #report-year { width: 100%; }
  .period-hint { font-size: 11.5px; margin-left: 0; }

  /* Stats: 2 cột nhỏ */
  .stat { padding: 12px 8px; }
  .stat .sv { font-size: 18px; }
  .stat .sl { font-size: 9.5px; }

  /* Buttons: stack full-width — dễ bấm bằng ngón cái */
  .btn { padding: 11px 16px; font-size: 13px; }
  .btn-row { flex-direction: column; gap: 8px; }
  .btn-row .btn { width: 100%; justify-content: center; }

  /* Auth screen */
  .auth-screen { padding: 14px; }
  .auth-box { padding: 24px 20px 28px; border-radius: 18px; }
  .auth-box h2 { font-size: 17px; }
  .auth-sub { font-size: 11.5px; margin-bottom: 18px; }
  .auth-logo img { height: 64px; }
  .auth-form input { padding: 11px 13px; font-size: 14.5px; }

  /* Tabs */
  .tab { padding: 8px 12px; font-size: 12px; }

  /* Tables: cell siêu nhỏ */
  thead th, td { padding: 7px 8px; font-size: 11.5px; }
  td.txt { max-width: 160px; }

  /* Admin tables: bảng có nhiều cột — chỉ scroll ngang trong tbl-wrap */
  .admin-table { font-size: 11.5px; }
  .admin-table th, .admin-table td { padding: 7px 8px; }
  .admin-btn { padding: 4px 9px; font-size: 11px; margin-right: 4px; }
}

/* === Mobile nhỏ (iPhone SE, Galaxy fold ngoài) === */
@media (max-width: 360px) {
  header h1 { font-size: 13px; }
  header .logo-header { height: 28px; }
  .header-unit { font-size: 8.5px; }
  .header-content { gap: 0; }

  /* Stats: 1 cột để con số dài không tràn */
  .stats { grid-template-columns: 1fr; }
  .stat { padding: 14px 12px; }
  .stat .sv { font-size: 22px; }
  .stat .sl { font-size: 10.5px; }

  /* User-bar: chỉ giữ tên + 1 nút logout */
  .user-bar .ub-name { max-width: 80px; }
}
