/* ======================================================
   METHODIO APP — Dashboard CSS
   Baut auf styles.css Tokens auf (--primary, --bg-dark etc.)
   Version: 1.0 · 2026
====================================================== */

/* ---------- App-spezifische Tokens ---------- */

:root {
    --app-bg:        #0c1221;
    --app-surface:   #141928;
    --app-surface2:  #1b2235;
    --app-surface3:  #212840;
    --app-border:    rgba(255, 255, 255, 0.06);
    --app-border2:   rgba(255, 255, 255, 0.11);
    --app-text:      #e8eaf2;
    --app-text-soft: #7c8299;
    --app-text-muted:#424862;

    /* Ampelfarben */
    --gruen:         #22c55e;
    --gruen-dim:     rgba(34, 197, 94, 0.10);
    --gelb:          #f59e0b;
    --gelb-dim:      rgba(245, 158, 11, 0.10);
    --rot:           #ef4444;
    --rot-dim:       rgba(239, 68, 44, 0.10);
    --blau:          #3b82f6;
    --blau-dim:      rgba(59, 130, 246, 0.10);

    /* Orange aus styles.css übernommen */
    --orange-dim:    rgba(255, 87, 34, 0.10);
    --orange-glow:   rgba(255, 87, 34, 0.20);

    --app-radius:    10px;
    --app-radius-sm: 7px;

    --sidebar-width: 224px;
}

/* ---------- Reset für App-Bereich ---------- */

body.app-body {
    background: var(--app-bg);
    color: var(--app-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    margin: 0;
}

/* ======================================================
   SIDEBAR
====================================================== */

.app-sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--app-surface);
    border-right: 1px solid var(--app-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 20px 18px 18px;
    border-bottom: 1px solid var(--app-border);
    flex-shrink: 0;
}

.sidebar-logo svg {
    width: 118px;
    height: auto;
    display: block;
}

