:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --border: #e2e4e9;
    --text: #1c2128;
    --text-muted: #6b7280;
    --accent: #2f6fed;
    --accent-dark: #2456c4;
    --active: #1f9d63;
    --active-dark: #177d4e;
    --danger: #e5484d;
    --radius: 14px;
    --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0 16px 40px;
    -webkit-tap-highlight-color: transparent;
}

/* ---------- Header ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg);
    padding: 16px 0 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.topbar h1 {
    font-size: 19px;
    margin: 0;
    letter-spacing: -0.01em;
}

.topbar .sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pill-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.pill-btn:hover { border-color: var(--accent); }

/* ---------- Kunden-Grid ---------- */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    max-width: 1100px;
    margin: 0 auto;
}

.timer-btn {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 12px;
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.12s ease, background-color 0.12s ease, border-color 0.12s ease;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 96px;
    word-break: break-word;
    text-align: center;
    color: var(--text);
}

.timer-btn:active { transform: scale(0.97); }

.timer-btn.active {
    background-color: var(--active);
    color: white;
    border-color: var(--active-dark);
}

.time-display {
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
    font-size: 13px;
    font-weight: 600;
    opacity: 0.85;
    background: rgba(0, 0, 0, 0.05);
    padding: 3px 9px;
    border-radius: 999px;
}

.timer-btn.active .time-display {
    background: rgba(255, 255, 255, 0.22);
    opacity: 1;
}

.empty-hint {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-muted);
    padding: 40px 0;
    font-size: 14px;
}

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 22, 28, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease;
    padding: 16px;
}

.modal-overlay.show {
    visibility: visible;
    opacity: 1;
}

.modal-content {
    background: var(--surface);
    padding: 24px;
    border-radius: 18px;
    box-shadow: 0 20px 40px rgba(16, 24, 40, 0.2);
    width: 100%;
    max-width: 400px;
}

.modal-content h3 {
    margin: 0 0 18px;
    font-size: 17px;
}

.field-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
    display: block;
    margin-bottom: 6px;
    margin-top: 14px;
}

.field-label:first-of-type { margin-top: 0; }

.modal-content input,
.modal-content select {
    width: 100%;
    padding: 11px 12px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    box-sizing: border-box;
    background: var(--surface);
    color: var(--text);
}

.modal-content input[type="datetime-local"] {
    font-family: var(--mono);
    font-size: 14px;
}

.modal-content input:focus,
.modal-content select:focus {
    border-color: var(--accent);
    outline: none;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn {
    border: none;
    padding: 12px 20px;
    font-size: 15px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    flex: 1;
}

.btn-primary { background-color: var(--accent); color: white; }
.btn-primary:hover { background-color: var(--accent-dark); }

.btn-secondary { background-color: var(--bg); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover { border-color: var(--text-muted); }

.btn-danger { background-color: var(--danger); color: white; }

.error-text {
    color: var(--danger);
    font-size: 13px;
    margin-top: 10px;
    display: none;
}

/* ---------- Login ---------- */
.login-wrap {
    max-width: 360px;
    margin: 90px auto 0;
    padding: 0 16px;
}

/* ---------- Verwaltungsseite ---------- */
.section {
    max-width: 1100px;
    margin: 0 auto 36px;
}

.section h2 {
    font-size: 16px;
    margin-bottom: 14px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
}

.inline-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.inline-form input, .inline-form select {
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
}

.inline-form input[type="text"] { flex: 2; min-width: 160px; }
.inline-form input[type="date"] { flex: 1; min-width: 140px; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

th, td {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.02em; }

td.taetigkeit-cell { white-space: normal; max-width: 260px; }

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
}

.badge-active { background: #e6f7ee; color: var(--active-dark); }
.badge-inactive { background: #f1f2f4; color: var(--text-muted); }
.badge-edited { background: #fff4e5; color: #b25e00; }

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

.icon-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12.5px;
    cursor: pointer;
    font-weight: 600;
}

.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

.table-scroll {
    overflow-x: auto;
}

@media (max-width: 640px) {
    .topbar h1 { font-size: 17px; }
    .grid-container { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}
