/* ===== ONE — ระบบจัดเก็บเอกสารกลางภาครัฐ ===== */
/* Thai flag palette, modern & clean */

:root {
  /* Thai flag */
  --flag-red: #A51931;
  --flag-red-soft: #C23A52;
  --flag-navy: #2D2A4A;
  --flag-navy-2: #3A3660;

  /* Light theme (default) */
  --bg: #F4F4F7;
  --bg-panel: #FFFFFF;
  --bg-elev: #FBFBFD;
  --bg-sunken: #EFEFF3;
  --ink: #1C1B2A;
  --ink-2: #54526A;
  --ink-3: #8E8CA3;
  --line: #E6E6EC;
  --line-2: #D9D9E2;
  --primary: var(--flag-navy);
  --primary-ink: #FFFFFF;
  --accent: var(--flag-red);
  --accent-soft: #FBEAED;
  --good: #1F7A4D;
  --good-soft: #E7F3EC;
  --warn: #B25E00;
  --warn-soft: #FBF0E2;
  --bad: #A51931;
  --bad-soft: #FBE9EC;
  --sidebar-bg: #2D2A4A;
  --sidebar-ink: #C9C7DC;
  --sidebar-ink-dim: #807DA0;
  --sidebar-active: #FFFFFF;
  --shadow-sm: 0 1px 2px rgba(28,27,42,.06), 0 1px 3px rgba(28,27,42,.04);
  --shadow-md: 0 4px 16px rgba(28,27,42,.08), 0 1px 4px rgba(28,27,42,.05);
  --shadow-lg: 0 18px 50px rgba(28,27,42,.16);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;
}

[data-theme="dark"] {
  --bg: #14131F;
  --bg-panel: #1D1B2B;
  --bg-elev: #232036;
  --bg-sunken: #191725;
  --ink: #ECEBF5;
  --ink-2: #A6A3C2;
  --ink-3: #8B88A8;
  --line: #2E2B42;
  --line-2: #383452;
  --primary: #6E6A9E;
  --primary-ink: #FFFFFF;
  --accent: #E0566F;
  --accent-soft: #3A1F2A;
  --good: #58C58C;
  --good-soft: #173326;
  --warn: #E2A24B;
  --warn-soft: #38280F;
  --bad: #E0566F;
  --bad-soft: #3A1F2A;
  --sidebar-bg: #1A1828;
  --sidebar-ink: #B4B1CE;
  --sidebar-ink-dim: #6B6890;
  --sidebar-active: #FFFFFF;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 6px 20px rgba(0,0,0,.4);
  --shadow-lg: 0 22px 60px rgba(0,0,0,.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: 'Sarabun', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background .3s ease, color .3s ease;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* default icon size — containers override below */
.ico { width: 20px; height: 20px; flex: none; }
.s-ico .ico { width: 22px; height: 22px; }
.dz-ico .ico { width: 28px; height: 28px; }
.tut-play .ico { width: 22px; height: 22px; }
.act-dot .ico { width: 18px; height: 18px; }
.lf-ico .ico { width: 16px; height: 16px; }
.file-ico .ico { display: none; }
.searchbar > .ico { color: var(--ink-3); }

/* ===== Flag mark ===== */
.flag-mark {
  display: inline-block;
  border-radius: 5px;
  overflow: hidden;
  flex: none;
  background:
    linear-gradient(to bottom,
      var(--flag-red) 0 16.66%,
      #fff 16.66% 33.33%,
      var(--flag-navy) 33.33% 66.66%,
      #fff 66.66% 83.33%,
      var(--flag-red) 83.33% 100%);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}

/* ===== Brand wordmark ===== */
.brand { display: flex; align-items: center; gap: 12px; }
.brand .flag-mark { width: 30px; height: 30px; }
.brand-name { font-weight: 800; letter-spacing: .14em; font-size: 19px; }
.brand-sub { font-size: 11.5px; letter-spacing: .02em; opacity: .7; font-weight: 500; }

/* ===== App layout ===== */
.app { display: grid; grid-template-columns: 256px 1fr; min-height: 100vh; }
.app.hidden { display: none; }

/* ===== Sidebar ===== */
.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  gap: 6px;
  overflow-y: auto;
}
.sidebar .brand { padding: 6px 8px 22px; }
.sidebar .brand-name { color: #fff; }
.sidebar .brand-sub { color: var(--sidebar-ink-dim); }
.nav-group-label {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--sidebar-ink-dim); padding: 16px 12px 6px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 12px; white-space: nowrap;
  padding: 11px 12px; border-radius: var(--radius-sm);
  color: var(--sidebar-ink); font-size: 15px; font-weight: 500;
  transition: background .15s, color .15s;
  width: 100%; text-align: left;
}
.nav-item .ico { width: 20px; height: 20px; flex: none; opacity: .85; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.1); color: #fff; font-weight: 600; }
.nav-item.active .ico { opacity: 1; }
.nav-item .badge {
  margin-left: auto; background: var(--flag-red); color: #fff;
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
}
/* ===== Sidebar Scroll ===== */
.sidebar { overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent; }
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 3px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.3); }

