:root {
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Manrope', system-ui, sans-serif;

    --navy: #0D2C61;
    --navy-deep: #081b40;
    --orange: #F15A29;
    --orange-tint: #FCE9E0;
    --navy-tint: #E9EEF7;
    --green: #16A34A;
    --amber: #D97706;
    --amber-tint: #FEF3E2;
    --red: #DC2626;
    --bg: #F5F7FA;
    --gray: #6B7280;
    --border: #E5E7EB;
    --text: #0D2C61;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    overscroll-behavior-y: contain;
}
a { color: var(--orange); text-decoration: none; }
a:hover { color: var(--navy); }
button { font-family: inherit; }
input, textarea { font-family: inherit; }

h1, h2, .ks-display { font-family: var(--font-display); }

@keyframes ksPulse { 0% { box-shadow: 0 0 0 0 rgba(22,163,74,.55);} 70% { box-shadow: 0 0 0 7px rgba(22,163,74,0);} 100% { box-shadow: 0 0 0 0 rgba(22,163,74,0);} }
@keyframes ksPulseOrange { 0% { box-shadow: 0 0 0 0 rgba(241,90,41,.55);} 70% { box-shadow: 0 0 0 7px rgba(241,90,41,0);} 100% { box-shadow: 0 0 0 0 rgba(241,90,41,0);} }
@keyframes ksPulseRed { 0% { box-shadow: 0 0 0 0 rgba(220,38,38,.55);} 70% { box-shadow: 0 0 0 7px rgba(220,38,38,0);} 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0);} }
@keyframes ksToastIn { from { transform: translateX(-24px); opacity: 0;} to { transform: translateX(0); opacity: 1;} }
@keyframes ksSheetIn { from { transform: translateY(100%);} to { transform: translateY(0);} }
@keyframes ksFade { from { opacity: 0;} to { opacity: 1;} }

.ks-scroll::-webkit-scrollbar { width: 0; height: 0; }

/* ─── App shell ─────────────────────────────────────────────────────────── */

#app {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    overflow: hidden;
}

.app-bar {
    flex: 0 0 auto;
    height: calc(56px + env(safe-area-inset-top));
    box-sizing: border-box;
    background: var(--navy);
    display: flex;
    align-items: center;
    gap: 11px;
    padding: env(safe-area-inset-top) 12px 0 14px;
    position: relative;
    overflow: hidden;
    z-index: 20;
}
/* Diagonal orange cut echoing the Kusoya logo */
.app-bar::after {
    content: '';
    position: absolute;
    right: 0; bottom: 0;
    width: 0; height: 0;
    border-left: 30px solid transparent;
    border-bottom: 30px solid var(--orange);
}
.app-bar-logo {
    flex: 0 0 auto; width: 32px; height: 32px; border-radius: 8px;
    background: #fff; display: flex; align-items: center; justify-content: center;
}
.app-bar-logo img { width: 24px; height: 24px; display: block; border-radius: 5px; }
.app-bar-title {
    font-size: 17px; font-weight: 700; font-family: var(--font-display);
    color: #fff; letter-spacing: -.2px;
}
.app-bar-spacer { flex: 1; }
.app-bar-icon-btn {
    position: relative; width: 38px; height: 38px; border: none; background: transparent;
    border-radius: 11px; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.app-bar-badge {
    position: absolute; top: 3px; right: 3px; min-width: 16px; height: 16px; padding: 0 4px;
    background: var(--orange); color: #fff; font-size: 10px; font-weight: 700;
    font-family: var(--font-display); border: 1.5px solid var(--navy); border-radius: 999px;
    display: flex; align-items: center; justify-content: center;
}
.app-bar-avatar-btn {
    flex: 0 0 auto; display: flex; align-items: center; gap: 4px; border: none;
    background: transparent; padding: 3px; cursor: pointer;
}
/* Reusable initials-in-a-circle avatar — size passed inline per use (see
   ui.avatarHtml). The app bar's own chip is just this with a subtle ring
   added on top, since it sits directly on the navy bar. */
.ks-avatar {
    border-radius: 50%; background: var(--orange); color: #fff;
    font-weight: 700; font-family: var(--font-display);
    display: flex; align-items: center; justify-content: center; overflow: hidden;
    flex: 0 0 auto;
}
.app-bar-avatar {
    box-shadow: 0 0 0 2px rgba(255,255,255,.25);
}

.ks-content {
    flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; position: relative;
    -webkit-overflow-scrolling: touch; padding-bottom: 26px;
}
.ks-screen { padding: 16px; animation: ksFade .25s ease; }
.ks-screen-loose { padding: 18px 16px 8px; animation: ksFade .25s ease; }

.bottom-tabs {
    flex: 0 0 auto; display: flex; background: #fff; border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
}
.tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 9px 0 8px; border: none; background: transparent; cursor: pointer;
    color: var(--gray); font-size: 10.5px; font-weight: 600; font-family: inherit;
}
.tab.active { color: var(--orange); }

