/* ==========================================================================
   Portal — hệ thống giao diện
   Bảng màu & bố cục lấy trực tiếp từ bộ mockup "Thiết kế giao diện Hệ thống
   Quản lý Hồ sơ" (tài liệu tư vấn kiến trúc, mục 2: tái dùng token CSS mockup).
   ========================================================================== */
:root {
  --navy-900: #142f4d;
  --navy-800: #1b3b5f;
  --navy-700: #234c78;
  --navy-600: #2b5b8a;

  --blue-600: #1668dc;
  --blue-700: #1257b8;
  --blue-100: #dbeafe;
  --blue-050: #eef5ff;

  --ink-900: #16324f;
  --ink-700: #33475e;
  --ink-500: #6b7c93;
  --ink-400: #8496ad;

  --line: #e6ecf2;
  --line-strong: #d5dfe9;
  --bg: #f4f7fa;
  --white: #fff;

  --green-600: #16a34a;
  --green-700: #15803d;
  --green-050: #dcfce7;
  --amber-700: #b45309;
  --amber-050: #fef3c7;
  --red-600: #dc2626;
  --red-700: #b91c1c;
  --red-050: #fee2e2;
  --slate-050: #eef2f6;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(20, 47, 77, .06);
  --shadow-md: 0 8px 28px rgba(20, 47, 77, .14);
  --sidebar-w: 268px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Segoe UI', Roboto, 'Helvetica Neue', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--ink-700);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue-600); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ------------------------------ Bố cục ------------------------------ */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--navy-800);
  color: #cfe0f0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 22px 20px 20px;
}
.brand .logo {
  width: 34px; height: 34px; flex: 0 0 34px; display: block; object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(214, 173, 84, .3));
}
.brand .name { font-size: 16.5px; font-weight: 700; color: #fff; line-height: 1.2; }
.brand-sub { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: #d4af5c; margin-top: 2px; }

.nav { flex: 1; overflow-y: auto; padding-bottom: 12px; }
.nav-section {
  padding: 16px 20px 8px; font-size: 10.5px; letter-spacing: .11em;
  text-transform: uppercase; color: #7f9cba; font-weight: 700;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px; color: #cfe0f0; cursor: pointer;
  border-left: 3px solid transparent; font-size: 14px;
}
.nav-item:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.nav-item.active {
  background: var(--navy-600); color: #fff; font-weight: 600;
  border-left-color: #67a6f5;
}
.nav-item .ico { width: 18px; height: 18px; flex: 0 0 18px; opacity: .95; }
.nav-item .badge-count {
  margin-left: auto; background: rgba(255,255,255,.16); color: #fff;
  border-radius: 20px; padding: 1px 8px; font-size: 11px; font-weight: 700;
}

.sidebar-user {
  display: flex; align-items: center; gap: 11px; padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, .1);
}
.sidebar-user .avatar { background: var(--blue-600); color: #fff; }
.sidebar-user .n { font-weight: 700; color: #fff; font-size: 13.5px; }
.sidebar-user .r { font-size: 12px; color: #9fbcd8; }
.sidebar-user .logout {
  margin-left: auto; background: none; border: 0; color: #9fbcd8; cursor: pointer; padding: 4px;
}
.sidebar-user .logout:hover { color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 74px; background: var(--white); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 20px; padding: 0 28px;
  position: sticky; top: 0; z-index: 20;
}
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--ink-500); font-size: 14px; }
.crumbs b { color: var(--ink-900); font-weight: 700; }
.crumbs .sep { color: #b9c6d4; }
.crumbs a { color: var(--ink-500); }
.crumbs a:hover { color: var(--blue-600); }

.search {
  margin-left: auto; position: relative; width: 320px;
}
.search input {
  width: 100%; height: 44px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 0 12px 0 38px; background: #fbfdff; outline: none;
}
.search input:focus { border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(22, 104, 220, .12); }
.search svg { position: absolute; left: 12px; top: 13px; color: var(--ink-400); }

.icon-btn {
  position: relative; width: 38px; height: 38px; border-radius: 50%; border: 0;
  background: transparent; color: var(--ink-500); cursor: pointer; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--slate-050); }
.icon-btn .dot {
  position: absolute; top: 8px; right: 9px; width: 7px; height: 7px;
  background: var(--red-600); border-radius: 50%; border: 1.5px solid #fff;
}

/* ------------------------------ Menu tài khoản (avatar góc trên) ------------------------------ */
.user-menu { position: relative; }
.user-menu-trigger {
  border: 0; background: transparent; padding: 0; cursor: pointer; border-radius: 50%;
  display: block; line-height: 0; transition: box-shadow .12s;
}
.user-menu-trigger:hover, .user-menu.open .user-menu-trigger {
  box-shadow: 0 0 0 3px var(--blue-050);
}
.user-menu-pop {
  position: absolute; top: calc(100% + 10px); right: 0; width: 240px; z-index: 30;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-md);
  padding: 14px; opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity .14s, transform .14s, visibility .14s;
}
.user-menu.open .user-menu-pop { opacity: 1; visibility: visible; transform: translateY(0); }
.user-menu-head { display: flex; align-items: center; gap: 11px; }
.user-menu-head .n { font-weight: 700; color: var(--ink-900); font-size: 13.5px; }
.user-menu-head .r { font-size: 12px; color: var(--ink-500); margin-top: 1px; }
.user-menu-sep { height: 1px; background: var(--line); margin: 12px -14px; }
.user-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: 0; background: transparent; padding: 9px 8px; border-radius: 8px; cursor: pointer;
  font-size: 13.5px; font-weight: 600; color: var(--ink-700); margin: 0 -8px;
}
.user-menu-item:hover { background: #fff5f5; color: var(--red-700); }
.user-menu-item svg { color: inherit; }

.content { padding: 26px 28px 48px; flex: 1; }

/* ------------------------------ Tiêu đề trang ------------------------------ */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: 26px; color: var(--ink-900); font-weight: 700; letter-spacing: -.2px; }
.page-head p { margin: 6px 0 0; color: var(--ink-500); font-size: 13.5px; }
.page-head .actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }

