/* OMS mobile - styl Dauch (config/dauch ui) w formie aplikacji iOS: duze tytuly, grupowane listy, arkusze od dolu.
   Kolory marki jak webapps/inspinia/modules/gkn/dauch/style.css. Dziala tez na Androidzie (rozne szerokosci, safe-area). */
@font-face { font-family: 'Aptos'; src: url('fonts/Aptos.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Aptos'; src: url('fonts/Aptos-SemiBold.ttf') format('truetype'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Aptos'; src: url('fonts/Aptos-Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }

:root {
    --red: #E30615;
    --black: #101010;
    --navy: #00194D;
    --gold: #EEB650;
    --green: #2E9E57;
    --orange: #E08A00;

    --bg: #F4F4F5;
    --card: #FFFFFF;
    --card2: #F7F7F8;
    --text: #101010;
    --muted: #7A7A80;
    --sep: rgba(60, 60, 67, .16);
    --fill: rgba(118, 118, 128, .12);
    --bar: rgba(244, 244, 245, .82);
    --primary: #101010;
    --on-primary: #FFFFFF;
    --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 16px rgba(0, 0, 0, .05);
    --radius: 14px;
    --font: 'Aptos', -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, "Segoe UI", sans-serif;
    --st: env(safe-area-inset-top, 0px);
    --sb: env(safe-area-inset-bottom, 0px);
    --sl: env(safe-area-inset-left, 0px);
    --sr: env(safe-area-inset-right, 0px);
    color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #000000;
        --card: #1C1C1E;
        --card2: #2C2C2E;
        --text: #F5F5F7;
        --muted: #98989F;
        --sep: rgba(84, 84, 88, .55);
        --fill: rgba(118, 118, 128, .24);
        --bar: rgba(18, 18, 18, .8);
        --primary: #F5F5F7;
        --on-primary: #101010;
        --navy: #6E8DD6;
        --green: #3CC06A;
        --shadow: none;
    }
    .logo-light { display: none !important; }
}
@media (prefers-color-scheme: light) { .logo-dark { display: none !important; } }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
    font: 17px/1.35 var(--font);
    -webkit-font-smoothing: antialiased;
    -webkit-user-select: none; user-select: none;
    -webkit-touch-callout: none;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-text-size-adjust: 100%;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
input { -webkit-user-select: text; user-select: text; }
[hidden] { display: none !important; }
svg { display: block; }

/* ---------- splash ---------- */
.splash { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); z-index: 50; transition: opacity .3s; }
.splash-logo { width: 46%; max-width: 220px; animation: pulse 1.6s ease-in-out infinite; }
.splash.gone { opacity: 0; pointer-events: none; }
@keyframes pulse { 50% { opacity: .55; } }

/* ---------- ekrany (stos jak UINavigationController) ---------- */
.app { position: fixed; inset: 0; overflow: hidden; }
.screen {
    position: absolute; inset: 0; background: var(--bg);
    display: flex; flex-direction: column;
    transition: transform .38s cubic-bezier(.2, .8, .2, 1), opacity .38s;
    will-change: transform;
}
.screen.enter { transform: translateX(100%); }
.screen.behind { transform: translateX(-28%); opacity: .6; pointer-events: none; }
.screen.leave { transform: translateX(100%); }
.screen.fade-enter { opacity: 0; transform: none; }

.navbar {
    flex: none; position: relative; z-index: 3;
    padding: calc(var(--st) + 4px) calc(8px + var(--sr)) 4px calc(8px + var(--sl));
    min-height: calc(var(--st) + 48px);
    display: flex; align-items: center; gap: 6px;
    background: var(--bar);
    -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
    border-bottom: .5px solid transparent;
    transition: border-color .2s;
}
.screen.scrolled .navbar { border-bottom-color: var(--sep); }
.nav-title {
    position: absolute; left: 80px; right: 80px; bottom: 13px; text-align: center;
    font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    opacity: 0; transition: opacity .2s;
}
.screen.scrolled .nav-title, .nav-title.always { opacity: 1; }
.nav-spacer { flex: 1; }
.nav-btn {
    border: 0; background: none; color: var(--text); padding: 8px; min-width: 44px; min-height: 40px;
    display: inline-flex; align-items: center; gap: 2px; font-size: 17px; border-radius: 10px;
}
.nav-btn:active { opacity: .45; }
.nav-btn svg { width: 24px; height: 24px; }
.nav-btn.back { padding-left: 2px; }
.nav-brand { height: 20px; margin-left: 10px; }
.avatar {
    width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--black); color: #fff;
    font-weight: 700; font-size: 14px; letter-spacing: .5px; display: flex; align-items: center; justify-content: center; margin-right: 6px;
}
@media (prefers-color-scheme: dark) { .avatar { background: var(--card2); } }

