: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 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 {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.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;
}
.app-bar-avatar {
    width: 34px; height: 34px; border-radius: 50%; background: var(--orange); color: #fff;
    font-size: 13px; font-weight: 700; font-family: var(--font-display);
    display: flex; align-items: center; justify-content: center;
    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;
}
.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-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;
}
.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;
}
.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; }

/* ─── 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;
}

/* ─── 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(--gray);
}
.ks-seg-btn.active { background: #fff; color: var(--navy); box-shadow: 0 1px 3px rgba(15,30,61,.15); }

/* ─── 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); }

/* ─── 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; }

/* ─── 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; }
