:root {
    --navy: #0f2a47;
    --navy-mid: #1a4a7a;
    --navy-dark: #0d2d4f;
    --gold: #c9a227;
    --gold-soft: #f0a500;
    --green: #2eaf6e;
    --red: #d93b3b;
    --ink: #1e293b;
    --muted: #64748b;
    --line: #e2e8f0;
    --line-soft: #f1f5f9;
    --bg: #f8fafc;
    --white: #ffffff;
    --radius: 4px;
    --radius-btn: 8px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Helvetica Neue", Raleway, "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body > header, body > footer { flex: 0 0 auto; }

.container { max-width: 1240px; margin: 0 auto; padding: 0 20px; }

/* Kopfzeile */

.nav { background: var(--navy-dark); color: var(--white); }
.nav .container { display: flex; align-items: center; gap: 22px; height: 56px; }

.nav-logo { display: flex; align-items: center; gap: 9px; text-decoration: none; flex-shrink: 0; }

.nav-logo-mark { position: relative; display: inline-block; width: 30px; height: 30px; }
.mark-bg {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: var(--navy);
    border-radius: 6px;
}
.mark-letter { color: var(--white); font-weight: 700; font-size: 16px; line-height: 1; margin-right: 3px; }
.mark-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 9px;
    height: 9px;
    border: 2px solid var(--gold-soft);
    border-radius: 50%;
}

.nav-logo-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { color: var(--white); font-weight: 600; letter-spacing: 3px; font-size: 13px; }
.brand-sub { color: var(--gold-soft); font-weight: 600; letter-spacing: 2px; font-size: 9px; text-transform: uppercase; }

.nav-links { display: flex; align-items: center; gap: 4px; list-style: none; margin: 0; padding: 0; flex: 1; }
.nav-links > li { position: relative; }
.nav-links a {
    display: inline-block;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 7px 11px;
    border-radius: 6px;
    line-height: 1.4;
}
.nav-links a:hover, .nav-links a:focus-visible { color: var(--white); background: rgba(255, 255, 255, .08); }

.nav-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 208px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(15, 42, 71, .12);
    padding: 5px 0;
    display: none;
    z-index: 40;
}
.nav-links > li:hover .nav-dropdown,
.nav-links > li:focus-within .nav-dropdown { display: block; }
.nav-dropdown a { display: block; color: var(--ink); padding: 7px 14px; border-radius: 0; font-size: 13px; }
.nav-dropdown a:hover { background: var(--line-soft); color: var(--navy-mid); }
.nav-dropdown a.is-gold { color: var(--gold); }
.nav-dropdown a.is-logout { color: var(--red); }

.nav-cta {
    background: transparent;
    color: #cbd5e1;
    border: 1px solid #35577a;
    border-radius: var(--radius-btn);
    padding: 0.4rem 0.85rem;
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}
.nav-cta:hover { background: rgba(255, 255, 255, .08); color: var(--white); }
.nav-logout { margin: 0; flex-shrink: 0; }

main { flex: 1 0 auto; padding: 12px 0 24px; }

.rolebar {
    background: var(--gold);
    color: #1b1b1b;
    font-size: 12.5px;
    font-weight: 600;
}
.rolebar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding-top: 6px;
    padding-bottom: 6px;
}
.rolebar.is-impersonating { background: var(--red); color: var(--white); }
.rolebar .btn { padding: 0.25rem 0.7rem; font-size: 12px; }
.rolebar-label { display: inline-flex; align-items: center; gap: 7px; }
.rolebar-dot { width: 8px; height: 8px; border-radius: 50%; background: #1b1b1b; }
.rolebar.is-impersonating .rolebar-dot { background: var(--white); }

.nav-ip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 11.5px;
    color: #9db3c9;
    background: rgba(255, 255, 255, .06);
    border: 1px solid #2c4a6b;
    border-radius: 6px;
    padding: 4px 9px;
    white-space: nowrap;
    user-select: all;
    margin-right: 8px;
}
.nav-ip-label { color: #6f8aa6; }

/* Typografie */

h1 { font-size: 22px; font-weight: 700; color: var(--navy-mid); margin: 8px 0 2px; }
h2 { font-size: 16px; font-weight: 700; color: var(--navy-mid); margin: 22px 0 8px; }
.sub { color: var(--muted); margin: 0 0 16px; font-size: 13px; }

/* Flächen */

.card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 14px;
}

.clock { display: flex; align-items: center; justify-content: space-between; gap: 22px; flex-wrap: wrap; }
.clock .state { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.clock .timer {
    font-size: 32px;
    font-weight: 700;
    color: var(--navy-mid);
    font-variant-numeric: tabular-nums;
    letter-spacing: -.02em;
    line-height: 1.15;
}
.clock .since { color: var(--muted); font-size: 12.5px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 4px; }
.kpi {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 11px 13px;
}
.kpi .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.kpi .value { font-size: 19px; font-weight: 700; color: var(--navy-mid); font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .value.neg { color: var(--red); }
.kpi .value.pos { color: var(--green); }

/* Tabellen */

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
th {
    background: var(--white);
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--line);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--line-soft); }