.content {
    flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain;
    padding: 0 calc(16px + var(--sr)) calc(28px + var(--sb)) calc(16px + var(--sl));
}
.content.with-footer { padding-bottom: calc(110px + var(--sb)); }
.wrap { max-width: 720px; margin: 0 auto; }

.large-title { font-size: 34px; font-weight: 700; letter-spacing: -.4px; line-height: 1.12; margin: 6px 4px 4px; }
.subtitle { color: var(--muted); font-size: 15px; margin: 0 4px 14px; }
.caption { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .3px; margin: 24px 16px 7px; }
.caption-row { display: flex; align-items: baseline; justify-content: space-between; margin: 24px 4px 7px 16px; }
.caption-row .caption { margin: 0; }
.link-btn { border: 0; background: none; color: var(--navy); font-size: 15px; padding: 4px 8px; font-weight: 600; }
.link-btn:active { opacity: .5; }

/* ---------- grupowane listy ---------- */
.group { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.row {
    display: flex; align-items: center; gap: 12px; min-height: 52px;
    padding: 10px 14px 10px 16px; position: relative; width: 100%; border: 0; background: none; text-align: left;
}
.row + .row::before { content: ''; position: absolute; top: 0; right: 0; left: 16px; border-top: .5px solid var(--sep); }
.row.with-icon + .row.with-icon::before { left: 60px; }
button.row:active, .row.tap:active { background: var(--fill); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 14px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-val { color: var(--muted); font-size: 16px; white-space: nowrap; }
.chev { width: 9px; height: 15px; color: #C4C4C7; flex: none; }
@media (prefers-color-scheme: dark) { .chev { color: #5A5A5E; } }
.row-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex: none; color: #fff; }
.row-icon svg { width: 19px; height: 19px; }

/* ---------- kafle modulow ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile {
    position: relative; border: 0; text-align: left; background: var(--card); border-radius: 18px; box-shadow: var(--shadow);
    padding: 16px; min-height: 132px; display: flex; flex-direction: column; justify-content: space-between;
    transition: transform .15s;
}
.tile:active { transform: scale(.97); }
.tile-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: #fff; }
.tile-icon svg { width: 26px; height: 26px; }
.tile-title { font-weight: 700; font-size: 17px; margin-top: 14px; line-height: 1.2; }
.tile-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.tile-badge {
    position: absolute; top: 12px; right: 12px; background: var(--orange); color: #fff;
    font-size: 12px; font-weight: 700; border-radius: 10px; padding: 2px 8px;
}
.bg-q { background: var(--navy); }
.bg-y { background: var(--red); }
.bg-hist { background: #5B5B60; }
@media (prefers-color-scheme: dark) { .bg-q { background: #23408A; } }

/* ---------- karty "kontynuuj" ---------- */
.resume {
    display: flex; gap: 14px; align-items: center; width: 100%; border: 0; text-align: left;
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 14px 14px 16px; margin-bottom: 10px;
    border-left: 4px solid var(--gold);
}
.resume:active { background: var(--fill); }
.resume-main { flex: 1; min-width: 0; }
.resume-kicker { font-size: 12px; font-weight: 700; color: var(--orange); text-transform: uppercase; letter-spacing: .4px; }
.resume-title { font-weight: 600; font-size: 17px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { height: 5px; border-radius: 3px; background: var(--fill); overflow: hidden; margin-top: 9px; }
.progress > i { display: block; height: 100%; background: var(--gold); border-radius: 3px; transition: width .3s; }
.resume-meta { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* ---------- pasek statusu synchronizacji ---------- */
.banner {
    display: flex; align-items: center; gap: 10px; border-radius: 12px; padding: 10px 14px; margin: 0 0 14px;
    font-size: 15px; background: var(--card); box-shadow: var(--shadow);
}
.banner svg { width: 20px; height: 20px; flex: none; }
.banner.offline { color: var(--muted); }
.banner.pending { color: var(--orange); }
.banner.error { color: var(--red); }
.banner.ok { color: var(--green); }
.banner .grow { flex: 1; }

/* ---------- statusy ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.chip svg { width: 15px; height: 15px; }
.chip.ok { color: var(--green); }
.chip.wait { color: var(--muted); }
.chip.send { color: var(--navy); }
.chip.bad { color: var(--red); }
.chip.draft { color: var(--orange); }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- wyszukiwarka ---------- */
.search {
    display: flex; align-items: center; gap: 6px; background: var(--fill); border-radius: 11px; padding: 0 10px; height: 38px; margin: 4px 0 6px;
}
.search svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.search input { flex: 1; border: 0; background: none; outline: 0; font-size: 17px; min-width: 0; height: 100%; }
.search input::placeholder { color: var(--muted); }

/* ---------- ankieta ---------- */
.survey-head { margin: 4px 4px 16px; }
.kicker { font-size: 13px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--red); }
.saved { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); margin-top: 8px; transition: color .3s; }
.saved svg { width: 14px; height: 14px; }
.saved.flash { color: var(--green); }
.sec-title { font-size: 13px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); margin: 26px 6px 4px; }
.sec-desc { font-size: 14px; color: var(--muted); margin: 0 6px 8px; }
.q {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
    border: 2px solid transparent; transition: border-color .25s;
}
.q.need { border-color: var(--gold); animation: nudge .4s; }
@keyframes nudge { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.q-num { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .4px; }
.q-text { font-size: 17px; font-weight: 600; margin-top: 4px; line-height: 1.3; -webkit-user-select: text; user-select: text; }
.q-help { font-size: 14px; color: var(--muted); margin-top: 6px; line-height: 1.35; white-space: pre-line; }
.answers { display: flex; gap: 8px; margin-top: 14px; }
.ans {
    flex: 1; height: 46px; border-radius: 12px; border: 0; background: var(--fill); font-weight: 600; font-size: 16px;
    display: flex; align-items: center; justify-content: center; gap: 6px; transition: background .15s, color .15s, transform .1s;
}
.ans svg { width: 16px; height: 16px; display: none; }
.ans:active { transform: scale(.96); }
.ans.on svg { display: block; }
.ans.yes.on { background: var(--green); color: #fff; }
.ans.no.on { background: var(--red); color: #fff; }
.ans.na.on { background: #6B6B70; color: #fff; }
.ans:disabled { opacity: .35; }
.ans.na { flex: .7; }
.oms-note { margin-top: 12px; font-size: 14px; border-radius: 10px; padding: 10px 12px; background: var(--card2); line-height: 1.35; }
.oms-note b { font-weight: 700; }
.oms-note.warn { color: var(--red); }

.footer {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
    padding: 10px calc(16px + var(--sr)) calc(10px + var(--sb)) calc(16px + var(--sl));
    background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
    border-top: .5px solid var(--sep);
}
.footer .wrap { display: flex; flex-direction: column; gap: 6px; }
.footer-note { text-align: center; font-size: 13px; color: var(--muted); }

/* ---------- przyciski ---------- */
.btn {
    display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; height: 52px; border: 0; border-radius: 13px;
    background: var(--primary); color: var(--on-primary); font-weight: 700; font-size: 17px; letter-spacing: .2px; text-decoration: none;
    transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.98); opacity: .85; }
.btn:disabled { opacity: .3; transform: none; }
.btn svg { width: 19px; height: 19px; }
.btn.red { background: var(--red); color: #fff; }
.btn.plain { background: var(--fill); color: var(--text); }
.btn.danger-text { background: var(--card); color: var(--red); font-weight: 600; }
.btn.small { height: 40px; font-size: 15px; border-radius: 10px; }

/* ---------- logowanie ---------- */
/* logowanie zawsze jasne (jak karta logowania Dauch): czarne logo OMS i czerwone DAUCH maja kontrast tez w trybie ciemnym */
.login {
    position: absolute; inset: 0; display: flex; flex-direction: column; overflow-y: auto; color-scheme: light;
    --card: #FFFFFF; --card2: #F7F7F8; --text: #101010; --muted: #6E6E73; --sep: rgba(60, 60, 67, .2); --fill: rgba(118, 118, 128, .12);
    --primary: #101010; --on-primary: #FFFFFF; --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 16px rgba(0, 0, 0, .05);
    background: #FFFFFF; color: #101010;
}
.login .logo-light { display: block !important; }
.login .logo-dark { display: none !important; }
.login-bar { height: calc(var(--st) + 6px); background: var(--red); flex: none; }
.login-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 32px; min-height: 340px; }
.login-oms { width: 62%; max-width: 280px; }
.login-dauch { width: 44%; max-width: 190px; margin-top: 18px; }
.login-tag { margin-top: 26px; color: var(--muted); font-size: 15px; text-align: center; max-width: 280px; }
.login-actions { padding: 0 calc(28px + var(--sr)) 0 calc(28px + var(--sl)); width: 100%; max-width: 460px; margin: 0 auto; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 18px 0; }
.or::before, .or::after { content: ''; flex: 1; border-top: .5px solid var(--sep); }
.login-err { color: var(--red); text-align: center; font-size: 15px; margin-top: 14px; }
.login-foot { text-align: center; padding: 28px 16px calc(20px + var(--sb)); }
.login-foot .claim { color: var(--red); font-weight: 700; letter-spacing: 1.4px; font-size: 15px; }
.login-foot .copy { color: var(--muted); font-size: 12px; margin-top: 8px; letter-spacing: .3px; }
.ms { width: 19px; height: 19px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.ms i { display: block; }

/* ---------- arkusze (bottom sheet) ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 20; opacity: 0; transition: opacity .3s; }
.sheet-backdrop.on { opacity: 1; }
.sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 92%; overflow-y: auto;
    background: var(--bg); border-radius: 16px 16px 0 0;
    padding: 8px calc(16px + var(--sr)) calc(18px + var(--sb)) calc(16px + var(--sl));
    transform: translateY(105%); transition: transform .38s cubic-bezier(.2, .8, .2, 1);
}
.sheet.on { transform: none; }
.sheet .wrap { max-width: 560px; }
.grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--fill); margin: 0 auto 12px; }
.sheet-title { font-size: 20px; font-weight: 700; text-align: center; margin: 4px 0 6px; }
.sheet-text { font-size: 15px; color: var(--muted); text-align: center; margin: 0 8px 18px; line-height: 1.4; }
.sheet .btn + .btn { margin-top: 10px; }
.field { display: block; width: 100%; height: 50px; border-radius: 12px; border: 0; background: var(--card); padding: 0 16px; font-size: 17px; outline: 0; margin-bottom: 10px; box-shadow: var(--shadow); }
.done-icon { width: 76px; height: 76px; border-radius: 50%; background: var(--green); color: #fff; display: flex; align-items: center; justify-content: center; margin: 12px auto 14px; animation: pop .45s cubic-bezier(.2, 1.6, .4, 1); }
.done-icon svg { width: 40px; height: 40px; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }

/* ---------- puste stany, szkielety ---------- */
.empty { text-align: center; color: var(--muted); padding: 40px 24px; font-size: 15px; line-height: 1.45; }
.empty svg { width: 46px; height: 46px; margin: 0 auto 12px; opacity: .6; }
.empty b { color: var(--text); display: block; font-size: 17px; margin-bottom: 4px; }
.skel { background: linear-gradient(90deg, var(--fill) 25%, var(--card2) 50%, var(--fill) 75%); background-size: 200% 100%; animation: sh 1.3s infinite; border-radius: 18px; }
@keyframes sh { to { background-position: -200% 0; } }

/* ---------- toast ---------- */
.toast {
    position: fixed; left: 50%; bottom: calc(26px + var(--sb)); transform: translateX(-50%); z-index: 40;
    background: rgba(28, 28, 30, .92); color: #fff; padding: 11px 18px; border-radius: 22px; font-size: 15px; max-width: 88%;
    text-align: center; box-shadow: 0 6px 24px rgba(0, 0, 0, .2); animation: toastIn .3s;
}
.toast.up { bottom: calc(96px + var(--sb)); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------- instalacja na ekranie glownym ---------- */
.install { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; margin: 0 0 14px; font-size: 14px; }
.install img { width: 40px; height: 40px; border-radius: 9px; flex: none; }
.install .grow { flex: 1; color: var(--muted); }
.install b { color: var(--text); display: block; font-size: 15px; }

.version { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; background: var(--gold); color: #101010; border-radius: 6px; padding: 2px 6px; vertical-align: middle; }

@media (min-width: 700px) {
    .large-title { font-size: 38px; }
    .tiles { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
    .screen, .sheet, .tile, .btn { transition: none; }
}
