:root {
    --bg-color: #000000;
    --card-bg: #1c1c1e;
    --card-inner: #2c2c2e;
    --text-main: #ffffff;
    --text-muted: #8e8e93;
    --accent-green: #30d158;
    --accent-blue: #0a84ff;
    --accent-red: #ff3b30;
    --border-radius: 16px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.app-container {
    width: 100%;
    max-width: 600px;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

header h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

header .version-badge {
    background: #2c2c2e;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    color: #ffffff;
}

/* Navigation Pills */
nav {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    background: #1c1c1e;
    padding: 6px;
    border-radius: 12px;
    margin-bottom: 24px;
}

nav button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px 4px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
}

nav button.active {
    background: #2c2c2e;
    color: #ffffff;
}

nav button.active.status-green {
    background: var(--accent-green);
    color: #000000;
}

/* Main Content Area */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

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

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #333;
}

.card-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.badge-crm {
    background: var(--accent-blue);
    color: white;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
}

.badge-green {
    background: var(--accent-green);
    color: black;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
}

.badge-blue {
    background: var(--accent-blue);
    color: white;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
}

/* Recording UI */
.recording-ui {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 40px 0;
}

/* Premium Recording UI */
.main-mic-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 50px 20px;
}

.mic-container {
    position: relative;
    width: 120px;
    height: 120px;
    background: #ffffff;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 2;
    margin-bottom: 20px;
}

.mic-container .mic-svg {
    width: 45px;
    height: 45px;
    color: #000;
    position: relative;
    z-index: 3;
}

.mic-ring {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    z-index: 1;
    transition: all 0.4s ease;
}

.mic-container.recording {
    background: #ff3b30;
    transform: scale(1.1);
}

.mic-container.recording .mic-svg {
    color: #fff;
}

.mic-container.recording .mic-ring {
    animation: ripple 1.5s infinite;
    background: rgba(255, 59, 48, 0.3);
}

@keyframes ripple {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.8); opacity: 0; }
}

.status-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 10px;
}

.progress-wrapper {
    width: 100%;
    margin-top: 30px;
}

.progress-bar {
    height: 6px;
    background: #2c2c2e;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    width: 0%;
    height: 100%;
    background: var(--accent-green);
    transition: width 0.4s ease;
}

.progress-status {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 8px;
}

/* Terminal Output Colors */
.event-log {
    background: #000000;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 15px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    max-height: 200px;
    overflow-y: auto;
    color: var(--accent-blue); /* Terminal-Blau */
    box-shadow: inset 0 0 20px rgba(10, 132, 255, 0.05);
    position: relative;
    overflow-x: hidden;
}

.event-item.info {
    color: var(--accent-blue);
}

.event-item.system {
    color: #0070e0;
    opacity: 0.8;
}

/* Side-by-Side Layout for Address and Terminal */
.address-terminal-container {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.address-terminal-container .editable-area {
    flex: 1;
}

.terminal-mini {
    flex: 1;
    max-width: 50%;
    height: 120px;
    font-size: 11px;
    margin-bottom: 0 !important;
}

/* Scanline Effekt Update für Blau */
.event-log::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(0, 0, 255, 0.06), rgba(0, 100, 255, 0.02), rgba(0, 0, 255, 0.06));
    z-index: 10;
    background-size: 100% 4px, 3px 100%;
    pointer-events: none;
}

.event-item.error {
    color: #ff3b30;
    font-weight: bold;
}

/* Scrollbar für Terminal */
.event-log::-webkit-scrollbar {
    width: 6px;
}
.event-log::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

/* Form Elements */
.content-area {
    background: var(--card-inner);
    border-radius: 12px;
    padding: 15px;
    font-size: 14px;
    line-height: 1.5;
    min-height: 80px;
}

.item-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.item-row {
    background: var(--card-inner);
    padding: 12px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;
    font-weight: 700;
    font-size: 18px;
}
.total-value { color: var(--accent-green); }

.mic-container.green {
    background: var(--accent-green);
}

.mic-container.green .mic-svg {
    color: #000000;
}

.mic-container.green:hover {
    transform: scale(1.08);
    background: #28b84d;
}

.green-ring {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 50%;
    background: rgba(48, 209, 88, 0.2);
    z-index: 1;
    transition: all 0.4s ease;
}

.button-group {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 20px;
    width: 100%;
}