/* ─── Typography helpers ────────────────────────────────────────────────── */

.ks-h1 { margin: 0 0 4px; font-size: 26px; font-weight: 800; color: var(--navy); letter-spacing: -.5px; }
.ks-h2 { margin: 0; font-size: 20px; font-weight: 800; color: var(--navy); letter-spacing: -.3px; }
.ks-sub { margin: 0 0 26px; font-size: 14px; color: var(--gray); }

/* ─── Cards, tiles, buttons ─────────────────────────────────────────────── */

.ks-card {
    background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 15px;
    box-shadow: 0 1px 2px rgba(15,30,61,.04);
}
.ks-card-hero {
    border-radius: 20px; padding: 20px; color: #fff;
    background: linear-gradient(150deg, var(--navy) 0%, #123566 100%);
    box-shadow: 0 14px 30px -12px rgba(15,30,61,.6);
    position: relative;
}
/* corner-fold accent — signature touch, hero cards only */
.ks-card-hero::before {
    content: '';
    position: absolute; top: 0; right: 0;
    width: 0; height: 0;
    border-top: 22px solid var(--orange);
    border-left: 22px solid transparent;
}

.ks-btn {
    width: 100%; height: 54px; border: none; border-radius: 14px; cursor: pointer;
    font-size: 16px; font-weight: 700; font-family: inherit;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
/* icons.power/icons.clockIn are drawn at 46x46 (sized for their original
   standalone use) — force them down to a normal inline-icon size wherever
   they end up inside a label-height button, so an icon+label button doesn't
   get dwarfed by an icon meant for a bigger context. */
.ks-btn svg { width: 18px; height: 18px; }
.ks-btn-primary { background: var(--orange); color: #fff; box-shadow: 0 8px 20px -6px rgba(241,90,41,.5); }
.ks-btn-outline { background: #fff; color: var(--navy); border: 1.5px solid var(--border); }
.ks-btn-danger { background: var(--red); color: #fff; }
.ks-btn-success { background: var(--green); color: #fff; }
.ks-btn:disabled, .ks-tile:disabled, .ks-picker-row:disabled {
    opacity: .45; cursor: not-allowed; pointer-events: none; box-shadow: none;
}

/* Solid, pulsing action dots for the per-assignment check-in/out timeline
   (Home) — built on the existing .ks-stepper-dot sizing/icon rules, added
   alongside -done/-pending. Unlike those two, these are real buttons (the
   "act on this step, right now" state) — solid color plus a live pulse ring
   so the step waiting on the technician reads as active/tappable rather
   than sitting flush with the other, purely informational timeline rows.
   Two of these can appear on screen at once (a technician with two active
   sites); solid + animated is what still reads as "a real control" at that
   scale, where a static pale tint reads as decoration. */
.ks-stepper-dot-action-primary { background: var(--orange); animation: ksPulseOrange 1.8s infinite; }
.ks-stepper-dot-action-danger { background: var(--red); animation: ksPulseRed 1.8s infinite; }
.ks-stepper-row-action {
    width: 100%; text-align: left; background: none; border: none; padding: 0;
    cursor: pointer; font-family: inherit;
}
.ks-stepper-row-action:disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.ks-stepper-row-action:disabled .ks-stepper-dot { animation: none; }

/* Soft color wash behind an action step's label — reinforces "this one's
   live" alongside the pulsing dot, without touching the rail/line so
   cross-row alignment in the timeline stays exact. */
.ks-stepper-label-action {
    display: inline-block; padding: 5px 11px; border-radius: 8px; margin-top: -1px;
}
.ks-stepper-label-action.primary { background: rgba(241,90,41,.1); }
.ks-stepper-label-action.danger { background: rgba(220,38,38,.1); }

.ks-tile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.ks-tile {
    background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 15px;
    text-align: left; cursor: pointer; font-family: inherit;
    display: flex; flex-direction: column; gap: 10px;
    box-shadow: 0 1px 2px rgba(15,30,61,.04); position: relative;
}
.ks-tile-icon {
    width: 40px; height: 40px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
}
/* Sheet header icon badge (e.g. the check-out confirm sheet) — same idea as
   .ks-btn svg above: icons.power/icons.clockIn are 46x46 natively, too big
   for a 44px badge, so this forces a sane inline size. */
.ks-sheet-icon-badge { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.ks-sheet-icon-badge svg { width: 22px; height: 22px; }
.ks-tile-label { font-size: 14px; font-weight: 700; color: var(--navy); }
.ks-tile-sub { font-size: 11.5px; color: var(--gray); margin-top: -4px; }
.ks-tile-badge {
    position: absolute; top: 13px; right: 13px; min-width: 20px; height: 20px; padding: 0 6px;
    background: var(--red); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px;
    display: flex; align-items: center; justify-content: center;
}

/* ─── Status pills / badges ─────────────────────────────────────────────── */

.ks-pill {
    display: inline-flex; align-items: center; gap: 9px; padding: 9px 16px; border-radius: 999px;
    font-size: 13.5px; font-weight: 700;
}
.ks-pill-dot { width: 10px; height: 10px; border-radius: 50%; }
.ks-badge {
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px;
    padding: 4px 9px; border-radius: 999px; display: inline-block;
    white-space: nowrap; flex-shrink: 0;
}
.ks-badge-green   { color: var(--green); background: #E7F6EC; }
.ks-badge-amber   { color: var(--amber); background: var(--amber-tint); }
.ks-badge-red     { color: var(--red);   background: #FCE9E9; }
.ks-badge-gray    { color: var(--gray);  background: #F1F3F7; }
.ks-badge-navy    { color: var(--navy);  background: var(--navy-tint); }
/* Solid variants — for a badge that's either not really a "status" at all
   (e.g. "Today" marking the current item) or is a status someone needs to
   register at a glance: task Completed/Pending on a worklist, a leave/HR
   request's pending/approved/rejected state, check-in status. Short-staffed
   and similar low-stakes site indicators stay on the tinted badges above —
   this isn't "every badge goes solid," it's "the ones that matter most stop
   reading as decoration," per the no-muted-colors rule in CLAUDE.md. */
.ks-badge-solid-orange { color: #fff; background: var(--orange); }
.ks-badge-solid-green  { color: #fff; background: var(--green); }
.ks-badge-solid-amber  { color: #fff; background: var(--amber); }
.ks-badge-solid-red    { color: #fff; background: var(--red); }
.ks-badge-solid-gray   { color: #fff; background: var(--gray); }
.ks-badge-solid-navy   { color: #fff; background: var(--navy); }

/* Multi-site supervisor's "current site, tap to switch" trigger row — opens
   ui.js's shared pickerSheetHtml()/bindPickerSheet() sheet. Only rendered
   when a supervisor covers more than one site (js/supervisor/home.js). */
.ks-site-switcher {
    display: flex; align-items: center; gap: 8px; width: 100%;
    height: 44px; padding: 0 14px; margin-bottom: 14px;
    background: #fff; border: 1px solid var(--border); border-radius: 12px;
    font-family: inherit; cursor: pointer;
}
.ks-site-switcher-label { flex: 1; text-align: left; font-size: 13.5px; font-weight: 700; color: var(--navy); }
.ks-site-switcher-count { font-size: 11.5px; color: var(--gray); }

/* Small icon+text context pill — e.g. "which shift does this task belong
   to" on the Tasks list/detail. Tinted, not solid: this is contextual
   info riding along with a row, not a control or the row's own status
   (which is what the solid badges above are for). */
.ks-info-chip {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
    background: var(--navy-tint); color: var(--navy);
}
.ks-info-chip svg { width: 12px; height: 12px; }

/* ─── Forms ──────────────────────────────────────────────────────────────── */

.ks-label { display: block; font-size: 12.5px; font-weight: 600; color: #374151; margin-bottom: 7px; }
.ks-input {
    width: 100%; height: 52px; border: 1px solid var(--border); border-radius: 13px;
    padding: 0 15px; font-size: 15px; color: var(--navy); background: #fff; margin-bottom: 16px;
}
.ks-textarea {
    width: 100%; height: 92px; border: 1px solid var(--border); border-radius: 13px;
    padding: 12px 14px; font-size: 14px; color: var(--navy); resize: none; margin-bottom: 16px;
}

/* Leave-type picker (js/staff/leave.js apply sheet) — a tappable icon grid
   instead of a plain <select>, since there are 8 leave types to choose among.
   Unselected tiles carry the type's own tone as an icon-chip tint (the
   existing "tint is fine as an icon wash" allowance); the selected tile goes
   solid, per this file's no-muted-colors rule — the active choice is a
   status a user should see at a glance, not something to search for. */
.ks-leave-type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 16px; }
.ks-leave-type-tile {
    display: flex; align-items: center; gap: 10px; text-align: left; font-family: inherit;
    border: 1.5px solid var(--border); border-radius: 13px; background: #fff;
    padding: 10px 12px; cursor: pointer;
}
.ks-leave-type-tile-icon {
    width: 32px; height: 32px; border-radius: 9px; flex: 0 0 auto;
    display: flex; align-items: center; justify-content: center;
    background: var(--tile-tint); color: var(--tile-color);
}
.ks-leave-type-tile-icon svg { width: 17px; height: 17px; }
.ks-leave-type-tile-label { font-size: 12.5px; font-weight: 700; color: var(--navy); }
.ks-leave-type-tile.selected { border-color: var(--tile-color); background: var(--tile-color); }
.ks-leave-type-tile.selected .ks-leave-type-tile-icon { background: rgba(255, 255, 255, .25); color: #fff; }
.ks-leave-type-tile.selected .ks-leave-type-tile-label { color: #fff; }

.ks-pw-field { position: relative; }
.ks-pw-field .ks-input { padding-right: 46px; }
.ks-pw-toggle {
    position: absolute; top: 0; right: 4px; height: 52px; width: 40px; margin-bottom: 16px;
    border: none; background: transparent; display: flex; align-items: center; justify-content: center;
    color: var(--gray); cursor: pointer;
}

/* ─── Segmented control ──────────────────────────────────────────────────── */

.ks-seg { display: flex; background: #EEF1F5; border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.ks-seg-btn {
    flex: 1; height: 38px; border: none; border-radius: 9px; font-size: 13.5px; font-weight: 600;
    cursor: pointer; background: transparent; color: var(--orange);
}
.ks-seg-btn.active { background: var(--navy); color: #fff; box-shadow: 0 1px 3px rgba(15,30,61,.25); }

/* ─── Searchable picker sheet ────────────────────────────────────────────── */

.ks-picker-search { display:flex; align-items:center; gap:9px; height:48px; border:1px solid var(--border); border-radius:12px; padding:0 14px; margin-bottom:14px; }
.ks-picker-search input { flex:1; border:none; outline:none; font-size:14.5px; font-family:inherit; background:transparent; color:var(--navy); }
.ks-picker-list { max-height:52vh; overflow-y:auto; }
.ks-picker-row { width:100%; text-align:left; background:#fff; border:1px solid var(--border); border-radius:12px; padding:13px 14px; margin-bottom:8px; display:flex; justify-content:space-between; align-items:center; cursor:pointer; font-family:inherit; }
.ks-picker-row.selected { border-color:var(--orange); background:var(--orange-tint); }
.ks-picker-row-label { font-size:14px; font-weight:600; color:var(--navy); }
.ks-picker-row-sub { font-size:12px; color:var(--gray); }
.ks-picker-empty { text-align:center; color:var(--gray); font-size:13.5px; padding:24px 0; }

/* ─── Progress stepper ───────────────────────────────────────────────────── */

.ks-stepper { margin-bottom: 16px; }
.ks-stepper-row { display: flex; gap: 13px; }
.ks-stepper-row:last-child .ks-stepper-body { padding-bottom: 0; }
.ks-stepper-rail { display: flex; flex-direction: column; align-items: center; flex: 0 0 auto; }
.ks-stepper-dot {
    width: 24px; height: 24px; border-radius: 50%; flex: 0 0 auto;
    display: flex; align-items: center; justify-content: center;
    font-size: 0; color: #fff; box-sizing: border-box;
}
.ks-stepper-dot-done     { background: var(--green); }
.ks-stepper-dot-active   { background: #fff; border: 2.5px solid var(--orange); }
.ks-stepper-dot-rejected { background: var(--red); }
.ks-stepper-dot-pending  { background: #fff; border: 2px solid var(--border); }
.ks-stepper-dot svg { width: 13px; height: 13px; }
.ks-stepper-line { width: 2px; flex: 1 1 auto; min-height: 22px; background: var(--border); margin: 2px 0; }
.ks-stepper-line-done { background: var(--green); }
.ks-stepper-body { padding-bottom: 20px; padding-top: 1px; }
.ks-stepper-label { font-size: 13.5px; font-weight: 700; color: var(--navy); }
.ks-stepper-sublabel { font-size: 12px; color: var(--gray); margin-top: 2px; }
/* .ks-stepper's default label colors assume a white card — unreadable
   dropped straight onto a dark hero (supervisor's own check-in panel).
   Not touching the shared component itself; the dark context opts in. */
.ks-stepper-on-dark .ks-stepper-label { color: #fff; }
.ks-stepper-on-dark .ks-stepper-sublabel { color: #cfdaf0; }

/* ─── Wizard steps (multi-step input forms) ──────────────────────────────── */

.ks-wizard-steps { display: flex; align-items: flex-start; margin-bottom: 22px; }
.ks-wizard-step { display: flex; flex-direction: column; align-items: center; gap: 5px; flex: 0 0 auto; width: 64px; }
.ks-wizard-step-dot {
    width: 26px; height: 26px; border-radius: 50%; flex: 0 0 auto;
    background: #fff; border: 2px solid var(--border); color: var(--gray);
    font-size: 12px; font-weight: 700; box-sizing: border-box;
    display: flex; align-items: center; justify-content: center;
}
.ks-wizard-step.active .ks-wizard-step-dot { border-color: var(--navy); background: var(--navy); color: #fff; }
.ks-wizard-step.done .ks-wizard-step-dot { border-color: var(--green); background: var(--green); }
.ks-wizard-step.done .ks-wizard-step-dot svg { width: 12px; height: 12px; }
.ks-wizard-step-label { font-size: 10.5px; color: var(--gray); font-weight: 600; text-align: center; }
.ks-wizard-step.active .ks-wizard-step-label { color: var(--navy); }
.ks-wizard-step.done .ks-wizard-step-label { color: var(--green); }
.ks-wizard-step-line { flex: 1 1 auto; height: 2px; background: var(--border); margin-top: 12px; }

/* ─── Centered error/permission-denied page ──────────────────────────────── */

.ks-error-page { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 56px 24px 24px; }
.ks-error-page-icon { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 18px; }
.ks-error-page-icon svg { width: 28px; height: 28px; }
.ks-error-page-title { font-size: 17px; font-weight: 800; color: var(--navy); margin-bottom: 6px; }
.ks-error-page-message { margin: 0; font-size: 13.5px; color: var(--gray); line-height: 1.5; max-width: 280px; }

/* ─── My Shifts month calendar ────────────────────────────────────────────── */

.ks-cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 10.5px; font-weight: 700; color: var(--gray); text-transform: uppercase; letter-spacing: .3px; margin-bottom: 8px; }
.ks-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.ks-cal-day {
    aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    border-radius: 10px; font-size: 13px; font-weight: 600; color: var(--navy); position: relative;
    background: transparent; border: none; padding: 0; font-family: inherit;
}
.ks-cal-day.empty { visibility: hidden; pointer-events: none; }
.ks-cal-day.has-record { cursor: pointer; background: var(--orange-tint); }
.ks-cal-day.has-record:active { background: #F8CDBB; }
.ks-cal-day.today { box-shadow: inset 0 0 0 1.5px var(--orange); }
.ks-cal-dots { display: flex; align-items: center; gap: 3px; margin-top: 3px; }
.ks-cal-dot { width: 6px; height: 6px; border-radius: 50%; }
.ks-cal-dot.present { background: var(--green); }
.ks-cal-dot.late, .ks-cal-dot.half_day { background: var(--amber); }
.ks-cal-dot.absent { background: var(--red); }
.ks-cal-dot-more { font-size: 8px; font-weight: 700; color: var(--gray); line-height: 1; }
.ks-cal-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.ks-cal-legend-item { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--gray); }

/* ─── Bottom sheet / toast ───────────────────────────────────────────────── */

.ks-sheet-backdrop {
    position: fixed; inset: 0; background: rgba(13,44,97,.45); z-index: 90;
    display: flex; align-items: flex-end; justify-content: center;
}
.ks-sheet {
    width: 100%; max-width: 480px; background: #fff; border-radius: 22px 22px 0 0;
    padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
    animation: ksSheetIn .25s ease; max-height: 85vh; overflow-y: auto;
}
.ks-toast {
    position: fixed; top: 16px; left: 16px; max-width: calc(100% - 32px);
    background: var(--navy); color: #fff; padding: 12px 20px; border-radius: 12px;
    font-size: 13.5px; font-weight: 600; z-index: 100; animation: ksToastIn .25s ease;
    display: flex; align-items: center; gap: 8px; box-shadow: 0 10px 24px -8px rgba(0,0,0,.4);
}
.ks-toast.success .ks-toast-dot { background: var(--green); }
.ks-toast.warning .ks-toast-dot { background: var(--amber); }
.ks-toast.error   .ks-toast-dot { background: var(--red); }
.ks-toast-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); }

/* ─── In-app file preview overlay ────────────────────────────────────────── */

.ks-file-preview-overlay {
    position: fixed; inset: 0; z-index: 110; background: var(--navy);
    display: flex; flex-direction: column;
}
.ks-file-preview-bar {
    flex: 0 0 auto; display: flex; justify-content: flex-end; gap: 8px;
    padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
}
.ks-file-preview-close, .ks-file-preview-download {
    width: 38px; height: 38px; border-radius: 10px; border: none;
    background: rgba(255,255,255,.15); color: #fff;
    display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.ks-file-preview-frame {
    flex: 1 1 auto; width: 100%; border: none; background: #fff;
}

/* ─── Splash ─────────────────────────────────────────────────────────────── */

.ks-splash {
    position: fixed; inset: 0;
    background: linear-gradient(165deg, var(--navy) 0%, #123058 55%, var(--navy-deep) 100%);
    overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; padding: 40px; animation: ksFade .4s ease;
}
.ks-splash::before {
    content: '';
    position: absolute; left: -8%; bottom: -6%; width: 130%; height: 62%;
    background: linear-gradient(115deg, var(--orange) 0%, #e04d1e 60%, #c8410f 100%);
    clip-path: polygon(0 100%, 100% 100%, 100% 40%);
    opacity: .95;
}
.ks-splash-logo { position: relative; border-radius: 22px; box-shadow: 0 18px 40px -10px rgba(0,0,0,.55); background: #fff; padding: 10px; }
.ks-splash-title { position: relative; margin-top: 26px; font-size: 40px; font-weight: 800; font-family: var(--font-display); color: #fff; letter-spacing: 4px; }
.ks-splash-sub { position: relative; margin-top: 6px; font-size: 14px; font-weight: 600; color: #cfdaf0; letter-spacing: 2.5px; text-transform: uppercase; }

/* ─── Pre-login walkthrough (3 slides between splash and login) ─────────── */

.ks-walkthrough { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--navy-deep); animation: ksFade .3s ease; }
.ks-walkthrough-image {
    flex: 1 1 58%; min-height: 0; position: relative;
    background-size: cover; background-position: center top;
}
.ks-walkthrough-image::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(to bottom, rgba(8,27,64,0) 55%, var(--navy-deep) 100%);
}
.ks-walkthrough-skip {
    position: absolute; top: 20px; right: 20px; z-index: 2;
    background: rgba(0,0,0,.35); color: #fff; border: none; border-radius: 999px;
    padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.ks-walkthrough-content { flex: 0 0 auto; padding: 20px 26px 34px; text-align: center; }
.ks-walkthrough-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 20px; }
.ks-walkthrough-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.25); transition: all .2s ease; }
.ks-walkthrough-dot.active { background: var(--orange); width: 22px; border-radius: 4px; }
.ks-walkthrough-title { font-family: var(--font-display); font-size: 23px; font-weight: 800; color: #fff; margin-bottom: 10px; letter-spacing: -.3px; }
.ks-walkthrough-text { font-size: 14px; color: #b9c5df; line-height: 1.5; margin: 0 0 26px; }

/* ─── Success confirmation ───────────────────────────────────────────────── */

.ks-success {
    position: fixed; inset: 0; z-index: 150; background: #fff;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; padding: 40px; animation: ksFade .3s ease;
}
.ks-success-badge { margin-bottom: 24px; }
.ks-success-image { width: 180px; height: 180px; object-fit: contain; animation: ksSuccessPop .45s cubic-bezier(0.34,1.56,0.64,1); }
.ks-success-svg { animation: ksSuccessPop .45s cubic-bezier(0.34,1.56,0.64,1); }
.ks-success-circle { stroke-dasharray: 226; stroke-dashoffset: 226; animation: ksSuccessDraw .5s ease-out .1s forwards; }
.ks-success-check { stroke-dasharray: 48; stroke-dashoffset: 48; animation: ksSuccessDraw .3s ease-out .55s forwards; }
.ks-success-title { font-size: 22px; font-weight: 800; font-family: var(--font-display); color: var(--navy); margin-bottom: 8px; }
.ks-success-subtitle { font-size: 14px; color: var(--gray); margin-bottom: 36px; max-width: 320px; line-height: 1.5; }

@keyframes ksSuccessPop { from { transform: scale(0); } 60% { transform: scale(1.08); } to { transform: scale(1); } }
@keyframes ksSuccessDraw { to { stroke-dashoffset: 0; } }

/* ─── Install-app prompt ─────────────────────────────────────────────────── */

.pwa-modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 200; display: flex; align-items: flex-end; backdrop-filter: blur(4px); }
.pwa-modal { background: #fff; border-radius: 24px 24px 0 0; width: 100%; padding: 8px 24px 40px; animation: ksSheetIn 0.3s cubic-bezier(0.34,1.2,0.64,1); }
.pwa-modal-handle { width: 40px; height: 4px; background: var(--border); border-radius: 99px; margin: 12px auto 20px; }
.pwa-modal-icon { width: 72px; height: 72px; border-radius: 18px; background: var(--navy); display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.pwa-modal-icon img { width: 48px; height: auto; }
.pwa-modal h2 { font-size: 22px; font-weight: 800; font-family: var(--font-display); text-align: center; margin-bottom: 6px; color: var(--navy); }
.pwa-modal p { font-size: 14px; color: var(--gray); text-align: center; margin-bottom: 24px; line-height: 1.5; }
.pwa-steps { display: flex; flex-direction: column; gap: 12px; margin-bottom: 28px; }
.pwa-step { display: flex; align-items: center; gap: 14px; background: var(--bg); border-radius: 12px; padding: 12px 14px; }
.pwa-step-num { width: 28px; height: 28px; border-radius: 50%; background: var(--navy); color: #fff; font-size: 13px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.pwa-step-text { font-size: 14px; font-weight: 500; color: var(--navy); }
.pwa-step-text strong { font-weight: 700; }
.btn-pwa-install { width: 100%; padding: 16px; background: linear-gradient(135deg, var(--navy), var(--navy-deep)); color: #fff; border: none; border-radius: 14px; font-size: 16px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; font-family: inherit; }
.btn-pwa-dismiss { width: 100%; padding: 12px; margin-top: 10px; background: none; border: none; color: var(--gray); font-size: 15px; cursor: pointer; font-family: inherit; }