/* ------------------------------ Băng chào — Bảng điều khiển ------------------------------ */
.dash-hero {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 20px;
  padding: 30px 32px; margin-bottom: 22px; border-radius: 18px; color: #fff;
  background: linear-gradient(120deg, var(--navy-900) 0%, var(--navy-700) 52%, var(--blue-600) 100%);
  box-shadow: var(--shadow-md);
}
.dash-hero::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(420px 220px at 88% -10%, rgba(212, 175, 92, .22), transparent 65%),
    radial-gradient(320px 200px at 102% 100%, rgba(103, 166, 245, .28), transparent 60%);
}
.dash-hero-body { position: relative; min-width: 0; }
.dash-hero-eyebrow {
  display: inline-flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: #d4af5c; margin-bottom: 8px;
}
.dash-hero h1 { margin: 0; font-size: 25px; font-weight: 700; letter-spacing: -.2px; color: #fff; }
.dash-hero p { margin: 7px 0 0; font-size: 13.5px; color: rgba(255, 255, 255, .78); max-width: 560px; line-height: 1.55; }
.dash-hero .actions { position: relative; margin-left: auto; display: flex; gap: 10px; flex: 0 0 auto; }
.dash-hero .btn {
  background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .28); color: #fff;
  backdrop-filter: blur(2px);
}
.dash-hero .btn:hover { background: rgba(255, 255, 255, .18); border-color: rgba(255, 255, 255, .4); }
.dash-hero .btn-primary {
  background: #fff; border-color: #fff; color: var(--navy-800);
}
.dash-hero .btn-primary:hover { background: #eef5ff; }
@media (max-width: 760px) {
  .dash-hero { flex-direction: column; align-items: flex-start; }
  .dash-hero .actions { margin-left: 0; }
}

/* ------------------------------ Nút ------------------------------ */
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--white);
  color: var(--ink-700); font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #bccbdb; background: #fbfdff; }
