/* ==========================================================================
   Delta Mail – Oberflächen-Stylesheet
   ========================================================================== */

:root {
    --bg:          #080e1a;
    --bg-soft:     #0f1728;
    --panel:       #131d31;
    --panel-2:     #1a2540;
    --line:        #223050;
    --text:        #e9eefb;
    --muted:       #94a4c2;
    --accent:      #7b9dff;
    --accent-2:    #4ad9c8;
    --ok:          #3ddc97;
    --warn:        #f6c453;
    --danger:      #ff8080;
    --radius:      14px;
    --shadow:      0 18px 40px -18px rgba(3, 8, 20, .9);
    --mono:        ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    background:
        radial-gradient(1100px 620px at 10% -12%, rgba(123, 157, 255, .20), transparent 62%),
        radial-gradient(900px 520px at 108% -6%, rgba(74, 217, 200, .13), transparent 58%),
        radial-gradient(760px 420px at 55% 112%, rgba(160, 107, 255, .10), transparent 62%),
        var(--bg);
    color: var(--text);
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overflow-wrap: break-word;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; font-weight: 650; letter-spacing: -.015em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

small, .muted { color: var(--muted); }
.mono { font-family: var(--mono); }

/* ------------------------------------------------------------- Grundgerüst */

.shell {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    background: linear-gradient(180deg, rgba(19, 29, 49, .95), rgba(8, 14, 26, .95));
    border-right: 1px solid var(--line);
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 6px;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #7b9dff 0%, #a06bff 55%, #4ad9c8 130%);
    box-shadow: 0 10px 24px -10px rgba(123, 157, 255, .95), inset 0 1px 0 rgba(255, 255, 255, .22);
    font-weight: 800;
    font-size: .92rem;
    letter-spacing: .02em;
    color: #fff;
    flex: 0 0 auto;
}

.brand-text b { display: block; font-size: .96rem; letter-spacing: .01em; }
.brand-text span { font-size: .74rem; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 3px; }

.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    color: var(--muted);
    font-size: .9rem;
    font-weight: 500;
    transition: background .15s, color .15s;
}

.nav a:hover { background: rgba(123, 157, 255, .1); color: var(--text); text-decoration: none; }
.nav a.active { background: rgba(123, 157, 255, .16); color: #fff; box-shadow: inset 0 0 0 1px rgba(123, 157, 255, .28); }
.nav a .ico { width: 18px; text-align: center; opacity: .9; }

.sidebar-foot { margin-top: auto; font-size: .78rem; color: var(--muted); display: grid; gap: 8px; }

.who {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: rgba(255, 255, 255, .02);
}

.avatar {
    width: 30px; height: 30px; border-radius: 9px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, #2b3d5f, #1b2740);
    border: 1px solid var(--line);
    font-size: .78rem; font-weight: 700; flex: 0 0 auto;
}

.who div { min-width: 0; }
.who b { display: block; font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who span { font-size: .72rem; color: var(--muted); }

/* ---------------------------------------------------------------- Inhalt   */

.main { padding: 26px 30px 60px; max-width: 1220px; min-width: 0; }

.topbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}

.topbar p { margin: 2px 0 0; color: var(--muted); font-size: .88rem; }

.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.card {
    background: linear-gradient(180deg, rgba(26, 37, 64, .78), rgba(19, 29, 49, .78));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}

.card.tight { padding: 14px 16px; }
.card h2 { display: flex; align-items: center; gap: 8px; }
.card .sub { color: var(--muted); font-size: .84rem; margin: -2px 0 14px; }

.stat { display: grid; gap: 4px; }
.stat .label { font-size: .76rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }
.stat .value { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; }
.stat .hint { font-size: .78rem; color: var(--muted); }

/* ------------------------------------------------------------------ Formen */

label.field { display: block; margin-bottom: 13px; }
label.field > span { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: 5px; }

input[type="text"], input[type="password"], input[type="email"], input[type="number"], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: rgba(9, 15, 27, .75);
    color: var(--text);
    font: inherit;
    font-size: .92rem;
    transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(123, 157, 255, .18);
}

input:disabled { opacity: .55; cursor: not-allowed; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 0 0 auto; }
.grow { flex: 1 1 auto; }

.check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: rgba(255, 255, 255, .015);
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.check:hover { border-color: #33456b; background: rgba(123, 157, 255, .06); }
.check input { margin: 3px 0 0; accent-color: var(--accent); width: 16px; height: 16px; }
.check b { display: block; font-size: .88rem; font-weight: 600; }
.check span { font-size: .78rem; color: var(--muted); }

/* ------------------------------------------------------------------ Knöpfe */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .04);
    color: var(--text);
    font: inherit;
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: transform .12s, background .15s, border-color .15s;
}

