/* Matama Studio Kundenportal – abgestimmt auf das Matama Design System */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&family=Lato:wght@400;700&display=swap');

:root {
    /* Matama Design System */
    --bg: #1C1C1C;
    --surface: #252525;
    --surface-2: #2E2E2E;
    --border: #3A3A3A;
    --text: #E0E0E0;
    --heading: #FFFFFF;
    --muted: #B0B0B0;
    --accent: #00E676;          /* Matama-Grün */
    --accent-dark: #00C853;
    --accent-soft: rgba(0, 230, 118, .1);
    --blue: #2680EA;
    --highlight: #FF6F00;       /* Matama-Orange */
    --success: #00E676;
    --error: #FF6B6B;
    --radius: 12px;
    --radius-sm: 8px;
    --glow-green: 0 0 20px rgba(0, 230, 118, 0.3);
    --font-heading: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-body: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    /* Sicherheitsnetz gegen seitliches Verrutschen; clip statt hidden,
       damit die sticky Kopfzeile/Sidebar weiter funktionieren. */
    overflow-x: clip;
}
/* Lange Dateinamen (Überschriften) dürfen umbrechen statt überzulaufen */
.page-head h1, .page-head h2 { overflow-wrap: anywhere; min-width: 0; }
a { color: var(--accent); text-decoration: none; transition: color 150ms ease; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--font-heading); color: var(--heading); }
h1 { font-size: 1.75rem; font-weight: 700; margin: .4em 0; }
h2 { font-size: 1.15rem; font-weight: 600; margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Topbar */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 24px; background: rgba(28, 28, 28, .95);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap; gap: 10px;
    position: sticky; top: 0; z-index: 200; backdrop-filter: blur(8px);
}
.brand { display: inline-flex; align-items: baseline; gap: 3px; font-family: var(--font-heading); color: var(--heading); }
.brand-wordmark { font-family: var(--font-heading); font-weight: 800; font-size: 1.35rem; letter-spacing: -.02em; color: var(--heading); }
.brand-dot { color: var(--accent); }
.brand-text { font-family: var(--font-heading); font-weight: 400; font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .22em; margin-left: 6px; }
.brand em { font-style: normal; font-weight: 400; color: var(--muted); font-size: .85rem; margin-left: 8px; }
.topbar nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.topbar nav a { color: var(--muted); font-weight: 500; }
.topbar nav a:hover { color: var(--accent); text-decoration: none; }
.user-chip { background: var(--surface-2); border: 1px solid var(--border); padding: 4px 13px; border-radius: 999px; font-size: .85rem; }
.logout { font-size: .85rem; }

/* Nutzer-Dropdown im Header */
.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary.user-chip::after { content: ' ▾'; color: var(--muted); }
.user-menu[open] summary.user-chip { border-color: var(--accent); color: var(--accent); }
.user-menu-panel {
    position: absolute; right: 0; top: calc(100% + 6px);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
    min-width: 150px; padding: 6px; z-index: 250;
    display: flex; flex-direction: column; gap: 2px;
}
.user-menu-panel a { padding: 8px 10px; border-radius: 6px; font-size: .85rem; font-weight: 500; }
.user-menu-panel a:hover { background: var(--surface-2); text-decoration: none; }
.user-menu-panel a.logout { color: var(--error); }

/* Nav-Zähler */
.nav-count {
    display: inline-block; min-width: 18px; text-align: center;
    background: var(--highlight); color: #fff; border-radius: 999px;
    font-size: .72rem; padding: 1px 6px; margin-left: 3px; font-weight: 700;
}

/* Layout */
.container { max-width: 1000px; margin: 0 auto; padding: 28px 20px 60px; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 24px; border-top: 1px solid var(--border); }
.back { color: var(--muted); font-size: .9rem; }

/* Seitenkopf mit Aktions-Buttons */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Einklappbare Anlege-Bereiche */
.create-box { display: none; }
.create-box.open { display: block; }

/* Cards */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 22px 24px; margin: 16px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
}
.card.empty { text-align: center; padding: 40px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.project-card { display: block; color: var(--text); transition: all 250ms ease; }
.project-card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-3px); box-shadow: var(--glow-green); }
.project-card h2 { margin-bottom: .3em; }
.project-card .meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { text-align: center; margin: 0; }
.stat strong { display: block; font-family: var(--font-heading); font-size: 1.9rem; color: var(--accent); }

/* Progress */
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 10px 0; }
.progress.big { height: 12px; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent-dark), var(--accent)); border-radius: 99px; }