.btn-primary { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }
.btn-primary:hover { background: var(--blue-700); border-color: var(--blue-700); }
.btn-danger { color: var(--red-700); border-color: #f3c9c9; }
.btn-danger:hover { background: #fff5f5; border-color: #e9a8a8; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ------------------------------ Thẻ / lưới ------------------------------ */
.card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px 20px; }
.card-title { font-size: 15.5px; font-weight: 700; color: var(--ink-900); margin: 0; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px 8px; }
.card-head .muted { margin-left: auto; font-size: 12.5px; color: var(--ink-400); }

.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.layout-side { display: grid; grid-template-columns: 268px minmax(0, 1fr); gap: 18px; align-items: start; }
.layout-side-3 { display: grid; grid-template-columns: 268px minmax(0, 1fr) 300px; gap: 18px; align-items: start; }

@media (max-width: 1280px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-side-3 { grid-template-columns: 240px minmax(0, 1fr); }
  .layout-side-3 > :nth-child(3) { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .sidebar { display: none; }
  .grid-4, .grid-2, .layout-side, .layout-side-3 { grid-template-columns: minmax(0, 1fr); }
  .search { width: 180px; }
}

/* Thẻ số liệu dashboard */
.stat { padding: 18px 20px; }
.stat .t { display: flex; align-items: center; gap: 10px; color: var(--ink-700); font-weight: 600; font-size: 14px; }
.stat .t svg { margin-left: auto; color: var(--blue-600); }
.stat .v { font-size: 34px; font-weight: 800; color: var(--ink-900); margin: 10px 0 6px; letter-spacing: -.5px; }
.stat .s { font-size: 12.5px; font-weight: 600; }
.s-green { color: var(--green-700); }
.s-amber { color: var(--amber-700); }
.s-red { color: var(--red-700); }
.s-muted { color: var(--ink-500); }

/* ==========================================================================
   Bảng điều khiển
   ========================================================================== */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 620px) { .stat-grid { grid-template-columns: minmax(0, 1fr); } }

.stat-tile {
  background: var(--white); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 20px 20px; box-shadow: var(--shadow-sm);
  transition: box-shadow .18s, transform .18s, border-color .18s;
}
.stat-tile-link { cursor: pointer; }
.stat-tile-link:hover {
  box-shadow: 0 10px 24px rgba(20, 47, 77, .12); transform: translateY(-2px); border-color: #d7e3f0;
}
.stat-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.stat-label {
  font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-400); font-weight: 700;
}
.stat-chip {
  margin-left: auto; width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center; flex: 0 0 38px;
}
.chip-blue { background: linear-gradient(150deg, #e8f1fe, #d7e8fd); color: #1257b8; }
.chip-amber { background: linear-gradient(150deg, #fdf3dd, #fbe8c2); color: #96660a; }
.chip-red { background: linear-gradient(150deg, #fdeaea, #fbd8d8); color: #b4302f; }
.chip-slate { background: linear-gradient(150deg, var(--slate-050), #e2e8f0); color: #5b6b7f; }
.chip-green { background: linear-gradient(150deg, #e3f6e3, #cdefcd); color: #0a7c0a; }

.stat-value {
  font-size: 33px; line-height: 1.1; font-weight: 800;
  color: var(--ink-900); letter-spacing: -.6px;
}
.stat-sub {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 700; margin-top: 10px; padding: 3px 9px 3px 8px; border-radius: 20px;
}
.tone-good { color: #0a7c0a; background: #e3f6e3; }
.tone-warning { color: #96660a; background: #fdf3dd; }
.tone-critical { color: #b4302f; background: #fdeaea; }
.tone-muted { color: var(--ink-500); font-weight: 600; background: var(--slate-050); }

.meter { height: 7px; border-radius: 20px; background: #e9eef4; overflow: hidden; margin-top: 14px; }
.meter > i {
  display: block; height: 100%; border-radius: 20px;
  background: linear-gradient(90deg, var(--blue-600), #4d9bef);
}

/* --- Biểu đồ cột ngang: một chuỗi, một màu, trục để mờ --- */
.bar-chart { display: flex; flex-direction: column; gap: 3px; }
.bar-row {
  display: grid; grid-template-columns: 148px minmax(0, 1fr) 58px;
  align-items: center; gap: 14px; padding: 8px; margin: 0 -8px;
  border-radius: 9px; cursor: pointer; transition: background .12s;
}
.bar-row:hover { background: #f5f9fd; }
.bar-name { font-size: 13.5px; font-weight: 600; color: var(--ink-900); }
.bar-track {
  height: 11px; background: #eef2f7; border-radius: 6px; position: relative; overflow: hidden;
}
.bar-fill {
  display: block; height: 100%; border-radius: 6px;
  background: linear-gradient(90deg, var(--blue-600), #52a1f2);
  transition: filter .12s;
}
.bar-row:hover .bar-fill { filter: brightness(.93); }
.bar-value {
  text-align: right; font-size: 13.5px; font-weight: 700; color: var(--ink-900);
  font-variant-numeric: tabular-nums;
}

/* --- Dải trạng thái: màu luôn đi kèm nhãn và số --- */
.status-bar { display: flex; gap: 3px; height: 13px; margin-bottom: 18px; border-radius: 7px; overflow: hidden; }
.status-seg { display: block; min-width: 4px; }
.seg-good { background: #0ca30c; }
.seg-warning { background: #fab219; }
.seg-neutral { background: #b6c0cd; }
.seg-critical { background: #d03b3b; }

.status-legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; }
.status-item {
  display: flex; align-items: center; gap: 9px; font-size: 13px; padding: 8px 10px;
  border-radius: 9px; background: #f8fafc;
}
.status-dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 9px; }
.dot-good { background: #0ca30c; }
.dot-warning { background: #fab219; }
.dot-neutral { background: #b6c0cd; }
.dot-critical { background: #d03b3b; }
.status-name { color: var(--ink-700); }
.status-count { margin-left: auto; color: var(--ink-900); font-weight: 700; font-variant-numeric: tabular-nums; }
.status-pct { color: var(--ink-400); font-size: 12px; min-width: 34px; text-align: right; }

/* --- Việc của tôi --- */
.pill {
  padding: 4px 11px; border-radius: 20px; font-size: 12px; font-weight: 700; white-space: nowrap;
}
.pill-warning { background: #fdf3dd; color: #96660a; }
.pill-good { background: #e3f6e3; color: #006300; }

.task-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 13px; margin: 0 -10px;
  border-radius: 10px; cursor: pointer; border-left: 3px solid transparent; transition: background .12s;
}
.task-row + .task-row { margin-top: 2px; }
.task-row:hover { background: #f5f9fd; }
.task-row.tone-blue { border-left-color: #1257b8; }
.task-row.tone-amber { border-left-color: #96660a; }
.task-row.tone-red { border-left-color: #b4302f; }
.task-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: 0 0 32px; }
.task-label { font-size: 13.5px; color: var(--ink-700); font-weight: 500; }
.task-count {
  margin-left: auto; font-size: 17px; font-weight: 700; color: var(--ink-900); font-variant-numeric: tabular-nums;
}
.task-go { color: var(--ink-400); }
.task-done { border-left-color: transparent; }
.task-done .task-count { color: var(--ink-400); font-weight: 600; }
.task-done .task-icon { background: var(--slate-050); color: var(--ink-400); }

/* --- Truy cập nhanh --- */
.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.quick-item {
  display: flex; align-items: center; gap: 10px; padding: 12px; text-align: left;
  border: 1px solid var(--line); border-radius: 11px; background: #fbfdff; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--ink-700); min-width: 0;
  transition: border-color .12s, background .12s, transform .12s;
}
.quick-item:hover { border-color: #bcd4f0; background: var(--blue-050); color: var(--blue-700); transform: translateY(-1px); }
.quick-item .qi-ico {
  flex: 0 0 30px; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: var(--slate-050); color: var(--ink-400); transition: background .12s, color .12s;
}
.quick-item:hover .qi-ico { background: var(--blue-100); color: var(--blue-700); }

/* --- Dòng hoạt động --- */
.feed { display: flex; flex-direction: column; position: relative; }
.feed-row {
  display: flex; align-items: flex-start; gap: 13px; padding: 11px 6px; margin: 0 -6px;
  border-radius: 9px; position: relative; transition: background .12s;
}
.feed-row:hover { background: #f8fafc; }
.feed-row:not(:last-child)::before {
  content: ''; position: absolute; left: 21px; top: 42px; bottom: -11px; width: 2px; background: var(--line);
}
.feed-avatar {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 50%;
  display: grid; place-items: center; position: relative; z-index: 1; box-shadow: 0 0 0 3px #fff;
}
.feed-alert { background: #fdeaea; color: #b4302f; }
.feed-body { min-width: 0; padding-top: 1px; }
.feed-text { font-size: 13.5px; color: var(--ink-700); line-height: 1.5; }
.feed-text b { color: var(--ink-900); }
.feed-danger { color: #b4302f; font-weight: 700; }
.feed-meta { font-size: 11.5px; color: var(--ink-400); margin-top: 3px; }

/* ------------------------------ Bảng ------------------------------ */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-400); font-weight: 700; padding: 12px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 13px 14px; border-bottom: 1px solid #f0f4f8; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafcfe; }
.table tbody tr.selected { background: var(--blue-050); }
.table .r-danger { background: #fff6f6; }
.table .r-danger:hover { background: #fff0f0; }
.cell-strong { font-weight: 700; color: var(--ink-900); }
.cell-sub { font-size: 12px; color: var(--ink-500); margin-top: 2px; }
.nowrap { white-space: nowrap; }
.table-wrap { overflow-x: auto; }

/* ------------------------------ Badge / chip ------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.no-dot::before { display: none; }
.b-green { background: var(--green-050); color: var(--green-700); }
.b-amber { background: var(--amber-050); color: var(--amber-700); }
.b-red { background: var(--red-050); color: var(--red-700); }
.b-gray { background: var(--slate-050); color: #64748b; }
.b-blue { background: var(--blue-100); color: #1d4ed8; }

.chip {
  display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 5px;
  background: var(--slate-050); color: var(--ink-700); font-size: 12px; font-weight: 600;
}

.avatar {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 50%;
  background: var(--blue-100); color: #1d4ed8;
  display: grid; place-items: center; font-size: 11px; font-weight: 800;
}
.avatar-lg { width: 38px; height: 38px; flex-basis: 38px; font-size: 13px; }
.avatar-sm { width: 26px; height: 26px; flex-basis: 26px; font-size: 10px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-right: -7px; border: 2px solid #fff; }
.avatar-photo { padding: 0; overflow: hidden; background: var(--slate-050); }
.avatar-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.avatar-preview {
  width: 120px; height: 120px; border-radius: 50%; overflow: hidden; margin: 0 auto 18px;
  background: var(--blue-100); display: grid; place-items: center; border: 1px solid var(--line);
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-preview-empty { font-size: 30px; font-weight: 800; color: #1d4ed8; }

.row { display: flex; align-items: center; gap: 10px; }
.row-tight { display: flex; align-items: center; gap: 6px; }
.col { display: flex; flex-direction: column; }
.spacer { flex: 1; }
.muted { color: var(--ink-500); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.strong { font-weight: 700; color: var(--ink-900); }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------ Cây thư mục ------------------------------ */
.tree-title {
  font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-400); font-weight: 700; padding: 16px 18px 8px;
}
.tree { padding: 0 10px 14px; }
.tree-item {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--ink-700); font-size: 13.5px;
}
.tree-item:hover { background: #f4f8fc; }
.tree-item.active { background: var(--blue-050); color: var(--blue-700); font-weight: 700; }
.tree-item .count { margin-left: auto; font-size: 12px; color: var(--ink-400); font-weight: 600; }
.tree-menu {
  margin-left: auto; border: 0; background: transparent; color: var(--ink-400);
  cursor: pointer; padding: 0 5px; border-radius: 5px; line-height: 1; font-size: 15px;
  opacity: 0; transition: opacity .12s;
}
.tree-item:hover .tree-menu, .tree-item.active .tree-menu { opacity: 1; }
.tree-menu:hover { background: #dbe7f4; color: var(--ink-900); }
.tree-item .tree-menu + .count { margin-left: 6px; }
.tree-item.active .count { color: var(--blue-700); }
.tree-children { margin-left: 16px; }

/* ------------------------------ Công tắc ------------------------------ */
.switch {
  position: relative; width: 42px; height: 23px; border-radius: 20px; background: #cbd5e1;
  border: 0; cursor: pointer; transition: background .15s; flex: 0 0 42px; padding: 0;
}
.switch::after {
  content: ''; position: absolute; top: 2.5px; left: 2.5px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.switch.on { background: var(--green-600); }
.switch.on::after { transform: translateX(19px); }
.switch:disabled { opacity: .55; cursor: not-allowed; }
.switch.sm { width: 36px; height: 20px; flex-basis: 36px; }
.switch.sm::after { width: 15px; height: 15px; top: 2.5px; left: 2.5px; }
.switch.sm.on::after { transform: translateX(16px); }

/* ------------------------------ Form ------------------------------ */
.field { margin-bottom: 15px; }
.label {
  display: block; font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-400); font-weight: 700; margin-bottom: 7px;
}
.input, .select, .textarea {
  width: 100%; height: 42px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 0 12px; background: #fff; outline: none;
}
.textarea { height: auto; padding: 10px 12px; min-height: 82px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(22, 104, 220, .12);
}
.radio-card {
  display: flex; gap: 11px; padding: 12px 13px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); cursor: pointer; margin-bottom: 9px; align-items: flex-start;
}
.radio-card:hover { border-color: #bccbdb; }
.radio-card.checked { border-color: var(--blue-600); background: var(--blue-050); }
.radio-card input { margin-top: 3px; accent-color: var(--blue-600); }
.radio-card .rt { font-weight: 700; color: var(--ink-900); }
.radio-card .rs { font-size: 12.5px; color: var(--ink-500); margin-top: 2px; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button {
  border: 0; background: #fff; padding: 9px 16px; cursor: pointer; font-weight: 600;
  color: var(--ink-500); font-size: 13.5px;
}
.seg button.active { background: var(--ink-900); color: #fff; }

.tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.tab {
  padding: 9px 17px; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: transparent; color: var(--ink-500); font-weight: 600; cursor: pointer; font-size: 13.5px;
}
.tab:hover { background: #eef3f8; }
.tab.active { background: #fff; border-color: var(--line-strong); color: var(--ink-900); box-shadow: var(--shadow-sm); }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar .btn svg { color: var(--ink-400); }

/* ------------------------------ Cảnh báo ------------------------------ */
.alert {
  display: flex; gap: 13px; padding: 15px 18px; border-radius: var(--radius);
  border: 1px solid #f5cccc; background: #fff5f5; margin-bottom: 20px; align-items: flex-start;
}
.alert .at { font-weight: 700; color: var(--red-700); margin-bottom: 3px; }
.alert .as { font-size: 13px; color: #8f4444; line-height: 1.5; }
.alert .btn { margin-left: auto; align-self: center; }
.alert svg { color: var(--red-600); flex: 0 0 20px; margin-top: 1px; }

.empty { padding: 46px 20px; text-align: center; color: var(--ink-400); }
.empty .e1 { font-weight: 700; color: var(--ink-500); margin-bottom: 5px; }

/* ------------------------------ Thanh tiến trình ------------------------------ */
.bar { height: 9px; border-radius: 20px; background: #eaf0f6; overflow: hidden; flex: 1; }
.bar > i { display: block; height: 100%; background: var(--blue-600); border-radius: 20px; }
.dept-row { display: grid; grid-template-columns: 160px 1fr 56px; gap: 14px; align-items: center; padding: 7px 0; }
.dept-row .n { font-weight: 700; color: var(--ink-900); font-size: 13.5px; }
.dept-row .c { text-align: right; font-weight: 700; color: var(--ink-900); }

/* ------------------------------ Timeline duyệt ------------------------------ */
.flow { display: flex; align-items: flex-start; margin: 20px 0 8px; }
.flow-step { flex: 1; display: flex; flex-direction: column; align-items: center; position: relative; }
.flow-step .dot {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 800; background: #fff; border: 1.6px solid var(--line-strong);
  color: var(--ink-400); z-index: 2;
}
.flow-step.done .dot { background: var(--green-600); border-color: var(--green-600); color: #fff; }
.flow-step.current .dot { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }
.flow-step.rejected .dot { background: var(--red-600); border-color: var(--red-600); color: #fff; }
.flow-step .lbl { margin-top: 9px; font-size: 12.5px; font-weight: 700; color: var(--ink-500); text-align: center; }
.flow-step.done .lbl { color: var(--green-700); }
.flow-step.current .lbl { color: var(--ink-900); }
.flow-step::before, .flow-step::after {
  content: ''; position: absolute; top: 12.5px; height: 2.4px; background: #e3e9ef;
}
.flow-step::before { left: 0; width: 50%; }
.flow-step::after { right: 0; width: 50%; }
.flow-step:first-child::before, .flow-step:last-child::after { display: none; }
.flow-step.done::before, .flow-step.done::after { background: var(--green-600); }
.flow-step.current::before { background: var(--green-600); }

/* Trình tự ký dọc */
.sign-track { position: relative; padding-left: 4px; }
.sign-step { display: flex; gap: 14px; padding-bottom: 20px; position: relative; }
.sign-step:last-child { padding-bottom: 0; }
.sign-step::before {
  content: ''; position: absolute; left: 15px; top: 32px; bottom: 0; width: 2.2px; background: #e3e9ef;
}
.sign-step:last-child::before { display: none; }
.sign-step.signed::before { background: var(--green-600); }
.sign-step .mark {
  width: 32px; height: 32px; flex: 0 0 32px; border-radius: 50%; display: grid; place-items: center;
  background: #eef2f6; color: var(--ink-400); font-weight: 800; font-size: 13px; z-index: 2;
}
.sign-step.signed .mark { background: var(--green-600); color: #fff; }
.sign-step.waiting .mark { background: var(--blue-600); color: #fff; }
.sign-step.rejected .mark { background: var(--red-600); color: #fff; }

/* ------------------------------ Xem trước & watermark ------------------------------ */
.preview-box {
  border: 1px solid var(--line); border-radius: var(--radius); background: #f7f9fc;
  min-height: 320px; position: relative; overflow: hidden; display: grid; place-items: center;
}
.preview-box iframe, .preview-box img { width: 100%; height: 560px; border: 0; background: #fff; }
.wm-layer {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden;
  display: flex; flex-wrap: wrap; align-content: flex-start; gap: 46px 26px; padding: 26px;
  transform: rotate(-22deg) scale(1.4); transform-origin: center;
}
.wm-layer span { color: rgba(120, 140, 165, .34); font-size: 12px; font-weight: 700; white-space: nowrap; }
.preview-lock {
  position: absolute; top: 14px; right: 14px; z-index: 3;
  background: rgba(27, 44, 60, .88); color: #fff; padding: 8px 14px; border-radius: 20px;
  font-size: 12.5px; font-weight: 700; display: flex; gap: 7px; align-items: center;
}

/* ------------------------------ Modal ------------------------------ */
.modal-back {
  position: fixed; inset: 0; background: rgba(16, 32, 50, .45); display: grid; place-items: center;
  z-index: 100; padding: 24px; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 12px; width: 100%; max-width: 560px; box-shadow: var(--shadow-md);
  max-height: 92vh; display: flex; flex-direction: column;
}
.modal.wide { max-width: 860px; }
.modal-head { padding: 20px 22px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-head h3 { margin: 0; font-size: 17px; color: var(--ink-900); }
.modal-head .x { margin-left: auto; border: 0; background: none; font-size: 22px; color: var(--ink-400); cursor: pointer; line-height: 1; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px 20px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--line); }

/* ------------------------------ Toast ------------------------------ */
.toasts { position: fixed; right: 22px; bottom: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--ink-900); color: #fff; padding: 13px 17px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); font-size: 13.5px; max-width: 420px; display: flex; gap: 10px;
  animation: slide-in .18s ease-out;
}
.toast.err { background: #a4262c; }
.toast.ok { background: #146c43; }
@keyframes slide-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ------------------------------ Đăng nhập ------------------------------ */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }

/*
 * Cột trái: nền tối kiểu bảng điều khiển kỹ thuật. Ba lớp chồng lên nhau —
 * lưới toạ độ, vệt sáng quét ngang, vài đốm sáng trôi chậm. Tất cả đều là
 * `pointer-events: none` và nằm dưới nội dung nên không cản thao tác.
 * Logo vàng của Khè Group là điểm nhấn duy nhất có màu ấm trên nền lạnh.
 */
.login-art {
  position: relative; overflow: hidden; isolation: isolate;
  background:
    radial-gradient(120% 90% at 12% 8%, #17365e 0%, transparent 55%),
    radial-gradient(90% 80% at 92% 96%, #1d4f86 0%, transparent 60%),
    linear-gradient(160deg, #060d19, #0d2036 62%, #123255);
  /* Kích thước co theo màn hình: laptop 13" chiều cao 650–700px vẫn phải đủ chỗ,
   * không để cột trái đẩy cả trang thành thanh cuộn dọc. */
  color: #fff; padding: clamp(28px, 5vh, 56px) clamp(32px, 4.5vw, 60px);
  display: flex; flex-direction: column; justify-content: center;
}
.login-art > * { position: relative; z-index: 1; }

/* Lưới toạ độ mảnh, mờ dần về phía dưới */
.la-grid {
  position: absolute; inset: -1px; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(120, 190, 255, .10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 190, 255, .10) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(120% 100% at 30% 0%, #000 25%, transparent 78%);
  -webkit-mask-image: radial-gradient(120% 100% at 30% 0%, #000 25%, transparent 78%);
}

/* Vệt sáng quét từ trên xuống, như thanh quét của máy đọc */
.la-scan {
  position: absolute; left: 0; right: 0; height: 190px; z-index: 0; pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(126, 200, 255, .09) 45%, rgba(212, 175, 92, .12) 55%, transparent);
  animation: la-scan 7.5s linear infinite;
}
@keyframes la-scan {
  0%   { transform: translateY(-200px); opacity: 0; }
  12%  { opacity: 1; }
  88%  { opacity: 1; }
  100% { transform: translateY(100vh); opacity: 0; }
}

/* Đốm sáng trôi rất chậm, tạo chiều sâu cho nền */
.la-orbs { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.la-orb {
  position: absolute; border-radius: 50%; filter: blur(46px); opacity: .5;
  animation: la-float 22s ease-in-out infinite;
}
.la-orb-1 { width: 300px; height: 300px; left: -70px; top: 8%;  background: #1f6fd0; }
.la-orb-2 { width: 240px; height: 240px; right: -50px; top: 42%; background: #c9a24a; opacity: .28; animation-delay: -7s; }
.la-orb-3 { width: 260px; height: 260px; left: 32%; bottom: -80px; background: #2aa0b8; opacity: .32; animation-delay: -14s; }
@keyframes la-float {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50%      { transform: translate3d(26px, -34px, 0) scale(1.12); }
}

.la-body { max-width: 520px; }
/* Logo xếp trên, tên hệ thống nằm dưới — để chữ "KHÈ GROUP" trong logo đủ lớn để đọc */
.la-brand { display: flex; flex-direction: column; align-items: flex-start; gap: clamp(8px, 1.6vh, 14px); margin-bottom: clamp(10px, 1.8vh, 18px); }
.la-logo { display: block; }
.la-logo img {
  width: clamp(112px, 17vh, 168px); height: auto; display: block;
  /* Ánh vàng hắt ra quanh logo, mạnh dần rồi dịu lại */
  filter: drop-shadow(0 0 18px rgba(214, 173, 84, .38));
  animation: la-glow 5s ease-in-out infinite;
}
/* Đường kẻ mảnh chuyển sắc, ngăn khối thương hiệu với phần nội dung */
.la-rule {
  height: 1px; width: 190px; margin: 0 0 clamp(12px, 2.4vh, 22px);
  background: linear-gradient(90deg, rgba(214, 173, 84, .85), rgba(126, 200, 255, .35), transparent);
}
@keyframes la-glow {
  0%, 100% { filter: drop-shadow(0 0 14px rgba(214, 173, 84, .28)); }
  50%      { filter: drop-shadow(0 0 26px rgba(214, 173, 84, .55)); }
}
.la-brand-text { min-width: 0; }
.la-brand-name {
  font-size: 21px; font-weight: 800; letter-spacing: .01em;
  background: linear-gradient(92deg, #fff 20%, #f0d79a 70%, #d4af5c);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.la-brand-sub { font-size: 12.5px; color: #93b4d6; letter-spacing: .12em; text-transform: uppercase; margin-top: 3px; }

.login-art h2 {
  font-size: clamp(21px, 3.4vh, 32px); margin: 0 0 clamp(9px, 1.6vh, 14px); line-height: 1.24;
  background: linear-gradient(96deg, #ffffff 35%, #cfe4ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-art p { color: #b9d2ea; line-height: 1.62; max-width: 460px; margin: 0 0 clamp(14px, 2.6vh, 26px); font-size: clamp(13px, 1.7vh, 15px); }
.login-art ul { padding: 0; margin: 0; }
.login-art li {
  color: #d6e6f6; margin-bottom: clamp(6px, 1.2vh, 11px); font-size: clamp(12.5px, 1.65vh, 14px); list-style: none; display: flex; gap: 11px; align-items: flex-start;
  animation: la-rise .5s ease-out backwards; animation-delay: calc(var(--i, 0) * 90ms + 150ms);
}
@keyframes la-rise { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }
.la-tick {
  flex: 0 0 19px; width: 19px; height: 19px; margin-top: 1px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11px; font-weight: 800;
  color: #0c2340; background: linear-gradient(140deg, #f0d79a, #c9a24a);
  box-shadow: 0 0 0 1px rgba(240, 215, 154, .35), 0 0 14px rgba(201, 162, 74, .35);
}

.login-form { display: grid; place-items: center; padding: 40px; background: #fff; }
.login-card { width: 100%; max-width: 400px; }
.login-card h1 { font-size: 24px; color: var(--ink-900); margin: 0 0 6px; }
/* Logo trong thẻ đăng nhập chỉ dùng khi màn hình hẹp, lúc cột trái bị ẩn */
.login-card-logo { display: none; }
.login-card-logo img { width: 92px; height: auto; display: block; margin: 0 auto 18px; }

.login-hint {
  margin-top: 20px; padding: 13px 15px; background: var(--blue-050); border: 1px solid #cfe1f8;
  border-radius: var(--radius-sm); font-size: 12.5px; color: #26527f; line-height: 1.6;
}
.login-hint code { background: #fff; padding: 1px 5px; border-radius: 4px; border: 1px solid #d9e6f5; }

@media (max-width: 900px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .login-card-logo { display: block; }
}

/* Người dùng đã bật "giảm chuyển động" thì bỏ hết hiệu ứng động */
@media (prefers-reduced-motion: reduce) {
  .la-scan, .la-orb, .la-logo img, .login-art li { animation: none; }
  .la-scan { display: none; }
}

/* ------------------------------ Trang chia sẻ công khai ------------------------------ */
.share-page { max-width: 1080px; margin: 0 auto; padding: 30px 22px 60px; }
.share-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.share-meta { display: flex; gap: 22px; flex-wrap: wrap; color: var(--ink-500); font-size: 13px; }
.share-blocked {
  max-width: 520px; margin: 90px auto; text-align: center; background: #fff; padding: 40px 34px;
  border-radius: 12px; border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.share-blocked h2 { color: var(--ink-900); margin: 16px 0 8px; }

/* ------------------------------ Nhập mã OTP ------------------------------ */
.otp-boxes { display: flex; gap: 9px; justify-content: center; margin: 4px 0 2px; }
.otp-box {
  width: 50px; height: 58px; text-align: center; font-size: 24px; font-weight: 800;
  color: var(--ink-900); border: 1.5px solid var(--line-strong); border-radius: 9px;
  background: #fbfdff; outline: none; caret-color: var(--blue-600);
}
.otp-box:focus { border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(22, 104, 220, .14); background: #fff; }
.otp-box:disabled { opacity: .6; }
@media (max-width: 420px) { .otp-box { width: 40px; height: 50px; font-size: 20px; } }

/* ------------------------------ SSO ------------------------------ */
.sso-divider {
  display: flex; align-items: center; gap: 12px; margin: 20px 0;
  color: var(--ink-400); font-size: 12.5px;
}
.sso-divider::before, .sso-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}

.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--ink-400); }
.kv dd { margin: 0; color: var(--ink-900); font-weight: 600; word-break: break-all; }

.code-box {
  font-family: Consolas, 'Courier New', monospace; font-size: 12.5px; background: #f7fafd;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px;
  word-break: break-all; color: var(--ink-700);
}

.steps { counter-reset: s; padding: 0; margin: 0; list-style: none; }
.steps li {
  counter-increment: s; position: relative; padding: 0 0 14px 34px; line-height: 1.65; font-size: 13px;
}
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0;
  width: 22px; height: 22px; border-radius: 50%; background: var(--blue-050);
  color: var(--blue-700); font-weight: 800; font-size: 11.5px; display: grid; place-items: center;
}

.dev-otp {
  margin-top: 16px; padding: 13px 15px; border-radius: var(--radius-sm);
  background: #fffbf1; border: 1px dashed #e3b768; text-align: center;
}
.dev-otp-t { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: #b45309; font-weight: 800; }
.dev-otp-c { font-size: 27px; font-weight: 800; letter-spacing: .3em; color: #8a5a1b; margin: 6px 0 4px; }
.dev-otp-s { font-size: 11.5px; color: #a07430; line-height: 1.5; }

.otp-target {
  text-align: center; background: var(--blue-050); border: 1px solid #cfe1f8;
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 18px;
  font-size: 13px; color: #26527f; line-height: 1.6;
}
.otp-target b { color: var(--ink-900); }

/* ------------------------------ Thiết bị tin cậy ------------------------------ */
.device-row {
  display: flex; gap: 13px; align-items: flex-start; padding: 14px 0;
  border-bottom: 1px solid #f0f4f8;
}
.device-row:last-child { border-bottom: 0; }
.device-icon {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 9px; display: grid; place-items: center;
  background: var(--blue-050); color: var(--blue-600);
}
.device-row.revoked { opacity: .55; }
.device-row.current .device-icon { background: var(--green-050); color: var(--green-700); }

/* ------------------------------ Trình xem điền & in ------------------------------ */
.vw-back {
  position: fixed; inset: 0; background: rgba(16, 32, 50, .55); z-index: 120;
  display: grid; place-items: center; padding: 18px;
}
.vw-shell {
  background: #fff; border-radius: 12px; box-shadow: var(--shadow-md);
  width: 100%; max-width: 1080px; height: 94vh; display: flex; flex-direction: column; overflow: hidden;
}
.vw-toolbar {
  display: flex; align-items: center; gap: 9px; padding: 12px 16px;
  border-bottom: 1px solid var(--line); background: #fbfdff; flex-wrap: wrap;
}
.vw-body { flex: 1; overflow: auto; background: #eef2f7; padding: 20px; }
.vw-foot {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  border-top: 1px solid var(--line); background: #fbfdff; color: var(--ink-500);
}
.vw-stage { display: flex; flex-direction: column; align-items: center; gap: 18px; position: relative; }
.vw-stage.vw-placing { cursor: crosshair; }
.vw-stage.vw-placing .vw-page { outline: 2px dashed var(--blue-600); outline-offset: 3px; }
.vw-page {
  position: relative; background: #fff; box-shadow: 0 2px 10px rgba(20, 47, 77, .18);
  max-width: 100%;
}
.vw-page-text { padding: 26px 30px; }
.vw-text {
  margin: 0; font-family: Consolas, 'Courier New', monospace; font-size: 13px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word; outline: none; min-height: 400px; color: var(--ink-900);
}
.vw-text:focus { background: #fbfdff; }
.vw-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 320px; color: var(--ink-500); gap: 4px; padding: 30px;
}

.vw-note {
  position: absolute; min-width: 90px; min-height: 24px; padding: 2px 20px 2px 5px;
  background: rgba(255, 255, 255, .82); border: 1px dashed var(--blue-600); border-radius: 4px;
  font-size: 13.5px; color: #10233a; outline: none; cursor: text; line-height: 1.35;
}
.vw-note:focus { background: #fff; border-style: solid; box-shadow: 0 0 0 3px rgba(22, 104, 220, .14); }
.vw-note.vw-tick {
  min-width: 0; padding: 0 18px 0 2px; border-color: var(--green-600);
  color: var(--green-700); font-size: 19px; font-weight: 800; cursor: default;
}
.vw-note-x {
  position: absolute; top: -1px; right: 0; width: 18px; height: 18px; line-height: 1;
  border: 0; background: transparent; color: #b91c1c; cursor: pointer; font-size: 15px; padding: 0;
}
.vw-wm { z-index: 5; }

.rotate-180 { transform: rotate(180deg); }

/* ------------------------------ Màn hình Trình ký ------------------------------ */

/* Băng việc-cần-làm, đặt trên cùng vì đó là lý do người ta mở màn hình này */
.sg-hero {
  display: flex; align-items: center; gap: 14px; padding: 16px 20px; margin-bottom: 14px;
  background: var(--white); border: 1px solid var(--line); border-left: 4px solid var(--green-600);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.sg-hero.act { border-left-color: var(--blue-600); background: linear-gradient(90deg, #f5f9ff, #fff 40%); }
.sg-hero-ico {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 11px; display: grid; place-items: center;
  background: var(--blue-050); color: var(--blue-600);
}
.sg-hero-ico.done { background: var(--green-050); color: var(--green-700); }
.sg-hero-t { font-size: 16px; font-weight: 700; color: var(--ink-900); }
.sg-hero-s { font-size: 12.5px; color: var(--ink-500); margin-top: 2px; }
.sg-hero .btn { margin-left: auto; }

/* Số liệu phụ: gọn một hàng, không cạnh tranh với băng việc phía trên */
.sg-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.sg-metric {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 16px; box-shadow: var(--shadow-sm);
}
.sg-metric-v { font-size: 24px; font-weight: 800; color: var(--ink-900); line-height: 1.1; }
.sg-metric-l { font-size: 12px; color: var(--ink-500); margin-top: 3px; }
.sg-metric-s { font-size: 11.5px; color: var(--ink-400); margin-top: 2px; }
.sg-metric-s.s-green { color: var(--green-700); }
.sg-metric-s.s-red { color: var(--red-700); font-weight: 600; }

.sg-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1100px) { .sg-layout { grid-template-columns: 1fr; } .sg-metrics { grid-template-columns: 1fr; } }

/* ---------- Danh sách đề xuất ---------- */
.sg-list-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px; font-size: 11px; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-400); font-weight: 700;
}
.sg-list-body { padding: 0 10px 12px; max-height: 620px; overflow-y: auto; }
.sg-item {
  display: block; width: 100%; text-align: left; cursor: pointer;
  border: 1px solid transparent; border-left: 3px solid var(--line-strong);
  background: transparent; border-radius: 8px; padding: 11px 12px; margin-bottom: 6px;
}
.sg-item:hover { background: #f7fafd; }
.sg-item.active { background: var(--blue-050); border-color: #cfe1f8; border-left-color: var(--blue-600); }
/* Vệt màu bên trái nhắc lại trạng thái, nhưng chữ trong huy hiệu mới là nguồn thông tin */
.sg-item.t-red { border-left-color: var(--red-600); }
.sg-item.t-amber { border-left-color: #d97706; }
.sg-item.t-green { border-left-color: var(--green-600); }
.sg-item-top { display: flex; align-items: flex-start; gap: 8px; }
.sg-item-title {
  font-size: 13.5px; font-weight: 600; color: var(--ink-900); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.sg-item-meta {
  font-size: 12px; color: var(--ink-500); margin-top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sg-item-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.sg-item-due { font-size: 11.5px; color: var(--ink-400); margin-top: 6px; }
.sg-item-due.late { color: var(--red-700); font-weight: 600; }

.sg-prog { display: inline-flex; align-items: center; gap: 6px; }
.sg-pips { display: inline-flex; gap: 3px; }
.sg-pips i { display: block; width: 13px; height: 4px; border-radius: 3px; background: #cbd5e1; }
.sg-pips i.ok { background: var(--green-600); }
.sg-pips i.no { background: var(--red-600); }

.sg-urgent {
  flex: 0 0 auto; font-size: 10px; font-weight: 800; letter-spacing: .06em;
  color: var(--red-700); background: var(--red-050); border: 1px solid #f5c2c2;
  border-radius: 4px; padding: 2px 6px;
}
.sg-urgent.lg { font-size: 11px; padding: 3px 8px; }

/* ---------- Chi tiết đề xuất ---------- */
.sg-head { padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.sg-title { margin: 0; font-size: 18px; font-weight: 700; color: var(--ink-900); line-height: 1.35; }
.sg-sub { font-size: 12.5px; color: var(--ink-500); }
.sg-progress { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.sg-bar { flex: 0 0 160px; height: 6px; border-radius: 4px; background: var(--slate-050); overflow: hidden; }
.sg-bar i { display: block; height: 100%; border-radius: 4px; background: var(--green-600); }
.sg-due.late { color: var(--red-700); font-weight: 600; }

.sg-actions {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 12px 20px; background: #fbfdff; border-bottom: 1px solid var(--line);
}
.sg-section {
  padding: 16px 20px 8px; font-size: 11px; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-400); font-weight: 700;
}

/* Trình tự ký dạng mốc thời gian, có đường nối để thấy rõ thứ tự nhiều cấp */
.sg-track { list-style: none; margin: 0; padding: 0 20px 20px; }
.sg-step { position: relative; display: flex; gap: 14px; padding-bottom: 18px; }
.sg-step:last-child { padding-bottom: 0; }
.sg-step::before {
  content: ''; position: absolute; left: 13px; top: 30px; bottom: 0; width: 2px; background: var(--line-strong);
}
.sg-step:last-child::before { display: none; }
.sg-step.signed::before { background: var(--green-600); }
.sg-dot {
  position: relative; z-index: 1; flex: 0 0 28px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 800;
  background: var(--white); border: 2px solid var(--line-strong); color: var(--ink-400);
}
.sg-step.signed .sg-dot { background: var(--green-600); border-color: var(--green-600); color: #fff; }
.sg-step.rejected .sg-dot { background: var(--red-600); border-color: var(--red-600); color: #fff; }
.sg-step.current .sg-dot {
  border-color: var(--blue-600); color: var(--blue-600);
  box-shadow: 0 0 0 4px rgba(22, 104, 220, .14);
}
.sg-step-body { min-width: 0; padding-top: 2px; }
.sg-step-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sg-step-top b { font-size: 13.5px; color: var(--ink-900); }
.sg-step-state { font-size: 12.5px; margin-top: 2px; color: var(--ink-500); }
.sg-step.signed .sg-step-state { color: var(--green-700); font-weight: 600; }
.sg-step.rejected .sg-step-state { color: var(--red-700); font-weight: 600; }
.sg-step.current .sg-step-state { color: var(--blue-600); font-weight: 600; }

.sg-cert {
  margin-top: 8px; padding: 9px 11px; border-radius: 7px;
  background: #f7fafd; border: 1px solid var(--line);
}
.sg-cert-l {
  display: flex; align-items: flex-start; gap: 7px; font-size: 11.5px; color: var(--ink-500);
  line-height: 1.5;
}
.sg-cert-l + .sg-cert-l { margin-top: 4px; }
.sg-cert-l svg { flex: 0 0 auto; margin-top: 1px; color: var(--ink-400); }
.sg-cert-l.warn { color: var(--amber-700); }
.sg-cert-l.warn svg { color: var(--amber-700); }

/* ------------------------------ Chọn chỗ ký trên văn bản ------------------------------ */
.sp-stage .vw-page { cursor: crosshair; }
.sp-mark {
  position: absolute; transform: translate(-50%, -50%); pointer-events: none;
  /* Đúng tỉ lệ khung 190×74 điểm sẽ đóng lên PDF, để nhìn trước cho sát */
  width: 190px; padding: 6px 9px; border-radius: 3px;
  background: rgba(238, 245, 255, .93); border: 1.2px solid var(--blue-600);
  box-shadow: 0 4px 14px rgba(22, 104, 220, .28);
}
.sp-mark-t { font-size: 7.5px; font-weight: 800; letter-spacing: .08em; color: var(--blue-600); }
.sp-mark-n { font-size: 11px; font-weight: 800; color: var(--ink-900); margin-top: 2px; }
.sp-mark-r { font-size: 8.5px; color: var(--ink-500); margin-top: 1px; }

/* ------------------------------ Soạn thảo Word / Excel ------------------------------ */
.oe-stage { display: block; }
.oe-wrap { display: flex; flex-direction: column; gap: 12px; }

.oe-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.oe-tab {
  border: 1px solid var(--line); background: #fff; border-radius: 7px 7px 0 0;
  padding: 7px 14px; font-size: 12.5px; font-weight: 700; color: var(--ink-500); cursor: pointer;
}
.oe-tab:hover { color: var(--ink-900); }
.oe-tab.active { background: var(--blue-050); border-color: #cfe1f8; color: var(--blue-700); }

.oe-sheet { background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: auto; max-height: 100%; }
.oe-grid { border-collapse: collapse; font-size: 12.5px; color: var(--ink-900); }
.oe-grid th, .oe-grid td { border: 1px solid #dfe6ee; }
.oe-colhead, .oe-rowhead, .oe-corner {
  background: #f3f6fa; color: var(--ink-500); font-weight: 700; font-size: 11px;
  text-align: center; padding: 4px 6px; position: sticky; z-index: 2;
}
.oe-colhead { top: 0; min-width: 84px; }
.oe-rowhead { left: 0; min-width: 34px; }
.oe-corner { top: 0; left: 0; z-index: 3; width: 34px; }
.oe-cell {
  padding: 4px 7px; min-width: 84px; max-width: 340px; outline: none;
  white-space: pre-wrap; word-break: break-word; vertical-align: top;
}
.oe-cell:focus { box-shadow: inset 0 0 0 2px var(--blue-600); background: #fbfdff; }
.oe-cell.oe-formula { color: var(--blue-700); }
.oe-cell.oe-changed { background: #fff8e6; }
.oe-cell.oe-changed:focus { background: #fffdf5; }

.oe-doc {
  background: #fff; box-shadow: 0 2px 10px rgba(20, 47, 77, .18);
  max-width: 820px; margin: 0 auto; padding: 34px 42px; min-height: 500px;
}
.oe-p {
  font-size: 13.5px; line-height: 1.65; color: var(--ink-900); outline: none;
  min-height: 1.65em; padding: 1px 3px; border-radius: 3px;
  /* Biểu mẫu hay có dòng chấm dài liền mạch — không cho nó đẩy trang rộng ra */
  word-break: break-word; overflow-wrap: anywhere;
}
.oe-p:focus { box-shadow: 0 0 0 2px rgba(22, 104, 220, .28); }
.oe-p.oe-heading { font-size: 16px; font-weight: 800; margin: 14px 0 6px; }
.oe-p.oe-changed { background: #fff8e6; }
.oe-doctable { border-collapse: collapse; width: 100%; margin: 10px 0; table-layout: fixed; }
.oe-doctable td {
  border: 1px solid #dfe6ee; padding: 5px 8px; vertical-align: top;
  word-break: break-word; overflow-wrap: anywhere;
}

@media print {
  body.vw-printing #vw-print-host .oe-doc { box-shadow: none; max-width: none; padding: 0; }
  body.vw-printing #vw-print-host .oe-sheet { border: 0; max-height: none; overflow: visible; }
  body.vw-printing #vw-print-host .oe-tabs,
  body.vw-printing #vw-print-host .oe-colhead,
  body.vw-printing #vw-print-host .oe-rowhead,
  body.vw-printing #vw-print-host .oe-corner { display: none; }
  body.vw-printing #vw-print-host .oe-changed { background: transparent; }
  body.vw-printing #vw-print-host .oe-grid { width: 100%; }
}

/* Khi in: chỉ in nội dung tài liệu, bỏ hết giao diện xung quanh */
#vw-print-host { display: none; }
body.vw-printing > *:not(#vw-print-host) { display: none !important; }
body.vw-printing #vw-print-host { display: block; }
@media print {
  body.vw-printing #vw-print-host .vw-page {
    box-shadow: none; break-inside: avoid; page-break-inside: avoid;
    width: 100% !important; margin: 0 0 6mm;
  }
  body.vw-printing #vw-print-host .vw-stage { gap: 0; }
  body.vw-printing .vw-note { border-color: transparent; background: transparent; }
  body.vw-printing .wm-layer { display: none; }
  @page { margin: 8mm; }
}

/* skeleton */
.skeleton { background: linear-gradient(90deg, #eef2f7 25%, #f7fafd 50%, #eef2f7 75%);
  background-size: 400% 100%; animation: sk 1.2s infinite; border-radius: 6px; }
@keyframes sk { from { background-position: 100% 0; } to { background-position: 0 0; } }