.btn:hover { background: rgba(255, 255, 255, .08); text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn.primary {
    background: linear-gradient(135deg, var(--accent), #6d5efc);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 10px 24px -12px rgba(123, 157, 255, .9);
}

.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.danger { color: #ffd9d9; border-color: rgba(248, 113, 113, .4); background: rgba(248, 113, 113, .1); }
.btn.danger:hover { background: rgba(248, 113, 113, .18); }
.btn.sm { padding: 6px 11px; font-size: .8rem; border-radius: 8px; }

/* ------------------------------------------------------------------ Tabellen */

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th {
    text-align: left;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    font-weight: 600;
    padding: 0 12px 9px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid rgba(34, 48, 80, .55); vertical-align: middle; }
tbody tr:hover { background: rgba(123, 157, 255, .05); }
tbody tr:last-child td { border-bottom: none; }
.right { text-align: right; }

.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell b { display: block; font-size: .9rem; }
.user-cell span { font-size: .76rem; color: var(--muted); }

/* -------------------------------------------------------------------- Badges */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: .73rem;
    font-weight: 600;
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge.ok    { color: var(--ok);     background: rgba(52, 211, 153, .12);  border-color: rgba(52, 211, 153, .3); }
.badge.off   { color: #b6c2d8;       background: rgba(148, 163, 184, .1);  border-color: rgba(148, 163, 184, .28); }
.badge.warn  { color: var(--warn);   background: rgba(251, 191, 36, .12);  border-color: rgba(251, 191, 36, .3); }
.badge.admin { color: #c4b5fd;       background: rgba(139, 92, 246, .14);  border-color: rgba(139, 92, 246, .34); }
.badge.info  { color: #7dd3fc;       background: rgba(56, 189, 248, .12);  border-color: rgba(56, 189, 248, .3); }
.badge.danger{ color: var(--danger); background: rgba(248, 113, 113, .12); border-color: rgba(248, 113, 113, .3); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ------------------------------------------------------------------- Balken */

.bar { height: 7px; border-radius: 999px; background: rgba(148, 163, 184, .16); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.bar.warn > i { background: linear-gradient(90deg, var(--warn), #fb923c); }
.bar.danger > i { background: linear-gradient(90deg, var(--danger), #fb7185); }

/* ------------------------------------------------------------------ Hinweise */

.alert {
    display: flex;
    gap: 11px;
    align-items: flex-start;
    padding: 12px 15px;
    border-radius: 12px;
    font-size: .88rem;
    margin-bottom: 16px;
    border: 1px solid;
}

.alert.ok     { background: rgba(52, 211, 153, .1);  border-color: rgba(52, 211, 153, .3);  color: #b8f5dc; }
.alert.err    { background: rgba(248, 113, 113, .1); border-color: rgba(248, 113, 113, .32); color: #ffd4d4; }
.alert.info   { background: rgba(123, 157, 255, .1);  border-color: rgba(123, 157, 255, .3);  color: #d5e2ff; }

/* -------------------------------------------------------------- Anmeldung  */

.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 30px 18px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: linear-gradient(180deg, rgba(26, 37, 64, .9), rgba(15, 23, 40, .95));
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 30px 28px;
    box-shadow: 0 30px 70px -30px rgba(0, 0, 0, .95);
}

.auth-card .brand { justify-content: center; margin-bottom: 18px; }
.auth-card h1 { text-align: center; font-size: 1.25rem; }
.auth-card .sub { text-align: center; color: var(--muted); font-size: .85rem; margin-bottom: 20px; }

/* ------------------------------------------------------------------ Startseite */

.hero {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    place-items: center;
    padding: 40px 20px;
}

.hero-inner { width: 100%; max-width: 880px; min-width: 0; text-align: center; }

.hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin-bottom: .35em; }
.hero p.lead { color: var(--muted); font-size: 1.02rem; margin: 0 auto 32px; max-width: 560px; }

.tiles { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); text-align: left; }

.tile {
    display: block;
    padding: 22px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(26, 37, 64, .82), rgba(15, 23, 40, .88));
    color: var(--text);
    transition: transform .16s, border-color .16s, box-shadow .16s;
    box-shadow: var(--shadow);
}

.tile:hover {
    text-decoration: none;
    transform: translateY(-3px);
    border-color: rgba(123, 157, 255, .55);
    box-shadow: 0 26px 50px -24px rgba(123, 157, 255, .55);
}

.tile .ico {
    width: 42px; height: 42px;
    border-radius: 12px;
    display: grid; place-items: center;
    font-size: 1.15rem;
    background: rgba(123, 157, 255, .14);
    border: 1px solid rgba(123, 157, 255, .3);
    margin-bottom: 13px;
}

.tile b { display: block; font-size: 1.02rem; margin-bottom: 3px; }
.tile span { font-size: .84rem; color: var(--muted); }

.hero-foot { margin-top: 30px; font-size: .8rem; color: var(--muted); }

/* ------------------------------------------------------------- Kleinkram    */

.klines { display: grid; gap: 9px; font-size: .87rem; }
.kline { display: flex; justify-content: space-between; gap: 14px; padding-bottom: 9px; border-bottom: 1px solid rgba(34, 48, 80, .5); }
.kline:last-child { border-bottom: none; padding-bottom: 0; }
.kline b { font-weight: 600; }
.kline code { font-family: var(--mono); font-size: .84rem; color: #bccdf6; }

.empty { text-align: center; padding: 34px 18px; color: var(--muted); font-size: .9rem; }

.inline-form { display: inline; }

.sep { height: 1px; background: var(--line); margin: 18px 0; border: 0; }

/* ==========================================================================
   Responsive: Desktop → Tablet → Handy
   ========================================================================== */

/* Kleine Laptops / grosse Tablets quer */
@media (max-width: 1180px) {
    .shell { grid-template-columns: 214px 1fr; }
    .main  { padding: 22px 22px 48px; }
}

/* Tablets hochkant und alles darunter: Sidebar wird zur Kopfleiste */
@media (max-width: 900px) {
    .shell { grid-template-columns: minmax(0, 1fr); }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 30;
        width: 100%;
        min-width: 0;
        height: auto;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px;
        padding: 10px 14px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        background: rgba(8, 14, 26, .92);
        -webkit-backdrop-filter: blur(14px);
        backdrop-filter: blur(14px);
    }

    .sidebar .brand { padding: 0; gap: 9px; }
    .sidebar .brand-mark { width: 32px; height: 32px; border-radius: 9px; font-size: .8rem; }
    .sidebar .brand-text b { font-size: .9rem; }
    .sidebar .brand-text span { display: none; }

    .nav {
        order: 3;
        width: 100%;
        min-width: 0;
        flex-direction: row;
        gap: 4px;
        overflow-x: auto;
        padding-bottom: 2px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .nav::-webkit-scrollbar { display: none; }
    .nav a { white-space: nowrap; padding: 8px 11px; font-size: .84rem; }
    .nav a .ico { width: 16px; }

    .sidebar-foot { margin: 0 0 0 auto; display: flex; align-items: center; gap: 8px; }
    .sidebar-foot .who { display: none; }

    .main { padding: 18px 16px 44px; max-width: none; }

    /* Tabellen seitlich scrollbar statt Layout sprengen */
    .card { overflow-x: auto; }
    .card table { min-width: 540px; }
    .card.tight table { min-width: 460px; }

    /* 16px verhindert das automatische Zoomen in iOS */
    input[type="text"], input[type="password"], input[type="email"],
    input[type="number"], select, textarea { font-size: 16px; }
}

/* Handy quer / kleine Tablets */
@media (max-width: 680px) {
    body { font-size: 14.5px; }
    h1 { font-size: 1.32rem; }
    .main { padding: 14px 12px 40px; }

    .topbar { gap: 10px; margin-bottom: 16px; }
    .topbar .btn { width: 100%; }

    .card { padding: 15px 14px; border-radius: 13px; }
    .card.tight { padding: 12px; }
    .grid { gap: 12px; }
    .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; }

    .stat .value { font-size: 1.5rem; }
    .row > .grow, .row > .btn { flex: 1 1 100%; }

    .kline { flex-wrap: wrap; }
    .kline code, .mono { overflow-wrap: anywhere; }

    table { font-size: .84rem; }
    th, td { padding-left: 9px; padding-right: 9px; }
    .card table { min-width: 480px; }
}

/* Handy hochkant */
@media (max-width: 480px) {
    .sidebar { padding: 9px 11px; gap: 8px; }
    .sidebar .brand-mark { width: 29px; height: 29px; }
    .sidebar .brand-text b { font-size: .84rem; }

    .nav { gap: 2px; }
    .nav a { padding: 7px 9px; font-size: .8rem; }
    .btn { padding: 10px 13px; }

    .main { padding: 12px 10px 36px; }
    .card { padding: 13px 12px; }
    .card table { min-width: 430px; }

    .hero {
        min-height: auto;
        place-items: start center;
        padding: 28px 14px 36px;
    }
    .hero h1 { font-size: 1.55rem; }
    .hero p.lead { font-size: .94rem; margin-bottom: 24px; }
    .tiles { grid-template-columns: 1fr; gap: 12px; }
    .tile { padding: 18px; }
    .hero-foot { font-size: .75rem; }

    .auth-wrap { padding: 18px 12px; place-items: start center; }
    .auth-card { padding: 22px 18px; border-radius: 15px; }
}

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