/* ==========================================================
   RSH Technik Lager System – Enterprise UI
   Dunkles Anthrazit, klare Linien, kompakte Tabellen.
   ========================================================== */

:root {
    --bg:            #14161a;
    --bg-elevated:   #1b1e24;
    --bg-card:       #1f232a;
    --bg-hover:      #262b33;
    --border:        #2c313a;
    --border-light:  #363c47;
    --text:          #e6e8eb;
    --text-dim:      #9aa1ab;
    --text-faint:    #6b7280;
    --accent:        #4f8cff;
    --accent-dim:    #2d4a80;
    --ok:            #3ecf8e;
    --ok-bg:         rgba(62,207,142,.12);
    --warn:          #e8b23e;
    --warn-bg:       rgba(232,178,62,.12);
    --danger:        #e2584f;
    --danger-bg:     rgba(226,88,79,.12);
    --info:          #4f8cff;
    --info-bg:       rgba(79,140,255,.12);
    --muted:         #8a919c;
    --muted-bg:      rgba(138,145,156,.12);
    --radius:        6px;
    --radius-lg:     10px;
    --shadow:        0 2px 10px rgba(0,0,0,.35);
    --sidebar-w:     230px;
    font-size: 15px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { font-weight: 600; letter-spacing: .01em; margin: 0 0 .6em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; font-size: .78rem; }
p { line-height: 1.55; }

/* ---------- Layout Shell ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: baseline;
    gap: .4em;
    padding: 22px 20px 18px;
    border-bottom: 1px solid var(--border);
}
.brand-mark { font-weight: 700; color: var(--accent); letter-spacing: .04em; }
.brand-name { font-weight: 600; font-size: .85rem; color: var(--text-dim); letter-spacing: .12em; }

.nav-main { flex: 1; padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius);
    color: var(--text-dim);
    font-size: .92rem;
}
.nav-item .ic { width: 1.2em; text-align: center; opacity: .85; }
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: #fff; }

.sidebar-footer { padding: 14px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 4px 12px; }
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--accent-dim); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: .85rem; flex-shrink: 0;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: .88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: .74rem; color: var(--text-faint); }
.nav-logout {
    display: block; text-align: center; font-size: .82rem; color: var(--text-faint);
    padding: 8px; border-radius: var(--radius); border: 1px solid var(--border);
}
.nav-logout:hover { color: var(--danger); border-color: var(--danger); }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: center; gap: 16px;
    padding: 14px 28px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky; top: 0; z-index: 5;
}
.search-form { flex: 0 1 420px; }
.search-form input {
    width: 100%; background: var(--bg-elevated); border: 1px solid var(--border);
    color: var(--text); padding: 8px 12px; border-radius: var(--radius); font-size: .88rem;
}
.search-form input:focus { outline: none; border-color: var(--accent); }
.topbar-spacer { flex: 1; }

.page { padding: 26px 28px 90px; max-width: 1280px; }
.bare-page { padding: 20px; max-width: 900px; margin: 0 auto; }

/* ---------- Flash ---------- */
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: .88rem; border: 1px solid; }
.flash-success { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.flash-error   { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.flash-info    { background: var(--info-bg); border-color: var(--info); color: var(--info); }

/* ---------- Cards / grids ---------- */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow);
    margin-bottom: 18px;
}
.card-flat { background: transparent; border: 1px solid var(--border); box-shadow: none; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 18px 20px;
}
.stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1; margin-bottom: 6px; }
.stat-label { font-size: .8rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 12px; gap: 10px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; border-radius: var(--radius); font-size: .88rem; font-weight: 600;
    border: 1px solid var(--border-light); background: var(--bg-elevated); color: var(--text);
    cursor: pointer;
}
.btn:hover { background: var(--bg-hover); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #3f78e0; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #c74a42; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }
.btn-sm { padding: 5px 10px; font-size: .78rem; }
.btn-lg { padding: 16px 20px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
    text-align: left; padding: 10px 14px; background: var(--bg-elevated);
    color: var(--text-dim); font-weight: 600; font-size: .74rem; text-transform: uppercase;
    letter-spacing: .05em; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }
.table-empty { padding: 26px; text-align: center; color: var(--text-faint); }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 999px; font-size: .74rem; font-weight: 600;
    border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok     { background: var(--ok-bg); color: var(--ok); }
.badge-warn   { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info   { background: var(--info-bg); color: var(--info); }
.badge-muted  { background: var(--muted-bg); color: var(--muted); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: .8rem; color: var(--text-dim); font-weight: 600; }
.field .hint { font-size: .74rem; color: var(--text-faint); }
input[type=text], input[type=search], input[type=number], input[type=date], input[type=time],
input[type=password], input[type=email], select, textarea {
    background: var(--bg-elevated); border: 1px solid var(--border-light); color: var(--text);
    padding: 9px 12px; border-radius: var(--radius); font-size: .9rem; font-family: inherit; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; margin: 0 0 16px; }
legend { padding: 0 8px; font-size: .8rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }

/* ---------- Tabs / detail nav ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tab { padding: 10px 14px; font-size: .86rem; color: var(--text-dim); border-bottom: 2px solid transparent; }
.tab.active { color: var(--text); border-color: var(--accent); }
.tab:hover { color: var(--text); }

/* ---------- Timeline / history ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: .86rem; }
.timeline li:last-child { border-bottom: none; }
.timeline .t-time { color: var(--text-faint); flex: 0 0 130px; }
.timeline .t-body strong { color: var(--text); }

/* ---------- Login screen ---------- */
.login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
    background: radial-gradient(circle at 30% 20%, #1c2028 0%, var(--bg) 60%);
}
.login-card {
    width: 100%; max-width: 360px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 36px 32px; box-shadow: var(--shadow); text-align: center;
}
.login-title { font-size: 1.1rem; font-weight: 700; letter-spacing: .1em; margin-bottom: 2px; }
.login-sub { font-size: .8rem; color: var(--text-dim); letter-spacing: .08em; margin-bottom: 26px; }
.login-card input[type=text] {
    text-align: center; font-size: 1.4rem; letter-spacing: .08em; padding: 14px; margin-bottom: 18px;
}
.login-card label { display: block; font-size: .78rem; color: var(--text-dim); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .06em; }
.login-alt { margin-top: 20px; font-size: .85rem; }
.login-alt a { color: var(--text-dim); }
.login-alt a:hover { color: var(--accent); }

/* ---------- Terminal (Lager-Tablet) ---------- */
body.terminal-mode { background: var(--bg); }
.terminal-page { min-height: 100vh; display: flex; flex-direction: column; padding: 24px; max-width: 640px; margin: 0 auto; }
.terminal-header { text-align: center; margin: 12px 0 28px; }
.terminal-header .t-brand { font-weight: 700; letter-spacing: .12em; color: var(--accent); font-size: .95rem; }
.terminal-header .t-title { font-size: 1.3rem; font-weight: 700; margin-top: 4px; }
.terminal-header .t-status { font-size: .8rem; color: var(--ok); margin-top: 6px; }
.terminal-input {
    font-size: 2rem; text-align: center; padding: 22px; letter-spacing: .06em;
    margin-bottom: 20px;
}
.terminal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 10px; }
.terminal-tile {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 32px 16px; text-align: center; font-size: 1.1rem; font-weight: 700;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.terminal-tile .t-icon { font-size: 2rem; }
.terminal-tile:active, .terminal-tile:hover { background: var(--bg-hover); border-color: var(--accent); }
.device-check {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 16px 18px; margin-bottom: 12px;
}
.device-check .d-info strong { display: block; font-size: 1rem; }
.device-check .d-info span { color: var(--text-faint); font-size: .82rem; }
.device-check.confirmed { border-color: var(--ok); background: var(--ok-bg); }
.device-check.incomplete { border-color: var(--danger); background: var(--danger-bg); }
.progress-bar { height: 8px; border-radius: 999px; background: var(--bg-elevated); overflow: hidden; margin: 16px 0; }
.progress-bar-fill { height: 100%; background: var(--ok); transition: width .2s; }

/* ---------- Bottom nav (mobile) ---------- */
.bottom-nav { display: none; }

@media (max-width: 880px) {
    .sidebar { display: none; }
    .app-shell { display: block; }
    .main-col { width: 100%; }
    .page { padding: 18px 16px 90px; }
    .topbar { padding: 12px 16px; }
    .bottom-nav {
        display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
        background: var(--bg-elevated); border-top: 1px solid var(--border);
        justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    }
    .bn-item {
        display: flex; flex-direction: column; align-items: center; gap: 2px;
        font-size: 1rem; color: var(--text-dim); padding: 6px 8px; border-radius: var(--radius);
    }
    .bn-item span { font-size: .62rem; text-transform: uppercase; letter-spacing: .04em; }
    .bn-action { background: var(--accent); color: #fff; font-weight: 700; font-size: 1.3rem; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

.muted { color: var(--text-faint); }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.small { font-size: .8rem; }
.divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-faint); }
.empty-state .es-icon { font-size: 2.2rem; margin-bottom: 10px; }

/* ---------- Kamera-Scan-Overlay ---------- */
.camera-scan-overlay {
    position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.85);
    display: flex; align-items: center; justify-content: center; padding: 20px;
}
.camera-scan-box {
    position: relative; width: 100%; max-width: 420px; background: var(--bg-elevated);
    border-radius: var(--radius-lg); overflow: hidden; padding: 16px; text-align: center;
}
.camera-scan-video { width: 100%; border-radius: var(--radius); background: #000; aspect-ratio: 4/3; object-fit: cover; }
.camera-scan-frame {
    position: absolute; top: 50px; left: 16px; right: 16px; bottom: 70px;
    border: 3px solid var(--accent); border-radius: var(--radius); pointer-events: none;
    box-shadow: 0 0 0 999px rgba(0,0,0,.25) inset;
}
.camera-scan-msg { color: var(--danger); font-size: .82rem; margin-top: 10px; min-height: 1.2em; }
.camera-scan-close { margin-top: 12px; }

/* ---------- Benachrichtigungen ---------- */
.notif-bell { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; color: var(--text-dim); }
.notif-bell:hover { background: var(--bg-hover); color: var(--text); }
.notif-badge {
    position: absolute; top: 2px; right: 2px; min-width: 15px; height: 15px; padding: 0 3px;
    background: var(--danger); color: #fff; border-radius: 999px; font-size: .62rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center; line-height: 1;
}
.notif-item { display: block; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 8px; }
.notif-item.unread { border-color: var(--accent); background: var(--info-bg); }
.notif-item .n-time { font-size: .74rem; color: var(--text-faint); }

/* ---------- Öffentliches Anfrage-Formular ---------- */
.request-page { max-width: 760px; margin: 0 auto; padding: 8px 0 70px; position: relative; isolation: isolate; }

.request-glow {
    position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden;
}
.request-glow::before, .request-glow::after {
    content: ''; position: absolute; width: 60vw; height: 60vw; max-width: 640px; max-height: 640px;
    border-radius: 50%; filter: blur(90px); opacity: .22;
}
.request-glow::before { top: -18vw; left: -14vw; background: radial-gradient(circle, #4f8cff, transparent 70%); }
.request-glow::after { top: 8vw; right: -18vw; background: radial-gradient(circle, #a855f7, transparent 70%); opacity: .16; }

.request-hero { text-align: center; padding: 48px 20px 34px; margin-bottom: 4px; }
.request-hero-icon {
    width: 68px; height: 68px; margin: 0 auto 20px;
    border-radius: 22px;
    background: linear-gradient(150deg, #6ba4ff, var(--accent) 45%, #335fc4);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 10px 30px -6px rgba(79,140,255,.55), 0 0 0 1px rgba(255,255,255,.08) inset;
}
.request-hero-icon svg { width: 30px; height: 30px; }
.request-hero h1 {
    font-size: 2.1rem; font-weight: 700; letter-spacing: -.01em; margin-bottom: .35em;
    background: linear-gradient(135deg, #fff, #aebdd6 85%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.request-hero p { color: var(--text-dim); max-width: 480px; margin: 0 auto; font-size: .98rem; line-height: 1.6; }

.request-form { display: flex; flex-direction: column; gap: 22px; }

.req-section {
    background: linear-gradient(175deg, var(--bg-card), var(--bg-elevated));
    border: 1px solid var(--border);
    border-radius: 16px; padding: 26px 28px;
    box-shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 12px 30px -16px rgba(0,0,0,.6);
    transition: border-color .2s;
}
.req-section:hover { border-color: var(--border-light); }
.req-section-head { display: flex; align-items: center; gap: 13px; margin-bottom: 20px; }
.req-section-head h2 { margin: 0; font-size: 1.1rem; letter-spacing: -.005em; }
.req-ic {
    width: 34px; height: 34px; flex: 0 0 34px; border-radius: 11px;
    background: linear-gradient(150deg, var(--accent-dim), #203153);
    border: 1px solid rgba(255,255,255,.06);
    color: #bcd2ff;
    display: flex; align-items: center; justify-content: center;
    font-size: .85rem; font-weight: 700;
}

.tech-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.tech-tile {
    position: relative;
    display: flex; flex-direction: column; gap: 12px;
    padding: 18px; border-radius: 14px; border: 1.5px solid var(--border);
    background: var(--bg-elevated); cursor: pointer;
    transition: border-color .18s, background .18s, transform .18s, box-shadow .18s;
}
.tech-tile:hover { border-color: var(--border-light); transform: translateY(-2px); }
.tech-tile input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.tech-tile-head { display: flex; align-items: center; gap: 11px; font-weight: 600; font-size: .98rem; }
.tech-tile-ic {
    width: 36px; height: 36px; flex: 0 0 36px; border-radius: 10px;
    background: var(--bg-hover); color: var(--text-dim);
    display: flex; align-items: center; justify-content: center;
    transition: background .18s, color .18s, box-shadow .18s;
}
.tech-tile-ic svg { width: 19px; height: 19px; }
.tech-tile-check {
    position: absolute; top: 14px; right: 14px; width: 20px; height: 20px; border-radius: 50%;
    background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center;
    opacity: 0; transform: scale(.5); transition: opacity .18s, transform .18s;
}
.tech-tile-check svg { width: 12px; height: 12px; }
.tech-tile textarea, .tech-tile select {
    min-height: 64px; opacity: .4; pointer-events: none; transition: opacity .18s;
}
.tech-tile select { min-height: auto; pointer-events: auto; }

.tech-tile:has(input:checked), .tech-tile.is-checked {
    border-color: var(--accent); background: var(--info-bg);
    box-shadow: 0 10px 26px -14px rgba(79,140,255,.6);
}
.tech-tile:has(input:checked) textarea, .tech-tile.is-checked textarea,
.tech-tile:has(input:checked) select, .tech-tile.is-checked select { opacity: 1; pointer-events: auto; }
.tech-tile:has(input:checked) .tech-tile-check, .tech-tile.is-checked .tech-tile-check { opacity: 1; transform: scale(1); }

.tech-tile[data-type="licht"]:has(input:checked) .tech-tile-ic,
.tech-tile[data-type="licht"].is-checked .tech-tile-ic { background: linear-gradient(150deg, #f6c453, #e09b1f); color: #241a04; box-shadow: 0 0 0 1px rgba(255,255,255,.12) inset; }
.tech-tile[data-type="ton"]:has(input:checked) .tech-tile-ic,
.tech-tile[data-type="ton"].is-checked .tech-tile-ic { background: linear-gradient(150deg, #c77dff, #9b3fe0); color: #fff; box-shadow: 0 0 0 1px rgba(255,255,255,.12) inset; }
.tech-tile[data-type="atrium"]:has(input:checked) .tech-tile-ic,
.tech-tile[data-type="atrium"].is-checked .tech-tile-ic { background: linear-gradient(150deg, #6ba4ff, var(--accent)); color: #fff; box-shadow: 0 0 0 1px rgba(255,255,255,.12) inset; }

.request-form input[type="text"], .request-form input[type="email"], .request-form input[type="date"],
.request-form input[type="number"], .request-form textarea, .request-form select {
    transition: border-color .15s, box-shadow .15s;
}
.request-form input:focus, .request-form textarea:focus, .request-form select:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,140,255,.18);
}

.request-submit-row { justify-content: center; padding-top: 4px; }
.request-form .btn-primary.btn-lg {
    background: linear-gradient(135deg, #6ba4ff, var(--accent) 55%, #3f6fd8);
    box-shadow: 0 12px 28px -10px rgba(79,140,255,.55);
    border: none; transition: transform .15s, box-shadow .15s;
}
.request-form .btn-primary.btn-lg:hover { transform: translateY(-1px); box-shadow: 0 16px 32px -10px rgba(79,140,255,.65); }

@media (max-width: 560px) {
    .request-hero { padding: 32px 10px 22px; }
    .request-hero h1 { font-size: 1.6rem; }
    .req-section { padding: 20px; }
}
