/* ── Reset & Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { height: 100%; background: #f2f2f7; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; max-width: 393px; margin: 0 auto; }

/* ── Screen ───────────────────────────────────────────────────────── */
.ilm-screen { display: flex; flex-direction: column; min-height: 100dvh; background: #f2f2f7; }

/* ── App-Bar (global, oben) ───────────────────────────────────────── */
.ilm-appbar {
    background: #3A6080; color: #fff;
    padding: 10px 14px;
    padding-top: max(10px, env(safe-area-inset-top));
    display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 20;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.ilm-appbar-logo {
    width: 40px; height: 40px; flex-shrink: 0;
    background: #0C2D4A; color: #fff;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 800; letter-spacing: 0.5px;
}
.ilm-appbar-title { font-size: 15px; font-weight: 700; line-height: 1.2; }
.ilm-appbar-user  { font-size: 12px; opacity: 0.8; margin-top: 1px; }

/* ── Header ───────────────────────────────────────────────────────── */
.ilm-header {
    background: #185FA5; color: #fff;
    padding: 12px 16px;
    padding-top: max(16px, env(safe-area-inset-top));
    display: flex; align-items: center; gap: 10px;
    position: sticky; top: 0; z-index: 10;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    min-height: 56px;
}
.ilm-header-title { flex: 1; font-size: 18px; font-weight: 600; }
.ilm-header-user  { font-size: 13px; opacity: 0.85; }
.ilm-header-btn   { background: rgba(255,255,255,0.2); border: none; color: #fff; padding: 7px 12px; border-radius: 8px; font-size: 14px; cursor: pointer; min-height: 36px; }
.ilm-back         { background: none; border: none; color: #fff; font-size: 26px; cursor: pointer; padding: 0 8px 0 0; line-height: 1; min-width: 36px; }

/* ── Login ────────────────────────────────────────────────────────── */
.ilm-login-wrap {
    min-height: 100dvh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(160deg, #0C447C 0%, #185FA5 50%, #2E86DE 100%);
    padding: 24px 20px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
}
.ilm-login-card {
    background: #fff; border-radius: 24px;
    padding: 36px 28px;
    width: 100%; max-width: 353px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.25);
}
.ilm-login-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.ilm-logo-icon  {
    width: 52px; height: 52px; background: #185FA5; color: #fff;
    border-radius: 0; display: flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 700;
}
.ilm-logo-text  { font-size: 24px; font-weight: 700; color: #185FA5; }
.ilm-version    { font-size: 12px; color: #999; margin-bottom: 28px; }

.ilm-pin-display { display: flex; gap: 20px; justify-content: center; margin-bottom: 28px; }
.ilm-pin-dot {
    width: 20px; height: 20px; border-radius: 50%;
    border: 2.5px solid #185FA5; background: transparent;
    transition: background 0.15s;
}
.ilm-pin-dot.filled { background: #185FA5; }

.ilm-numpad {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
    margin-bottom: 24px;
}
.ilm-key {
    padding: 0; height: 68px; font-size: 26px; font-weight: 500;
    background: #f5f5f7; border: none; border-radius: 14px;
    cursor: pointer; transition: background 0.1s, transform 0.1s;
    color: #1a1a1a; display: flex; align-items: center; justify-content: center;
}
.ilm-key:active { background: #e0e0e5; transform: scale(0.95); }
.ilm-key-ok     { background: #185FA5; color: #fff; }
.ilm-key-ok:active { background: #0C447C; }
.ilm-key-del    { background: #f5f5f7; color: #666; }
.ilm-key:disabled { opacity: 0.5; cursor: default; }

.ilm-scan-hint  { text-align: center; }
.ilm-scan-btn   { background: none; border: 1.5px solid #185FA5; color: #185FA5; padding: 10px 24px; border-radius: 24px; font-size: 15px; cursor: pointer; min-height: 44px; }
.ilm-error      { background: #FDECEA; color: #A32D2D; border-radius: 10px; padding: 12px 16px; font-size: 14px; margin-bottom: 16px; text-align: center; }
.ilm-loading    { text-align: center; font-size: 14px; color: #888; margin-top: 12px; }

/* ── Hauptmenü ────────────────────────────────────────────────────── */
.ilm-menu-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 14px; padding: 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.ilm-menu-btn {
    background: #fff; border: 0.5px solid #e0e0e0; border-radius: 16px;
    padding: 22px 12px; display: flex; flex-direction: column; align-items: center; gap: 10px;
    cursor: pointer; transition: background 0.1s, transform 0.1s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06); min-height: 110px;
}
.ilm-menu-btn:active { background: #f0f0f5; transform: scale(0.97); }
.ilm-menu-btn.disabled { opacity: 0.4; cursor: not-allowed; }
.ilm-menu-icon  { font-size: 36px; }
.ilm-menu-label { font-size: 14px; font-weight: 500; color: #1a1a1a; text-align: center; }
.ilm-menu-btn-logout { border-color: #FDECEA; }
.ilm-menu-btn-logout .ilm-menu-label { color: #A32D2D; }

/* ── Listen ───────────────────────────────────────────────────────── */
.ilm-list { flex: 1; overflow-y: auto; padding: 8px 0; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.ilm-list-item {
    background: #fff; margin: 0 14px 10px; border-radius: 12px;
    padding: 14px 16px; cursor: pointer; border: 0.5px solid #e8e8e8;
    transition: background 0.1s; min-height: 60px;
}
.ilm-list-item:active { background: #f5f5f7; }
.ilm-list-item.eigenes { border-left: 3px solid #185FA5; }
.ilm-list-main { display: flex; gap: 10px; align-items: baseline; margin-bottom: 5px; }
.ilm-list-nr   { font-weight: 600; font-size: 14px; color: #185FA5; flex-shrink: 0; }
.ilm-list-bez  { font-size: 15px; color: #1a1a1a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ilm-list-sub  { display: flex; justify-content: space-between; font-size: 12px; color: #888; }
.ilm-empty     { text-align: center; color: #aaa; padding: 48px 24px; font-size: 15px; }
.ilm-loading-bar { background: #E6F1FB; color: #185FA5; padding: 10px 16px; font-size: 14px; text-align: center; }
.ilm-result-count { font-size: 13px; color: #888; padding: 8px 16px 0; }

/* ── Scan Area ────────────────────────────────────────────────────── */
.ilm-scan-area  { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.ilm-scan-field { display: flex; gap: 10px; }
.ilm-scan-input { flex: 1; }
.ilm-scan-cam-btn {
    background: #185FA5; border: none; color: #fff; padding: 0 16px;
    border-radius: 12px; font-size: 22px; cursor: pointer; min-width: 52px;
}

/* ── Inputs & Buttons ─────────────────────────────────────────────── */
.ilm-input {
    width: 100%; padding: 13px 16px; border: 1px solid #ddd; border-radius: 12px;
    font-size: 16px; outline: none; background: #fff; min-height: 48px;
}
.ilm-input:focus { border-color: #185FA5; box-shadow: 0 0 0 3px rgba(24,95,165,0.1); }
.ilm-btn {
    padding: 13px 20px; border: 1px solid #ddd; border-radius: 12px;
    background: #fff; font-size: 15px; font-weight: 500; cursor: pointer;
    min-height: 48px;
}
.ilm-btn-primary  { background: #185FA5; color: #fff; border-color: #185FA5; }
.ilm-btn-primary:active { background: #0C447C; }
.ilm-btn-danger   { background: #A32D2D; color: #fff; border-color: #A32D2D; }
.ilm-btn-success  { background: #2E7D32; color: #fff; border-color: #2E7D32; }
.ilm-btn-success:active { background: #1B5E20; }

/* ── Lagerauskunft ────────────────────────────────────────────────── */
.ilm-lager-item {
    background: #fff; margin: 0 14px 10px; border-radius: 12px;
    padding: 14px 16px; border: 0.5px solid #e8e8e8;
}
.ilm-lager-produkt { font-size: 15px; font-weight: 600; color: #1a1a1a; margin-bottom: 8px; }
.ilm-lager-details { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.ilm-lager-lagerort { font-size: 13px; color: #666; }
.ilm-lager-bestand  { font-size: 18px; font-weight: 700; color: #185FA5; }
.ilm-lager-bestand.leer { color: #A32D2D; }
.ilm-lager-extra    { font-size: 12px; color: #888; margin-top: 3px; }
.ilm-lager-extra.abgelaufen { color: #A32D2D; font-weight: 500; }

/* ── Info ─────────────────────────────────────────────────────────── */
.ilm-info-card  { background: #fff; margin: 16px; border-radius: 14px; overflow: hidden; border: 0.5px solid #e0e0e0; }
.ilm-info-row   { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 0.5px solid #f0f0f0; min-height: 52px; }
.ilm-info-row:last-child { border-bottom: none; }
.ilm-info-label { font-size: 14px; color: #888; }
.ilm-info-value { font-size: 14px; font-weight: 500; color: #1a1a1a; text-align: right; max-width: 60%; word-break: break-all; }

/* ── Modal ────────────────────────────────────────────────────────── */
.ilm-modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 100;
    display: flex; align-items: flex-end; justify-content: center;
}
.ilm-modal {
    background: #fff; border-radius: 24px 24px 0 0; padding: 28px 20px;
    width: 100%; max-width: 393px;
    padding-bottom: max(28px, env(safe-area-inset-bottom));
}
.ilm-modal-title   { font-size: 18px; font-weight: 600; margin-bottom: 18px; }
.ilm-modal-actions { display: flex; gap: 12px; margin-top: 18px; }
.ilm-modal-actions .ilm-btn { flex: 1; }
.ilm-form-group    { margin-bottom: 14px; }
.ilm-form-group label { font-size: 13px; color: #666; margin-bottom: 6px; display: block; font-weight: 500; }

/* ── iPhone 17 Rahmen (nur Desktop/Entwicklung) ───────────────────── */
@media (min-width: 500px) {
    html {
        background: #1a1a2e;
        min-height: 100vh;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    body {
        width: 393px;
        min-height: 852px;
        border-radius: 54px;
        overflow: hidden;
        position: relative;
        box-shadow:
            0 0 0 2px #3a3a3a,
            0 0 0 10px #1a1a1a,
            0 0 0 12px #3a3a3a,
            0 0 60px rgba(0,0,0,0.8);
        border: none;
    }
    /* Dynamic Island */
    body::before {
        content: '';
        position: fixed;
        top: 12px;
        left: 50%;
        transform: translateX(-50%);
        width: 120px;
        height: 34px;
        background: #1a1a1a;
        border-radius: 20px;
        z-index: 9999;
    }
}

/* ── Tabelle ──────────────────────────────────────────────────────── */
.ilm-we-table-wrap { flex: 1; overflow-y: auto; overflow-x: auto; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.ilm-table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: 13px; }
.ilm-table thead tr { background: #f5f5f7; position: sticky; top: 0; z-index: 1; }
.ilm-table th { padding: 10px 10px; text-align: left; font-size: 11px; font-weight: 600; color: #666; text-transform: uppercase; border-bottom: 1px solid #e0e0e0; }
.ilm-table td { padding: 12px 10px; border-bottom: 0.5px solid #f0f0f0; color: #1a1a1a; vertical-align: middle; }
.ilm-table tbody tr:active td { background: #f5f5f7; }
.ilm-table tbody tr.eigenes td { border-left: 3px solid #185FA5; }
.ilm-table tbody tr { cursor: pointer; }
.td-overflow { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Modal oben ───────────────────────────────────────────────────── */
.ilm-modal-overlay-top { align-items: flex-start; }
.ilm-modal-overlay-top .ilm-modal {
    border-radius: 0 0 24px 24px;
    padding-top: max(28px, env(safe-area-inset-top));
}

/* ── Sticky Tabellen-Header ───────────────────────────────────────── */
.ilm-table thead { position: sticky; top: 0; z-index: 2; }
.ilm-table thead tr { background: #f5f5f7; box-shadow: 0 1px 0 #e0e0e0; }

/* ── Footer ───────────────────────────────────────────────────────── */
.ilm-footer {
    display: flex; gap: 10px; padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    background: #fff; border-top: 0.5px solid #e0e0e0;
    position: sticky; bottom: 0;
}

/* ── Position Erfassen ────────────────────────────────────────────── */
.ilm-pos-wrap    { padding: 16px; display: flex; flex-direction: column; gap: 14px; flex: 1; overflow-y: auto; }
.ilm-pos-info    { font-size: 12px; color: #1a7a3a; margin-top: 5px; font-weight: 500; }
.ilm-pos-error   { font-size: 12px; color: #A32D2D; margin-top: 5px; }
.ilm-pos-error-lg { font-size: 16px; font-weight: 700; color: #A32D2D; margin-top: 6px; }
.ilm-input-err   { border-color: #A32D2D !important; }
