:root {
    --bg: #1a2433;
    --surface: #27303F;
    --surface-hover: #2f3a4a;
    --border: #3d4d5e;
    --border-focus: #9D6381;
    --text: #f5f5ff;
    --text-muted: #a8b4c0;
    --text-dim: #6a7a8a;
    --accent: #9D6381;       /* Rosewood */
    --accent-secondary: #58A1BA; /* Petrol */
    --accent-glow: rgba(157, 99, 129, 0.2);
    --success: #7EA16B;      /* Sagegreen */
    --success-bg: rgba(126, 161, 107, 0.12);
    --error: #e07070;
    --error-bg: rgba(224, 112, 112, 0.1);
    --radius: 10px;
    --font: 'DM Sans', -apple-system, sans-serif;
    --mono: 'JetBrains Mono', monospace;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

.app-container {
    max-width: 640px;
    margin: 0 auto;
    padding: 24px 20px 80px;
}

/* Header */
.header {
    padding: 32px 0 40px;
    text-align: center;
}

.header-brand {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 12px;
}

.header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text);
}

.header-sub {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Config bar */
.config-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 32px;
    font-size: 13px;
    color: var(--text-muted);
}

.config-bar .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--error);
    flex-shrink: 0;
    transition: background 0.3s;
}

.config-bar .dot.connected {
    background: var(--accent-secondary);
}

.config-bar span {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sections */
.form-section {
    margin-bottom: 28px;
}

.section-label {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 14px;
    padding-left: 2px;
}

/* Field grid */
.field-row {
    display: grid;
    gap: 12px;
    margin-bottom: 12px;
}

.field-row.two { grid-template-columns: 1fr 1fr; }
.field-row.three { grid-template-columns: 1fr 1fr 1fr; }
.field-row.two-one { grid-template-columns: 2fr 1fr; }

@media (max-width: 480px) {
    .field-row.two, .field-row.three, .field-row.two-one {
        grid-template-columns: 1fr;
    }
}

/* Fields */
.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.field label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    padding-left: 2px;
}

.field label .required {
    color: var(--accent);
    margin-left: 2px;
}

select,
input[type="text"],
input[type="password"],
input[type="date"],
input[type="time"],
textarea {
    width: 100%;
    padding: 10px 12px;
    font-family: var(--font);
    font-size: 15px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238888a0' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 6l3.5 4 3.5-4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
    cursor: pointer;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

select:focus,
input[type="password"]:focus,
input:focus,
textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

select:hover,
input:hover,
textarea:hover {
    border-color: #4d5f70;
}

/* Submit */
.submit-area {
    margin-top: 36px;
}

.btn-submit {
    width: 100%;
    padding: 14px;
    font-family: var(--font);
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.btn-submit:hover:not(:disabled) {
    background: #8a5470;
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-submit:active:not(:disabled) {
    transform: translateY(0);
}

.btn-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 14px 24px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 100;
    max-width: 90vw;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(52, 211, 153, 0.2);
}

.toast.error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid rgba(248, 113, 113, 0.2);
}

/* Loading shimmer */
.loading-shimmer {
    background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius);
    height: 42px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Setup overlay */
.setup-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.setup-card {
    max-width: 420px;
    width: 100%;
    text-align: center;
}

.setup-card h2 {
    font-size: 22px;
    margin-bottom: 8px;
}

.setup-card p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.setup-card .field {
    text-align: left;
    margin-bottom: 16px;
}

.btn-connect {
    width: 100%;
    padding: 12px;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
}

.btn-connect:hover { background: #8a5470; }

.hidden { display: none !important; }

/* Submitted entry preview */
.last-entry {
    margin-top: 16px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-muted);
}

.last-entry strong {
    color: var(--text);
    font-weight: 500;
}

/* Tabs */
.tab-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    margin-bottom: 32px;
    gap: 4px;
}

.tab {
    padding: 9px 16px;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dim);
    background: transparent;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.18s;
}

.tab:hover:not(.active) {
    color: var(--text-muted);
    background: var(--surface-hover);
}

.tab.active {
    color: var(--text);
    background: var(--bg);
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

.tab-panel {
    animation: fadeIn 0.15s ease;
}

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

/* Verlauf */
.verlauf-controls {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 20px;
}

.btn-load {
    padding: 10px 16px;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.btn-load:hover {
    border-color: var(--border-focus);
    color: var(--text);
}

.verlauf-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.verlauf-loading,
.verlauf-empty {
    padding: 20px;
    text-align: center;
    font-size: 14px;
    color: var(--text-dim);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.protokoll-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.protokoll-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.protokoll-date {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    flex-shrink: 0;
}

.protokoll-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-left: auto;
}

.tag {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--bg);
    color: var(--text-dim);
    border: 1px solid var(--border);
}

.tag-lk {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-glow);
}

.protokoll-field {
    display: flex;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

.protokoll-field-label {
    flex-shrink: 0;
    width: 64px;
    font-weight: 500;
    color: var(--text-dim);
    font-size: 12px;
    padding-top: 1px;
}