/* ===== Nav Dropdown ===== */
.nav-dropdown { position: relative; }
.nav-dropdown-toggle { justify-content: flex-start; gap: 12px; }
.nav-dropdown-toggle .nav-caret { margin-left: auto; transition: transform .2s; }
.nav-dropdown.open .nav-dropdown-toggle .nav-caret { transform: rotate(180deg); }
.nav-dropdown-menu { display: none; padding-left: 12px; gap: 2px; }
.nav-dropdown.open .nav-dropdown-menu { display: flex; flex-direction: column; }
.nav-dropdown-menu .nav-item { padding-left: 24px; font-size: 14px; }
.nav-dropdown-menu .nav-item .ico { width: 16px; height: 16px; }

.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.08); }
.user-chip { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: var(--radius-sm); }
.avatar {
  width: 38px; height: 38px; border-radius: 999px; flex: none;
  background: linear-gradient(135deg, var(--flag-red), var(--flag-red-soft));
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.user-chip > div:not(.avatar) { min-width: 0; line-height: 1.35; }
.user-chip .u-name { color: #fff; font-size: 14px; font-weight: 600; white-space: nowrap; }
.user-chip .u-org { color: var(--sidebar-ink-dim); font-size: 12px; white-space: nowrap; }

/* ===== Main ===== */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 32px; background: var(--bg-panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 21px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.topbar .crumb { font-size: 13px; color: var(--ink-3); white-space: nowrap; }
.topbar-spacer { flex: 1; }
.content { padding: 28px 32px 60px; max-width: 1280px; width: 100%; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 10px 18px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14.5px;
  background: var(--bg-sunken); color: var(--ink); transition: all .15s; white-space: nowrap;
  border: 1px solid transparent;
}
.btn:hover { background: var(--line); }
.btn .ico { width: 18px; height: 18px; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--flag-navy-2); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; border: 1px solid var(--line-2); color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg-sunken); color: var(--ink); }
.btn-ghost.active { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
[data-theme="dark"] .btn-ghost.active { background: var(--flag-navy-2); border-color: var(--flag-navy-2); }
.btn-sm { padding: 7px 13px; font-size: 13.5px; border-radius: var(--radius-xs); }
.btn-icon { padding: 9px; border-radius: var(--radius-xs); background: var(--bg-sunken); }
.btn-icon:hover { background: var(--line); }
.btn-icon.danger:hover { background: var(--bad-soft); color: var(--bad); }
.btn-icon.downloaded { background: var(--warn-soft); color: var(--warn); }
.btn-icon.downloaded:hover { background: var(--warn-soft); color: var(--warn); filter: brightness(.92); }

/* ===== Cards ===== */
.card {
  background: var(--bg-panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  color: var(--ink);
}
.card-pad { padding: 22px 24px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: 16.5px; font-weight: 700; }
.card-head .sub { font-size: 13px; color: var(--ink-3); }

/* ===== Stat cards ===== */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.stat {
  background: var(--bg-panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat .s-ico {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; margin-bottom: 14px;
}
.stat .s-label { font-size: 13.5px; color: var(--ink-2); font-weight: 500; }
.stat .s-value { font-size: 32px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; margin-top: 2px; }
.stat .s-value .unit { font-size: 16px; font-weight: 600; color: var(--ink-3); margin-left: 4px; }
.stat .s-delta { font-size: 12.5px; font-weight: 600; margin-top: 8px; display: inline-flex; gap: 4px; align-items: center; }
.s-delta.up { color: var(--good); }
.s-delta.down { color: var(--bad); }
.ico-tint-navy { background: rgba(45,42,74,.1); color: var(--flag-navy); }
.ico-tint-red { background: var(--accent-soft); color: var(--accent); }
.ico-tint-good { background: var(--good-soft); color: var(--good); }
.ico-tint-warn { background: var(--warn-soft); color: var(--warn); }
[data-theme="dark"] .ico-tint-navy { background: rgba(110,106,158,.18); color: #9D99CE; }

/* ===== Chart ===== */
.chart { display: flex; align-items: flex-end; gap: 14px; height: 220px; padding: 12px 4px 0; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.chart-bars { display: flex; gap: 5px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.bar { width: 46%; border-radius: 6px 6px 0 0; min-height: 4px; }
.bar.imp { background: linear-gradient(to top, var(--flag-navy), var(--flag-navy-2)); }
.bar.dl { background: linear-gradient(to top, var(--flag-red), var(--flag-red-soft)); }
.chart-x { font-size: 12px; color: var(--ink-3); font-weight: 500; }
.legend { display: flex; gap: 18px; align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); }
.dot { width: 11px; height: 11px; border-radius: 3px; }

/* ===== Tables ===== */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tbl thead th {
  text-align: left; font-size: 12px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 700; padding: 12px 16px; border-bottom: 1px solid var(--line);
  background: var(--bg-elev); white-space: nowrap;
}
.tbl tbody td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: var(--bg-elev); }
.tbl .num { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tbl .fname { display: flex; align-items: center; gap: 11px; font-weight: 600; }
.file-ico {
  width: 34px; height: 40px; flex: none; border-radius: 5px; position: relative;
  background: var(--bg-sunken); border: 1px solid var(--line-2);
  display: grid; place-items: end center; padding-bottom: 5px;
  font-size: 8.5px; font-weight: 800; letter-spacing: .02em;
}
.file-ico.pdfa { color: var(--good); border-color: color-mix(in srgb, var(--good) 35%, var(--line-2)); }
.file-ico.pdf { color: var(--warn); }
.file-ico.bad { color: var(--bad); }
.file-ico::before { content: ""; position: absolute; top: 0; right: 0; border-width: 0 9px 9px 0; border-style: solid; border-color: var(--bg-panel) var(--bg-panel) transparent transparent; }

/* ===== Badges ===== */
.badge-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600;
  padding: 4px 11px; border-radius: 999px; white-space: nowrap;
}
.bp-good { background: var(--good-soft); color: var(--good); }
.bp-warn { background: var(--warn-soft); color: var(--warn); }
.bp-bad { background: var(--bad-soft); color: var(--bad); }
.bp-navy { background: rgba(45,42,74,.08); color: var(--flag-navy); }
[data-theme="dark"] .bp-navy { background: rgba(110,106,158,.2); color: #ABA7D6; }
.bp-neutral { background: var(--bg-sunken); color: var(--ink-2); }

/* ===== Type select ===== */
.sel {
  appearance: none; padding: 8px 34px 8px 13px; border-radius: var(--radius-xs);
  border: 1px solid var(--line-2); background: var(--bg-panel); font-size: 14px; font-weight: 500;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238E8CA3' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 11px center; min-width: 190px; cursor: pointer;
}
.sel.req-empty { border-color: var(--accent); color: var(--accent); }
.sel:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

/* ===== Dropzone ===== */
.dropzone {
  border: 2px dashed var(--line-2); border-radius: var(--radius); background: var(--bg-elev);
  padding: 44px 32px; text-align: center; transition: all .2s; position: relative;
}
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dz-ico { width: 60px; height: 60px; margin: 0 auto 16px; border-radius: 16px; display: grid; place-items: center; background: rgba(45,42,74,.08); color: var(--flag-navy); }
[data-theme="dark"] .dz-ico { background: rgba(110,106,158,.18); color: #9D99CE; }
.dz-title { font-size: 18px; font-weight: 700; }
.dz-sub { font-size: 14px; color: var(--ink-2); margin-top: 4px; }
.dz-types { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

/* ===== Tutorial card ===== */
.tut { display: grid; grid-template-columns: 200px 1fr; gap: 0; overflow: hidden; }
.tut-thumb {
  background: linear-gradient(135deg, var(--flag-navy), #1C1A30); position: relative;
  display: grid; place-items: center; min-height: 132px;
}
.tut-play { width: 52px; height: 52px; border-radius: 999px; background: rgba(255,255,255,.95); display: grid; place-items: center; color: var(--flag-red); box-shadow: var(--shadow-md); }
.tut-thumb .tut-tag { position: absolute; top: 12px; left: 12px; font-size: 11px; font-weight: 700; color: #fff; background: rgba(255,255,255,.16); padding: 3px 9px; border-radius: 6px; letter-spacing: .03em; }
.tut-body { padding: 18px 22px; display: flex; flex-direction: column; justify-content: center; }

/* ===== Search ===== */
.searchbar { display: flex; align-items: center; gap: 12px; background: var(--bg-panel); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 6px 8px 6px 18px; box-shadow: var(--shadow-sm); }
.searchbar input { flex: 1; border: none; outline: none; background: transparent; font-size: 16px; padding: 10px 0; }
.searchbar input::placeholder { color: var(--ink-3); }
.filter-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.result {
  display: flex; gap: 16px; padding: 18px 20px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--bg-panel); transition: box-shadow .15s, border-color .15s;
}
.result:hover { box-shadow: var(--shadow-md); border-color: var(--line-2); }
.result .snippet { font-size: 14px; color: var(--ink-2); margin-top: 6px; line-height: 1.6; }
.result mark { background: rgba(165,25,49,.16); color: var(--accent); padding: 0 2px; border-radius: 3px; font-weight: 600; }
[data-theme="dark"] .result mark { background: rgba(224,86,111,.22); color: #F0889B; }
.result-meta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 12.5px; color: var(--ink-3); }
.result-meta b { color: var(--ink-2); font-weight: 600; }

/* ===== Group table (library) ===== */
.group { margin-bottom: 22px; }
.group-head { display: flex; align-items: center; gap: 12px; padding: 10px 4px 12px; }
.group-head .g-title { font-size: 16px; font-weight: 700; }
.group-head .g-count { font-size: 13px; color: var(--ink-3); }
.group-head .line-fill { flex: 1; height: 1px; background: var(--line); }

/* ===== Login ===== */
.login-wrap { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100vh; }
.login-art {
  background: linear-gradient(150deg, #2D2A4A 0%, #211F38 55%, #1A1830 100%);
  color: #fff; padding: 56px 60px; display: flex; flex-direction: column; position: relative; overflow: hidden;
}
.login-art .ribbon { position: absolute; right: -80px; top: -80px; width: 360px; height: 360px; border-radius: 50%; background: radial-gradient(circle, rgba(165,25,49,.35), transparent 70%); }
.login-art .ribbon2 { position: absolute; left: -60px; bottom: -120px; width: 320px; height: 320px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.06), transparent 70%); }
.login-art .brand .brand-name { color: #fff; }
.login-art .brand .brand-sub { color: rgba(255,255,255,.6); }
.login-art h2 { font-size: 38px; font-weight: 800; line-height: 1.18; letter-spacing: -.02em; margin-top: auto; max-width: 14ch; }
.login-art p.lede { font-size: 16px; color: rgba(255,255,255,.72); margin-top: 16px; max-width: 42ch; line-height: 1.7; }
.login-feats { display: flex; flex-direction: column; gap: 12px; margin-top: 32px; }
.login-feat { display: flex; align-items: center; gap: 12px; font-size: 14.5px; color: rgba(255,255,255,.85); }
.login-feat .lf-ico { width: 30px; height: 30px; border-radius: 8px; background: rgba(255,255,255,.1); display: grid; place-items: center; flex: none; }
.login-art .gov-foot { margin-top: 40px; font-size: 12.5px; color: rgba(255,255,255,.45); }
.login-form-side { display: grid; place-items: center; padding: 40px; background: var(--bg); }
.login-card { width: 100%; max-width: 400px; }
.login-card h3 { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.login-card .lc-sub { color: var(--ink-2); margin-top: 6px; margin-bottom: 28px; font-size: 15px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 7px; }
.input {
  width: 100%; padding: 13px 15px; border-radius: var(--radius-sm); border: 1px solid var(--line-2);
  background: var(--bg-panel); font-size: 15.5px; transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(45,42,74,.12); }
.input-group { position: relative; }
.input-group .ig-btn { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: var(--ink-3); padding: 6px; border-radius: 6px; }
.login-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; font-size: 13.5px; }
.login-row a { color: var(--accent); font-weight: 600; }
.checkrow { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.login-foot { text-align: center; margin-top: 22px; font-size: 13px; color: var(--ink-3); }

/* ===== Misc ===== */
.section-title { font-size: 15px; font-weight: 700; color: var(--ink-2); margin-bottom: 14px; display: flex; align-items: center; gap: 9px; }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar-spacer { flex: 1; }
.theme-toggle { display: inline-flex; background: var(--bg-sunken); border-radius: 999px; padding: 3px; gap: 2px; }
.theme-toggle button { padding: 7px 11px; border-radius: 999px; color: var(--ink-3); display: grid; place-items: center; }
.theme-toggle button.on { background: var(--bg-panel); color: var(--ink); box-shadow: var(--shadow-sm); }
.kbar { display: flex; gap: 8px; align-items: center; }
.org-bar { display: flex; flex-direction: column; gap: 15px; }
.org-row { display: flex; flex-direction: column; gap: 7px; }
.org-row-top { display: flex; align-items: baseline; gap: 12px; }
.org-row .o-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-track { height: 10px; border-radius: 999px; background: var(--bg-sunken); overflow: hidden; }
.org-fill { height: 100%; border-radius: 999px; background: linear-gradient(to right, var(--flag-navy), var(--flag-navy-2)); }
.org-row .o-val { text-align: right; font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; flex: none; color: var(--ink-2); }
.activity { display: flex; flex-direction: column; }
.act-row { display: flex; align-items: flex-start; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.act-row:last-child { border-bottom: none; }
.act-body { flex: 1; min-width: 0; }
.act-title { display: flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 500; overflow: hidden; }
.act-title span.act-ico { flex-shrink: 0; }
.act-meta { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }
.act-ico { width: 26px; height: 26px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; }
.act-time { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; padding-top: 2px; }
.act-item { display: flex; align-items: center; gap: 13px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.act-item:last-child { border-bottom: none; }
.act-dot { width: 36px; height: 36px; border-radius: 999px; display: grid; place-items: center; flex: none; }
.act-item .a-main { font-size: 14px; font-weight: 600; }
.act-item .a-sub { font-size: 12.5px; color: var(--ink-3); }
.act-item .a-time { margin-left: auto; font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }
.hint { display: flex; gap: 10px; padding: 13px 16px; border-radius: var(--radius-sm); font-size: 13.5px; line-height: 1.55; }
.hint-info { background: rgba(45,42,74,.05); color: var(--ink-2); border: 1px solid var(--line); }
[data-theme="dark"] .hint-info { background: rgba(110,106,158,.1); }
.hint-warn { background: var(--warn-soft); color: var(--warn); }
.hint .ico { flex: none; margin-top: 1px; }
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 22px; }
.grid-2b { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.mt-22 { margin-top: 22px; }
.mt-18 { margin-top: 18px; }
.screen { display: none; }
.screen.active { display: block; }
.del-x { color: var(--ink-3); }
.row-bad { background: var(--bad-soft) !important; }
[data-theme="dark"] .row-bad { background: rgba(224,86,111,.08) !important; }
.cell-strong { font-weight: 700; }
.muted { color: var(--ink-3); }

/* ===== Font size toggle ===== */
.fs-toggle {
  display: inline-flex; align-items: center; background: var(--bg-sunken);
  border-radius: 999px; padding: 3px; gap: 2px;
}
.fs-toggle button {
  padding: 5px 10px; border-radius: 999px; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 2px; font-weight: 700; font-size: 14px; line-height: 1;
}
.fs-toggle button:hover { background: var(--bg-panel); color: var(--ink); box-shadow: var(--shadow-sm); }
.fs-readout { font-size: 11.5px; font-weight: 700; color: var(--ink-3); min-width: 38px; text-align: center; padding: 0 2px; }
.fs-minus, .fs-plus { font-size: 11px; font-weight: 900; }

/* ===== Topbar user section ===== */
.topbar-divider { width: 1px; height: 26px; background: var(--line-2); flex: none; }
.topbar-user { display: flex; align-items: center; gap: 10px; color: var(--ink-1); }
.topbar-user:hover { opacity: .85; }
.avatar-sm { width: 34px; height: 34px; font-size: 13px; border-radius: 10px; overflow: hidden; }
.tu-meta { line-height: 1.3; }
.tu-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.tu-org { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }

/* ===== Profile page ===== */
.avatar-preview {
  width: 100px; height: 100px; border-radius: 999px; overflow: hidden;
  background: linear-gradient(135deg, var(--flag-red), var(--flag-red-soft));
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 32px;
  border: 3px solid var(--line);
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-field { display: flex; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.profile-field:last-of-type { border-bottom: none; }
.pf-label { width: 130px; flex: none; font-size: 13px; color: var(--ink-3); padding-top: 1px; }
.pf-value { font-size: 14px; color: var(--ink-1); word-break: break-all; }
.text-danger-soft { color: #dc3545; }
html[data-theme="dark"] .text-danger-soft { color: #f87171; }

/* ===== Content zoom (font scale) ===== */
.content { zoom: var(--content-zoom, 1); }

/* ===== Secret Import Screen ===== */
.sec-banner {
  display: flex; align-items: center; gap: 16px; padding: 18px 22px;
  background: var(--bad-soft); border: 1.5px solid color-mix(in srgb, var(--bad) 28%, transparent);
  border-radius: var(--radius);
}
.sec-ico {
  width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: color-mix(in srgb, var(--bad) 12%, var(--bg-panel)); color: var(--bad);
}
.sec-ico .ico { width: 22px; height: 22px; }
.sec-title { font-size: 16px; font-weight: 700; color: var(--bad); }
.sec-desc { font-size: 13px; color: var(--ink-2); margin-top: 3px; line-height: 1.55; }
.sec-clear { margin-left: auto; flex: none; }
.dropzone-sec { border-color: color-mix(in srgb, var(--bad) 25%, var(--line-2)); }
.dropzone-sec.drag { border-color: var(--bad); background: var(--bad-soft); }
.dz-ico-sec { background: color-mix(in srgb, var(--bad) 10%, var(--bg-panel)); color: var(--bad); }

/* ===== Classification guide & level badges ===== */
.cg-row {
  display: flex; align-items: flex-start; gap: 16px; padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.cg-row:last-child { border-bottom: none; }
.cg-txt { font-size: 13.5px; color: var(--ink-2); line-height: 1.55; padding-top: 3px; }
.lvl-badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 5px 14px; border-radius: 8px; font-size: 13.5px; font-weight: 700;
  flex: none; min-width: 90px; letter-spacing: .02em; white-space: nowrap;
}
.lvl-1 { background: var(--warn-soft); color: var(--warn); }
.lvl-2 { background: oklch(93% 0.05 30); color: oklch(40% 0.2 25); }
.lvl-3 { background: var(--bad-soft); color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 22%, transparent); }
[data-theme="dark"] .lvl-2 { background: oklch(28% 0.08 25); color: oklch(72% 0.15 25); }

/* Class select dynamic coloring */
.class-sel { transition: color .15s, border-color .15s; }
.class-sel.lvl-1 { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line-2)); }
.class-sel.lvl-2 { color: oklch(40% 0.2 25); border-color: oklch(75% 0.1 25); }
.class-sel.lvl-3 { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line-2)); }

/* Allow nav items to wrap so long Thai text fits */
.nav-item { white-space: normal; }

/* Anchor nav items */
a.nav-item { text-decoration: none; cursor: pointer; }

/* ===== Sidebar Beta badge ===== */
.badge-beta {
  margin-left: auto; font-size: 10px; font-weight: 700; letter-spacing: .06em;
  padding: 2px 7px; border-radius: 999px; text-transform: uppercase;
  background: rgba(224,86,111,.18); color: #F0889B; border: 1px solid rgba(224,86,111,.32);
}

/* ===== Chat with AI ===== */
.chat-shell {
  display: flex; flex-direction: column; height: calc(100vh - 168px); min-height: 540px;
  background: var(--bg-panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.chat-bar {
  display: flex; align-items: center; gap: 16px; padding: 16px 22px;
  border-bottom: 1px solid var(--line); background: var(--bg-elev);
}
.chat-bar-left { display: flex; align-items: center; gap: 13px; min-width: 0; }
.chat-orb {
  width: 42px; height: 42px; border-radius: 13px; flex: none; display: grid; place-items: center;
  color: #fff; background: linear-gradient(135deg, var(--flag-navy) 0%, #5a3a6b 55%, var(--flag-red) 100%);
  box-shadow: 0 4px 14px rgba(45,42,74,.3);
}
.chat-orb .ico { width: 22px; height: 22px; }
.chat-title { font-size: 16px; font-weight: 700; }
.chat-sub { font-size: 12.5px; color: var(--ink-3); }

/* model picker */
.model-pick { position: relative; margin-left: auto; flex: none; }
.model-btn {
  display: flex; align-items: center; gap: 9px; padding: 8px 13px; border-radius: var(--radius-sm); white-space: nowrap;
  border: 1px solid var(--line-2); background: var(--bg-panel); font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow-sm);
}
.model-cur, .model-cur-sub { white-space: nowrap; }
.chat-bar-left > div { min-width: 0; }
.chat-title, .chat-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-btn:hover { border-color: var(--ink-3); }
.model-btn .ico { width: 17px; height: 17px; color: var(--ink-3); }
.model-dot { width: 9px; height: 9px; border-radius: 999px; background: var(--good); flex: none; }
.model-cur-sub {
  font-size: 11px; font-weight: 600; color: var(--ink-2); background: var(--bg-sunken);
  padding: 1px 7px; border-radius: 999px;
}
.model-menu {
  position: absolute; right: 0; top: calc(100% + 8px); width: 320px; z-index: 50;
  background: var(--bg-panel); border: 1px solid var(--line-2); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 7px; display: none;
}
.model-pick.open .model-menu { display: block; }
.model-opt {
  display: flex; align-items: flex-start; gap: 11px; padding: 10px 11px; border-radius: var(--radius-sm);
  cursor: pointer; width: 100%; text-align: left;
}
.model-opt:hover { background: var(--bg-elev); }
.model-opt .mo-dot { width: 9px; height: 9px; border-radius: 999px; flex: none; margin-top: 6px; }
.model-opt .mo-name { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.model-opt .mo-desc { font-size: 12px; color: var(--ink-3); margin-top: 1px; }
.model-opt .mo-check { margin-left: auto; color: var(--accent); display: none; }
.model-opt.sel .mo-check { display: block; }
.mo-tag { font-size: 10px; font-weight: 700; letter-spacing: .04em; padding: 1px 6px; border-radius: 999px; white-space: nowrap; flex: none; }
.mo-name { flex-wrap: wrap; }
.mo-tag.local { background: var(--accent-soft); color: var(--accent); }
.mo-tag.cloud { background: rgba(45,42,74,.08); color: var(--flag-navy); }
[data-theme="dark"] .mo-tag.cloud { background: rgba(110,106,158,.2); color: #ABA7D6; }

/* thread */
.chat-thread { flex: 1; overflow-y: auto; padding: 26px 26px 10px; display: flex; flex-direction: column; gap: 22px; }
.msg { display: flex; gap: 13px; max-width: 82%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-av {
  width: 34px; height: 34px; border-radius: 10px; flex: none; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--flag-navy), var(--flag-red)); margin-top: 2px;
}
.msg-av .ico { width: 18px; height: 18px; }
.msg.user .msg-av { background: var(--bg-sunken); color: var(--ink-2); }
.bubble {
  padding: 13px 17px; border-radius: 16px; font-size: 14.5px; line-height: 1.62; white-space: pre-wrap;
}
.msg.ai .bubble { background: var(--bg-elev); border: 1px solid var(--line); border-top-left-radius: 5px; }
.msg.user .bubble { background: var(--flag-navy); color: #fff; border-top-right-radius: 5px; }
[data-theme="dark"] .msg.user .bubble { background: #3b3766; }
.msg-name { font-size: 12px; color: var(--ink-3); font-weight: 600; margin-bottom: 5px; }
.msg-name b { color: var(--ink-2); font-weight: 700; }
.cite-label { font-size: 12px; color: var(--ink-3); font-weight: 600; margin: 12px 0 8px; display: flex; align-items: center; gap: 7px; }
.cite-list { display: flex; flex-direction: column; gap: 8px; }
.cite-chip {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--bg-panel); font-size: 13px;
}
.cite-chip:hover { border-color: var(--line-2); box-shadow: var(--shadow-sm); }
.cite-chip .cc-name { font-weight: 600; }
.cite-chip .cc-meta { font-size: 11.5px; color: var(--ink-3); }
.cite-chip .cc-dl { margin-left: auto; color: var(--accent); display: grid; place-items: center; }
.cite-chip .cc-dl .ico { width: 17px; height: 17px; }
.typing { display: inline-flex; gap: 5px; padding: 4px 2px; }
.typing i { width: 8px; height: 8px; border-radius: 999px; background: var(--ink-3); animation: tdot 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes tdot { 0%,60%,100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }

/* composer */
.chat-composer { border-top: 1px solid var(--line); padding: 14px 20px 16px; background: var(--bg-panel); }
.chip-row { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 12px; }
.chip-row.hide { display: none; }
.sug-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--bg-elev); font-size: 13.5px; font-weight: 500; color: var(--ink-2);
}
.sug-chip:hover { border-color: var(--flag-navy); color: var(--ink); background: var(--bg-panel); }
.sug-chip .ico { width: 15px; height: 15px; color: var(--accent); }
.composer-box {
  display: flex; align-items: flex-end; gap: 10px; background: var(--bg-elev);
  border: 1px solid var(--line-2); border-radius: var(--radius); padding: 8px 8px 8px 12px;
}
.composer-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(45,42,74,.1); }
.comp-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: var(--ink-3); flex: none; }
.comp-icon:hover { background: var(--bg-sunken); color: var(--ink-2); }
.composer-box textarea {
  flex: 1; border: none; outline: none; background: transparent; resize: none; font-size: 15px;
  line-height: 1.5; padding: 9px 2px; max-height: 140px; color: var(--ink);
}
.comp-send {
  width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex: none;
  background: var(--accent); color: #fff; transition: filter .15s, opacity .15s;
}
.comp-send:hover { filter: brightness(1.07); }
.comp-send .ico { width: 19px; height: 19px; }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.composer-foot span:first-child { display: inline-flex; align-items: center; gap: 6px; }
.composer-foot .ico { width: 14px; height: 14px; color: var(--good); }

/* ===== Bootstrap modal theme integration ===== */
.modal-content {
  background: var(--bg-panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.modal-header, .modal-footer { border-color: var(--line); }
.modal-header .btn-close { filter: var(--bs-btn-close-filter, none); opacity: .55; }
[data-theme="dark"] .modal-header .btn-close { filter: invert(1); }
.modal-body .field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.modal-body .field { margin-bottom: 14px; }
.modal-body .input, .modal-body .sel {
  width: 100%; padding: 10px 14px; border-radius: var(--radius-xs);
  border: 1px solid var(--line-2); background: var(--bg-panel);
  color: var(--ink); font-size: 14.5px; font-family: inherit;
}
.modal-body .sel { appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238E8CA3' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 11px center;
}
.modal-body .input:focus, .modal-body .sel:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }
.modal-err { font-size: 13px; color: var(--bad); padding: 10px 14px; border-radius: var(--radius-xs); background: var(--bad-soft); margin-bottom: 12px; display: none; }
.modal-err.show { display: block; }

/* ===== DataTables integration (DT 1.x + DT 2.x) ===== */
/* Wrapper — DT 1.x: dataTables_wrapper, DT 2.x: dt-container */
.dataTables_wrapper,
.dt-container { padding: 16px 20px 18px; color: var(--ink); }

/* Search & Length controls */
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_length,
.dt-container .dt-search,
.dt-container .dt-length {
  margin-bottom: 14px;
  font-size: 13.5px;
  color: var(--ink-2);
}
.dataTables_wrapper .dataTables_filter { float: right; }
.dataTables_wrapper .dataTables_length { float: left; }
.dataTables_wrapper::after { content: ''; display: table; clear: both; }

/* Inputs */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select,
.dt-container .dt-search input,
.dt-container .dt-length select {
  appearance: none;
  padding: 7px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-xs);
  background: var(--bg-panel);
  color: var(--ink);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  margin-left: 6px;
  transition: border-color .15s;
}
.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus,
.dt-container .dt-search input:focus,
.dt-container .dt-length select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(45,42,74,.09); }
.dataTables_wrapper .dataTables_length select,
.dt-container .dt-length select { padding-right: 28px; cursor: pointer; }

/* Info */
.dataTables_wrapper .dataTables_info,
.dt-container .dt-info {
  float: left;
  font-size: 12.5px;
  color: var(--ink-3);
  padding-top: 10px;
}

/* Pagination — DT 1.x */
.dataTables_wrapper .dataTables_paginate { float: right; padding-top: 6px; }
.dataTables_wrapper .dataTables_paginate::after { content: ''; display: table; clear: both; }
.dataTables_wrapper .dataTables_paginate .paginate_button {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 8px;
  border-radius: var(--radius-xs); font-size: 13px; font-weight: 500;
  color: var(--ink-2) !important; cursor: pointer;
  background: none; border: 1px solid transparent;
  transition: all .15s; user-select: none;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover:not(.disabled) {
  background: var(--bg-sunken) !important; color: var(--ink) !important; border-color: var(--line-2) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--flag-navy) !important; color: #fff !important; border-color: transparent !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
  color: var(--ink-3) !important; cursor: default; opacity: .5;
}
.dataTables_wrapper .dataTables_paginate span { display: inline-flex; gap: 2px; }
.dataTables_wrapper .dataTables_paginate .paginate_button.previous,
.dataTables_wrapper .dataTables_paginate .paginate_button.next { font-size: 12px; }

/* Pagination — DT 2.x */
.dt-container .dt-paging { padding-top: 6px; }
.dt-container .dt-paging .dt-paging-button {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 8px;
  border-radius: var(--radius-xs); font-size: 13px; font-weight: 500;
  color: var(--ink-2) !important; cursor: pointer;
  background: none; border: 1px solid transparent;
  transition: all .15s; user-select: none; font-family: inherit;
}
.dt-container .dt-paging .dt-paging-button:hover:not([disabled]):not(.disabled) {
  background: var(--bg-sunken) !important; color: var(--ink) !important; border-color: var(--line-2) !important;
}
.dt-container .dt-paging .dt-paging-button.current,
.dt-container .dt-paging .dt-paging-button.current:hover {
  background: var(--flag-navy) !important; color: #fff !important; border-color: transparent !important;
}
.dt-container .dt-paging .dt-paging-button[disabled],
.dt-container .dt-paging .dt-paging-button.disabled {
  color: var(--ink-3) !important; cursor: default; opacity: .5;
}

/* Processing indicator */
.dataTables_wrapper .dataTables_processing,
.dt-container .dt-processing {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-panel); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 22px;
  font-size: 13px; color: var(--ink-2); box-shadow: var(--shadow-sm); z-index: 100;
}
.dataTables_wrapper table.tbl,
.dt-container table.tbl { margin-bottom: 0; }
.dataTables_wrapper .dataTables_empty,
.dt-container .dt-empty { text-align: center; color: var(--ink-3); padding: 32px !important; }

/* Sort indicators — DT 1.x class names */
table.tbl thead th.sorting,
table.tbl thead th.sorting_asc,
table.tbl thead th.sorting_desc,
table.tbl thead th.dt-orderable-asc,
table.tbl thead th.dt-orderable-desc { cursor: pointer; padding-right: 28px; position: relative; }
table.tbl thead th.sorting::after,
table.tbl thead th.dt-orderable-asc::after,
table.tbl thead th.dt-orderable-desc::after { content: '↕'; font-size: 9px; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-3); opacity: .4; }
table.tbl thead th.sorting_asc::after,
table.tbl thead th.dt-ordering-asc::after  { content: '▲'; font-size: 8px; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--flag-navy); opacity: 1; }
table.tbl thead th.sorting_desc::after,
table.tbl thead th.dt-ordering-desc::after { content: '▼'; font-size: 8px; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--flag-navy); opacity: 1; }
/* Hide DataTables 2.x built-in sort arrows — we use our own */
table.tbl thead th.dt-orderable-asc span.dt-column-order,
table.tbl thead th.dt-orderable-desc span.dt-column-order,
table.tbl thead th.dt-ordering-asc span.dt-column-order,
table.tbl thead th.dt-ordering-desc span.dt-column-order { display: none; }

/* ===== DataTables dark mode overrides ===== */
/* Use html[data-theme="dark"] prefix for max specificity + hardcoded hex to avoid variable issues */
html[data-theme="dark"] table.dataTable,
html[data-theme="dark"] table.tbl { color: #ECEBF5; }

html[data-theme="dark"] table.tbl thead th,
html[data-theme="dark"] table.tbl thead td,
html[data-theme="dark"] table.dataTable thead th,
html[data-theme="dark"] table.dataTable thead td {
  color: #A6A3C2 !important;
  background-color: #232036 !important;
  border-color: #2E2B42 !important;
}
html[data-theme="dark"] table.tbl tbody td,
html[data-theme="dark"] table.dataTable tbody td {
  color: #ECEBF5 !important;
  border-color: #2E2B42 !important;
}
html[data-theme="dark"] table.tbl tbody tr:hover td,
html[data-theme="dark"] table.dataTable tbody tr:hover td { background-color: #232036 !important; }
html[data-theme="dark"] table.tbl tfoot th,
html[data-theme="dark"] table.tbl tfoot td,
html[data-theme="dark"] table.dataTable tfoot th,
html[data-theme="dark"] table.dataTable tfoot td {
  color: #A6A3C2 !important;
  background-color: #232036 !important;
  border-color: #2E2B42 !important;
}
/* Wrapper text & controls — DT 1.x */
html[data-theme="dark"] .dataTables_wrapper { color: #ECEBF5; }
html[data-theme="dark"] .dataTables_wrapper .dataTables_filter label,
html[data-theme="dark"] .dataTables_wrapper .dataTables_length label { color: #A6A3C2; }
html[data-theme="dark"] .dataTables_wrapper .dataTables_info { color: #726F92; }
html[data-theme="dark"] .dataTables_wrapper .dataTables_filter input,
html[data-theme="dark"] .dataTables_wrapper .dataTables_length select {
  background: #1D1B2B; color: #ECEBF5; border-color: #383452;
}
/* Wrapper text & controls — DT 2.x */
html[data-theme="dark"] .dt-container { color: #ECEBF5; }
html[data-theme="dark"] .dt-container .dt-search label,
html[data-theme="dark"] .dt-container .dt-length label { color: #A6A3C2; }
html[data-theme="dark"] .dt-container .dt-info { color: #726F92; }
html[data-theme="dark"] .dt-container .dt-search input,
html[data-theme="dark"] .dt-container .dt-length select {
  background: #1D1B2B !important; color: #ECEBF5 !important; border-color: #383452 !important;
}
/* Sort arrows */
html[data-theme="dark"] table.tbl thead th.sorting_asc::after,
html[data-theme="dark"] table.tbl thead th.dt-ordering-asc::after  { color: #9D99CE; }
html[data-theme="dark"] table.tbl thead th.sorting_desc::after,
html[data-theme="dark"] table.tbl thead th.dt-ordering-desc::after { color: #9D99CE; }

/* DataTables cell avatar row */
.dt-avatar-row { display: flex; align-items: center; gap: 10px; }
.dt-avatar-row .avatar { flex: none; }

/* ===== Upload Overlay ===== */
.upload-overlay {
  position: fixed; inset: 0;
  background: rgba(28,27,42,.6);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
}
.upload-overlay-box {
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 44px 56px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  min-width: 300px;
}
.upload-spinner {
  width: 52px; height: 52px;
  border: 4px solid var(--line-2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: upl-spin .75s linear infinite;
}
@keyframes upl-spin { to { transform: rotate(360deg); } }
.uol-title { font-size: 18px; font-weight: 700; color: var(--ink); }
.uol-sub   { font-size: 13.5px; color: var(--ink-3); }

/* ===== Dashboard: navy elements — dark mode visibility fix ===== */
.dot-imp { background: var(--flag-navy); }
.dot-dl  { background: var(--flag-red); }
[data-theme="dark"] .bar.imp {
  background: linear-gradient(to top, #5A5690, #8683B8);
}
[data-theme="dark"] .bar.dl {
  background: linear-gradient(to top, var(--accent), #F0889B);
}
[data-theme="dark"] .org-fill {
  background: linear-gradient(to right, #5A5690, #8683B8);
}
[data-theme="dark"] .dot-imp { background: #7B77B0; }
[data-theme="dark"] .dot-dl  { background: var(--accent); }