.sidebar-logo-tag {
    font-size: 9px;
    color: var(--app-text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-top: 6px;
    font-family: monospace;
}

/* Nav */
.sidebar-nav {
    padding: 10px 8px;
    flex: 1;
}

.nav-section-label {
    font-size: 9px;
    color: var(--app-text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 10px 10px 4px;
    display: block;
    font-family: monospace;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: var(--app-radius-sm);
    cursor: pointer;
    color: var(--app-text-soft);
    font-size: 13px;
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
    margin-bottom: 1px;
    border: 1px solid transparent;
}

.nav-item:hover {
    background: var(--app-surface2);
    color: var(--app-text);
}

.nav-item.active {
    background: var(--orange-dim);
    color: var(--primary);
    font-weight: 500;
    border-color: rgba(255, 87, 34, 0.18);
}

.nav-item .nav-icon {
    width: 16px;
    text-align: center;
    font-size: 14px;
    flex-shrink: 0;
}

.nav-badge {
    margin-left: auto;
    background: var(--primary);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 999px;
    min-width: 18px;
    text-align: center;
    font-family: monospace;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px 8px;
    border-top: 1px solid var(--app-border);
    flex-shrink: 0;
}

.mode-toggle {
    background: var(--app-surface2);
    border: 1px solid var(--app-border2);
    border-radius: var(--app-radius-sm);
    padding: 3px;
    display: flex;
    margin-bottom: 10px;
}

.mode-btn {
    flex: 1;
    padding: 5px;
    border-radius: 5px;
    border: none;
    background: transparent;
    color: var(--app-text-muted);
    font-size: 10px;
    cursor: pointer;
    transition: all 0.12s;
    letter-spacing: 0.03em;
    font-family: monospace;
}

.mode-btn.active {
    background: var(--app-surface3);
    color: var(--app-text);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: var(--app-radius-sm);
    background: var(--app-surface2);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--orange-dim);
    border: 1.5px solid rgba(255, 87, 34, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 10px;
    color: var(--primary);
    flex-shrink: 0;
}

.user-name { font-size: 12px; font-weight: 500; color: var(--app-text); }
.user-role { font-size: 10px; color: var(--app-text-muted); font-family: monospace; }

/* ======================================================
   MAIN LAYOUT
====================================================== */

.app-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.app-topbar {
    height: 52px;
    border-bottom: 1px solid var(--app-border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 14px;
    background: var(--app-bg);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-title {
    font-weight: 700;
    font-size: 15px;
    color: var(--app-text);
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-date {
    font-size: 11px;
    color: var(--app-text-soft);
    font-family: monospace;
}

/* Content */
.app-content {
    padding: 24px;
    flex: 1;
}

/* ======================================================
   BUTTONS (App-Varianten)
====================================================== */

.app-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 13px;
    border-radius: var(--app-radius-sm);
    border: none;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.12s;
    font-family: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.app-btn-primary {
    background: var(--primary);
    color: #fff;
}

.app-btn-primary:hover { background: var(--primary-dark); }

.app-btn-ghost {
    background: transparent;
    color: var(--app-text-soft);
    border: 1px solid var(--app-border2);
}

.app-btn-ghost:hover {
    color: var(--app-text);
    background: var(--app-surface2);
}

.app-btn-danger {
    background: transparent;
    color: var(--rot);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.app-btn-danger:hover { background: var(--rot-dim); }

/* Icon Buttons */
.ico-btn {
    width: 26px;
    height: 26px;
    border-radius: 5px;
    border: 1px solid var(--app-border2);
    background: transparent;
    color: var(--app-text-soft);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.1s;
}

.ico-btn:hover { background: var(--app-surface2); color: var(--app-text); }
.ico-btn.approve:hover { background: var(--gruen-dim); color: var(--gruen); border-color: rgba(34, 197, 94, 0.3); }
.ico-btn.reject:hover  { background: var(--rot-dim);   color: var(--rot);   border-color: rgba(239, 68, 68, 0.3); }

/* ======================================================
   KPI CARDS
====================================================== */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 22px;
}

.kpi-grid-5 {
    grid-template-columns: repeat(5, 1fr);
}

.kpi-card {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    padding: 18px;
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s;
    animation: fadeUp 0.35s ease both;
}

.kpi-card:nth-child(1) { animation-delay: 0.04s; }
.kpi-card:nth-child(2) { animation-delay: 0.08s; }
.kpi-card:nth-child(3) { animation-delay: 0.12s; }
.kpi-card:nth-child(4) { animation-delay: 0.16s; }
.kpi-card:nth-child(5) { animation-delay: 0.20s; }

.kpi-card:hover { border-color: var(--app-border2); }

.kpi-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    border-radius: var(--app-radius) var(--app-radius) 0 0;
}

.kpi-orange::after { background: var(--primary); }
.kpi-green::after  { background: var(--gruen); }
.kpi-yellow::after { background: var(--gelb); }
.kpi-red::after    { background: var(--rot); }
.kpi-blue::after   { background: var(--blau); }

.kpi-label {
    font-size: 9px;
    color: var(--app-text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 10px;
    font-family: monospace;
}

.kpi-value {
    font-weight: 800;
    font-size: 28px;
    color: var(--app-text);
    line-height: 1;
    margin-bottom: 5px;
}

.kpi-value-sm { font-size: 20px; }

.kpi-sub { font-size: 11px; color: var(--app-text-soft); }

.kpi-icon {
    position: absolute;
    top: 14px; right: 14px;
    font-size: 18px;
    opacity: 0.15;
}

/* ======================================================
   PANELS
====================================================== */

.app-panel {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    overflow: hidden;
    margin-bottom: 20px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 18px;
    border-bottom: 1px solid var(--app-border);
    background: var(--app-surface2);
}

.panel-title {
    font-weight: 700;
    font-size: 13px;
    color: var(--app-text);
}

.panel-actions {
    display: flex;
    gap: 6px;
}

/* ======================================================
   ANFRAGEN TABELLE
====================================================== */

.anfragen-table {
    width: 100%;
}

.t-head,
.t-row {
    display: grid;
    grid-template-columns: 30px 1fr 140px 90px 110px 120px 90px;
    padding: 0 18px;
    align-items: center;
}

.t-head {
    padding-top: 9px;
    padding-bottom: 9px;
    background: var(--app-surface2);
    border-bottom: 1px solid var(--app-border);
}

.t-col {
    font-size: 9px;
    color: var(--app-text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-family: monospace;
}

.t-row {
    padding-top: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--app-border);
    cursor: pointer;
    transition: background 0.1s;
    text-decoration: none;
    color: inherit;
}

.t-row:last-child { border-bottom: none; }
.t-row:hover { background: var(--app-surface2); }

.t-row.selected {
    background: rgba(255, 87, 34, 0.05);
    border-left: 2px solid var(--primary);
    padding-left: 16px;
}

/* Ampel Dot */
.ampel-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin: 0 auto;
}

.dot-gruen  { background: var(--gruen);  box-shadow: 0 0 5px var(--gruen); }
.dot-gelb   { background: var(--gelb);   box-shadow: 0 0 5px var(--gelb); }
.dot-rot    { background: var(--rot);    box-shadow: 0 0 5px var(--rot); }

.row-title  { font-size: 13px; font-weight: 500; color: var(--app-text); }
.row-sub    { font-size: 11px; color: var(--app-text-soft); margin-top: 1px; }

.row-actions { display: flex; gap: 5px; }

/* ======================================================
   BADGES
====================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
    font-family: monospace;
    white-space: nowrap;
}

.badge-gruen  { background: var(--gruen-dim);  color: var(--gruen); }
.badge-gelb   { background: var(--gelb-dim);   color: var(--gelb); }
.badge-rot    { background: var(--rot-dim);    color: var(--rot); }
.badge-blau   { background: var(--blau-dim);   color: var(--blau); }
.badge-orange { background: var(--orange-dim); color: var(--primary); }
.badge-neutral{ background: var(--app-surface2); color: var(--app-text-soft); }

/* ======================================================
   DETAIL PANEL
====================================================== */

.detail-panel {
    display: none;
    margin-bottom: 20px;
}

.detail-panel.open { display: block; }

.detail-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--app-border);
}

.detail-title {
    font-weight: 800;
    font-size: 17px;
    color: var(--app-text);
    margin-bottom: 3px;
}

.detail-meta {
    font-size: 11px;
    color: var(--app-text-soft);
    font-family: monospace;
}

.detail-body { padding: 18px 20px; }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.detail-block {
    background: var(--app-surface2);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-sm);
    padding: 11px 13px;
}

.detail-block-label {
    font-size: 9px;
    color: var(--app-text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 3px;
    font-family: monospace;
}

.detail-block-value {
    font-size: 13px;
    color: var(--app-text);
    font-weight: 500;
}

/* Positions Tabelle */
.pos-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 14px;
    font-size: 12px;
}

.pos-table th {
    text-align: left;
    font-size: 9px;
    color: var(--app-text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 7px 10px;
    border-bottom: 1px solid var(--app-border);
    background: var(--app-surface2);
    font-family: monospace;
    font-weight: 400;
}

.pos-table td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--app-border);
    color: var(--app-text);
}

