/* =====================================================================
   Visual refresh — colours, icons, depth and typography only.
   Loaded after style.css; layout, chart types and positions are unchanged.
   Remove the <link> to theme.css in index.html to go back to the old look.
   ===================================================================== */

:root {
  --bg: #eef1f7;
  --surface: #ffffff;
  --ink: #18213a;
  --ink-2: #46506a;
  --muted: #7c859b;
  --line: #e2e6ef;
  --line-2: #eef1f6;
  --primary: #1e2d5c;
  --primary-2: #2f4796;
  --accent: #f2b705;
  --head: #fff5d6;
  --head-ink: #5a4300;
  --total: #f5c542;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 48, .04), 0 8px 24px rgba(16, 24, 48, .06);
  --shadow-hover: 0 2px 4px rgba(16, 24, 48, .06), 0 14px 32px rgba(16, 24, 48, .10);

  /* line icons (24×24, stroke) used through CSS masks */
  --i-logo: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 3.2A9 9 0 1 0 20.8 14a1 1 0 0 0-1-1H13a2 2 0 0 1-2-2V4a.9.9 0 0 0-1-.8z'/%3E%3Cpath d='M15 3.5A9 9 0 0 1 20.5 9H16a1 1 0 0 1-1-1V3.5z'/%3E%3C/svg%3E");
  --i-invoice: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3v4a1 1 0 0 0 1 1h4'/%3E%3Cpath d='M17 21H7a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7l5 5v11a2 2 0 0 1-2 2z'/%3E%3Cpath d='M9 13h6M9 17h6'/%3E%3C/svg%3E");
  --i-wallet: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17 8V5a1 1 0 0 0-1-1H6a2 2 0 0 0 0 4h12a1 1 0 0 1 1 1v3m0 4v3a1 1 0 0 1-1 1H6a2 2 0 0 1-2-2V6'/%3E%3Cpath d='M20 12v4h-4a2 2 0 0 1 0-4h4'/%3E%3C/svg%3E");
  --i-hourglass: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 20v-2a6 6 0 1 1 12 0v2a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1z'/%3E%3Cpath d='M6 4v2a6 6 0 1 0 12 0V4a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1z'/%3E%3C/svg%3E");
  --i-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 9v4M12 16.5v.01'/%3E%3Cpath d='M10.4 3.9 2.6 17.5A1.8 1.8 0 0 0 4.2 20h15.6a1.8 1.8 0 0 0 1.6-2.5L13.6 3.9a1.8 1.8 0 0 0-3.2 0z'/%3E%3C/svg%3E");
  --i-trend: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 17l6-6 4 4 8-8'/%3E%3Cpath d='M14 7h7v7'/%3E%3C/svg%3E");
  --i-target: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='1'/%3E%3Ccircle cx='12' cy='12' r='5'/%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3C/svg%3E");
  --i-cart: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='6' cy='19' r='2'/%3E%3Ccircle cx='17' cy='19' r='2'/%3E%3Cpath d='M17 17H6V3H4'/%3E%3Cpath d='M6 5l14 1-1 7H6'/%3E%3C/svg%3E");
  --i-calendar: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='5' width='16' height='16' rx='2'/%3E%3Cpath d='M16 3v4M8 3v4M4 11h16M8 15h2v2H8z'/%3E%3C/svg%3E");
  --i-table: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Cpath d='M3 10h18M10 5v14'/%3E%3C/svg%3E");
  --i-chart: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 20h16'/%3E%3Crect x='5' y='12' width='3' height='6' rx='1'/%3E%3Crect x='10.5' y='6' width='3' height='12' rx='1'/%3E%3Crect x='16' y='9' width='3' height='9' rx='1'/%3E%3C/svg%3E");
  --i-users: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M3 21v-2a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v2M16 3.13a4 4 0 0 1 0 7.75M21 21v-2a4 4 0 0 0-3-3.85'/%3E%3C/svg%3E");
  --i-user: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3Cpath d='M6 21v-2a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v2'/%3E%3C/svg%3E");
  --i-clock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 3'/%3E%3C/svg%3E");
  --i-upload: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2'/%3E%3Cpath d='M7 9l5-5 5 5M12 4v12'/%3E%3C/svg%3E");
  --i-history: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 8v4l2 2'/%3E%3Cpath d='M3.05 11a9 9 0 1 1 .5 4M3 20v-5h5'/%3E%3C/svg%3E");
  --i-settings: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.3 4.3c.4-1.8 3-1.8 3.4 0a1.7 1.7 0 0 0 2.6 1.1c1.5-.9 3.3.8 2.4 2.4a1.7 1.7 0 0 0 1 2.5c1.8.4 1.8 3 0 3.4a1.7 1.7 0 0 0-1 2.6c.9 1.5-.9 3.3-2.4 2.4a1.7 1.7 0 0 0-2.6 1c-.4 1.8-3 1.8-3.4 0a1.7 1.7 0 0 0-2.6-1c-1.5.9-3.3-.9-2.4-2.4a1.7 1.7 0 0 0-1-2.6c-1.8-.4-1.8-3 0-3.4a1.7 1.7 0 0 0 1-2.5c-.9-1.6.9-3.3 2.4-2.4a1.7 1.7 0 0 0 2.6-1.1z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
}