.button-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.mic-container.orange {
    background: var(--accent-orange, #ff9500);
}

.mic-container.orange .mic-svg {
    color: #000000;
}

.mic-container.orange:hover {
    transform: scale(1.08);
    background: #ffaa33;
}

.orange-ring {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 50%;
    background: rgba(255, 149, 0, 0.2);
    z-index: 1;
    transition: all 0.4s ease;
}

.mic-container.small {
    width: 65px;
    height: 65px;
    margin-bottom: 8px;
    margin-top: 0;
}

.mic-container.small .mic-svg {
    width: 28px;
    height: 28px;
}

.mic-container.blue {
    background: #0a84ff;
}

.mic-container.blue .mic-svg {
    color: #ffffff;
}

.mic-container.blue:hover {
    transform: scale(1.08);
    background: #0070e0;
}

.blue-ring {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 50%;
    background: rgba(10, 132, 255, 0.2);
    z-index: 1;
    transition: all 0.4s ease;
}

/* Editable Elements Styles */
.editable-area {
    width: 100%;
    background: var(--card-inner);
    border: 1px solid #444;
    border-radius: 12px;
    padding: 15px;
    font-family: var(--font-family);
    font-size: 14px;
    color: var(--text-main);
    line-height: 1.5;
    resize: vertical;
    transition: all 0.2s ease;
}

.editable-area:focus {
    outline: none;
    border-color: var(--accent-blue);
    background: #1c1c1e;
    box-shadow: 0 0 10px rgba(10, 132, 255, 0.1);
}

/* Missing Data Highlighting */
.missing-data {
    border: 1px solid rgba(255, 69, 58, 0.5) !important;
    background: rgba(255, 69, 58, 0.05) !important;
    box-shadow: 0 0 10px rgba(255, 69, 58, 0.2);
    animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 5px rgba(255, 69, 58, 0.2); }
    50% { box-shadow: 0 0 15px rgba(255, 69, 58, 0.4); }
    100% { box-shadow: 0 0 5px rgba(255, 69, 58, 0.2); }
}

.price-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.item-qty { width: 60px; text-align: center; }
.item-label { flex: 3; }
.item-price { width: 100px; text-align: right; }

.item-row input {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: var(--font-family);
    font-size: 14px;
    width: 100%;
}

/* Rückfrage "als neuen Preis übernehmen". Erscheint nur, wenn der Preis einer
   Katalogposition geändert wurde - sonst wäre sie bei jeder Zeile im Weg. */
.price-learn {
    flex-basis: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 11px;
    color: var(--text-muted);
    cursor: pointer;
}

.price-learn input[type="checkbox"] {
    width: auto !important;
    accent-color: var(--accent-blue);
    cursor: pointer;
}

/* Die Zeile muss umbrechen dürfen, damit die Rückfrage darunter Platz hat. */
.item-row {
    flex-wrap: wrap;
}

/* Diktierter Preis statt Katalogpreis. Bewusst auffällig: eine verhörte Zahl
   landet sonst ungeprüft auf der Offerte. */
.price-spoken {
    color: var(--accent-green) !important;
    font-weight: 700;
    text-decoration: underline dotted;
    text-underline-offset: 3px;
}

/* Dritter Zustand (CATALOG-AND-QUOTES-DESIGN.md §6): Position erkannt, aber
   noch ohne Preis. Muss nach "hier fehlt etwas" aussehen - nicht nach 0.00,
   das wie ein gewolltes Gratisangebot durchginge. */
