/* =====================================================================
   EFIS Nội bộ – giao diện theo nhận diện EFIS English
   Xanh dương #0070BA · Xanh lá #3BB44B
   ===================================================================== */
:root {
  --blue: #0070ba; --blue-700: #005a96; --blue-900: #0b3a63; --blue-50: #eaf4fb; --blue-100: #d4e8f6;
  --green: #3bb44b; --green-700: #2a8c38; --green-50: #ecf8ee; --green-100: #d3efd7;
  --bg: #f3f6fa; --panel: #ffffff; --ink: #13213a; --ink-2: #3c4a63; --muted: #6b7890; --line: #e2e8f0; --line-2: #edf1f6;
  --head: #f6f9fc;
  --accent: var(--blue); --accent-ink: #ffffff; --accent-soft: var(--blue-50);
  --good: #1f8a3a; --good-bg: #e6f6ea; --warn: #9a6200; --warn-bg: #fff3d6; --bad: #c0352b; --bad-bg: #fdecea;
  --g1: #f2f8fd; --g2: #f1faf3; --g3: #fff8ec; --g4: #f6f3ff; --g5: #fdf2f6;
  --shadow-sm: 0 1px 2px rgba(15, 35, 70, .06);
  --shadow: 0 1px 3px rgba(15, 35, 70, .08), 0 4px 14px rgba(15, 35, 70, .05);
  --shadow-lg: 0 18px 50px rgba(15, 35, 70, .22);
  --radius: 14px; --radius-sm: 10px;
  --nav-w: 248px;
  --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1520; --panel: #151e2b; --ink: #e7edf6; --ink-2: #c3cddc; --muted: #8d9ab0; --line: #243246; --line-2: #1d2939;
    --head: #1a2534; --accent-soft: #10304c; --blue-50: #10304c; --blue-100: #16406a; --green-50: #12321b; --green-100: #18442a;
    --good: #5fd38a; --good-bg: #133322; --warn: #f2c14e; --warn-bg: #3a2f10; --bad: #ff8a80; --bad-bg: #3d1716;
    --g1: #142235; --g2: #13261b; --g3: #2a2314; --g4: #1d1b33; --g5: #2c1724;
    --shadow-sm: none; --shadow: 0 1px 0 rgba(255,255,255,.03); --shadow-lg: 0 18px 50px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
a { color: var(--blue); }
::selection { background: var(--blue-100); }

/* ---------- form controls ---------- */
label { display: block; font-size: 12.5px; font-weight: 500; color: var(--muted); margin: 12px 0 6px; }
input, select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel); transition: border-color .15s, box-shadow .15s; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 112, 186, .15); }
select { cursor: pointer; }
textarea { min-height: 70px; resize: vertical; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel);
  border-radius: var(--radius-sm); padding: 8px 14px; cursor: pointer; white-space: nowrap; font-weight: 500;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { border-color: var(--blue); color: var(--blue); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--blue); color: #fff; border-color: var(--blue); font-weight: 600; box-shadow: 0 2px 8px rgba(0, 112, 186, .25); }
