:root {
  --bg: #eef1f6;
  --card: #ffffff;
  --ink: #1e2733;
  --ink-soft: #5b6673;
  --ink-faint: #97a1af;
  --line: #e3e7ee;
  --primary: #2b4c7e;
  --primary-dark: #223d66;
  --primary-soft: #eaf0f9;
  --accent: #e8912d;
  --green: #1b7a3d;
  --green-soft: #e5f4ea;
  --red: #c02c22;
  --red-soft: #fbe9e7;
  --shadow: 0 1px 2px rgba(20,35,60,.06), 0 6px 20px rgba(20,35,60,.06);
  --shadow-lg: 0 10px 40px rgba(20,35,60,.16);
  --radius: 14px;
  --radius-sm: 9px;
  font-family: -apple-system, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--ink); font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

#app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: linear-gradient(180deg, #223d66 0%, #1a2f50 100%);
  color: #cdd7e6; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px 18px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #d67d1c); color: #fff; font-weight: 800; letter-spacing: .5px;
  box-shadow: 0 4px 14px rgba(232,145,45,.35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { color: #fff; font-size: 13px; white-space: nowrap; letter-spacing: -.2px; }
.brand-text span { font-size: 11.5px; color: #8ea3c4; }
.nav { display: flex; flex-direction: column; gap: 3px; padding: 8px 12px; margin-top: 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 10px;
  color: #b6c4da; font-weight: 500; transition: background .15s, color .15s;
}
.nav a svg { width: 20px; height: 20px; fill: currentColor; opacity: .85; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(255,255,255,.12); color: #fff; }
.nav a.active svg { opacity: 1; }
.sidebar-foot { margin-top: auto; padding: 16px; }
.balance-mini {
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px;
}
.balance-mini span { font-size: 11.5px; color: #8ea3c4; }
.balance-mini strong { font-size: 20px; color: #fff; }

/* ---------- Topbar ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 30px; background: rgba(255,255,255,.7); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-size: 19px; font-weight: 700; }
.month-picker { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line);
  padding: 7px 12px; border-radius: 10px; box-shadow: var(--shadow); }
.month-picker svg { width: 18px; height: 18px; fill: var(--primary); }
.month-picker select { border: 0; background: transparent; font-weight: 600; cursor: pointer; padding-right: 4px; }
.view { padding: 26px 30px 60px; }

/* ---------- Cards & grid ---------- */
.grid { display: grid; gap: 18px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.card h3 { font-size: 14px; color: var(--ink-soft); font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title-row h3 { margin: 0; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 18px; }
.kpi { position: relative; overflow: hidden; }
.kpi .kpi-label { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.kpi .kpi-value { font-size: 30px; font-weight: 800; margin: 8px 0 2px; letter-spacing: -.5px; }
.kpi .kpi-sub { font-size: 12.5px; color: var(--ink-faint); }
.kpi .kpi-icon { position: absolute; top: 16px; right: 16px; width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center; }
.kpi .kpi-icon svg { width: 22px; height: 22px; }
.icon-blue { background: var(--primary-soft); } .icon-blue svg { fill: var(--primary); }
.icon-green { background: var(--green-soft); } .icon-green svg { fill: var(--green); }
.icon-red { background: var(--red-soft); } .icon-red svg { fill: var(--red); }
.icon-amber { background: #fdf1e0; } .icon-amber svg { fill: var(--accent); }
.pos { color: var(--green); } .neg { color: var(--red); }

.cols-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; margin-bottom: 18px; align-items: start; }
.cols-2b { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; align-items: start; }

/* ---------- Calendar ---------- */
.cal-head { display: grid; grid-template-columns: repeat(7,1fr); gap: 6px; margin-bottom: 6px; }
.cal-head span { text-align: center; font-size: 11px; font-weight: 700; color: var(--ink-faint); text-transform: uppercase; }
.cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 6px; }
.cal-cell { aspect-ratio: 1 / .82; border-radius: 9px; border: 1px solid var(--line); padding: 6px 7px;
  display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; transition: transform .1s, box-shadow .1s; background: #fff; }
.cal-cell:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.cal-cell.empty { background: transparent; border: 0; cursor: default; }
.cal-cell .d { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.cal-cell .h { font-size: 12px; font-weight: 700; align-self: flex-end; }
.cal-cell.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-cell.wknd { background: #f7f9fc; }
.cal-cell.national { background: #fdf1e0; border-color: #f4dcb8; }
.cal-cell.off, .cal-cell.personal { background: #f0f1f4; }
.lvl-0 .h { color: var(--ink-faint); }
.lvl-1 { background: #eaf0f9 !important; } .lvl-2 { background: #cddcf1 !important; }
.lvl-3 { background: #9fbde3 !important; } .lvl-4 { background: #6f9bd4 !important; }
.lvl-3 .d, .lvl-3 .h, .lvl-4 .d, .lvl-4 .h { color: #17325c; }
.cal-legend { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-faint); }
.cal-legend i { width: 13px; height: 13px; border-radius: 4px; display: inline-block; }

/* ---------- Charts ---------- */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 150px; padding-top: 8px; }
.bars .bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; min-width: 0; }
.bars .bar { width: 100%; max-width: 22px; background: linear-gradient(180deg, #3d68a8, var(--primary)); border-radius: 5px 5px 2px 2px; transition: height .3s; position: relative; }
.bars .bar:hover { background: var(--accent); }
.bars .bl { font-size: 9.5px; color: var(--ink-faint); }
.donut-wrap { display: flex; align-items: center; gap: 18px; }
.donut-legend { display: flex; flex-direction: column; gap: 9px; flex: 1; min-width: 0; }
.donut-legend .li { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.donut-legend .li i { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }
.donut-legend .li .lname { color: var(--ink-soft); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.donut-legend .li .lval { font-weight: 700; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .3px;
  color: var(--ink-faint); font-weight: 700; padding: 10px 12px; border-bottom: 2px solid var(--line); white-space: nowrap; }
table.data td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #f8fafd; }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data td.center { text-align: center; }
.tot-row td { font-weight: 800; border-top: 2px solid var(--line); background: #f8fafd; }
.muted { color: var(--ink-faint); }
.act-text { max-width: 520px; white-space: pre-wrap; line-height: 1.45; }
.wd { color: var(--ink-faint); font-size: 12px; }

/* badges & chips */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.badge.work { background: var(--primary-soft); color: var(--primary); }
.badge.off { background: #eceef2; color: var(--ink-soft); }
.badge.personal { background: #eceef2; color: var(--ink-soft); }
.badge.national { background: #fdf1e0; color: #b9761f; }
.cat-tag { font-size: 11.5px; color: var(--ink-soft); background: #f1f3f7; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.file-chip { display: inline-flex; align-items: center; gap: 5px; background: var(--primary-soft); color: var(--primary);
  padding: 3px 8px; border-radius: 7px; font-size: 11.5px; font-weight: 600; margin: 2px 3px 2px 0; max-width: 150px; }
.file-chip a { display: inline-flex; align-items: center; gap: 5px; overflow: hidden; }
.file-chip .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip svg { width: 13px; height: 13px; fill: currentColor; flex-shrink: 0; }
.file-chip .del { cursor: pointer; opacity: .6; font-weight: 800; }
.file-chip .del:hover { opacity: 1; color: var(--red); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; cursor: pointer; transition: background .15s, box-shadow .15s, transform .06s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; fill: currentColor; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 3px 10px rgba(43,76,126,.25); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-green { background: var(--green); color: #fff; box-shadow: 0 3px 10px rgba(27,122,61,.25); }
.btn-green:hover { filter: brightness(.94); }
.btn-red { background: var(--red); color: #fff; }
.btn-red:hover { filter: brightness(.94); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink-soft); box-shadow: var(--shadow); }
.btn-ghost:hover { border-color: #c9d2df; color: var(--ink); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.icon-btn { width: 32px; height: 32px; padding: 0; justify-content: center; border-radius: 8px; background: transparent; border: 1px solid transparent; color: var(--ink-faint); }
.icon-btn:hover { background: #f0f2f6; color: var(--primary); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }
.icon-btn svg { width: 16px; height: 16px; fill: currentColor; }
.actions-row { display: flex; gap: 10px; flex-wrap: wrap; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }

/* ---------- Forms / modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(24,34,52,.5); backdrop-filter: blur(2px);
  display: grid; place-items: center; z-index: 100; padding: 20px; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); width: 100%; max-width: 520px;
  max-height: 90vh; overflow: auto; animation: pop .18s cubic-bezier(.2,.9,.3,1.2); }
@keyframes pop { from { transform: scale(.96) translateY(8px); opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; background: #fafbfc; border-radius: 0 0 16px 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; background: #fff; transition: border .15s, box-shadow .15s; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
.field .hint { font-size: 11.5px; color: var(--ink-faint); }
.close-x { cursor: pointer; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: var(--ink-faint); border: 0; background: transparent; }
.close-x:hover { background: #f0f2f6; color: var(--ink); }
.close-x svg { width: 18px; height: 18px; fill: currentColor; }

/* dropzone */
.dropzone { border: 2px dashed var(--line); border-radius: 11px; padding: 18px; text-align: center; color: var(--ink-faint);
  cursor: pointer; transition: border .15s, background .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.dropzone svg { width: 26px; height: 26px; fill: currentColor; margin-bottom: 4px; }
.filelist { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* ---------- Reports ---------- */
.report-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.report-preview { margin-top: 16px; border: 1px solid var(--line); border-radius: 10px; overflow: auto; max-height: 420px; }
.report-preview table.data th { position: sticky; top: 0; background: #fff; z-index: 1; }

/* empty state */
.empty { text-align: center; padding: 44px 20px; color: var(--ink-faint); }
.empty svg { width: 52px; height: 52px; fill: #ccd4e0; margin-bottom: 12px; }
.empty h3 { color: var(--ink-soft); margin-bottom: 6px; }

/* toast */
.toast-root { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: #1e2733; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow-lg);
  font-weight: 500; display: flex; align-items: center; gap: 10px; animation: slidein .2s ease; max-width: 360px; }
.toast.ok { background: #1b7a3d; } .toast.err { background: #c02c22; }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } }

.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.section-head h2 { font-size: 17px; }
.spin { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: rot .7s linear infinite; margin: 40px auto; }
@keyframes rot { to { transform: rotate(360deg); } }

.inline-filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-filters select { border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; background: #fff; font-weight: 600; box-shadow: var(--shadow); }

@media (max-width: 1050px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .cols-2, .cols-2b, .report-cards { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; width: 240px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .view { padding: 18px 16px 50px; }
  .topbar { padding: 14px 16px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 12px; }
  .form-grid { grid-template-columns: 1fr; }
}

/* print */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  #app { display: block; }
  .view { padding: 0; }
}

/* ---------- Auth (login / setup) ---------- */
.auth-screen { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(135deg, #2f74b8 0%, #24558c 55%, #1d3f6b 100%); overflow: auto; z-index: 300; }
.auth-card { background: #fff; width: 100%; max-width: 400px; border-radius: 20px; padding: 34px 30px 26px;
  box-shadow: 0 20px 60px rgba(0,0,0,.32); text-align: center; animation: pop .2s cubic-bezier(.2,.9,.3,1.2); }
.auth-logo { width: 104px; height: 104px; border-radius: 22px; object-fit: cover; box-shadow: var(--shadow); margin-bottom: 16px; }
.auth-title { font-size: 20px; font-weight: 800; color: var(--ink); }
.auth-sub { color: var(--ink-soft); font-size: 13.5px; margin: 6px 0 22px; }
.auth-form { text-align: left; display: flex; flex-direction: column; gap: 13px; }
.auth-fields { display: flex; flex-direction: column; gap: 13px; }
.auth-field { display: flex; flex-direction: column; gap: 5px; }
.auth-field label { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.auth-field input { border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; font-size: 15px; transition: border .15s, box-shadow .15s; }
.auth-field input:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.auth-err { background: var(--red-soft); color: var(--red); border-radius: 9px; padding: 10px 12px; font-size: 13px; font-weight: 500; }
.auth-btn { justify-content: center; padding: 12px; font-size: 15px; margin-top: 4px; }
.auth-note { color: var(--ink-faint); font-size: 11.5px; margin-top: 16px; }

/* ---------- Sidebar logo + user box ---------- */
.brand-logo { width: 42px; height: 42px; border-radius: 11px; object-fit: cover; box-shadow: 0 3px 12px rgba(0,0,0,.25); flex-shrink: 0; }
.user-box { margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.user-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #d67d1c);
  color: #fff; font-weight: 800; display: grid; place-items: center; flex-shrink: 0; }
.user-name { color: #fff; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 96px; }
.user-role { color: #8ea3c4; font-size: 11px; }
.user-actions { display: flex; gap: 2px; }
.user-actions .icon-btn { color: rgba(255,255,255,.65); }
.user-actions .icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.user-actions .icon-btn.danger:hover { background: rgba(255,120,105,.2); color: #ff9a8f; }

/* ---------- Sidebar clock ---------- */
.sidebar-clock { margin: 12px 16px 0; padding: 13px 14px; border-radius: 12px;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.07); text-align: center; }
.clock-time { color: #fff; font-size: 25px; font-weight: 800; letter-spacing: 1px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.clock-date { color: #8ea3c4; font-size: 12px; margin-top: 3px; }
