:root {
  --bg: #f1f4f9;
  --card: #ffffff;
  --ink: #1c2733;
  --muted: #67758c;
  --brand: #0f4c81;
  --brand-dark: #0b3a63;
  --accent: #1f9d63;
  --warn: #c0392b;
  --line: #dfe5ee;
  --shadow: 0 1px 3px rgba(16, 42, 67, .12), 0 4px 16px rgba(16, 42, 67, .08);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  background: linear-gradient(180deg, var(--brand-dark), var(--brand));
  color: #fff;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
}

.brand { font-size: 20px; font-weight: 800; letter-spacing: 2px; display: flex; align-items: center; gap: 8px; }
.brand-logo { height: 34px; width: auto; border-radius: 6px; }
.brand-sub { font-size: 11px; opacity: .75; margin-bottom: 24px; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: rgba(255,255,255,.85);
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: background .15s;
}
.nav-item:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.2); color: #fff; font-weight: 600; }

.sidebar-foot { display: flex; flex-direction: column; gap: 4px; border-top: 1px solid rgba(255,255,255,.15); padding-top: 10px; }

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

.topbar {
  height: 58px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
.page-title { font-size: 17px; font-weight: 700; }
.topbar-user { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 10px; }
.topbar-user .top-date { color: var(--ink); font-weight: 600; background: #eef3fa; padding: 5px 10px; border-radius: 8px; font-size: 12px; }

.content { padding: 14px 20px; flex: 1; }

.dash-hero.panel { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; background: linear-gradient(120deg, #0b3a63 0%, #0f4c81 45%, #2080c4 100%); color: #fff; border-radius: 16px; padding: 16px 22px; }
.dash-hero .hero-greet { font-size: 19px; font-weight: 800; color: #fff; }
.dash-hero .hero-sub { color: rgba(255,255,255,.82); font-size: 12.5px; margin-top: 3px; }
.dash-hero .hero-pill { background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.28); color: #fff; border-radius: 12px; padding: 9px 20px; display: flex; flex-direction: column; align-items: center; min-width: 128px; }
.hero-pill .hpd { font-size: 22px; font-weight: 800; line-height: 1; }
.hero-pill small { font-size: 10.5px; opacity: .9; margin-top: 4px; text-transform: uppercase; letter-spacing: .6px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 22px; }
.card { background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 16px 18px; }
.card .num { font-size: 28px; font-weight: 800; color: var(--brand); margin-top: 4px; }
.card .lbl { color: var(--muted); font-size: 13px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 13px 15px; display: flex; gap: 12px; align-items: center; border: 1px solid rgba(15, 76, 129, .08); border-top: 3px solid transparent; transition: transform .12s ease, box-shadow .12s ease; }
.kpi:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(15, 76, 129, .12); }
.kpi .icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.kpi .icon svg { width: 20px; height: 20px; }
.kpi .num { font-size: 22px; font-weight: 800; line-height: 1; letter-spacing: -.4px; }
.kpi .lbl { color: var(--muted); font-size: 12px; margin-top: 4px; }
.kpi .delta { font-size: 11px; font-weight: 600; margin-top: 3px; }
.kpi.blue { border-top-color: #4f8fd0; }
.kpi.green { border-top-color: #34a06b; }
.kpi.orange { border-top-color: #e2913a; }
.kpi.purple { border-top-color: #7a63d6; }
.kpi.teal { border-top-color: #1a9aa8; }
.kpi.deep { border-top-color: #5b5fb0; }
.kpi.blue .icon { background: #e3edf9; color: #0f4c81; }
.kpi.green .icon { background: #dff3ea; color: #148356; }
.kpi.orange .icon { background: #fdeedd; color: #b96a12; }
.kpi.purple .icon { background: #ece7fb; color: #5b3fc9; }
.kpi.teal .icon { background: #dff2f4; color: #0d7f8c; }
.kpi.deep .icon { background: #e5e8f5; color: #3d3f8f; }

.dbar { align-items: flex-end; }
.dbar label { margin-bottom: 8px; }
.dbar-note { margin-left: auto; color: var(--muted); font-size: 12.5px; }
.dash-sub { color: var(--muted); font-weight: 500; font-size: 11px; }
.week-date { width: 74px; font-weight: 600; font-size: 13px; }
.week-now { color: #0f4c81; }
.week-now::after { content: ' • this week'; color: #0f4c81; font-size: 10px; font-weight: 600; }
.stat-row { display: grid; grid-template-columns: 120px 1fr auto; gap: 10px; align-items: center; padding: 7px 0; }
.stat-lbl { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat-val { font-size: 13px; font-weight: 800; color: var(--ink); min-width: 46px; text-align: right; }
.stat-row .track { height: 10px; border-radius: 6px; background: #eef2f8; overflow: hidden; }
.stat-row .track .fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--brand), #3f7cc0); }
.stat-row .track .fill.orange { background: linear-gradient(90deg, #f5a623, #f7c048); }
.stat-row .track .fill.red { background: linear-gradient(90deg, #d8451f, #ef6c5a); }
.stat-row .track .fill.green { background: linear-gradient(90deg, #1f9d55, #4ec97e); }

.lwlift { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.lwlift th, .lwlift td { padding: 7px 6px; text-align: center; border-bottom: 1px solid var(--line); }
.lwlift thead th { font-size: 11px; color: var(--muted); font-weight: 700; white-space: nowrap; }
.lwlift th.lw-name, .lwlift td.lw-name { text-align: left; font-weight: 600; color: var(--ink); white-space: nowrap; }
.lwlift .lw-badge { display: inline-block; min-width: 22px; padding: 2px 6px; border-radius: 20px; background: #e6f4ec; color: #1f7a4d; font-weight: 700; font-size: 11.5px; }
.lwlift .lw-none { color: #c3ccd8; }
.lwlift .wk-now { background: #eef5ff; }
.lwlift th.tot, .lwlift td.lw-total { font-weight: 800; color: var(--brand); }
.lwlift tfoot td { font-weight: 800; color: var(--ink); border-bottom: 0; border-top: 2px solid var(--line); }

.lfit-row { display: grid; grid-template-columns: 130px 1fr 60px 108px; gap: 10px; align-items: center; padding: 7px 0; }
.lfit-row .lfit-name { font-size: 12.5px; color: var(--ink); font-weight: 600; }
.lfit-row .track { height: 10px; border-radius: 6px; background: #eef2f8; overflow: hidden; }
.lfit-row .track .fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--brand), #3f7cc0); }
.lfit-row .track .fill.green { background: linear-gradient(90deg, #1f9d55, #4ec97e); }
.lfit-row .track .fill.red { background: linear-gradient(90deg, #d8451f, #ef6c5a); }
.lfit-row .lfit-val { font-size: 13px; font-weight: 800; color: var(--ink); text-align: right; }
.lfit-row .lfit-meta { font-size: 11.5px; color: var(--muted); text-align: right; }
.lfit-row .lfit-meta .err { color: #d8451f; font-weight: 700; }

.dash-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-bottom: 16px; }
.dash-grid.wide { grid-template-columns: 1fr; }
@media (max-width: 1000px) { .dash-grid { grid-template-columns: 1fr; } }

.dash-grid2 { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px; margin-bottom: 16px; }
.dash-grid2 > .panel { margin-bottom: 0; padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.dash-grid2 h2 { font-size: 13px; margin: 0 0 12px; padding-bottom: 9px; border-bottom: 1px solid var(--line); }
.dash-grid2 .matrix-cell { margin-bottom: 8px; }
.dash-grid2 .chart-empty { padding: 10px 0; font-size: 12px; }
.dash-grid2 .recent-item { padding: 7px 0; gap: 10px; }
.dash-grid2 .recent-item .avatar { width: 26px; height: 26px; font-size: 10px; }
.dash-grid2 .recent-item .who b { font-size: 12px; }
.dash-grid2 .recent-item .who span { font-size: 11px; }
.dash-scroll { max-height: 168px; overflow: auto; }
.grid6 { grid-column: span 6; }
.grid3 { grid-column: span 3; }
.grid7 { grid-column: span 7; }
.grid5 { grid-column: span 5; }
.grid12 { grid-column: span 12; }
@media (max-width: 1500px) { .grid6 { grid-column: span 8; } .grid3 { grid-column: span 4; } .grid7, .grid5 { grid-column: span 6; } }
@media (max-width: 1200px) { .grid6, .grid3, .grid7, .grid5 { grid-column: span 12; } }

.panel h2 { margin: 0 0 16px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.panel h2 .head-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); display: inline-block; }

.vchart { display: block; width: 100%; height: auto; }
.trend-box { width: 100%; min-width: 0; }
.chart-empty { color: var(--muted); font-size: 13px; padding: 18px 0; text-align: center; }

.dot { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.matrix-cell { display: flex; align-items: center; gap: 12px; }
.matrix-cell .track { flex: 1; background: #eef2f8; height: 10px; border-radius: 6px; overflow: hidden; }
.matrix-cell .track .fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--brand), #3f7cc0); }
.matrix-cell .pct { min-width: 42px; text-align: right; font-weight: 700; font-size: 13px; }

.recent-item { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.recent-item:last-child { border-bottom: 0; }
.recent-item .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.recent-item .who { flex: 1; }
.recent-item .who b { display: block; font-size: 13px; }
.recent-item .who span { color: var(--muted); font-size: 12px; }

.panel { background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 18px; margin-bottom: 20px; }
.panel h2 { margin: 0 0 14px; font-size: 15px; }

.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters label { font-size: 13px; color: var(--muted); }
.filters select, .filters input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 14px; min-width: 170px; }
.filters select:focus, .filters input:focus { outline: none; border-color: var(--brand); }

table.grid { width: 100%; border-collapse: collapse; background: #fff; font-size: 13px; }
table.grid th, table.grid td { border: 1px solid var(--line); padding: 6px 8px; text-align: center; }
table.grid th { background: #eef3fa; font-weight: 600; position: sticky; top: 0; }
table.grid td.cp { text-align: left; font-weight: 500; }
table.grid select { width: 100%; padding: 4px; border: 1px solid var(--line); border-radius: 6px; }
table.grid input.cl-in { width: 100%; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; background: #fff; }
table.grid input.cl-in:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 2px rgba(31, 157, 99, .15); }
table.grid td.dim { background: #f7f9fc; color: var(--muted); }

.report-block { margin-bottom: 26px; }
.report-block h2 { font-size: 15px; color: var(--brand); margin: 0 0 8px; }

.btn { background: var(--brand); color: #fff; border: 0; border-radius: 8px; padding: 9px 16px; cursor: pointer; font-size: 14px; }
.btn:hover { background: var(--brand-dark); }
.btn.ghost { background: #eef2f8; color: var(--ink); }
.btn.ghost:hover { background: #dfe6f0; }
.btn.green { background: #1f9d63; color: #fff; }
.btn.green:hover { background: #157a4a; }
.btn.danger { background: var(--warn); }
.btn.danger:hover { background: #a02e20; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.meta-edit { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.meta-edit input { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; max-width: 180px; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-row .name { width: 160px; font-weight: 600; }
.bar-track { flex: 1; background: #eef2f8; border-radius: 8px; overflow: hidden; height: 22px; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--brand), #3f7cc0); color: #fff; font-size: 11px; line-height: 22px; padding-left: 8px; white-space: nowrap; }

.user-table td { text-align: left; }
.actions { display: flex; gap: 6px; justify-content: center; }

.badge { padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.on { background: #d9f2e4; color: #0b6b3f; }
.badge.off { background: #f9e0dd; color: #a02e20; }
.badge.warn { background: #fdeedd; color: #b96a12; }

.alert-card { display: flex; align-items: center; gap: 14px; border-left: 4px solid #d8451f; padding: 14px 16px; margin-bottom: 16px; }
.alert-card .alert-ico { width: 40px; height: 40px; border-radius: 12px; background: #fbe3e0; color: #b3261e; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.alert-card .alert-ico svg { width: 22px; height: 22px; }
.alert-card .alert-main { flex: 1; min-width: 0; }
.alert-card .alert-main b { font-size: 14px; }
.alert-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.alert-chip { font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 20px; background: #fdeedd; color: #b96a12; }
.alert-chip.overdue { background: #f9e0dd; color: #a02e20; }

.alert-note { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.alert-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow: auto; }
.alert-item { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfe; }
.alert-item.overdue { border-color: #f1c9c2; background: #fdf4f3; }
.alert-item.due { border-color: #f3d9b8; background: #fefaf3; }
.alert-item .alert-when { flex: 1; min-width: 0; }
.alert-item .alert-when b { display: block; font-size: 13px; }
.alert-item .alert-when span { color: var(--muted); font-size: 11.5px; }
.alert-item .alert-lifts { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.alert-item .alert-lifts span { font-size: 11px; background: #eef3fa; color: #0f4c81; padding: 2px 7px; border-radius: 20px; }

.modal-mask { position: fixed; inset: 0; background: rgba(10, 20, 35, .45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: 14px; box-shadow: var(--shadow); width: 440px; max-width: 94vw; padding: 22px; }
.modal h3 { margin: 0 0 16px; }
.modal label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 4px; }
.modal input, .modal select { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.modal textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 12px; font-size: 14px; font-family: inherit; resize: vertical; }
.modal-row { display: flex; gap: 10px; }
.modal-row > div { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.modal .error { color: var(--warn); font-size: 13px; margin: 6px 0; }

.toast-root { position: fixed; top: 70px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; animation: fade .2s ease; }
.toast.ok { background: var(--accent); }
.toast.err { background: var(--warn); }
@keyframes fade { from { opacity: 0; transform: translateY(-6px); } }

.login-body { display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0b3a63, #0f4c81 60%, #1f6fae); }
.login-wrap { width: 380px; text-align: center; }
.login-brand { color: #fff; font-size: 30px; font-weight: 800; letter-spacing: 4px; }
.login-sub { color: rgba(255,255,255,.8); margin: 6px 0 26px; font-size: 14px; }
.login-card { background: #fff; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.35); padding: 30px; text-align: left; }
.login-card h1 { margin: 0 0 18px; font-size: 20px; }
.login-card label { font-size: 13px; color: var(--muted); }
.login-card input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; margin: 6px 0 14px; font-size: 15px; }
.login-card input:focus { outline: none; border-color: var(--brand); }
.login-foot { color: rgba(255,255,255,.65); margin-top: 18px; font-size: 12px; }
.error { color: var(--warn); font-size: 13px; min-height: 18px; }

.login-logo { max-height: 62px; max-width: 200px; object-fit: contain; margin-bottom: 10px; display: block; margin-left: auto; margin-right: auto; }

.settings-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 16px; align-items: start; }
.settings-grid .panel { margin-bottom: 0; }
.settings-grid label { font-size: 13px; color: var(--muted); display: block; margin: 10px 0 4px; }
.settings-grid input[type="text"], .settings-grid input:not([type="file"]) { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; margin-bottom: 6px; }
.settings-grid input:focus { outline: none; border-color: var(--brand); }
.settings-grid input[type="file"] { font-size: 13px; margin: 4px 0; }
.settings-grid hr.soft { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.logo-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.logo-prev { max-height: 56px; max-width: 140px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; padding: 4px; background: #fff; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 10px; padding: 10px 12px; background: #f7f9fc; border: 1px solid var(--line); border-radius: 10px; }
.perm-check { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; cursor: pointer; }
.perm-check input { width: 16px; height: 16px; accent-color: var(--brand); }
.acc-tag { display: inline-block; background: #eef2f8; color: #0f4c81; font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; margin: 1px 2px 1px 0; }
@media (max-width: 1250px) { .settings-grid { grid-template-columns: 1fr; } }

.chart-note { color: var(--muted); font-size: 12.5px; margin-top: 6px; }

.sign-box { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #f7f9fc; }
.sign-box > b { font-size: 13px; color: #0f4c81; }
.sign-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 12px; margin-top: 8px; }
.sign-item { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; padding: 5px 8px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.sign-item input { width: 16px; height: 16px; accent-color: #1f9d63; }
.sign-item input:disabled { cursor: not-allowed; }
.sign-name { font-weight: 600; }
.sign-item small { color: var(--muted); margin-left: auto; }
.sign-note .signed { color: #0b6e4f; font-weight: 700; }
.sign-note .pending { color: #9aa6b5; }

@media (max-width: 860px) {
  .sidebar { width: 68px; padding: 14px 8px; }
  .brand, .brand-sub { font-size: 11px; letter-spacing: 0; }
  .nav-item { font-size: 12px; padding: 8px 6px; text-align: center; }
  .sidebar-foot .nav-item { font-size: 11px; }
}
