/* ============================================================
   Signatur-Verwaltung – „Control Room"
   Editorial-technische Optik: Navy-Sidebar, warmes Arbeitsfeld,
   Teal-Akzent. Bricolage Grotesque (Display) + IBM Plex (Text/Mono).
   ============================================================ */

:root {
    --ink:        #0b1a2b;   /* Sidebar / dunkle Flächen */
    --ink-2:      #14283f;
    --ink-line:   #1f3a57;
    --paper:      #f6f5f1;   /* warmes Arbeitsfeld */
    --card:       #ffffff;
    --line:       #e6e3da;
    --text:       #16202b;
    --muted:      #6b7682;
    --accent:     #0d9488;   /* Teal */
    --accent-ink: #0a6f66;
    --accent-soft:#d7f2ee;
    --warn:       #c2410c;
    --danger:     #b91c4a;
    --ok:         #157a52;
    --ok-soft:    #d6f3e4;
    --radius:     14px;
    --shadow:     0 1px 2px rgba(11,26,43,.05), 0 8px 24px -12px rgba(11,26,43,.18);
    --shadow-lg:  0 24px 60px -24px rgba(11,26,43,.35);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--paper);
    color: var(--text);
    font-family: "IBM Plex Sans", system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ---- Layout ---- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 248px;
    flex-shrink: 0;
    background:
        radial-gradient(120% 60% at 0% 0%, rgba(13,148,136,.18), transparent 60%),
        var(--ink);
    color: #cdd8e4;
    padding: 26px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    border-right: 1px solid var(--ink-line);
    display: flex;
    flex-direction: column;
}

.brand {
    font-family: "Bricolage Grotesque", sans-serif;
    font-weight: 800;
    font-size: 21px;
    letter-spacing: -0.02em;
    color: #fff;
    padding: 4px 12px 22px;
    display: flex;
    align-items: center;
    gap: 9px;
}
.brand .dot {
    width: 11px; height: 11px; border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(13,148,136,.25);
}

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
    color: #aebccb;
    padding: 10px 14px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--ink-2); color: #fff; }
.nav-link.active {
    background: linear-gradient(90deg, rgba(13,148,136,.22), rgba(13,148,136,.05));
    color: #fff;
    box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar .foot {
    margin-top: auto;
    padding: 14px 12px 0;
    font-family: "IBM Plex Mono", monospace;
    font-size: 11px;
    color: #5d6f82;
}

.content { flex: 1; padding: 36px 44px; max-width: 1280px; }

/* ---- Headings ---- */
h1 {
    font-family: "Bricolage Grotesque", sans-serif;
    font-weight: 800;
    font-size: 30px;
    letter-spacing: -0.03em;
    margin: 0 0 4px;
}
h1 + .sub { color: var(--muted); margin: 0 0 26px; }
h3 {
    font-family: "Bricolage Grotesque", sans-serif;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 16px;
    font-size: 18px;
}

/* ---- Toolbar ---- */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}

/* ---- Cards ---- */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    margin-bottom: 22px;
}