.pos-table tr:last-child td { border-bottom: none; }
.pos-table .mono { font-family: monospace; }
.pos-table .muted { color: var(--app-text-soft); }

/* Zusammenfassung */
.detail-summary {
    display: flex;
    justify-content: flex-end;
    gap: 22px;
    padding: 14px 0 0;
    border-top: 1px solid var(--app-border);
}

.sum-item { text-align: right; }
.sum-label { font-size: 10px; color: var(--app-text-soft); margin-bottom: 2px; }
.sum-value { font-family: monospace; font-size: 13px; font-weight: 500; color: var(--app-text); }
.sum-value.total { font-size: 17px; color: var(--primary); }

/* Detail Aktionen */
.detail-actions {
    display: flex;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--app-border);
    background: var(--app-surface2);
}

/* ======================================================
   ZEITFILTER (Auswertung)
====================================================== */

.time-filter {
    display: flex;
    gap: 3px;
    margin-bottom: 20px;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-sm);
    padding: 3px;
    width: fit-content;
}

.tf-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 5px;
    background: transparent;
    color: var(--app-text-soft);
    font-size: 10px;
    cursor: pointer;
    transition: all 0.12s;
    white-space: nowrap;
    font-family: monospace;
}

.tf-btn:hover { color: var(--app-text); }
.tf-btn.active { background: var(--app-surface3); color: var(--app-text); }

/* ======================================================
   CHARTS (einfache CSS-Balken)
====================================================== */

.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 14px;
}

.chart-body {
    padding: 16px 18px;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bar-label {
    font-size: 11px;
    color: var(--app-text-soft);
    width: 90px;
    flex-shrink: 0;
}

.bar-track {
    flex: 1;
    height: 6px;
    background: var(--app-surface2);
    border-radius: 3px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}

.bar-value {
    font-family: monospace;
    font-size: 11px;
    color: var(--app-text);
    width: 60px;
    text-align: right;
    flex-shrink: 0;
}

/* Donut */
.donut-wrap {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 8px 0;
}

.donut-svg { width: 100px; height: 100px; flex-shrink: 0; }

.donut-legend { display: flex; flex-direction: column; gap: 8px; flex: 1; }

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--app-text-soft);
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-val {
    margin-left: auto;
    font-family: monospace;
    font-size: 11px;
}

