/* Eflogify OS — design system */
:root {
  --brand: #C3317C; --brand-2: #E4589F; --brand-soft: rgba(195, 49, 124, .14);
  --navy: #151F2C;
  --green: #22C38E; --green-soft: rgba(34, 195, 142, .13);
  --red: #F2546B; --red-soft: rgba(242, 84, 107, .13);
  --amber: #F5A524; --amber-soft: rgba(245, 165, 36, .14);
  --blue: #5B8DEF; --blue-soft: rgba(91, 141, 239, .14);
  --radius: 18px; --radius-sm: 12px;
  --font: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --num: 'Inter', 'IBM Plex Sans Arabic', sans-serif;
  --side-w: 268px;
}
[data-theme="dark"] {
  --bg: #0A0E15; --bg-2: #0E131C; --surface: #121924; --surface-2: #17202D; --line: rgba(255,255,255,.07); --line-2: rgba(255,255,255,.12);
  --text: #EEF1F6; --muted: #8C97A8; --faint: #5E6878;
  --shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 20px 40px -24px rgba(0,0,0,.6);
  --glow: radial-gradient(1200px 500px at 85% -10%, rgba(195,49,124,.16), transparent 60%), radial-gradient(900px 500px at -10% 110%, rgba(91,141,239,.08), transparent 60%);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #F3F5F9; --bg-2: #EBEEF4; --surface: #FFFFFF; --surface-2: #F7F8FB; --line: rgba(21,31,44,.08); --line-2: rgba(21,31,44,.14);
  --text: #151F2C; --muted: #5F6B7D; --faint: #9AA3B2;
  --shadow: 0 1px 2px rgba(21,31,44,.04), 0 12px 32px -18px rgba(21,31,44,.18);
  --glow: radial-gradient(1200px 500px at 85% -10%, rgba(195,49,124,.08), transparent 60%);
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); background-image: var(--glow); background-attachment: fixed; color: var(--text); font-size: 14.5px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
small { color: var(--muted); }
.ic { flex-shrink: 0; }
.num, .kpi-val, td.n, .money { font-family: var(--num); font-feature-settings: "tnum"; }
.cur { font-family: var(--font); font-size: .62em; color: var(--muted); font-weight: 500; margin-inline-start: 2px; }
[data-theme="dark"] .logo-dark-hide { display: none !important; }
[data-theme="light"] .logo-light-hide { display: none !important; }
[data-theme="dark"] .when-light, [data-theme="light"] .when-dark { display: none; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: var(--side-w); background: var(--bg-2); border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; z-index: 40; transition: transform .3s cubic-bezier(.2,.8,.2,1); }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 22px 22px 14px; }
.side-brand .logo { height: 34px; width: auto; }
.brand-tag { font-family: var(--num); font-weight: 800; font-size: 11px; padding: 3px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-2); letter-spacing: .08em; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 6px 14px 14px; scrollbar-width: thin; }
.nav-group { font-size: 11px; font-weight: 600; color: var(--faint); padding: 18px 10px 6px; letter-spacing: .02em; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--muted); font-weight: 500; position: relative; transition: background .15s, color .15s; }
.nav-link:hover { background: var(--surface); color: var(--text); }
.nav-link.active { background: linear-gradient(90deg, transparent, var(--brand-soft)); color: var(--text); }
.nav-link.active::before { content: ""; position: absolute; inset-inline-start: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 4px 4px 0; background: var(--brand); box-shadow: 0 0 12px var(--brand); }
.nav-link.active .ic { color: var(--brand-2); }
.side-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); }
.me { display: flex; align-items: center; gap: 10px; min-width: 0; }
.me small { display: block; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.avatar { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--brand), #7B2A8F); }
.main { flex: 1; margin-inline-start: var(--side-w); min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; padding: 18px 32px; background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); }
.page-title { flex: 1; min-width: 0; }
.page-title h1 { font-size: 21px; }
.page-title p { margin: 0; color: var(--muted); font-size: 13px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.content { padding: 26px 32px 60px; max-width: 1480px; }
.scrim { display: none; }

/* ---------- Buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font: 600 14px var(--font); cursor: pointer; transition: transform .12s, background .15s, box-shadow .15s, border-color .15s; white-space: nowrap; }
.btn:hover { border-color: var(--faint); }
.btn:active { transform: scale(.97); }
.btn-brand { background: linear-gradient(135deg, var(--brand-2), var(--brand)); border-color: transparent; color: #fff; box-shadow: 0 8px 22px -10px var(--brand); }
.btn-brand:hover { box-shadow: 0 10px 28px -8px var(--brand); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--red); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 10px; }
.btn-lg { height: 48px; font-size: 15px; padding: 0 24px; }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; transition: color .15s, border-color .15s; }
.icon-btn:hover { color: var(--text); border-color: var(--line-2); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 10px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 12px; height: 42px; padding: 0 12px; width: 100%; outline: none; transition: border-color .15s, box-shadow .15s; }
textarea { height: auto; padding: 10px 12px; min-height: 80px; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
input[type="checkbox"], input[type="radio"] { width: auto; height: auto; accent-color: var(--brand); }
input[type="file"] { padding: 9px; height: auto; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; justify-content: flex-start; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); }
.seg { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; scrollbar-width: none; }
.seg label { flex: 1; cursor: pointer; }
.seg input { display: none; }
.seg span { display: block; text-align: center; padding: 8px 10px; border-radius: 10px; font-weight: 600; font-size: 13px; color: var(--muted); white-space: nowrap; transition: all .15s; }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 2px 10px rgba(0,0,0,.18); }
.seg[data-seg="type"] input[value="income"]:checked + span { color: var(--green); }
.seg[data-seg="type"] input[value="expense"]:checked + span { color: var(--red); }
.amount-field { position: relative; }
.amount-field input { height: 70px; font: 700 34px var(--num); text-align: center; border-radius: 16px; letter-spacing: -.02em; }
.amount-field span { position: absolute; inset-inline-start: 18px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; }

/* ---------- Cards ---------- */
.grid { display: grid; gap: 18px; }
.g-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-main { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h3 { font-size: 15.5px; display: flex; align-items: center; gap: 8px; }
.card-head h3 .ic { color: var(--brand-2); }
.card-head small { font-size: 12.5px; }
.card.flush { padding: 0; }
.card.flush .card-head { padding: 18px 20px 0; }
.mb { margin-bottom: 18px; }
.mt { margin-top: 18px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 18px; }
.toolbar .field { min-width: 140px; flex: 1 1 140px; max-width: 220px; }
.toolbar .spacer { flex: 1; }

/* KPI */
.kpi { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.kpi-top { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi-top i { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.kpi-val { font-size: 27px; font-weight: 700; margin-top: 10px; letter-spacing: -.02em; line-height: 1.2; }
.kpi-foot { margin-top: 8px; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kpi.hero { background: linear-gradient(140deg, #D23B89 0%, #A52569 45%, #3A1638 100%); border: 0; color: #fff; box-shadow: 0 24px 50px -24px rgba(195,49,124,.7); }
.kpi.hero::after { content: ""; position: absolute; width: 260px; height: 260px; border-radius: 50%; border: 40px solid rgba(255,255,255,.06); inset-inline-start: -90px; bottom: -150px; }
.kpi.hero .kpi-top, .kpi.hero .kpi-foot, .kpi.hero .cur { color: rgba(255,255,255,.8); }
.kpi.hero .kpi-top i { background: rgba(255,255,255,.15); color: #fff; }
.kpi.green .kpi-top i { background: var(--green-soft); color: var(--green); }
.kpi.red .kpi-top i { background: var(--red-soft); color: var(--red); }
.kpi.amber .kpi-top i { background: var(--amber-soft); color: var(--amber); }
.kpi.blue .kpi-top i { background: var(--blue-soft); color: var(--blue); }
.kpi.brand .kpi-top i { background: var(--brand-soft); color: var(--brand-2); }
.pos { color: var(--green); } .neg { color: var(--red); } .warn { color: var(--amber); } .muted { color: var(--muted); }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: start; font-weight: 600; font-size: 12px; color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }
td.n { white-space: nowrap; font-weight: 600; }
.t-strong { font-weight: 600; }
.t-sub { display: block; font-size: 12px; color: var(--muted); }
tfoot td { font-weight: 700; background: var(--surface-2); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.tx-ic { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; }
.tx-ic.income { background: var(--green-soft); color: var(--green); }
.tx-ic.expense { background: var(--red-soft); color: var(--red); }
.tx-ic.owner_draw, .tx-ic.owner_deposit { background: var(--amber-soft); color: var(--amber); }
.tx-ic.transfer, .tx-ic.opening { background: var(--blue-soft); color: var(--blue); }
.tx-cell { display: flex; align-items: center; gap: 12px; min-width: 200px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.b-ok { background: var(--green-soft); color: var(--green); }
.b-bad { background: var(--red-soft); color: var(--red); }
.b-warn { background: var(--amber-soft); color: var(--amber); }
.b-info { background: var(--blue-soft); color: var(--blue); }
.b-brand { background: var(--brand-soft); color: var(--brand-2); }
.b-mute { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

/* Lists */
.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.li:last-child { border-bottom: 0; }
.li .grow { flex: 1; min-width: 0; }
.li .grow b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .grow small { font-size: 12px; }
.bar { height: 7px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.bar.green > i { background: var(--green); } .bar.red > i { background: var(--red); } .bar.amber > i { background: var(--amber); }

/* Bank / credit cards */
.cc { position: relative; border-radius: 20px; padding: 20px; color: #fff; min-height: 178px; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; box-shadow: 0 20px 40px -22px rgba(0,0,0,.7); isolation: isolate; }
.cc::before { content: ""; position: absolute; inset: 0; background: radial-gradient(400px 200px at 100% 0%, rgba(255,255,255,.22), transparent 60%), linear-gradient(140deg, var(--c1, #C3317C), var(--c2, #2A1430)); z-index: -1; }
.cc::after { content: ""; position: absolute; width: 220px; height: 220px; border-radius: 50%; border: 34px solid rgba(255,255,255,.07); inset-inline-start: -70px; bottom: -120px; z-index: -1; }
.cc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.cc-name { font-weight: 700; font-size: 15px; }
.cc-type { font-size: 11.5px; opacity: .8; }
.cc-bal { font: 700 26px var(--num); letter-spacing: -.02em; }
.cc-bal .cur { color: rgba(255,255,255,.75); }
.cc-foot { display: flex; justify-content: space-between; align-items: end; font-size: 12px; opacity: .9; gap: 8px; }
.cc-num { font-family: var(--num); letter-spacing: .18em; font-size: 13px; }
.cc .bar { background: rgba(255,255,255,.2); margin-top: 8px; } .cc .bar > i { background: #fff; }
.chip { width: 34px; height: 26px; border-radius: 6px; background: linear-gradient(135deg, #F7D27A, #C99A3B); opacity: .9; }

/* Flash / empty / modal */
.flash { display: flex; align-items: center; gap: 10px; margin: 18px 32px 0; padding: 12px 16px; border-radius: 14px; font-weight: 500; border: 1px solid; }
.flash-ok { background: var(--green-soft); color: var(--green); border-color: rgba(34,195,142,.25); }
.flash-err { background: var(--red-soft); color: var(--red); border-color: rgba(242,84,107,.25); }
.flash-warn { background: var(--amber-soft); color: var(--amber); border-color: rgba(245,165,36,.25); }
.empty { text-align: center; padding: 40px 20px; color: var(--faint); }
.empty p { margin: 10px 0 0; color: var(--muted); }
.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(5,8,12,.6); backdrop-filter: blur(6px); }
.modal.open { display: flex; animation: fade .18s ease; }
.modal-card { width: min(620px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: 22px; padding: 22px; box-shadow: 0 40px 80px -30px rgba(0,0,0,.7); animation: rise .25s cubic-bezier(.2,.8,.2,1); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-head h3 { font-size: 18px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } }
details.inline summary { cursor: pointer; list-style: none; }
details.inline summary::-webkit-details-marker { display: none; }

/* Attendance calendar */
.att-grid { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 6px; }
.att-day { border-radius: 12px; padding: 8px; min-height: 74px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; display: flex; flex-direction: column; gap: 2px; }
.att-day b { font-family: var(--num); font-size: 13px; }
.att-day.s-absent { background: var(--red-soft); border-color: rgba(242,84,107,.25); }
.att-day.s-leave, .att-day.s-excused, .att-day.s-weekend_work { background: var(--blue-soft); border-color: rgba(91,141,239,.25); }
.att-day.s-untracked, .att-day.s-weekend, .att-day.s-holiday, .att-day.s-future, .att-day.s-na { opacity: .5; }
.att-day.late { box-shadow: inset 0 -3px 0 var(--amber); }
.att-head { text-align: center; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.heat td { text-align: center; padding: 6px 4px; font-size: 11px; }
.heat .cell { width: 26px; height: 26px; border-radius: 7px; display: inline-grid; place-items: center; font-family: var(--num); font-weight: 600; }
.cell.s-present { background: var(--green-soft); color: var(--green); }
.cell.s-present.late { background: var(--amber-soft); color: var(--amber); }
.cell.s-absent { background: var(--red-soft); color: var(--red); }
.cell.s-leave, .cell.s-excused, .cell.s-weekend_work { background: var(--blue-soft); color: var(--blue); }
.cell.s-untracked, .cell.s-weekend, .cell.s-holiday, .cell.s-future, .cell.s-na, .cell.s-pending { background: var(--surface-2); color: var(--faint); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: middle; }

/* Charts */
.chart-box { position: relative; height: 300px; }
.chart-box.sm { height: 230px; }
.donut-wrap { display: grid; grid-template-columns: 180px 1fr; gap: 18px; align-items: center; }
.donut-wrap .chart-box { height: 180px; }

/* Payslip print */
.slip { background: #fff; color: #151F2C; border-radius: 20px; padding: 36px; max-width: 820px; margin: 0 auto; box-shadow: var(--shadow); }
.slip h2 { font-size: 20px; }
.slip-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-bottom: 20px; border-bottom: 3px solid #C3317C; }
.slip-head img { height: 44px; }
.slip-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 22px 0; }
.slip-meta div { background: #F5F6FA; border-radius: 12px; padding: 10px 12px; }
.slip-meta small { color: #6B7584; display: block; font-size: 11.5px; }
.slip-meta b { font-size: 14px; }
.slip-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.slip table { font-size: 13.5px; }
.slip th { background: #F5F6FA; color: #5F6B7D; border-color: #E6E9EF; }
.slip td { border-color: #EEF0F4; }
.slip-net { margin-top: 22px; display: flex; justify-content: space-between; align-items: center; background: linear-gradient(135deg, #D23B89, #7A1F55); color: #fff; padding: 18px 22px; border-radius: 16px; }
.slip-net b { font: 800 28px var(--num); }
.slip-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 46px; font-size: 13px; color: #6B7584; }
.slip-sign div { border-top: 1px dashed #C9CED8; padding-top: 8px; }

/* Login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 26px; padding: 34px 30px; box-shadow: var(--shadow); }
.auth-card .logo { height: 46px; display: block; margin: 0 auto 8px; }
.auth-card h1 { text-align: center; font-size: 19px; margin-bottom: 4px; }
.auth-card p.lead { text-align: center; color: var(--muted); margin: 0 0 24px; font-size: 13.5px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }

/* Code */
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; direction: ltr; text-align: left; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 12px; padding: 12px 14px; font-size: 12.5px; word-break: break-all; position: relative; }
.steps { counter-reset: s; display: flex; flex-direction: column; gap: 14px; }
.steps > div { counter-increment: s; display: flex; gap: 14px; }
.steps > div::before { content: counter(s); flex-shrink: 0; width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-2); font: 700 14px var(--num); }

/* Bottom nav (mobile) */
.bottom-nav { display: none; }
.only-mobile { display: none; }

@media (max-width: 1200px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .g-main { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .sidebar { transform: translateX(100%); box-shadow: -30px 0 60px rgba(0,0,0,.4); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.5); }
  .main { margin-inline-start: 0; }
  .only-mobile { display: inline-grid; }
  .hide-mobile { display: none !important; }
  .topbar { padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); }
  .page-title h1 { font-size: 18px; }
  .content { padding: 16px 14px 110px; }
  .flash { margin: 12px 14px 0; }
  .g-3, .g-2 { grid-template-columns: 1fr; }
  .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .card { padding: 16px; border-radius: 16px; }
  .kpi { padding: 15px 16px; }
  .kpi-val { font-size: 22px; }
  .toolbar .field { max-width: none; }
  .donut-wrap { grid-template-columns: 1fr; }
  .chart-box { height: 240px; }
  .bottom-nav { display: flex; position: fixed; z-index: 50; inset-inline: 10px; bottom: max(10px, env(safe-area-inset-bottom)); height: 66px; align-items: center; justify-content: space-around; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border: 1px solid var(--line-2); border-radius: 22px; box-shadow: 0 18px 40px -16px rgba(0,0,0,.5); }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; color: var(--muted); width: 62px; }
  .fab { width: 56px; height: 56px; border-radius: 18px; border: 0; color: #fff; background: linear-gradient(135deg, var(--brand-2), var(--brand)); box-shadow: 0 12px 26px -8px var(--brand); display: grid; place-items: center; margin-top: -30px; cursor: pointer; }
  .modal { align-items: flex-end; padding: 0; }
  .modal-card { border-radius: 24px 24px 0 0; max-height: 92vh; padding-bottom: max(22px, env(safe-area-inset-bottom)); }
  .slip { padding: 20px; } .slip-meta { grid-template-columns: repeat(2, 1fr); } .slip-cols { grid-template-columns: 1fr; }
  .att-day { min-height: 56px; padding: 5px; font-size: 10.5px; }
  .hide-sm { display: none; }
  /* table → cards */
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  table.responsive td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 10px; }
  table.responsive td[data-l]::before { content: attr(data-l); color: var(--muted); font-size: 12px; }
  table.responsive td.main-cell { display: block; padding-bottom: 6px; }
  table.responsive td.main-cell::before { display: none; }
  table.responsive tfoot { display: block; }
}
@media (max-width: 520px) {
  .g-4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-val { font-size: 19px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: 1fr; }
}
@media print {
  .sidebar, .topbar, .bottom-nav, .no-print, .flash { display: none !important; }
  .main { margin: 0; } .content { padding: 0; }
  body { background: #fff !important; }
  .slip { box-shadow: none; padding: 0; }
  .card { box-shadow: none; border-color: #ddd; }
}

/* Built-in SVG charts */
.chart-holder { position: absolute; inset: 0; }
.chart-box > .chart-holder { position: absolute; inset: 0; }
.svgchart { display: block; overflow: visible; font-family: var(--num); }
.svgchart .ct-sm { font-size: 11px; font-family: var(--font); }
.svgchart .ct-big { font-size: 22px; font-weight: 700; }
.svgchart .arc { transition: opacity .15s; cursor: pointer; }
.svgchart .arc:hover { opacity: .82; }
.svgchart .bar-anim { animation: grow .7s cubic-bezier(.2,.8,.2,1) both; transform-box: fill-box; transform-origin: bottom; }
.svgchart .line-anim { stroke-dasharray: 2000; animation: draw 1.2s ease both; }
.svgchart .line-anim[stroke-dasharray="6 4"] { animation: none; stroke-dasharray: 6 4; }
@keyframes grow { from { transform: scaleY(0); } }
@keyframes draw { from { stroke-dashoffset: 2000; } to { stroke-dashoffset: 0; } }
.chart-tip { position: fixed; z-index: 200; pointer-events: none; display: none; background: var(--surface-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 12px; padding: 9px 12px; font-size: 12.5px; box-shadow: 0 14px 30px -12px rgba(0,0,0,.5); min-width: 120px; line-height: 1.7; }
.chart-tip i { display: inline-block; width: 8px; height: 8px; border-radius: 3px; margin-inline-end: 6px; }
