:root {
    --primary: #3b6fd6;
    --primary-dark: #2c56ad;
    --danger: #d64545;
    --success: #2f9e5b;
    --bg: #f4f6fb;
    --card-bg: #ffffff;
    --text: #1f2733;
    --muted: #6b7688;
    --border: #e3e7ee;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(20, 30, 60, 0.06), 0 1px 2px rgba(20, 30, 60, 0.08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 960px; margin: 0 auto; padding: 24px 16px 64px; }

/* --- Topbar --- */
.topbar { background: var(--card-bg); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 960px; margin: 0 auto; display: flex; align-items: center; gap: 20px; padding: 12px 16px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.nav-links { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav-links a { padding: 8px 12px; border-radius: 8px; color: var(--muted); font-size: 0.92rem; }
.nav-links a.active, .nav-links a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.logout-form { display: flex; align-items: center; gap: 10px; }
.me { color: var(--muted); font-size: 0.9rem; }

/* --- Cards & layout --- */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card h2 { margin-top: 0; font-size: 1.05rem; }
.page-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.page-header h1 { margin: 0; font-size: 1.4rem; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.group-card { display: block; }
.group-card h3 { margin: 0 0 8px; }

.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.stat-label { color: var(--muted); font-size: 0.85rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; }

/* --- Timer --- */
.timer-card { text-align: center; }
.timer-display { font-size: 2.6rem; font-weight: 700; font-variant-numeric: tabular-nums; margin: 10px 0; color: var(--primary); }

/* --- Forms --- */
label { display: flex; flex-direction: column; gap: 6px; font-size: 0.88rem; color: var(--muted); margin-bottom: 12px; }
label.checkbox-line { flex-direction: row; align-items: center; gap: 8px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], select {
    padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 0.95rem; color: var(--text); background: #fff;
}
input[type=color] { width: 48px; height: 36px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: end; }
.field-row label { min-width: 140px; flex: 1; }
.filter-bar { display: flex; gap: 14px; flex-wrap: wrap; align-items: end; margin-bottom: 18px; }
.form-card { max-width: 520px; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }
.inline-form, .inline-edit-form { display: inline; }
.inline-edit-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* --- Buttons --- */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 10px 16px; border-radius: 8px; border: 1px solid transparent; font-size: 0.92rem; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #eef2fb; color: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.link-btn { background: none; border: none; color: var(--danger); cursor: pointer; padding: 0; font-size: 0.88rem; text-decoration: underline; }

/* --- Table --- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th, .data-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.data-table th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.note-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions-cell { display: flex; gap: 10px; }

/* --- Tags / badges --- */
.tag { display: inline-block; padding: 3px 10px; border-radius: 999px; background: color-mix(in srgb, var(--tag-color) 18%, white); color: var(--tag-color); font-size: 0.8rem; font-weight: 600; border: 1px solid color-mix(in srgb, var(--tag-color) 40%, white); }
.tag-list { list-style: none; padding: 0; display: flex; gap: 8px; flex-wrap: wrap; }
.color-dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; background: #eef1f6; color: var(--muted); font-size: 0.78rem; }
.badge-billed { background: #e6f6ec; color: var(--success); }

/* --- Alerts --- */
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 0.9rem; }
.alert-success { background: #e6f6ec; color: #1c6b3d; }
.alert-error { background: #fdecec; color: #a72d2d; }

.muted { color: var(--muted); }
.muted-link { display: inline-block; margin-top: 14px; color: var(--muted); font-size: 0.88rem; }

/* --- Auth pages --- */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.auth-box { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px; max-width: 380px; width: 100%; }
.auth-title { margin-top: 0; font-size: 1.3rem; }

/* --- Error pages --- */
.error-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.error-box { text-align: center; }
.error-box h1 { font-size: 3rem; margin-bottom: 0; color: var(--primary); }

/* --- Schnellstarts: Wabenraster --- */
.hex-toggle-checkbox { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }

.hex-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    padding: 6px 0 2px;
}

.hex-tile {
    position: relative;
    width: 118px;
    height: 104px;
    flex: 0 0 auto;
}

.hex-tile:nth-child(even) { margin-top: 30px; }

.hex-start {
    position: absolute;
    inset: 0;
    border: none;
    cursor: pointer;
    clip-path: polygon(25% 4%, 75% 4%, 100% 50%, 75% 96%, 25% 96%, 0% 50%);
    background: var(--tile-color, var(--primary));
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px 14px;
    font: inherit;
    transition: transform .12s ease, filter .12s ease;
}
.hex-start:hover { transform: scale(1.05); filter: brightness(1.06); }
.hex-start .hex-name { font-weight: 700; font-size: 0.82rem; line-height: 1.15; }
.hex-start .hex-meta { font-size: 0.68rem; opacity: 0.85; margin-top: 4px; }

.hex-delete-form { position: absolute; top: -2px; right: 6px; }
.hex-delete {
    width: 20px; height: 20px; border-radius: 50%;
    border: 1px solid var(--border); background: #fff; color: var(--muted);
    font-size: 0.8rem; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.hex-delete:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.hex-add {
    display: block;
    cursor: pointer;
    clip-path: polygon(25% 4%, 75% 4%, 100% 50%, 75% 96%, 25% 96%, 0% 50%);
    background: transparent;
    border: 2px dashed var(--border);
    color: var(--muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
}
.hex-add .hex-plus { font-size: 1.4rem; line-height: 1; font-weight: 700; }
.hex-add .hex-name { font-size: 0.78rem; margin-top: 2px; }
.hex-add:hover { border-color: var(--primary); color: var(--primary); }

.quickstart-form-wrap { display: none; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
#qs-toggle:checked ~ .quickstart-form-wrap { display: block; }

.manual-start-wrap summary,
details.manual-start-wrap > summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 0.88rem;
    margin-bottom: 10px;
}
.manual-start-wrap[open] summary { margin-bottom: 14px; }

@media (max-width: 640px) {
    .topbar-inner { flex-direction: column; align-items: flex-start; }
    .nav-links { width: 100%; }
    .timer-display { font-size: 2.1rem; }
}
