:root {
    --primary: #2563eb;
    --primary-light: rgba(37,99,235,0.08);
    --primary-lighter: rgba(37,99,235,0.15);
    --text: #1e293b;
    --text-secondary: #64748b;
    --bg: #f1f5f9;
    --card: #ffffff;
    --border: #e2e8f0;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-light: rgba(239,68,68,0.1);
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --topbar-h: 56px;
    --bottomnav-h: 64px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}
*{margin:0;padding:0;box-sizing:border-box;}
body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif;background:var(--bg);color:var(--text);line-height:1.5;-webkit-font-smoothing:antialiased;overflow:hidden;height:100dvh;}

/* ===== LOGIN ===== */
.login-screen{display:flex;justify-content:center;align-items:center;min-height:100dvh;background:linear-gradient(160deg,var(--primary),#1e40af);padding:1.5rem;}
.login-box{background:var(--card);padding:2.5rem 2rem;border-radius:20px;width:100%;max-width:380px;box-shadow:0 20px 60px rgba(0,0,0,0.2);}
.login-icon{width:64px;height:64px;margin:0 auto 1.25rem;background:var(--primary-light);border-radius:16px;display:flex;align-items:center;justify-content:center;}
.login-icon svg{width:32px;height:32px;stroke:var(--primary);}
.login-box h1{text-align:center;font-size:1.5rem;font-weight:700;color:var(--text);margin-bottom:0.25rem;}
.login-sub{text-align:center;color:var(--text-secondary);margin-bottom:1.5rem;font-size:0.9rem;}
.login-box form{display:flex;flex-direction:column;gap:0.75rem;}
.input-icon{position:relative;}
.input-icon svg{position:absolute;left:14px;top:50%;transform:translateY(-50%);width:18px;height:18px;stroke:var(--text-secondary);pointer-events:none;}
.input-icon input{width:100%;padding:0.85rem 0.85rem 0.85rem 44px;border:1.5px solid var(--border);border-radius:10px;font-size:1rem;background:var(--bg);color:var(--text);transition:border-color 0.2s;}
.input-icon input:focus{outline:none;border-color:var(--primary);background:var(--card);}
.btn-login{width:100%;padding:0.9rem;border:none;border-radius:10px;background:var(--primary);color:#fff;font-size:1rem;font-weight:600;cursor:pointer;margin-top:0.5rem;transition:opacity 0.2s;}
.btn-login:active{opacity:0.85;}
.login-error{color:var(--danger);font-size:0.85rem;text-align:center;display:none;}
.login-error.show{display:block;}

/* ===== APP SHELL ===== */
.app{display:flex;flex-direction:column;height:100dvh;max-width:600px;margin:0 auto;background:var(--bg);position:relative;overflow:hidden;}
.topbar{height:var(--topbar-h);padding-top:var(--safe-top);background:var(--card);border-bottom:1px solid var(--border);display:flex;align-items:center;padding-left:0.5rem;padding-right:1rem;gap:0.5rem;flex-shrink:0;z-index:10;}
.topbar-btn{width:40px;height:40px;border:none;background:none;cursor:pointer;display:flex;align-items:center;justify-content:center;border-radius:10px;transition:background 0.15s;flex-shrink:0;}
.topbar-btn svg{width:22px;height:22px;stroke:var(--text);}
.topbar-btn:active{background:var(--primary-light);}
.topbar-title{flex:1;font-size:1.1rem;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.topbar-user{font-size:0.8rem;color:var(--text-secondary);white-space:nowrap;}

/* ===== MAIN CONTENT ===== */
.main{flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch;padding:1rem;padding-bottom:calc(var(--bottomnav-h) + var(--safe-bottom) + 1rem);}

/* ===== VIEWS & TRANSITIONS ===== */
.view{display:none;animation:fadeUp 0.25s ease;}
.view.active{display:block;}
@keyframes fadeUp{from{opacity:0;transform:translateY(12px);}to{opacity:1;transform:translateY(0);}}

/* ===== SEARCH BAR ===== */
.searchbar{position:relative;margin-bottom:1rem;}
.searchbar svg{position:absolute;left:14px;top:50%;transform:translateY(-50%);width:18px;height:18px;stroke:var(--text-secondary);pointer-events:none;}
.searchbar input{width:100%;padding:0.8rem 0.8rem 0.8rem 42px;border:1.5px solid var(--border);border-radius:10px;font-size:0.95rem;background:var(--card);color:var(--text);transition:border-color 0.2s,box-shadow 0.2s;}
.searchbar input:focus{outline:none;border-color:var(--primary);box-shadow:0 0 0 3px rgba(37,99,235,0.1);}

.subtitle{color:var(--text-secondary);font-size:0.85rem;margin-bottom:0.75rem;}

/* ===== CARD LIST ===== */
.list{display:flex;flex-direction:column;gap:0.5rem;}
.list-card{background:var(--card);border:1px solid var(--border);border-radius:var(--radius);padding:0.9rem 1rem;display:flex;align-items:center;gap:0.75rem;cursor:pointer;transition:box-shadow 0.15s,transform 0.15s;-webkit-tap-highlight-color:transparent;}
.list-card:active{transform:scale(0.985);box-shadow:var(--shadow-md);}
.list-card .lc-icon{width:40px;height:40px;border-radius:10px;background:var(--primary-light);display:flex;align-items:center;justify-content:center;flex-shrink:0;}
.list-card .lc-icon svg{width:20px;height:20px;stroke:var(--primary);}
.list-card .lc-body{flex:1;min-width:0;}
.list-card .lc-title{font-weight:600;font-size:0.95rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.list-card .lc-sub{font-size:0.8rem;color:var(--text-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.list-card .lc-chevron{flex-shrink:0;}
.list-card .lc-chevron svg{width:18px;height:18px;stroke:var(--text-secondary);}

/* List card with actions */
.list-card .lc-actions{display:flex;gap:0.35rem;flex-shrink:0;}

/* ===== ACTION BUTTONS (Edit/Delete) ===== */
.btn-icon{width:38px;height:38px;border:none;border-radius:10px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;transition:background 0.15s;-webkit-tap-highlight-color:transparent;}
.btn-icon svg{width:17px;height:17px;}
.btn-icon.edit{background:var(--primary-lighter);color:var(--primary);}
.btn-icon.edit svg{stroke:var(--primary);}
.btn-icon.edit:active{background:rgba(37,99,235,0.25);}
.btn-icon.del{background:var(--danger-light);color:var(--danger);}
.btn-icon.del svg{stroke:var(--danger);}
.btn-icon.del:active{background:rgba(239,68,68,0.2);}

/* ===== HISTORY ROW (kompakt) ===== */
.history-row{background:var(--card);border:1px solid var(--border);border-radius:var(--radius);padding:0.65rem 0.75rem;display:flex;align-items:center;gap:0.6rem;}
.hr-left{display:flex;flex-direction:column;align-items:flex-start;gap:0.2rem;flex-shrink:0;min-width:80px;}
.hr-date{font-size:0.78rem;font-weight:600;color:var(--text-secondary);}
.hr-center{flex:1;min-width:0;display:flex;flex-direction:column;gap:0.1rem;}
.hr-liter{font-weight:700;font-size:1rem;}
.hr-note{font-size:0.75rem;color:var(--text-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-style:italic;}
.hr-actions{display:flex;gap:0.25rem;flex-shrink:0;}

/* Status badges */
.badge{display:inline-block;padding:0.2rem 0.6rem;border-radius:20px;font-size:0.78rem;font-weight:600;}
.badge-ok{background:#d1fae5;color:#065f46;}
.badge-wartung{background:#fef3c7;color:#92400e;}
.badge-storung{background:#fee2e2;color:#991b1b;}
.badge-defekt{background:#fecaca;color:#7f1d1d;}

/* ===== FAB ===== */
.fab{position:fixed;bottom:calc(var(--bottomnav-h) + var(--safe-bottom) + 1rem);right:max(1rem,calc((100vw - 600px)/2 + 1rem));width:56px;height:56px;border-radius:16px;background:var(--primary);color:#fff;border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:0 4px 16px rgba(37,99,235,0.4);transition:transform 0.15s;z-index:5;-webkit-tap-highlight-color:transparent;}
.fab svg{width:26px;height:26px;stroke:#fff;}
.fab:active{transform:scale(0.9);}

/* ===== FORMS / CARD ===== */
.card{background:var(--card);border:1px solid var(--border);border-radius:var(--radius);padding:1rem;}
.form-card{margin-bottom:1rem;}
.form-card form{display:flex;flex-direction:column;gap:0.6rem;}
.form-card label{font-size:0.8rem;font-weight:600;color:var(--text-secondary);text-transform:uppercase;letter-spacing:0.03em;}
.form-card input,.form-card select,.form-card textarea{width:100%;padding:0.75rem;border:1.5px solid var(--border);border-radius:10px;font-size:0.95rem;font-family:inherit;color:var(--text);background:var(--bg);transition:border-color 0.2s;}
.form-card input:focus,.form-card select:focus,.form-card textarea:focus{outline:none;border-color:var(--primary);background:var(--card);}
.form-row-inline{display:flex;gap:0.5rem;align-items:flex-end;}
.form-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:0.75rem;}
.form-head h3{margin:0;font-size:1rem;font-weight:600;}
.close-btn{width:32px;height:32px;border:none;background:var(--bg);border-radius:8px;cursor:pointer;display:flex;align-items:center;justify-content:center;}
.close-btn svg{width:18px;height:18px;stroke:var(--text-secondary);}
.form-btns{display:flex;gap:0.5rem;margin-top:0.5rem;}
.btn-primary{flex:1;padding:0.75rem;border:none;border-radius:10px;background:var(--primary);color:#fff;font-size:0.95rem;font-weight:600;cursor:pointer;transition:opacity 0.15s;}
.btn-primary:active{opacity:0.85;}
.btn-flat{flex:1;padding:0.75rem;border:1.5px solid var(--border);border-radius:10px;background:var(--card);color:var(--text-secondary);font-size:0.95rem;font-weight:500;cursor:pointer;}

/* ===== MENU GRID ===== */
.menu-grid{display:grid;grid-template-columns:1fr 1fr;gap:0.75rem;}
.menu-card{background:var(--card);border:1.5px solid var(--border);border-radius:16px;padding:1.5rem 1rem;text-align:center;cursor:pointer;transition:border-color 0.2s,box-shadow 0.2s;display:flex;flex-direction:column;align-items:center;gap:0.5rem;-webkit-tap-highlight-color:transparent;}
.menu-card:active{border-color:var(--primary);box-shadow:0 4px 12px rgba(37,99,235,0.12);}
.menu-card svg{width:36px;height:36px;stroke:var(--primary);}
.menu-card h3{font-size:0.95rem;color:var(--text);margin:0;}
.menu-card p{font-size:0.78rem;color:var(--text-secondary);margin:0;}

/* ===== BOTTOM NAV ===== */
.bottomnav{height:var(--bottomnav-h);padding-bottom:var(--safe-bottom);background:var(--card);border-top:1px solid var(--border);display:flex;justify-content:space-around;align-items:center;flex-shrink:0;z-index:10;}
.nav-tab{display:flex;flex-direction:column;align-items:center;gap:2px;border:none;background:none;cursor:pointer;padding:0.4rem 0.75rem;border-radius:10px;transition:color 0.15s;-webkit-tap-highlight-color:transparent;color:var(--text-secondary);min-width:0;}
.nav-tab svg{width:22px;height:22px;stroke:currentColor;transition:stroke 0.15s;}
.nav-tab span{font-size:0.65rem;font-weight:500;letter-spacing:0.01em;}
.nav-tab.active{color:var(--primary);}
.nav-tab:active{background:var(--primary-light);}

/* ===== EMPTY STATE ===== */
.empty{text-align:center;padding:3rem 1rem;color:var(--text-secondary);}
.empty svg{width:48px;height:48px;stroke:var(--border);margin-bottom:0.75rem;}
.empty p{font-size:0.9rem;}

/* ===== GROUP LABEL ===== */
.group-label{font-size:0.75rem;font-weight:700;color:var(--text-secondary);text-transform:uppercase;letter-spacing:0.05em;padding:0.75rem 0 0.25rem 0.25rem;margin-top:0.5rem;}
.group-label:first-child{margin-top:0;}

/* ===== TYP SELECT LIST ===== */
.typ-select-list{max-height:200px;overflow-y:auto;border:1.5px solid var(--border);border-radius:10px;background:var(--bg);}
.typ-item{display:flex;align-items:center;justify-content:space-between;padding:0.6rem 0.75rem;border-bottom:1px solid var(--border);cursor:pointer;transition:background 0.12s;-webkit-tap-highlight-color:transparent;}
.typ-item:last-child{border-bottom:none;}
.typ-item:active{background:var(--primary-light);}
.typ-info{display:flex;flex-direction:column;min-width:0;}
.typ-name{font-weight:600;font-size:0.9rem;}
.typ-kat{font-size:0.75rem;color:var(--text-secondary);}
.typ-add{width:32px;height:32px;border-radius:8px;background:rgba(16,185,129,0.12);display:flex;align-items:center;justify-content:center;flex-shrink:0;}
.typ-add svg{width:16px;height:16px;stroke:var(--success);}

/* ===== LOCK HINT ===== */
.lock-hint{width:38px;height:38px;display:flex;align-items:center;justify-content:center;opacity:0.3;}

/* ===== RESPONSIVE ===== */
@media(min-width:601px){
    .app{border-left:1px solid var(--border);border-right:1px solid var(--border);}
    .menu-grid{grid-template-columns:1fr 1fr 1fr;}
}