/* ---- Stat tiles ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px 22px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}
.stat::after {
    content: "";
    position: absolute; right: -20px; top: -20px;
    width: 80px; height: 80px; border-radius: 50%;
    background: var(--accent-soft);
    opacity: .6;
}
.stat .num {
    font-family: "Bricolage Grotesque", sans-serif;
    font-weight: 800;
    font-size: 38px;
    line-height: 1;
    letter-spacing: -0.03em;
    color: var(--ink);
    position: relative;
}
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 6px; position: relative; }

/* ---- Tables ---- */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
th, td { text-align: left; padding: 13px 16px; }
thead th {
    background: #fbfaf7;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
    font-weight: 600;
    border-bottom: 1px solid var(--line);
}
tbody tr { border-top: 1px solid var(--line); }
tbody tr:first-child { border-top: none; }
tbody tr:hover { background: #fbfaf7; }
td { vertical-align: middle; }

/* ---- Buttons ---- */
.btn {
    border: none;
    border-radius: 10px;
    padding: 9px 16px;
    cursor: pointer;
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 14px;
    font-weight: 600;
    background: var(--accent);
    color: #fff;
    transition: transform .08s, box-shadow .15s, background .15s;
    box-shadow: 0 1px 2px rgba(13,148,136,.4);
}
.btn:hover { background: var(--accent-ink); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-secondary { background: #eef0ec; color: var(--text); box-shadow: none; }
.btn-secondary:hover { background: #e4e7e0; }
.btn-danger { background: var(--danger); box-shadow: none; }
.btn-danger:hover { background: #9f1742; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

/* ---- Forms ---- */
.form-row { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
input, select, textarea {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    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 var(--accent-soft);
}
textarea {
    min-height: 200px;
    font-family: "IBM Plex Mono", monospace;
    font-size: 13px;
    line-height: 1.55;
    resize: vertical;
}
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin: 0 0 16px; }
legend { font-size: 12px; color: var(--muted); padding: 0 8px; font-weight: 600; }

/* ---- Badges ---- */
.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-on { background: var(--ok-soft); color: var(--ok); }
.badge-off { background: #fbe0e8; color: var(--danger); }
.badge-secondary { background: #eef0ec; color: var(--muted); }

/* ---- Editor mit Live-Vorschau ---- */
.editor-split { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 980px) { .editor-split { grid-template-columns: 1fr; } }
.preview-box {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 18px;
    background:
        linear-gradient(#fff, #fff) padding-box,
        repeating-linear-gradient(45deg, #f0efe9 0 10px, #f6f5f1 10px 20px) border-box;
    min-height: 200px;
    overflow: auto;
}
.preview-head {
    font-family: "IBM Plex Mono", monospace;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    margin-bottom: 10px;
}

.muted { color: var(--muted); }
.mono { font-family: "IBM Plex Mono", monospace; }

/* ---- Login ---- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(80% 50% at 50% 0%, rgba(13,148,136,.10), transparent 60%),
        var(--paper);
    padding: 24px;
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 32px 30px;
    box-shadow: var(--shadow-lg);
}
.login-card .brand { color: var(--ink); }
.login-error {
    background: #fbe0e8;
    color: var(--danger);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 16px;
}

/* ---- Mandanten-Karten (CodeTwo-inspiriert) ---- */
.tenant-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 18px;
}
.tenant-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    overflow: hidden;
    transition: transform .12s, box-shadow .15s, border-color .15s;
}
.tenant-card::before {
    content: "";
    position: absolute; left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--card-accent, var(--accent));
}
.tenant-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: #d8d3c6;
}
.tenant-card.is-inactive { opacity: .62; }
.tenant-card.is-inactive::before { background: var(--muted); }

.tenant-head { display: flex; align-items: center; gap: 14px; }
.tenant-logo {
    width: 52px; height: 52px;
    border-radius: 12px;
    object-fit: contain;
    background: #fff;
    border: 1px solid var(--line);
    padding: 5px;
    flex-shrink: 0;
}
.tenant-logo-ph {
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--accent), var(--accent-ink));
    color: #fff;
    font-family: "Bricolage Grotesque", sans-serif;
    font-weight: 800;
    font-size: 20px;
    letter-spacing: -0.02em;
    padding: 0;
    border: none;
}
.tenant-title { flex: 1; min-width: 0; }
.tenant-name {
    font-family: "Bricolage Grotesque", sans-serif;
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.02em;
    color: var(--ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tenant-desc {
    color: var(--muted);
    font-size: 12.5px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    background: var(--accent-soft);
    color: var(--accent-ink);
    border-radius: 999px;
    padding: 3px 11px;
    font-size: 12px;
    font-weight: 600;
    font-family: "IBM Plex Mono", monospace;
}
.chip-empty { background: #f1efe9; color: var(--muted); font-style: italic; }
.chip-time { background: #eef2ff; color: #3730a3; font-family: "IBM Plex Sans", sans-serif; }

/* ---- Vorlagen-Karte: Farb-Swatch ---- */
.tpl-swatch {
    width: 52px; height: 52px;
    border-radius: 12px;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,.08);
    box-shadow: inset 0 0 0 4px rgba(255,255,255,.6);
}

/* ---- Regel-Karte: Prioritäts-Badge ---- */
.prio-badge {
    width: 46px; height: 46px;
    flex-shrink: 0;
    border-radius: 12px;
    background: var(--ink);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-family: "Bricolage Grotesque", sans-serif;
    font-weight: 800;
    font-size: 17px;
    letter-spacing: -0.02em;
}

.tenant-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 14px 0 4px;
    border-top: 1px solid var(--line);
}
.tstat { display: flex; flex-direction: column; gap: 3px; }
.tstat-num {
    font-family: "Bricolage Grotesque", sans-serif;
    font-weight: 800;
    font-size: 22px;
    line-height: 1;
    color: var(--ink);
    letter-spacing: -0.02em;
}
.tstat-lbl { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.graph-pill { font-size: 13px; font-weight: 700; }
.graph-on { color: var(--ok); }
.graph-off { color: var(--muted); }

.tenant-actions { display: flex; gap: 8px; margin-top: auto; }

/* ---- Statistik: Balkenchart ---- */
.chart {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 200px;
    padding: 8px 4px 0;
}
.chart-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    height: 100%;
}
.chart-val { font-size: 11px; color: var(--muted); font-family: "IBM Plex Mono", monospace; min-height: 14px; }
.chart-stack {
    width: 100%;
    max-width: 36px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    border-radius: 7px 7px 0 0;
    overflow: hidden;
    background: transparent;
    transition: height .2s;
}
.chart-rest { background: #e4e1d7; width: 100%; }
.chart-ok { background: linear-gradient(180deg, var(--accent), var(--accent-ink)); width: 100%; }
.chart-day { font-size: 10.5px; color: var(--muted); font-family: "IBM Plex Mono", monospace; }
.chart-legend { display: flex; gap: 18px; margin-top: 14px; font-size: 12.5px; color: var(--muted); }
.chart-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.chart-legend .dot-ok { background: var(--accent); }
.chart-legend .dot-rest { background: #e4e1d7; }

/* ---- Mini-Meter (Status-Anteil) ---- */
.meter {
    display: inline-block;
    width: 78%;
    height: 9px;
    background: #eef0ec;
    border-radius: 999px;
    overflow: hidden;
    vertical-align: middle;
    margin-right: 8px;
}
.meter-fill { height: 100%; background: var(--muted); border-radius: 999px; transition: width .25s; }
.meter-fill.meter-good { background: var(--accent); }
.meter-fill.meter-bad { background: var(--danger); }

/* ---- Empty-State ---- */
.empty-state {
    text-align: center;
    padding: 56px 24px;
    background: var(--card);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
}
.empty-state .empty-icon { font-size: 44px; margin-bottom: 8px; }
.empty-state h3 { margin: 0 0 6px; }
.empty-state p { margin: 0 0 18px; }

/* ---- Microsoft-365-Login-Button ---- */
.btn-entra {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    background: #2f2f2f;
    color: #fff;
    text-decoration: none;
    padding: 12px 16px;
    border-radius: 10px;
    font-weight: 600;
    box-shadow: none;
    transition: background .15s;
}
.btn-entra:hover { background: #1f1f1f; }
.ms-logo {
    display: inline-grid;
    grid-template-columns: 9px 9px;
    grid-template-rows: 9px 9px;
    gap: 2px;
}
.ms-logo span { display: block; width: 9px; height: 9px; }
.ms-logo span:nth-child(1) { background: #f25022; }
.ms-logo span:nth-child(2) { background: #7fba00; }
.ms-logo span:nth-child(3) { background: #00a4ef; }
.ms-logo span:nth-child(4) { background: #ffb900; }

.breakglass { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.breakglass summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    list-style: none;
    user-select: none;
}
.breakglass summary::-webkit-details-marker { display: none; }
.breakglass summary::before { content: "🔑 "; }
.breakglass[open] summary { margin-bottom: 4px; }

/* ---- Logout-Button in der Sidebar ---- */
.logout-btn {
    background: transparent;
    border: 1px solid var(--ink-line);
    color: #aebccb;
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 12.5px;
    font-family: inherit;
    cursor: pointer;
    width: 100%;
    transition: background .15s, color .15s;
}
.logout-btn:hover { background: var(--ink-2); color: #fff; }