.btn.primary:hover { background: var(--blue-700); border-color: var(--blue-700); color: #fff; }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.block { width: 100%; justify-content: center; margin-top: 12px; padding: 11px 14px; }
.err { color: var(--bad); font-size: 13px; margin-top: 10px; min-height: 18px; }
.note { color: var(--muted); font-size: 12.5px; margin-top: 10px; line-height: 1.6; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 9px; cursor: pointer; font-weight: 500; color: var(--ink-2); transition: background .15s, color .15s; }
.seg button:hover { background: var(--head); }
.seg button.on { background: var(--blue); color: #fff; font-weight: 600; box-shadow: 0 1px 4px rgba(0, 112, 186, .3); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar select, .toolbar input[type=date] { width: auto; padding: 7px 10px; }
.toolbar .sp { flex: 1; }
.check { display: flex; gap: 8px; align-items: center; margin-top: 12px; color: var(--ink); font-size: 13.5px; font-weight: 400; cursor: pointer; }
.check input { width: auto; accent-color: var(--blue); }

/* ---------- đăng nhập ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art {
  position: relative; overflow: hidden; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(1200px 600px at -10% 110%, rgba(59, 180, 75, .55), transparent 60%),
              linear-gradient(150deg, #0b3a63 0%, #0070ba 55%, #1e8fc7 100%);
}
.login-art::after {
  content: ''; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%;
  border: 46px solid rgba(255, 255, 255, .07);
}
.login-art .logo-row { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 18px; letter-spacing: .01em; }
.login-art .logo-row img { width: 44px; height: 44px; border-radius: 50%; background: #fff; padding: 2px; }
.login-art h2 { font-size: 34px; line-height: 1.2; margin: 0 0 12px; font-weight: 700; max-width: 440px; }
.login-art p { margin: 0; opacity: .85; max-width: 420px; font-size: 15px; }
.login-art .chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.login-art .chips span { background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .22); padding: 5px 12px; border-radius: 999px; font-size: 13px; }
.login-form { display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 32px; width: 100%; max-width: 400px; }
.card .card-logo { display: block; width: 92px; margin: 0 auto 10px; }
.card h1 { margin: 0; text-align: center; font-size: 20px; }
.card p { margin: 6px 0 18px; color: var(--muted); text-align: center; }
@media (max-width: 860px) { .login { grid-template-columns: 1fr; } .login-art { display: none; } }

/* ---------- khung app ---------- */
.shell { display: flex; min-height: 100vh; }
.nav {
  width: var(--nav-w); flex: none; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 14px;
  color: #dbe9f6; background: linear-gradient(180deg, #0b3a63 0%, #0a4a7f 60%, #0b5a95 100%);
}
.nav .brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 18px; color: #fff; font-weight: 700; font-size: 16px; }
.nav .brand img { width: 38px; height: 38px; border-radius: 50%; background: #fff; padding: 2px; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.nav .brand small { display: block; font-weight: 500; font-size: 11.5px; color: #9cc5e6; letter-spacing: .02em; }
.nav nav { flex: 1; overflow: auto; margin: 0 -4px; padding: 0 4px; }
.nav nav::-webkit-scrollbar { width: 6px; } .nav nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 3px; }
.nav .grp { margin-bottom: 4px; }
.nav .grp-title { display: flex; align-items: center; gap: 9px; padding: 9px 10px; font-weight: 600; color: #fff; font-size: 13.5px; }
.nav .grp-title .ico { width: 22px; text-align: center; }
.nav .grp-title .soon { margin-left: auto; font-size: 10.5px; font-weight: 500; color: #9cc5e6; border: 1px solid rgba(156, 197, 230, .35); border-radius: 999px; padding: 0 7px; }
.nav a.item {
  position: relative; display: flex; align-items: center; gap: 6px; padding: 7px 10px 7px 41px; margin: 1px 0; border-radius: 9px;
  color: #c9dff2; text-decoration: none; font-size: 13.5px; transition: background .15s, color .15s;
}
.nav a.item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav a.item.on { background: #fff; color: var(--blue-900); font-weight: 600; box-shadow: 0 2px 10px rgba(0, 0, 0, .15); }
.nav a.item.on::before { content: ''; position: absolute; left: 22px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: var(--green); }
.nav a.item.home { padding-left: 10px; }
.nav a.item.home.on::before { display: none; }
.nav .item .pill { margin-left: auto; background: rgba(255,255,255,.12); color: #9cc5e6; }
.nav .item.on .pill { background: var(--head); color: var(--muted); }
.nav .me { border-top: 1px solid rgba(255, 255, 255, .12); padding: 14px 8px 0; display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: #9cc5e6; }
.nav .me .avatar { width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--green); color: #fff; font-weight: 700; }
.nav .me b { color: #fff; font-weight: 600; display: block; font-size: 13px; }
.nav .me .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav .me .btn { background: transparent; border-color: rgba(255, 255, 255, .25); color: #dbe9f6; padding: 5px 9px; }
.nav .me .btn:hover { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.4); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 4; display: flex; align-items: center; gap: 12px; padding: 12px 22px; min-height: 60px;
  background: rgba(255, 255, 255, .85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
@media (prefers-color-scheme: dark) { .top { background: rgba(21, 30, 43, .85); } }
.crumb { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.crumb span { color: var(--muted); font-weight: 500; }
.top-actions { margin-left: auto; display: flex; gap: 8px; }
.menu-btn { display: none; }
.page { padding: 20px 22px 28px; min-width: 0; }
.hello { display: flex; align-items: center; gap: 14px; margin: 2px 0 18px; }
.hello h2 { margin: 0; font-size: 22px; }
.hello p { margin: 2px 0 0; color: var(--muted); }
.placeholder { background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); padding: 48px; text-align: center; color: var(--muted); }
.placeholder h2 { color: var(--ink); margin: 0 0 6px; font-size: 18px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.tile {
  position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; text-decoration: none;
  color: var(--ink); display: block; box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s, border-color .15s; overflow: hidden;
}
.tile::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 4px; background: linear-gradient(90deg, var(--blue), var(--green)); }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--blue-100); }
.tile .i { font-size: 24px; }
.tile .t { font-weight: 700; margin-top: 8px; }
.tile .d { color: var(--muted); font-size: 13px; margin-top: 2px; }

@media (max-width: 860px) {
  .nav { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .nav.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .page { padding: 16px; }
  .top { padding: 10px 16px; }
}

/* ---------- KPI ---------- */
.meta { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 14px 18px; box-shadow: var(--shadow-sm); overflow: hidden; }
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--blue); }
.kpi:nth-child(even)::before { background: var(--green); }
.kpi .l { color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.kpi .v { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; color: var(--blue-900); }
@media (prefers-color-scheme: dark) { .kpi .v { color: #fff; } }
.kpi .s { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---------- bảng ---------- */
.tablewrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 260px); box-shadow: var(--shadow-sm); }
.tablewrap::-webkit-scrollbar { height: 10px; width: 10px; }
.tablewrap::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; border: 2px solid var(--panel); }
table.grid { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-variant-numeric: tabular-nums; }
table.grid th, table.grid td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); border-right: 1px solid var(--line-2); text-align: right; white-space: nowrap; }
table.grid th {
  position: sticky; top: 0; z-index: 2; background: var(--head); color: var(--ink-2); font-weight: 600; font-size: 12px;
  text-align: center; white-space: normal; min-width: 70px; border-bottom: 1px solid var(--line);
}
table.grid thead tr:nth-child(2) th { top: 35px; }
table.grid .c1 { background: var(--g1); } table.grid .c2 { background: var(--g2); } table.grid .c3 { background: var(--g3); }
table.grid .c4 { background: var(--g4); } table.grid .c5 { background: var(--g5); }
table.grid thead .c1 { box-shadow: inset 0 3px 0 var(--blue); } table.grid thead .c2 { box-shadow: inset 0 3px 0 var(--green); }
table.grid thead .c3 { box-shadow: inset 0 3px 0 #f0a020; } table.grid thead .c4 { box-shadow: inset 0 3px 0 #7c5cdb; }
table.grid thead .c5 { box-shadow: inset 0 3px 0 #d6457a; }
table.grid thead tr:nth-child(2) th { box-shadow: none; }
table.grid td.name, table.grid th.name { position: sticky; left: 0; text-align: left; background: var(--panel); z-index: 1; min-width: 180px; box-shadow: 1px 0 0 var(--line); }
table.grid th.name { z-index: 3; background: var(--head); }
table.grid tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--head) 45%, var(--panel)); }
table.grid tbody tr:nth-child(even) td.name { background: color-mix(in srgb, var(--head) 45%, var(--panel)); }
table.grid tr.team td, table.grid tr.team td.name { font-weight: 700; background: var(--blue-50) !important; color: var(--blue-900); }
@media (prefers-color-scheme: dark) { table.grid tr.team td, table.grid tr.team td.name { color: #fff; } }
table.grid tbody tr:hover td, table.grid tbody tr:hover td.name { background: var(--blue-50) !important; }
table.grid td.txt { text-align: left; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); text-align: left; }
table.list th { background: var(--head); font-size: 12px; font-weight: 600; color: var(--ink-2); position: sticky; top: 0; }
table.list tbody tr:hover td { background: var(--blue-50); }
.up { color: var(--good); font-weight: 600; } .down { color: var(--bad); font-weight: 600; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-weight: 600; font-size: 12px; white-space: nowrap; }
.p-good { background: var(--good-bg); color: var(--good); }
.p-warn { background: var(--warn-bg); color: var(--warn); }
.p-bad { background: var(--bad-bg); color: var(--bad); }
.p-mute { background: var(--head); color: var(--muted); }
a.lk { color: var(--blue); cursor: pointer; text-decoration: none; font-weight: 500; }
a.lk:hover { text-decoration: underline; }
.empty { padding: 48px; text-align: center; color: var(--muted); }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(11, 30, 55, .45); backdrop-filter: blur(2px); display: grid; place-items: center; padding: 16px; z-index: 40; animation: fade .15s ease-out; }
.sheet { background: var(--panel); border-radius: 18px; width: 100%; max-width: 780px; max-height: 92vh; overflow: auto; box-shadow: var(--shadow-lg); animation: rise .18s ease-out; }
.sheet.wide { max-width: 1200px; }
.sheet .hd { display: flex; align-items: center; gap: 10px; padding: 16px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 2; }
.sheet .hd h2 { margin: 0; font-size: 17px; flex: 1; display: flex; align-items: center; gap: 10px; }
.sheet .bd { padding: 6px 22px 22px; }
.sheet .ft { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--panel); }
.fgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 2px 16px; }
fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 14px 0 0; padding: 6px 16px 16px; }
legend { font-weight: 700; padding: 0 8px; color: var(--blue-900); }
@media (prefers-color-scheme: dark) { legend { color: #9cc5e6; } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