.price-unpriced {
    border: 1px dashed var(--accent-yellow, #ffd60a) !important;
    background: rgba(255, 214, 10, 0.08) !important;
}

.item-qty {
    width: 50px !important;
    color: var(--accent-blue) !important;
    font-weight: 700;
    text-align: center;
}

.item-label {
    flex-grow: 1;
    margin: 0 10px;
}

.item-price {
    width: 80px !important;
    text-align: right;
    font-weight: 600;
}

.btn-mini-save {
    background: rgba(10, 132, 255, 0.1);
    border: 1px solid rgba(10, 132, 255, 0.3);
    color: var(--accent-blue);
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-mini-save:hover {
    background: var(--accent-blue);
    color: white;
}

.btn-secondary {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid #333;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 12px;
    cursor: pointer;
    margin-top: 10px;
}

/* Admin Dashboard */
.admin-dashboard {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-top: 10px;
}

.metric-item {
    background: var(--card-inner);
    padding: 15px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.metric-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.metric-value {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
}

.status-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.status-pill {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.status-pill.green { background: rgba(48, 209, 88, 0.1); color: var(--accent-green); border: 1px solid rgba(48, 209, 88, 0.3); }
.status-pill.blue { background: rgba(10, 132, 255, 0.1); color: var(--accent-blue); border: 1px solid rgba(10, 132, 255, 0.3); }

/* ==========================================================================
   Simulationsblock (Bexio-Attrappe)
   ==========================================================================
   Muss sich sichtbar vom Rest abheben. Ein Platzhalter, der aussieht wie eine
   echte Funktion, ist gefaehrlicher als gar keiner - jemand glaubt sonst, seine
   Buchhaltung sei nachgefuehrt. Deshalb gestrichelter Rahmen, gedaempfte
   Farben und ein Warnton statt der ueblichen Akzentfarbe. */
.sim-block {
    margin-top: 20px;
    padding: 14px;
    border: 1px dashed rgba(255, 214, 10, 0.45);
    border-radius: var(--border-radius);
    background: rgba(255, 214, 10, 0.04);
}

.sim-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.sim-badge {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(255, 214, 10, 0.15);
    color: #ffd60a;
    border: 1px solid rgba(255, 214, 10, 0.35);
}

.sim-note {
    font-size: 11px;
    color: var(--text-muted);
}

/* Terminal-Optik wie beim CRM-Abgleich - signalisiert "technische Ausgabe",
   nicht "Beleg". */
.sim-terminal {
    margin-top: 12px;
    padding: 10px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.35);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    line-height: 1.7;
    color: #8fbf8f;
    max-height: 180px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.sim-terminal .sim-line-warn { color: #ffd60a; }

/* ==========================================================================
   Zahlungs-QR
   ==========================================================================
   Der Code braucht eine helle Ruhezone. Auf dem dunklen Grund der Anwendung
   liest ihn manche Handykamera gar nicht - deshalb sitzt er bewusst auf einer
   weissen Kachel und sieht dadurch "wie aufgeklebt" aus. Das ist richtig so:
   es ist ein Stueck Papier auf dem Bildschirm. */
.qr-block {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--card-inner);
    text-align: center;
}

.qr-title {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.qr-tile {
    display: inline-block;
    padding: 12px;
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    line-height: 0;
}

.qr-tile img {
    width: 180px;
    height: 180px;
    display: block;
}

.qr-hint {
    margin-top: 8px;
    font-size: 11px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--text-muted);
    word-break: break-all;
}

.qr-missing {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--card-inner);
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.6;
}

.qr-missing a {
    display: inline-block;
    margin-top: 8px;
    padding: 10px 16px;      /* fingerbreit - draussen, am Handy, mit Handschuh */
    background: var(--card-inner);
    border-radius: 8px;
    color: var(--accent-blue);
    text-decoration: none;
    font-size: 13px;
}

/* Vollbild zum Scannen */
.qr-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 20px;
}

.qr-overlay[hidden] { display: none; }

.qr-overlay img {
    width: min(80vw, 80vh);
    height: min(80vw, 80vh);
}

.qr-overlay-caption {
    color: #000;
    font-size: 14px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    text-align: center;
}

/* Hinweis auf fehlende Bankangaben. Angebot, keine Fehlermeldung - deshalb
   ruhige Farben und kein Warnton. Wer seit zwanzig Jahren bar kassiert, soll
   nicht den Eindruck bekommen, etwas falsch gemacht zu haben. */
.setup-notice {
    background: var(--card-bg);
    border: 1px solid var(--card-inner);
    border-radius: var(--border-radius);
    padding: 16px;
    margin-bottom: 16px;
}

.setup-question { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.setup-body { font-size: 13px; color: var(--text-muted); }

.setup-missing {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    line-height: 1.5;
}

.setup-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

/* Fingerbreit: wird draussen am Handy bedient, manchmal mit Handschuh. */
.setup-button {
    display: inline-block;
    padding: 12px 18px;
    background: var(--accent-blue);
    color: #fff;
    border-radius: 10px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

.setup-dismiss {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-family);
    font-size: 13px;
    cursor: pointer;
    padding: 8px 4px;
}

.setup-cash {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

/* "Weiter mit RE-..." - der Weg zurueck zu einer offenen Rechnung. */
.resume-bar { margin-bottom: 16px; }

.resume-bar button {
    width: 100%;
    padding: 14px;
    background: var(--card-inner);
    border: 1px solid var(--accent-green);
    border-radius: var(--border-radius);
    color: var(--accent-green);
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

/* In der Rechnungsliste ist die Kachel nur Anzeige - ohne Vollbild waere ein
   Zeigefinger-Cursor ein Versprechen, das der Klick nicht einloest. */
.qr-tile.qr-static { cursor: default; }