/* ======================================================
   LITE MODE
====================================================== */

.lite-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
}

.lite-card {
    background: var(--app-surface2);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 13px;
    cursor: pointer;
    transition: border-color 0.12s;
}

.lite-card:hover { border-color: var(--app-border2); }

.lite-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
}

.lite-icon.gruen  { background: var(--gruen-dim); }
.lite-icon.gelb   { background: var(--gelb-dim); }
.lite-icon.rot    { background: var(--rot-dim); }

.lite-info { flex: 1; }
.lite-name { font-size: 14px; font-weight: 600; color: var(--app-text); margin-bottom: 2px; }
.lite-sub  { font-size: 11px; color: var(--app-text-soft); }

.lite-price     { font-family: monospace; font-size: 15px; color: var(--app-text); text-align: right; }
.lite-price-sub { font-size: 10px; color: var(--app-text-muted); text-align: right; }

.lite-actions { display: flex; gap: 7px; flex-shrink: 0; }

.lite-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--app-radius-sm);
    border: none;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s;
    background: var(--app-surface3);
    color: var(--app-text-soft);
}

.lite-btn:hover { color: var(--app-text); }
.lite-btn.approve { background: var(--gruen-dim); color: var(--gruen); }
.lite-btn.approve:hover { background: var(--gruen); color: #fff; }

/* Standard/Lite Visibility */
body.lite-mode .standard-only { display: none; }
body:not(.lite-mode) .lite-only { display: none; }

/* ======================================================
   MODAL (Preis anpassen)
====================================================== */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 500;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
    background: var(--app-surface);
    border: 1px solid var(--app-border2);
    border-radius: var(--app-radius);
    padding: 24px;
    width: min(440px, calc(100vw - 40px));
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-title {
    font-weight: 700;
    font-size: 15px;
    color: var(--app-text);
    margin-bottom: 16px;
}

.modal-field { margin-bottom: 14px; }

.modal-label {
    display: block;
    font-size: 11px;
    color: var(--app-text-soft);
    margin-bottom: 5px;
    font-family: monospace;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.modal-input {
    width: 100%;
    padding: 9px 12px;
    background: var(--app-surface2);
    border: 1px solid var(--app-border2);
    border-radius: var(--app-radius-sm);
    color: var(--app-text);
    font-size: 13px;
    font-family: monospace;
    transition: border-color 0.12s;
}

.modal-input:focus {
    outline: none;
    border-color: rgba(255, 87, 34, 0.4);
    box-shadow: 0 0 0 3px var(--orange-dim);
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--app-border);
}

/* ======================================================
   STAMMDATEN TABELLE (daten.html)
====================================================== */

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    text-align: left;
    font-size: 9px;
    color: var(--app-text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 9px 14px;
    border-bottom: 1px solid var(--app-border);
    background: var(--app-surface2);
    font-family: monospace;
    font-weight: 400;
}

.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--app-border);
    color: var(--app-text);
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tr:hover td { background: var(--app-surface2); }

.data-table .mono { font-family: monospace; font-size: 12px; }
.data-table .muted { color: var(--app-text-soft); }

/* ======================================================
   NOTIFICATIONS / PULSE
====================================================== */

.pulse {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
    margin-left: 6px;
    vertical-align: middle;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ======================================================
   EMPTY STATE
====================================================== */

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--app-text-soft);
}

.empty-state-icon { font-size: 32px; margin-bottom: 12px; opacity: 0.4; }
.empty-state-title { font-weight: 600; font-size: 14px; color: var(--app-text); margin-bottom: 6px; }
.empty-state-sub { font-size: 12px; }

/* ======================================================
   ANIMATIONS
====================================================== */

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fade-up { animation: fadeUp 0.3s ease both; }

/* ======================================================
   RESPONSIVE (Tablet)
====================================================== */

@media (max-width: 1100px) {
    :root { --sidebar-width: 200px; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .kpi-grid-5 { grid-template-columns: repeat(3, 1fr); }
    .detail-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    :root { --sidebar-width: 0px; }
    .app-sidebar { display: none; }
    .app-main { margin-left: 0; }
    .t-head, .t-row { grid-template-columns: 28px 1fr 80px 70px; }
    .t-col:nth-child(n+5), .t-row > *:nth-child(n+5) { display: none; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .chart-grid { grid-template-columns: 1fr; }
}