/* Pflege-Oberfläche des Resultservers - bewusst schlank und ohne Framework. */

:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --border: #d7dae0;
    --text: #1d2229;
    --muted: #6b7280;
    --accent: #1f6feb;
    --accent-dark: #1a5cc4;
    --danger: #b42318;
    --ok-bg: #e7f6ec;
    --ok-border: #a7d8b8;
    --err-bg: #fdecea;
    --err-border: #f0b4ae;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body.centered {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

/* ---- Kopfzeile ---- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text);
    text-decoration: none;
}

.topbar .logout {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
}

.user {
    color: var(--muted);
    font-size: 0.9rem;
}

/* ---- Seitenrahmen ---- */

.page {
    max-width: 1180px;
    margin: 0 auto;
    padding: 1.5rem;
}

h1 {
    font-size: 1.35rem;
    margin: 1.25rem 0 0.25rem;
}

.hint {
    color: var(--muted);
    font-size: 0.85rem;
    margin: 0.25rem 0;
}

.muted {
    color: var(--muted);
    font-size: 0.85rem;
}

.empty {
    padding: 2rem;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: 6px;
    color: var(--muted);
    text-align: center;
}

/* ---- Meldungen ---- */

.flash {
    margin: 1rem 0 0;
    padding: 0.6rem 0.9rem;
    background: var(--ok-bg);
    border: 1px solid var(--ok-border);
    border-radius: 6px;
}

.error-box {
    margin: 0 0 1rem;
    padding: 0.6rem 0.9rem;
    background: var(--err-bg);
    border: 1px solid var(--err-border);
    border-radius: 6px;
    color: var(--danger);
}

.error {
    display: block;
    margin-top: 0.2rem;
    color: var(--danger);
    font-size: 0.82rem;
}

/* ---- Werkzeugleiste ---- */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.daynav, .actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

form.inline {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
}

/* ---- Bedienelemente ---- */

.btn {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.9rem;
    line-height: 1.4;
    text-decoration: none;
    cursor: pointer;
}

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

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

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

.btn-plain {
    background: transparent;
    border-color: transparent;
    color: var(--muted);
}

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

.btn-danger:hover {
    background: var(--danger);
    color: #fff;
}

.btn-small {
    padding: 0.2rem 0.5rem;
    font-size: 0.82rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
select {
    width: 100%;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
}

form.inline input[type="date"] {
    width: auto;
}

label {
    display: block;
    margin-bottom: 0.2rem;
    font-size: 0.85rem;
    color: var(--muted);
}

/* ---- Tabelle ---- */

.grid {
    width: 100%;
    margin-top: 1rem;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.grid th, .grid td {
    padding: 0.45rem 0.6rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.grid th {
    background: #eef0f4;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
}

.grid tbody tr:last-child td {
    border-bottom: none;
}

.grid tbody tr:hover {
    background: #f8f9fb;
}

.grid td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.state, .tag {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    background: #eef0f4;
    font-size: 0.8rem;
    white-space: nowrap;
}

/* ---- Formular ---- */

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

.form {
    margin-top: 1rem;
}

.form .row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form .field {
    flex: 1 1 220px;
}

.form .field.small {
    flex: 0 0 110px;
}

.form .field.checkbox {
    display: flex;
    align-items: flex-end;
}

.form .field.checkbox label {
    color: var(--text);
    font-size: 0.9rem;
}

.form .field.checkbox input {
    width: auto;
    margin-right: 0.3rem;
}

.buttons {
    display: flex;
    gap: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.danger-zone {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* ---- Anmeldung ---- */

.login-card {
    width: min(360px, 92vw);
}

.login-card h1 {
    margin-top: 0;
}

.login-card label {
    margin-top: 0.75rem;
}

.login-card .btn {
    width: 100%;
    margin-top: 1.25rem;
}

/* ---- Hauptnavigation ---- */

.mainnav {
    display: flex;
    gap: 1rem;
    margin-right: auto;
    margin-left: 1.5rem;
}

.mainnav a {
    color: var(--muted);
    font-size: 0.9rem;
    text-decoration: none;
}

.mainnav a:hover {
    color: var(--text);
}

/* ---- Stärken sortieren ---- */

.scale {
    margin-top: 1rem;
}

.scale .row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
    margin-top: 0.5rem;
}

.scale .field.small {
    flex: 0 0 150px;
}

.sortable .handle-col {
    width: 2rem;
}

.sortable .pos-col {
    width: 4rem;
}

.sortable .strength-col {
    width: 7rem;
}

.sortable-row {
    cursor: grab;
}

.sortable-row .handle {
    color: var(--muted);
    letter-spacing: -2px;
    user-select: none;
}

.sortable-row.dragging {
    opacity: 0.4;
    background: #eaf1fd;
}

.sortable-row td.position {
    font-variant-numeric: tabular-nums;
    color: var(--muted);
}

.strength-input {
    width: 100%;
    text-align: right;
}

/* ---- Tabelle ---- */

.ranking .pos-col {
    width: 4rem;
}

.ranking th.num, .ranking th.adj-col {
    text-align: right;
}

.ranking td.position {
    font-variant-numeric: tabular-nums;
    color: var(--muted);
}

.ranking td.points {
    font-weight: 600;
}

/* Die Korrekturspalten stehen bewusst abgesetzt: links das Rechenergebnis,
   rechts das, was von Hand dazukommt. */
.ranking .adj-col {
    width: 6rem;
    background: #fbfbfd;
}

.ranking th.adj-col {
    border-left: 1px solid var(--border);
}

.ranking td.adj-col:first-of-type {
    border-left: 1px solid var(--border);
}

.ranking .adj-input {
    width: 100%;
    text-align: right;
}

.ranking .note-input {
    width: 100%;
}

.ranking tr.adjusted td.points {
    color: #b45309;
}