/* Status-Steps */
.status-steps { list-style: none; padding: 0; margin: 14px 0 6px; display: flex; flex-wrap: wrap; gap: 8px; }
.status-steps li {
    padding: 5px 14px; border-radius: 999px; font-size: .82rem;
    background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.status-steps li.done { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.status-steps li.current { background: var(--accent); color: #1C1C1C; border-color: var(--accent); font-weight: 700; }

/* Badges */
.badge { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: .78rem; background: rgba(38, 128, 234, .12); color: var(--blue); border: 1px solid var(--blue); white-space: nowrap; }
.badge-fertig { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.badge-new { background: rgba(255, 111, 0, .14); color: var(--highlight); border-color: var(--highlight); font-weight: 700; }
.badge-seen { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.badge-off { background: transparent; color: var(--muted); border-color: var(--muted); }

/* Tabs */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 20px 0 0; border-bottom: 1px solid var(--border); }
.tab-btn {
    background: none; border: none; cursor: pointer; font: inherit; font-weight: 600;
    color: var(--muted); padding: 10px 16px; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    display: inline-flex; align-items: center; gap: 6px;
    border-bottom: 2px solid transparent; transition: all 150ms ease;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-badge {
    display: inline-block; min-width: 18px; text-align: center;
    background: var(--highlight); color: #fff; border-radius: 999px;
    font-size: .72rem; padding: 1px 6px; font-weight: 700;
}
.tab-panel { display: none; margin-top: 0; border-top-left-radius: 0; }
.tab-panel.active { display: block; }

/* Thumbnails */
.thumb-table th:first-child, .thumb-table td.thumb-cell { width: 56px; }
.thumb {
    display: block; width: 48px; height: 48px; border-radius: var(--radius-sm);
    object-fit: cover; background: var(--surface-2); border: 1px solid var(--border);
}
.thumb-icon {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 1px; line-height: 1;
}
.thumb-emoji { font-size: 1.3rem; }
.thumb-ext { font-size: .58rem; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }

/* PDF-Thumbnail: echtes Seiten-Preview per PDF.js, Icon bleibt als Fallback im DOM */
.thumb-pdf { position: relative; overflow: hidden; }
.thumb-pdf .thumb-icon { position: absolute; inset: 0; }
.thumb-pdf-canvas {
    position: absolute; inset: 0; width: 100%; height: 100%;
    object-fit: contain; background: #fff; display: none;
}
.thumb-pdf.pdf-rendered .thumb-icon { display: none; }
.thumb-pdf.pdf-rendered .thumb-pdf-canvas { display: block; }

/* Neue Datei hervorheben */
.row-new { background: rgba(255, 111, 0, .05); }
.row-disabled { opacity: .5; }
.row-disabled a { color: var(--muted); }

/* Sortierbare Tabellenköpfe (Admin-Projekt: Studio-Dateien) */
.table th a.sort-link { color: var(--muted); text-decoration: none; font-weight: 500; }
.table th a.sort-link:hover { color: var(--text); }
.table th a.sort-link.active { color: var(--accent); font-weight: 700; }

/* Forms */
.form label { display: block; margin: 10px 0; font-size: .9rem; color: var(--muted); }
.form input[type=text], .form input[type=email], .form input[type=password],
.form textarea, .form select, .form input[type=file] {
    display: block; width: 100%; margin-top: 5px; padding: 11px 13px;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text); font: inherit;
    transition: border-color 150ms ease;
}
.form input:focus, .form textarea:focus, .form select:focus { outline: none; border-color: var(--accent); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; align-items: end; }
.form-row .wide { grid-column: 1 / -1; }
.form.inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.form.inline input, .form.inline select { width: auto; margin: 0; }
.upload-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.upload-form input[type=file] { flex: 1; min-width: 200px; margin: 0; }
.upload-form select { width: auto; margin: 0; display: inline-block; }

/* Buttons – wie auf matama.studio: Grün mit dunkler Schrift, Hover weiß + Glow */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 22px; border: none; border-radius: var(--radius-sm);
    background: var(--accent); color: #1C1C1C; font: inherit;
    font-weight: 700; cursor: pointer; transition: all 250ms ease;
}
.btn:hover { background: #fff; box-shadow: var(--glow-green); transform: translateY(-2px); text-decoration: none; color: #1C1C1C; }
.btn.small { padding: 5px 13px; font-size: .82rem; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); background: transparent; box-shadow: none; }
.btn.danger { background: transparent; border: 1px solid var(--error); color: var(--error); }
.btn.danger:hover { background: var(--error); color: #fff; box-shadow: none; }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; color: var(--muted); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }

/* Chat – Studio rechts (grün), Kunde links (grau) */
.chat { margin-bottom: 16px; display: flex; flex-direction: column; }
.msg { max-width: 78%; margin: 6px 0; padding: 11px 15px; border-radius: var(--radius); }
.msg-me {
    align-self: flex-start;
    background: var(--surface-2); border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.msg-studio {
    align-self: flex-end;
    background: rgba(0, 230, 118, .16); border: 1px solid var(--accent);
    border-bottom-right-radius: 4px;
}
.msg-studio .msg-head { text-align: right; }
.msg-head { font-size: .8rem; color: var(--muted); margin-bottom: 4px; }
.msg-body { white-space: normal; overflow-wrap: anywhere; }

/* Quelle-Label bei übernommenen Nachrichten */
.msg-source {
    display: inline-block; font-size: .72rem; color: var(--highlight);
    border: 1px solid var(--highlight); border-radius: 999px;
    padding: 1px 8px; margin-left: 6px; vertical-align: middle;
}

/* Nachricht löschen (Admin) */
.msg-delete { display: inline; margin-left: 8px; }
.msg-delete button {
    background: none; border: none; color: var(--muted); cursor: pointer;
    font-size: 1rem; line-height: 1; padding: 0 4px; border-radius: 4px;
}
.msg-delete button:hover { color: var(--error); }

/* Rows (Admin-Listen) */
.row-item {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 12px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.row-item:last-child { border-bottom: none; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-actions form { margin: 0; }
.row-actions details { position: relative; }
.row-actions summary { list-style: none; }
.row-actions summary::-webkit-details-marker { display: none; }

/* ============================================================
   Kundenverwaltung (admin/kunden.php)
   Eine Zeile pro Ansprechpartner, eine sichtbare Hauptaktion,
   alles Weitere im Menü – damit die Liste scanbar bleibt.
   ============================================================ */
.filter-bar { display: flex; align-items: center; gap: 12px; margin: 18px 0 10px; }
.filter-bar input[type=search] {
    flex: 1; max-width: 420px; padding: 10px 14px;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 999px; color: var(--text); font: inherit;
    transition: border-color 150ms ease;
}
.filter-bar input[type=search]:focus { outline: none; border-color: var(--accent); }

.company-card { padding: 18px 22px; }
.company-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
    padding-bottom: 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.company-title h2 { margin: 0 0 2px; font-size: 1.15rem; }

.ap-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 11px 0; border-bottom: 1px solid rgba(255, 255, 255, .05);
}
.ap-row:last-of-type { border-bottom: none; }
.ap-info { min-width: 0; }
.ap-name { font-weight: 700; color: var(--heading); display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.ap-mail { display: block; margin-top: 1px; }
.ap-mail:hover { color: var(--accent); }
.ap-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.ap-empty { padding: 12px 0 4px; }
.ap-form { margin-top: 12px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: .85rem; }
.checkbox-label input[type=checkbox] { width: auto; margin: 0; }

/* Aktionsmenü (Firma & Ansprechpartner) */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary { border-color: var(--accent); color: var(--accent); }
.menu-panel {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 260;
    min-width: 232px; padding: 6px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: 0 10px 28px rgba(0, 0, 0, .5);
    display: flex; flex-direction: column; gap: 2px;
}
.menu-panel form { margin: 0; }
.menu-item {
    display: block; width: 100%; text-align: left;
    background: none; border: none; font: inherit; cursor: pointer;
    padding: 9px 10px; border-radius: 6px; color: var(--text); font-size: .85rem;
}
.menu-item:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.menu-item--danger { color: var(--error); }
.menu-item--danger:hover { background: rgba(255, 107, 107, .12); color: var(--error); }
.menu-form { padding: 8px 10px 6px; border-top: 1px solid var(--border); margin-top: 2px; }
.menu-label { display: block; font-size: .78rem; color: var(--muted); margin-bottom: 5px; }
.menu-inline { display: flex; gap: 6px; }
.menu-inline input {
    flex: 1; min-width: 0; padding: 7px 10px; font-size: .85rem;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text); font-family: inherit;
}
.menu-inline input:focus { outline: none; border-color: var(--accent); }

.abo-box { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.abo-box h3 { font-size: 1rem; margin-bottom: 10px; }

@media (max-width: 700px) {
    .company-card { padding: 16px; }
    .company-head { flex-wrap: wrap; }
    .ap-row { flex-wrap: wrap; align-items: flex-start; }
    .ap-actions { width: 100%; justify-content: flex-end; }
    .ap-actions .btn { min-height: 40px; }
    .menu-panel { right: 0; left: auto; min-width: min(280px, 78vw); }
    .filter-bar input[type=search] { max-width: none; }
}

/* Einladungslink */
.invite-link { margin-top: 8px; }
.invite-link input {
    width: 100%; max-width: 480px; padding: 7px 10px; font-size: .8rem;
    background: var(--surface-2); border: 1px dashed var(--accent);
    border-radius: var(--radius-sm); color: var(--text); cursor: copy;
}

/* Vorschau-Banner (Matama-Orange als Highlight) */
.preview-bar {
    background: var(--highlight); color: #fff; text-align: center;
    padding: 9px 16px; font-size: .9rem; position: sticky; top: 0; z-index: 300;
    font-weight: 500;
}
.preview-bar a { color: #fff; text-decoration: underline; margin-left: 12px; font-weight: 700; }

/* Lade-Spinner */
.spinner-wrap { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 14px 0; font-size: .9rem; }
.spinner {
    width: 20px; height: 20px; border-radius: 50%;
    border: 3px solid var(--surface-2); border-top-color: var(--accent);
    animation: spin .8s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Datei-Viewer & Bewertung – bricht aus dem schmalen Container aus.
   Gilt so nur im Admin-Bereich, wo der Container mittig im Fenster sitzt. */
.viewer-card {
    text-align: center; padding: 12px;
    position: relative; left: 50%; transform: translateX(-50%);
    width: min(96vw, 1600px);
}
/* In der Kundenansicht steht der Inhalt NEBEN der Sidebar, ist also nicht
   fenster-mittig: der obige Ausbruch würde rechts aus dem Fenster ragen.
   Hier reicht der Ausbruch bis an die Container-Kanten. */
.portal-shell .viewer-card {
    left: auto; transform: none;
    width: auto;
    margin-left: calc(-1 * clamp(16px, 3vw, 40px));
    margin-right: calc(-1 * clamp(16px, 3vw, 40px));
}
.viewer-img { max-width: 100%; max-height: 85vh; border-radius: var(--radius-sm); user-select: none; -webkit-user-drag: none; }
.viewer-pdf { width: 100%; height: 85vh; min-height: 480px; border: none; border-radius: var(--radius-sm); background: #fff; }
@media (max-width: 600px) {
    .viewer-img { max-height: 70vh; }
    .viewer-pdf { height: 70vh; min-height: 360px; }
}
/* Wasserzeichen-Overlay auf nicht-finalen Entwürfen – reine Darstellung,
   in die Datei selbst wird NICHTS eingebrannt (siehe lib/watermark.php) */
.media-wrap { position: relative; display: inline-block; max-width: 100%; vertical-align: top; }
.media-wrap:has(.viewer-pdf) { display: block; }
.watermark-overlay {
    position: absolute; inset: 0;
    pointer-events: none; z-index: 5;
    background-repeat: repeat;
    border-radius: var(--radius-sm);
}
/* Eingeklappter System-/Debug-Bereich (Admin-Übersicht) */
.system-box summary { cursor: pointer; user-select: none; }
.system-box .system-box-inner { margin-top: 12px; display: grid; gap: 8px; justify-items: start; }

/* Aktivitäts-Feed: NEU seit letztem Besuch hervorheben, Älteres dimmen */
.event-new { background: rgba(0, 230, 118, .06); border-color: rgba(0, 230, 118, .35); }
.event-seen { opacity: .6; }

/* 🧵 Motiv-Verlauf (Versions-Faden: V1 → Review → V2 …) */
.flow { margin-top: 10px; }
.flow-step { display: flex; gap: 14px; position: relative; padding-bottom: 22px; }
.flow-step::before { content: ''; position: absolute; left: 21px; top: 46px; bottom: 0; width: 2px; background: var(--accent); opacity: .35; }
.flow-step:last-child { padding-bottom: 0; }
.flow-step:last-child::before { display: none; }
.flow-marker {
    flex: 0 0 44px; height: 44px; border-radius: 50%;
    border: 2px solid var(--accent); color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-heading); font-weight: 600; z-index: 1;
}
.flow-step.current .flow-marker { background: var(--accent); color: #1C1C1C; }
.flow-body { flex: 1; min-width: 0; text-align: left; }
.flow-head { display: flex; gap: 12px; align-items: center; }
.flow-thumb .thumb { width: 64px; height: 64px; object-fit: cover; }
.flow-comments { margin-top: 8px; display: grid; gap: 6px; }
.flow-comment { background: rgba(255, 111, 0, .07); border: 1px solid rgba(255, 111, 0, .3); padding: 6px 10px; border-radius: 6px; font-size: .9em; overflow-wrap: anywhere; }
.flow-comment.from-studio { background: rgba(0, 230, 118, .07); border-color: rgba(0, 230, 118, .3); }
.flow-author { color: var(--muted); margin-right: 4px; }

/* 📝 Interne Notizen (nur Admin) */
.note-card { border-color: var(--highlight); text-align: left; }

/* 🧵 Motiv-Verwaltung in der Datei-Ansicht (nur Admin) */
.motif-admin-card { border-color: var(--accent); text-align: left; }
.motif-admin-card .form { margin-bottom: 10px; }
.badge-version { border-color: var(--accent); color: var(--accent); }

/* Prominentes Revisions-Badge neben dem Dateititel */
.badge-rev {
    border-color: var(--accent); color: var(--accent);
    font-size: .45em; vertical-align: middle; white-space: nowrap;
}

/* Kleiner Button-Spinner (AJAX-Aktionen) */
.spinner.small { width: 14px; height: 14px; border-width: 2px; display: inline-block; vertical-align: middle; }

/* Sammel-Auswahl in der Studio-Dateitabelle */
.bulk-bar { display: none; align-items: center; gap: 10px; margin: 10px 0; }
.col-select { width: 30px; }
.col-select input[type=checkbox] { width: auto; margin: 0; cursor: pointer; }

/* 🔔 "Neu für dich"-Markierungen (Kundenansicht) */
.sidenav-badge--new { background: var(--highlight); color: #fff; }
.news-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--highlight); margin-left: 6px; vertical-align: middle; }
.badge-news { border-color: var(--highlight); color: var(--highlight); text-decoration: none; }
a.badge-news:hover { background: var(--highlight); color: #fff; text-decoration: none; }
.project-progress-badges { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.draft-card .badge-news { margin-top: 4px; display: inline-block; }

/* 📚 Ältere (ersetzte) Revisionen: aus der Haupttabelle ausgelagert, eingeklappt */
.row-superseded { opacity: .55; }
.old-revisions { margin-top: 14px; }
.old-revisions summary { cursor: pointer; display: inline-block; }
.old-revisions table { margin-top: 10px; }

/* 👁 Mail-Vorschau in der Benachrichtigungs-Warteschlange */
.mail-preview { margin-top: 12px; }
.mail-preview summary { cursor: pointer; display: inline-block; }
.mail-preview-box { margin-top: 10px; border: 1px solid var(--accent); border-radius: 8px; overflow: hidden; }
.mail-preview-meta { padding: 10px 14px; border-bottom: 1px solid rgba(255,255,255,.08); background: rgba(0,230,118,.05); }
.mail-preview-text {
    margin: 0; padding: 14px; white-space: pre-wrap; word-break: break-word;
    font-family: inherit; font-size: .92rem; line-height: 1.5; color: var(--text, #eee);
}
/* Vor/Zurück-Navigation zwischen Studio-Dateien */
.entwurf-nav {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    margin: 6px 0 14px;
}
.entwurf-nav .btn.disabled {
    opacity: .35; pointer-events: none;
}
.entwurf-nav-pos { white-space: nowrap; }

/* Bewertung oben hervorheben (Kundenansicht) */
.rate-card { border-color: var(--accent); box-shadow: var(--glow-green); }
.rate-hint { color: var(--highlight); }

.stars-form { display: flex; align-items: center; gap: 4px; }
.star-btn {
    background: none; border: none; cursor: pointer; padding: 0 3px;
    font-size: 2rem; line-height: 1; color: var(--surface-2);
    -webkit-text-stroke: 1px var(--muted); transition: color 150ms ease, transform 150ms ease;
}
.star-btn.active { color: #FFC400; -webkit-text-stroke: 0; }
.star-btn:hover { transform: scale(1.15); }
.star-btn.hover-fill { color: #FFC400; -webkit-text-stroke: 0; }
.stars-form.hovering .star-btn.active:not(.hover-fill) { color: var(--surface-2); -webkit-text-stroke: 1px var(--muted); }
.stars-small { color: #FFC400; letter-spacing: 2px; }
.review-counter { color: var(--muted); }

/* Flash */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin: 14px 0; font-size: .92rem; }
.flash-success { background: var(--accent-soft); border: 1px solid var(--accent); color: var(--accent); }
.flash-error { background: rgba(255,107,107,.12); border: 1px solid var(--error); color: var(--error); }

/* Login */
.login-box { max-width: 420px; margin-top: 8vh; text-align: center; }
.login-box .card { text-align: left; }
.login-brand { display: inline-flex; align-items: baseline; gap: 3px; margin-bottom: 4px; }
.login-brand .brand-wordmark { font-size: 1.6rem; }
.login-brand .brand-text { font-size: .78rem; }

/* Fehlerseiten (error_page()) */
.error-page { text-align: center; }
.error-page .error-code {
    display: inline-block; font-family: var(--font-heading); font-weight: 700;
    font-size: .72rem; letter-spacing: .06em; color: var(--error);
    background: rgba(255,107,107,.12); border: 1px solid var(--error);
    border-radius: 999px; padding: 3px 12px; margin-bottom: 14px;
}
.error-page .error-icon { font-size: 2.4rem; line-height: 1; margin: 4px 0 10px; }
.error-page p { margin: 8px 0 22px; }

/* Danger Zone */
.danger-zone { border-color: rgba(255,107,107,.4); }

@media (max-width: 600px) {
    .container { padding: 18px 14px 50px; }
    .msg { max-width: 100%; }
}

/* ============================================================
   Smartphone: Kopfzeile & Navigation
   Statt umbrechender Zeilen eine feste Kopfzeile mit horizontal
   scrollbarer Navigation – auf 360px genauso ruhig wie auf 414px.
   ============================================================ */
@media (max-width: 700px) {
    .topbar {
        padding: 10px 14px; gap: 10px;
        flex-wrap: nowrap; align-items: center;
        padding-left: max(14px, env(safe-area-inset-left));
        padding-right: max(14px, env(safe-area-inset-right));
    }
    .brand { min-width: 0; flex: none; }
    .brand-wordmark { font-size: 1.12rem; }
    .brand-text, .brand em { display: none; }

    .topbar-right { gap: 10px; min-width: 0; flex: 1; justify-content: flex-end; flex-wrap: nowrap; }
    .topbar nav {
        flex-wrap: nowrap; gap: 16px; overflow-x: auto; min-width: 0;
        scrollbar-width: none; -ms-overflow-style: none;
        -webkit-overflow-scrolling: touch;
        margin-right: 2px;
    }
    .topbar nav::-webkit-scrollbar { display: none; }
    .topbar nav a { white-space: nowrap; padding: 10px 0; font-size: .9rem; }

    .user-chip { padding: 6px 10px; font-size: .8rem; max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: none; }
    .user-menu-panel { min-width: 170px; }
}

/* Sehr schmale Geräte: Nutzer-Chip auf den Avatar reduzieren */
@media (max-width: 460px) {
    .user-chip { font-size: 0; padding: 5px; gap: 0; max-width: none; }
    .user-avatar { margin-right: 0; font-size: .68rem; }
    .user-menu summary.user-chip::after { content: ''; }
    .preview-bar { font-size: .82rem; padding: 8px 12px; }
    .preview-bar a { display: block; margin: 4px 0 0; }
}

/* Kunden-Sidebar auf dem Handy: Projektwahl oben, Bereiche als scrollbare Reiter */
@media (max-width: 700px) {
    .sidebar {
        flex-direction: column; align-items: stretch; gap: 10px;
        padding: 12px 14px;
        padding-left: max(14px, env(safe-area-inset-left));
        padding-right: max(14px, env(safe-area-inset-right));
    }
    .switcher, .switcher-single { width: 100%; margin-bottom: 0; }
    .sidenav {
        flex-direction: row; flex-wrap: nowrap; gap: 6px;
        overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none;
        -webkit-overflow-scrolling: touch;
    }
    .sidenav::-webkit-scrollbar { display: none; }
    .sidenav-item { flex: none; white-space: nowrap; padding: 11px 14px; min-height: 44px; }
    .sidenav-item.active { box-shadow: inset 0 -3px 0 var(--accent); }
    .sidebar-help { display: none; }
    .portal-shell .container { padding: 20px 14px 60px; }
}

/* ============================================================
   Neues Sidebar-Layout (Matama Design System, Kundenportal Phase 2)
   ============================================================ */

.topbar-right { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.user-avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; border-radius: 50%; margin-right: 8px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #08120d; font-family: var(--font-heading); font-weight: 700; font-size: .68rem;
    vertical-align: middle;
}

.portal-shell { display: flex; align-items: stretch; max-width: 1240px; margin: 0 auto; }
.portal-shell .container { flex: 1; min-width: 0; max-width: 880px; margin: 0; padding: 28px clamp(16px, 3vw, 40px) 60px; }

.sidebar {
    width: 244px; flex: none; border-right: 1px solid var(--border);
    background: rgba(37, 37, 37, .35); padding: 22px 14px; display: flex; flex-direction: column; gap: 4px;
    min-height: calc(100vh - 57px);
    /* Menü bleibt beim Scrollen stehen (Topbar ist 57px hoch und selbst sticky) */
    position: sticky; top: 57px; align-self: flex-start;
    max-height: calc(100vh - 57px); overflow-y: auto;
}

/* Projekt-Switcher */
.switcher { position: relative; margin-bottom: 14px; }
.switcher summary { list-style: none; cursor: pointer; }
.switcher summary::-webkit-details-marker { display: none; }
.switcher-current {
    display: flex; flex-direction: column; gap: 2px; padding: 10px 12px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    transition: border-color 150ms ease;
}
.switcher[open] .switcher-current { border-color: var(--accent); }
.switcher-current::after { content: '▾'; float: right; color: var(--muted); }
.switcher-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.switcher-name { font-weight: 700; color: var(--heading); font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.switcher-single {
    padding: 10px 12px; margin-bottom: 14px; font-weight: 700; color: var(--heading); font-size: .92rem;
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
}
.switcher-panel {
    position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 210;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .4); padding: 6px; display: flex; flex-direction: column; gap: 2px;
    max-height: 260px; overflow-y: auto;
}
.switcher-option { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border-radius: 6px; color: var(--text); }
.switcher-option:hover { background: var(--surface-2); text-decoration: none; }
.switcher-option.active { color: var(--accent); background: var(--accent-soft); }
.switcher-option-status { font-size: .74rem; color: var(--muted); }

/* Sidebar-Navigation */
.sidenav { display: flex; flex-direction: column; gap: 2px; }
.sidenav-item {
    display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
    font-family: var(--font-heading); font-weight: 600; font-size: .92rem;
    padding: 11px 12px; border-radius: 9px; color: var(--muted);
    transition: all 150ms ease;
}
.sidenav-item:hover { color: var(--text); background: rgba(255, 255, 255, .04); text-decoration: none; }
.sidenav-item.active { background: var(--accent-soft); color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.sidenav-icon { font-size: 1.05rem; line-height: 1; }
.sidenav-label { flex: 1; }
.sidenav-badge {
    min-width: 20px; text-align: center; background: var(--accent); color: #08120d;
    border-radius: 999px; font-size: .72rem; font-weight: 700; padding: 1px 7px;
}
.sidebar-help { margin-top: auto; padding: 14px 12px 4px; border-top: 1px solid var(--border); }
.sidebar-help-text { font-size: .78rem; color: var(--muted); margin-bottom: 10px; }
.sidebar-help-cta { display: block; width: 100%; text-align: center; padding: 9px 14px; }

@media (max-width: 900px) {
    .portal-shell { flex-direction: column; }
    .sidebar {
        width: auto; min-height: 0; border-right: none; border-bottom: 1px solid var(--border);
        flex-direction: row; flex-wrap: wrap; align-items: center;
        position: static; max-height: none; overflow: visible;
    }
    .switcher, .switcher-single { margin-bottom: 0; }
    .sidenav { flex-direction: row; flex-wrap: wrap; }
    .sidebar-help { margin-top: 0; padding: 0; border-top: none; }
    .sidebar-help-text { display: none; }
    .sidebar-help-cta { width: auto; }
}

/* Dashboard */
.dash-head { margin-bottom: 22px; }
.dash-eyebrow { font-size: .8rem; color: var(--accent); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.dash-head h1 { margin: 6px 0 0; }
.dash-head p { margin: 6px 0 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; }
.stat-card-num { font-family: var(--font-heading); font-weight: 800; font-size: 1.9rem; color: var(--accent); }
.stat-card-num--white { color: var(--heading); }
.stat-card-num--orange { color: var(--highlight); }
.stat-card-label { color: var(--muted); font-size: .9rem; margin-top: 2px; }

.project-progress-card { margin-top: 0; }
.project-progress-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.project-progress-head h2 { margin: 0; }

.dash-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.dash-cols .card { margin-top: 0; }
.dash-cols h3 { margin-bottom: 14px; }

.activity-feed { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.activity-item { display: flex; gap: 12px; align-items: flex-start; }
.activity-icon {
    width: 30px; height: 30px; flex: none; border-radius: 8px;
    display: flex; align-items: center; justify-content: center; font-size: .95rem;
}
.activity-icon--green { background: var(--accent-soft); }
.activity-icon--blue { background: rgba(38, 128, 234, .14); }
.activity-icon--orange { background: rgba(255, 111, 0, .14); }
.activity-text { color: var(--text); font-size: .92rem; }
.activity-time { margin-top: 1px; }

.next-steps { display: flex; flex-direction: column; gap: 10px; }
.next-step-btn {
    text-align: left; background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
    font: inherit; padding: 13px 16px; border-radius: 9px; display: flex; align-items: center;
    justify-content: space-between; transition: all 150ms ease;
}
.next-step-btn:hover { border-color: var(--accent); text-decoration: none; }
.next-step-arrow { color: var(--accent); }
.next-step-arrow--orange { color: var(--highlight); }

/* Entwürfe-Karten (projekt.php) */
.panel-section { display: none; }
.panel-section.active { display: block; animation: ms-fade .25s ease both; }
@keyframes ms-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.panel-section-head { margin-bottom: 18px; }
.panel-section-head h2 { margin-bottom: 4px; }

.draft-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.draft-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; transition: border-color 150ms ease; }
.draft-card:hover { border-color: var(--accent); }
.draft-card-cover {
    position: relative; display: block; aspect-ratio: 4/3; overflow: hidden;
    background: var(--surface-2);
}
.draft-card-cover .thumb { width: 100%; height: 100%; border-radius: 0; border: none; }
.draft-card-cover .thumb-icon { width: 100%; height: 100%; justify-content: center; gap: 6px; }
.draft-card-cover .thumb-emoji { font-size: 2.2rem; }
.draft-card-new {
    position: absolute; top: 10px; right: 10px; font-size: .72rem; font-weight: 700;
    padding: 3px 10px; border-radius: 999px; background: var(--highlight); color: #fff; z-index: 6;
}
.draft-card-body { padding: 16px 18px 18px; }
.draft-card-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.draft-card-title-row h3 { font-size: 1.02rem; font-weight: 700; margin: 0; }
.draft-card-title-row h3 a { color: var(--heading); }
.draft-card-title-row h3 a:hover { color: var(--accent); text-decoration: none; }
.draft-card-tag { white-space: nowrap; flex: none; }
.draft-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.draft-card-stars { gap: 1px; }
.draft-card-stars .star-btn { font-size: 1.3rem; padding: 0 1px; }

/* Dateien-Upload (projekt.php) */
.upload-dropzone-form { margin-bottom: 26px; }
.upload-dropzone {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    text-align: center; padding: 38px 20px; border: 1.5px dashed var(--border); border-radius: 14px;
    background: rgba(37, 37, 37, .5); cursor: pointer; transition: all 150ms ease; margin-bottom: 12px;
}
.upload-dropzone:hover { border-color: var(--accent); }
.upload-dropzone input[type=file] { display: none; }
.upload-dropzone-icon { font-size: 2rem; }
.upload-dropzone-text { font-weight: 700; color: var(--heading); }
.upload-dropzone-submit { display: block; margin: 0 auto; }
.dateien-list-title { margin-bottom: 12px; }

.file-row-list { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.file-row { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--surface-2); transition: background 150ms ease; }
.file-row:last-child { border-bottom: none; }
.file-row:hover { background: rgba(0, 230, 118, .04); }
.file-row-thumb { flex: none; }
.file-row-info { flex: 1; min-width: 0; }
.file-row-name { font-weight: 700; color: var(--heading); font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-row-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.file-row-actions form { margin: 0; }

/* Nachrichten (projekt.php) */
.chat-card .chat { margin-bottom: 16px; }

/* 🔗 Projekt-Links (Web-Projekte ohne Entwurfs-Freigabe) */
.link-card { border-color: var(--accent); }
.link-list { display: grid; gap: 10px; margin-top: 12px; }
.link-item {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-2); color: var(--text); transition: border-color 150ms ease;
}
.link-item:hover { border-color: var(--accent); text-decoration: none; }
.link-item-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.link-item-main strong { color: var(--heading); }
.link-item-go { color: var(--accent); font-weight: 700; font-size: .85rem; white-space: nowrap; }

/* 🔐 Zugangsdaten-Tresor */
.secret-reveal { border-color: var(--highlight); }
.secret-plain {
    margin: 10px 0 14px; padding: 14px 16px;
    background: var(--bg); border: 1px solid var(--highlight); border-radius: var(--radius-sm);
    color: var(--text); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .92rem; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
    user-select: all;
}
.secret-row { align-items: flex-start; }

/* Rechnungen & Abo */
.abo-hero {
    position: relative; overflow: hidden;
    background: linear-gradient(135deg, rgba(0, 230, 118, .12), rgba(37, 37, 37, .9));
    border: 1px solid var(--accent); border-radius: var(--radius);
    padding: 24px 26px; margin: 16px 0;
}
.abo-hero-row { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.abo-hero-eyebrow {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .12em;
    color: var(--accent); font-weight: 700; margin-bottom: 4px;
}
.abo-hero h2 { margin: 0 0 4px; font-size: 1.4rem; }
.abo-hero-price { text-align: right; }
.abo-hero-amount { font-family: var(--font-heading); font-weight: 800; font-size: 1.9rem; color: var(--heading); white-space: nowrap; }
.abo-hero-amount span { font-size: .9rem; font-weight: 400; color: var(--muted); }
.abo-hero-meta {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px;
    margin-top: 20px; padding-top: 18px; border-top: 1px solid rgba(255, 255, 255, .1);
}
.abo-hero-meta-label { font-size: .78rem; color: var(--muted); margin-bottom: 2px; }
.abo-hero-meta-value { font-weight: 700; color: var(--text); }
.abos-extra-title { margin: 28px 0 10px; font-size: 1.05rem; }

/* Dokument-Tabellen (Angebote, Rechnungen, weitere Abos) */
.doc-table { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.doc-row {
    display: grid;
    grid-template-columns: minmax(90px, 1.1fr) minmax(90px, 1fr) minmax(80px, .9fr) minmax(90px, 1fr) auto;
    gap: 10px 14px; align-items: center;
    padding: 11px 14px; border-bottom: 1px solid var(--border);
    font-size: .9rem;
}
.doc-row:last-child { border-bottom: none; }
.doc-row--head { background: var(--surface-2); color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.doc-row:not(.doc-row--head):hover { background: rgba(0, 230, 118, .04); }
.doc-row-num { font-weight: 700; color: var(--heading); word-break: break-word; }
.doc-row-amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc-row-action { text-align: right; white-space: nowrap; }
.doc-row-action a { font-weight: 700; font-size: .85rem; }
.doc-row .badge { justify-self: start; }

@media (max-width: 700px) {
    /* Mobil: Karten-Layout statt Tabellenraster – jede Angabe bekommt ihre Zeile */
    .doc-row { grid-template-columns: 1fr auto; gap: 4px 12px; padding: 14px; }
    .doc-row--head { display: none; }
    .doc-row-num { grid-column: 1; font-size: 1rem; }
    .doc-row-action { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
    .doc-row > div:not(.doc-row-num):not(.doc-row-action) { grid-column: 1; color: var(--muted); font-size: .85rem; }
    .abo-hero { padding: 20px; }
    .abo-hero-price { text-align: left; }
}