body { background: var(--bg); color: var(--ink); }

/* ---------- logo mark ---------- */
.brand-mark { position: relative; font-size: 0; background: var(--accent); box-shadow: 0 6px 16px rgba(242, 183, 5, .35); }
.brand-mark::after {
  content: ''; position: absolute; inset: 22%; background: var(--primary);
  -webkit-mask: var(--i-logo) center / contain no-repeat; mask: var(--i-logo) center / contain no-repeat;
}

/* ---------- top bar: navy ---------- */
.topbar { background: var(--primary); border-bottom: 0; box-shadow: 0 4px 18px rgba(16, 24, 48, .18); }
.brand-title { color: #fff; }
.brand-sub { color: #aeb9de; }
.tabs button { color: #c6cfec; }
.tabs button:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.tabs button.active { background: rgba(255, 255, 255, .16); color: #fff; }
.topbar .user-name { color: #fff; }
.topbar .role-badge { background: var(--accent); color: var(--primary); }
.topbar .role-badge.finance { background: #ffe49a; color: #4b3700; }
.topbar .btn.ghost { background: transparent; color: #e6ebfa; border-color: rgba(255, 255, 255, .25); }
.topbar .btn.ghost:hover { background: rgba(255, 255, 255, .1); }
.topbar select { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .22); color: #fff; }
.topbar select option { color: var(--ink); background: #fff; }

/* ---------- buttons & inputs ---------- */
.btn { border-radius: 10px; transition: background .15s, border-color .15s, box-shadow .15s, transform .1s; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); box-shadow: 0 4px 12px rgba(30, 45, 92, .22); }
.btn.primary:hover { background: var(--primary-2); }
.btn.ghost { background: var(--surface); border-color: var(--line); }
.btn.ghost:hover { background: #f4f6fb; border-color: #cfd6e6; }
input, select { border-color: var(--line); border-radius: 10px; }

/* ---------- cards ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card h2 { font-weight: 800; letter-spacing: -.1px; }

/* section icon badge before the card title */
.card[data-ic] > h2, .card[data-ic] > .card-head h2 { position: relative; padding-inline-start: 42px; min-height: 32px; display: flex; align-items: center; }
.card[data-ic] > h2::before, .card[data-ic] > .card-head h2::before {
  content: ''; position: absolute; inset-inline-start: 0; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border-radius: 10px; background: #e8edfb;
}
.card[data-ic] > h2::after, .card[data-ic] > .card-head h2::after {
  content: ''; position: absolute; inset-inline-start: 7px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; background: var(--primary-2);
  -webkit-mask: var(--ic) center / contain no-repeat; mask: var(--ic) center / contain no-repeat;
}
.card-head p { padding-inline-start: 42px; }
.card[data-ic] > h2 + p, .card[data-ic] > h2 + .muted { margin-top: -4px; }

[data-ic="invoice"] { --ic: var(--i-invoice); } [data-ic="wallet"] { --ic: var(--i-wallet); }
[data-ic="hourglass"] { --ic: var(--i-hourglass); } [data-ic="alert"] { --ic: var(--i-alert); }
[data-ic="trend"] { --ic: var(--i-trend); } [data-ic="target"] { --ic: var(--i-target); }
[data-ic="cart"] { --ic: var(--i-cart); } [data-ic="calendar"] { --ic: var(--i-calendar); }
[data-ic="table"] { --ic: var(--i-table); } [data-ic="chart"] { --ic: var(--i-chart); }
[data-ic="users"] { --ic: var(--i-users); } [data-ic="user"] { --ic: var(--i-user); }
[data-ic="clock"] { --ic: var(--i-clock); } [data-ic="upload"] { --ic: var(--i-upload); }
[data-ic="history"] { --ic: var(--i-history); } [data-ic="settings"] { --ic: var(--i-settings); }

/* ---------- KPI cards ---------- */
.kpi-group-title b { font-size: 15px; font-weight: 800; display: inline-flex; align-items: center; gap: 8px; }
.kpi-group-title b::before { content: ''; width: 4px; height: 16px; border-radius: 4px; background: var(--accent); }
.kpi {
  --kc: var(--primary-2); --kbg: #e8edfb;
  border: 1px solid var(--line); border-top: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease; position: relative; overflow: hidden;
}
.kpi::after { /* thin colour line along the top edge */
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--kc); opacity: .85;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.kpi.k-good { --kc: var(--good); --kbg: #e2f4ea; }
.kpi.k-warn { --kc: #d18a00; --kbg: #fff1d1; }
.kpi.k-bad { --kc: var(--bad); --kbg: #fce4e2; }
.kpi.k-accent { --kc: #c99700; --kbg: #fff4d1; }
.kpi[data-ic] .kpi-label { position: relative; padding-inline-start: 40px; min-height: 30px; display: flex; align-items: center; font-weight: 600; color: var(--ink-2); }
.kpi[data-ic] .kpi-label::before {
  content: ''; position: absolute; inset-inline-start: 0; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; border-radius: 9px; background: var(--kbg);
}
.kpi[data-ic] .kpi-label::after {
  content: ''; position: absolute; inset-inline-start: 6px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; background: var(--kc);
  -webkit-mask: var(--ic) center / contain no-repeat; mask: var(--ic) center / contain no-repeat;
}
.kpi-value { color: var(--ink); }
.meter { height: 7px; background: #edf0f6; }
.meter > span { background: var(--kc); }

/* ---------- month filter ---------- */
.filter-bar { border: 1px solid var(--line); border-inline-start: 4px solid var(--accent); box-shadow: var(--shadow); }
.month-pick select { border-color: #cfd6e6; background: #f8f9fc; }

/* ---------- segmented switch & chips ---------- */
.seg { background: #edf0f6; }
.seg button[aria-selected="true"] { color: var(--primary); }
.chip[aria-pressed="true"] { background: #e8edfb; border-color: var(--primary-2); color: var(--primary); }

/* ---------- report tables (desktop look; phone card view keeps its own styles) ---------- */
@media (min-width: 641px) {
  .table-wrap:has(> table.rep) { border: 1px solid var(--line); border-radius: 12px; }
  table.rep { border: 0; }
  table.rep th, table.rep td { border-color: #e7eaf1; }
  table.rep tr > :first-child { border-inline-start: 0; }
  table.rep tr > :last-child { border-inline-end: 0; }
  table.rep thead tr:first-child th { border-top: 0; }
  table.rep tbody tr:last-child td { border-bottom: 0; }
  table.rep thead th { background: var(--head); color: var(--head-ink); }
  table.rep thead th.super { background: #fffaea; }
  table.rep thead th.target-h { background: #ffe9a3; }
  table.rep tbody tr:nth-child(even):not(.total) td { background: #fafbfd; }
  table.rep td.lead { background: #f3f5fb; color: var(--primary); }
  table.rep tr.total td { background: var(--total); color: #3a2a00; }
  table.rep.clickable tbody tr:not(.total):hover td { background: #eef2fd; }
}
.pill { padding: 2px 10px; }

/* ---------- lists ---------- */
table.list th { color: var(--muted); background: #f8f9fc; }
table.list tr.link:hover td { background: #f3f6fe; }

/* ---------- target bar, horizontal bars ---------- */
.target-bar .track { height: 12px; background: #edf0f6; }
.hbar .bar { height: 14px; background: #edf0f6; }

/* ---------- charts: "ocean" style ---------- */
.chart .grid line { stroke: #edf1f7; }
.chart .axis text { fill: #8792ab; }
.legend { gap: 6px 16px; color: var(--ink-2); }
.legend i { border-radius: 3px; }
.legend i.dash { border-top: 2.4px dashed #f59e0b; width: 18px; }

.gauge { max-width: 220px; }
.gauge .g-val { font-size: 27px; font-weight: 800; fill: var(--ink); text-anchor: middle; }
.gauge .g-cap { font-size: 10.5px; fill: var(--muted); text-anchor: middle; font-family: inherit; }
.gauge .g-lbl { font-size: 10px; fill: #8792ab; text-anchor: middle; }

.mini .m-bar { fill: #c7d8f5; }
.mini .m-bar.cur { fill: #1e3a8a; }
.mini .m-bar.neg { fill: #a7e3c6; }
.mini .m-bar.neg.cur { fill: var(--good); }
.mini .m-avg { stroke: #f59e0b; stroke-width: 2.2; stroke-dasharray: 6 3; }
.mini-cap .m-key { border-top-color: #f59e0b; }

/* ageing: one multi-segment bar + legend */
.age-stack { display: flex; gap: 3px; height: 26px; border-radius: 8px; overflow: hidden; background: #edf0f6; }
.age-stack span { display: block; height: 100%; min-width: 3px; color: #fff; font-size: 11.5px; font-weight: 700; display: flex; align-items: center; justify-content: center; white-space: nowrap; overflow: hidden; }
.age-legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px 18px; }
.age-legend div { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.age-legend i { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }
.age-legend b { margin-inline-start: auto; color: var(--ink); direction: ltr; }
.age-legend small { color: var(--muted); font-size: 11.5px; }

/* ---------- quick course settings (finance manager) ---------- */
.q-title { gap: 8px; }
.q-edit {
  width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--line); background: #f6f8fc; cursor: pointer;
  position: relative; flex-shrink: 0; padding: 0;
}
.q-edit::before {
  content: ''; position: absolute; inset: 5px; background: var(--muted);
  -webkit-mask: var(--i-settings) center / contain no-repeat; mask: var(--i-settings) center / contain no-repeat;
}
.q-edit:hover { background: #e8edfb; border-color: var(--primary-2); }
.q-edit:hover::before { background: var(--primary-2); }
body.can-edit .q-title > span { cursor: pointer; }
body.can-edit .q-title > span:hover { text-decoration: underline dotted; text-underline-offset: 5px; }
.q-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.q-item { flex-direction: row; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; color: var(--ink); font-weight: 600; }
.q-item:hover { background: #f6f8fc; }
.q-item input { width: 17px; height: 17px; accent-color: var(--primary-2); }
.q-item:has(input:not(:checked)) { color: var(--muted); background: #fafbfd; }

/* ---------- tooltip ---------- */
.tooltip { background: #18213a; border-radius: 12px; box-shadow: 0 10px 30px rgba(16, 24, 48, .25); }

/* ---------- modal ---------- */
.modal { background: rgba(16, 24, 48, .5); backdrop-filter: blur(2px); }
.modal-card { border-radius: 18px; }
.modal-head { background: #f6f8fc; border-radius: 18px 18px 0 0; }

/* ---------- upload drop zone ---------- */
.drop { border-color: #c9d1e3; background: #f8f9fd; border-radius: 16px; }
.drop:hover, .drop.over { border-color: var(--primary-2); background: #eef2fd; }

/* ---------- login ---------- */
.login {
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(96, 128, 230, .35), transparent 60%),
    radial-gradient(800px 600px at 0% 110%, rgba(47, 71, 150, .45), transparent 60%),
    var(--primary);
}
.login-card { border-radius: 20px; box-shadow: 0 24px 60px rgba(0, 0, 0, .35); }
.login-card .brand-mark { width: 56px; height: 56px; border-radius: 16px; }

/* ---------- phones ---------- */
@media (max-width: 640px) {
  .card-head p { padding-inline-start: 0; }
  .card[data-ic] > h2, .card[data-ic] > .card-head h2 { padding-inline-start: 38px; min-height: 28px; }
  .card[data-ic] > h2::before, .card[data-ic] > .card-head h2::before { width: 28px; height: 28px; border-radius: 8px; }
  .card[data-ic] > h2::after, .card[data-ic] > .card-head h2::after { inset-inline-start: 6px; width: 16px; height: 16px; }
  .kpi[data-ic] .kpi-label { padding-inline-start: 34px; min-height: 26px; }
  .kpi[data-ic] .kpi-label::before { width: 26px; height: 26px; border-radius: 8px; }
  .kpi[data-ic] .kpi-label::after { inset-inline-start: 5px; width: 16px; height: 16px; }
  .kpi:hover { transform: none; }
}

/* ---------- print: keep it plain ---------- */
@media print {
  .kpi::after, .card h2::before, .card h2::after, .kpi-label::before, .kpi-label::after { display: none !important; }
  .card h2, .kpi-label { padding-inline-start: 0 !important; }
}