td .btn { white-space: nowrap; }
td form { display: inline-block; margin: 0; }
td form.inline { display: inline-flex; }

.row-actions { white-space: nowrap; text-align: right; width: 1%; }
.row-actions form, .row-actions .btn { margin-left: 5px; }
.row-actions form.inline { gap: 6px; align-items: center; }
.row-actions form.inline > div { min-width: 0; }
.row-actions form.inline input { min-width: 96px; }
.row-actions label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}
.toggle-cell { white-space: nowrap; }

/* Schaltflächen */

.btn {
    display: inline-block;
    border: 1px solid transparent;
    border-radius: var(--radius-btn);
    padding: 0.55rem 0.95rem;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary { background: var(--navy-mid); color: var(--white); }
.btn-primary:hover { background: var(--navy); }
.btn-gold { background: var(--gold); color: #1b1b1b; }
.btn-gold:hover { background: var(--gold-soft); }
.btn-danger { background: var(--red); color: var(--white); }
.btn-danger:hover { background: #c22f2f; }
.btn-ghost { background: var(--white); color: var(--navy-mid); border-color: var(--line); }
.btn-ghost:hover { background: var(--line-soft); }
.btn-small { padding: 0.3rem 0.6rem; font-size: 12px; font-weight: 600; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* Formulare */

form.stack { display: grid; gap: 11px; }
form.inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin: 0; }
form.inline > div { min-width: 140px; }
form.inline .narrow { min-width: 110px; max-width: 132px; }

label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

input, select, textarea {
    font: inherit;
    font-size: 13px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--white);
    color: var(--ink);
    width: 100%;
    min-height: 34px;
}

input::placeholder { color: #94a3b8; }

select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 32px;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2364748b' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    cursor: pointer;
    text-overflow: ellipsis;
}
select:hover { border-color: #cbd5e1; }
select:disabled { background-color: var(--line-soft); color: var(--muted); cursor: not-allowed; }
select optgroup { font-style: normal; font-weight: 700; color: var(--navy-mid); background: var(--line-soft); }
select option { color: var(--ink); background: var(--white); }

input:focus, select:focus, textarea:focus, .btn:focus-visible, .nav-links a:focus-visible, .nav-cta:focus-visible {
    outline: 2px solid var(--navy-mid);
    outline-offset: 1px;
}

input.masked { font-variant-numeric: tabular-nums; }
input.masked:invalid { border-color: var(--red); }
input.masked:invalid:placeholder-shown { border-color: var(--line); }

.field-hint { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }

.nav-badge {
    display: inline-block;
    min-width: 17px;
    padding: 0 5px;
    margin-left: 5px;
    border-radius: 9px;
    background: var(--gold-soft);
    color: #1b1b1b;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
    vertical-align: text-top;
}

.nav-dropdown .nav-badge { background: var(--red); color: var(--white); }

/* Terminalmodus */

.terminal-body { background: #0d2d4f; color: var(--white); }

.terminal-bar { background: rgba(0, 0, 0, .18); }
.terminal-bar .container { display: flex; align-items: center; gap: 10px; height: 58px; }

.terminal-main { flex: 1 0 auto; padding: 20px 0 40px; }

.terminal-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    color: var(--white);
}
.terminal-device { font-size: 13px; color: #9db3c9; letter-spacing: .05em; text-transform: uppercase; }
.terminal-clock {
    display: block;
    font-size: 40px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}
.terminal-date { color: #9db3c9; font-size: 14px; }

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 14px;
}
.tiles form { margin: 0; }

.tile {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    width: 100%;
    min-height: 108px;
    padding: 18px;
    border-radius: 10px;
    background: #143b63;
    color: var(--white);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.tile { border-color: #1f4a78; }
.tile:hover { background: #17456f; }
.tile:disabled { opacity: .45; cursor: not-allowed; }
.tile.is-working { background: #14523d; border-color: #1e7a5a; }
.tile-name { font-size: 19px; font-weight: 700; line-height: 1.2; }
.tile-state { font-size: 13px; color: #b6c8da; }

.terminal-center { display: flex; justify-content: center; padding: 12px 0; }

.terminal-card {
    background: var(--white);
    color: var(--ink);
    border-radius: 10px;
    padding: 26px 28px;
    width: 100%;
    max-width: 440px;
}
.terminal-card h1 { margin-top: 0; }

.pin-input {
    font-size: 30px;
    letter-spacing: .35em;
    text-align: center;
    min-height: 56px;
}

.btn-terminal { display: block; width: 100%; text-align: center; padding: 0.85rem 1rem; font-size: 16px; margin-top: 10px; }

.terminal-body .msg { max-width: 720px; margin-left: auto; margin-right: auto; }

/* Kennwortprüfung */

.pw-meter { margin-top: 8px; }

.pw-bar {
    height: 5px;
    border-radius: 3px;
    background: var(--line);
    overflow: hidden;
}

.pw-fill {
    height: 100%;
    width: 0;
    border-radius: 3px;
    background: var(--red);
    transition: width .15s linear, background-color .15s linear;
}

.pw-fill.is-weak { background: var(--red); }
.pw-fill.is-medium { background: var(--gold-soft); }
.pw-fill.is-strong { background: var(--green); }

.pw-status {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    margin-top: 5px;
    color: var(--muted);
}
.pw-status.is-strong { color: var(--green); }
.pw-status.is-weak { color: var(--red); }

.pw-reqs {
    list-style: none;
    margin: 7px 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 2px 14px;
}

.pw-reqs li {
    font-size: 11.5px;
    color: var(--muted);
    padding-left: 17px;
    position: relative;
    line-height: 1.7;
}

.pw-reqs li::before {
    content: "○";
    position: absolute;
    left: 0;
    top: 0;
    font-size: 11px;
    color: #cbd5e1;
}

.pw-reqs li.is-met { color: var(--green); }
.pw-reqs li.is-met::before { content: "✓"; color: var(--green); font-weight: 700; }

.checkbox-field { display: flex; align-items: center; gap: 8px; min-height: 34px; }
.checkbox-field input[type="checkbox"] { width: 16px; height: 16px; min-height: 0; margin: 0; }
.checkbox-field label { margin: 0; text-transform: none; letter-spacing: 0; font-size: 12.5px; }

/* Meldungen */

.msg {
    padding: 11px 14px 11px 15px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    font-size: 13px;
    line-height: 1.55;
    border: 1px solid;
    border-left-width: 3px;
}
.msg strong { font-weight: 700; }
.msg-error { background: #fef2f2; border-color: #fecaca; border-left-color: var(--red); color: #7f1d1d; }
.msg-ok { background: #f0fdf4; border-color: #bbf7d0; border-left-color: var(--green); color: #14532d; }
.msg-warn { background: #fffbeb; border-color: #fde68a; border-left-color: var(--gold-soft); color: #78350f; }
.msg-info { background: #eff6ff; border-color: #bfdbfe; border-left-color: #2563eb; color: #1e3a8a; }
.msg ul { margin: 8px 0 0; padding-left: 18px; }
.msg-title { display: block; font-weight: 700; margin-bottom: 6px; font-size: 13.5px; }

/* Hervorgehobene Codes */

.code-box {
    display: inline-block;
    margin: 4px 0 8px;
    padding: 10px 16px;
    background: var(--white);
    border: 2px solid var(--navy-mid);
    border-radius: 6px;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: .14em;
    color: var(--navy-mid);
    user-select: all;
    line-height: 1.25;
}

.code-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.code-list li {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .1em;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 6px 11px;
    color: var(--ink);
    user-select: all;
}

.code-url {
    display: inline-block;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 13px;
    background: rgba(255, 255, 255, .7);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 2px 7px;
    user-select: all;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid;
}
.badge-open { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.badge-ok { background: #f0fdf4; color: #15803d; border-color: #86efac; }
.badge-bad { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--muted); word-break: break-all; }

/* Anmeldung */

.login-wrap { max-width: 400px; margin: 48px auto; }
.login-brand { display: flex; justify-content: center; margin-bottom: 22px; }
.login-brand img { width: 232px; height: auto; display: block; }
.login-wrap .card { padding: 22px 24px; }

/* Fuß */

.footer {
    flex-shrink: 0;
    background: var(--white);
    border-top: 1px solid var(--line);
    color: var(--muted);
    margin-top: 28px;
}
.footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 13px 0;
    flex-wrap: wrap;
    font-size: 12px;
}
.footer-bottom p { margin: 0; }
.footer-bottom-links { display: flex; gap: 16px; list-style: none; margin: 0; padding: 0; }
.footer-bottom-links a { color: var(--muted); text-decoration: none; }
.footer-bottom-links a:hover { color: var(--navy-mid); }

@media (max-width: 860px) {
    .nav .container { flex-wrap: wrap; height: auto; gap: 10px; padding-top: 9px; padding-bottom: 9px; }
    .nav-links { order: 3; width: 100%; gap: 2px; overflow-x: auto; }
    .nav-links a { white-space: nowrap; }
    .nav-dropdown { position: static; display: block; box-shadow: none; border: 0; background: transparent; padding: 0; min-width: 0; }
    .nav-dropdown a { color: #94a3b8; padding: 6px 0 6px 12px; }
    .nav-dropdown a:hover { background: transparent; color: var(--white); }
    .clock .timer { font-size: 27px; }
    th:nth-child(n+5), td:nth-child(n+5) { display: none; }
    .row-actions { display: table-cell !important; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
