
:root {
    color-scheme: light dark;

    --accent: #3978c5;
    --accent-hover: #2862a7;
    --accent-soft: #e8f1fc;

    --bg: #f5f7fb;
    --surface: #ffffff;
    --text: #243047;
    --muted: #64748b;
    --border: #e2e8f0;

    --success: #27845b;
    --danger: #d64545;

    --radius: 14px;
    --shadow: 0 4px 18px rgb(30 50 80 / 6%);
}

/* Base */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system,
        BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.65;
    background: var(--bg);
    color: var(--text);
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 160ms ease;
}

a:hover {
    color: var(--accent-hover);
}

/* Header and navigation */

header {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 1rem clamp(1rem, 4vw, 3rem);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 10px rgb(30 50 80 / 3%);
}

header .brand {
    color: var(--text);
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    white-space: nowrap;
}

header nav {
    display: flex;
    align-items: center;
    flex: 1;
    flex-wrap: wrap;
    gap: 0.4rem;
}

header nav a,
header .auth > a {
    display: inline-block;
    padding: 0.5rem 0.85rem;
    border-radius: 9px;
    font-size: 0.95rem;
    font-weight: 550;
}

header nav a {
    color: var(--muted);
}

header nav a:hover,
header .auth > a:hover {
    color: var(--accent);
    background: var(--accent-soft);
}

header .auth {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

header .auth form {
    margin: 0;
}

/* Main content */

main {
    width: min(100% - 2rem, 70rem);
    margin: 2.5rem auto;
    padding: 0;
}

/* Headings */

h1, h2, h3 {
    line-height: 1.25;
    letter-spacing: -0.035em;
    color: var(--text);
}

h1 {
    font-size: clamp(2rem, 4vw, 2.8rem);
    margin: 0 0 1rem;
}

h2 {
    font-size: 1.6rem;
    margin-top: 2rem;
}

p {
    color: var(--muted);
}

/* Forms and controls */

label {
    display: block;
    margin-bottom: 0.8rem;
    font-weight: 600;
}

label.inline {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

input,
select,
textarea,
button {
    font: inherit;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
    width: 100%;
    max-width: 28rem;
    padding: 0.7rem 0.85rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 9px;
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgb(57 120 197 / 15%);
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--accent);
}

form.stack {
    max-width: 28rem;
}

/* Buttons */

button {
    padding: 0.65rem 1rem;
    color: white;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 9px;
    font-weight: 650;
    cursor: pointer;
    transition: background 160ms ease, transform 160ms ease;
}

button:hover {
    background: var(--accent-hover);
}

button:active {
    transform: translateY(1px);
}

button:focus-visible,
a:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

button.link {
    padding: 0.4rem 0.6rem;
    color: var(--accent);
    background: transparent;
    border: none;
    text-decoration: none;
    font-weight: 600;
}

button.link:hover {
    background: var(--accent-soft);
}

/* Tables */

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

th, td {
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--muted);
    background: var(--bg);
    font-size: 0.85rem;
    font-weight: 700;
}

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

tbody tr:hover {
    background: var(--accent-soft);
}

td label.inline {
    margin: 0;
}

/* Layout helpers */

.row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.row input {
    width: auto;
}

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

/* Status messages */

.error {
    padding: 0.75rem 1rem;
    color: var(--danger);
    background: rgb(214 69 69 / 8%);
    border-radius: 9px;
}

.ok {
    padding: 0.75rem 1rem;
    color: var(--success);
    background: rgb(39 132 91 / 9%);
    border-radius: 9px;
}

/* Smaller screens */

@media (max-width: 700px) {
    header {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem;
    }

    header nav {
        width: 100%;
    }

    header .auth {
        width: 100%;
    }

    main {
        width: calc(100% - 2rem);
        margin: 1.5rem auto;
    }

    table {
        display: block;
        overflow-x: auto;
    }
}

/* Respect system dark mode */

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --bg: #151a24;
        --surface: #1e2634;
        --text: #e7edf7;
        --muted: #a3b1c6;
        --border: #343e50;
        --accent: #83b6ff;
        --accent-hover: #b0d0ff;
        --accent-soft: #293a52;
        --success: #70d6a3;
        --danger: #ff9292;
        --shadow: 0 4px 18px rgb(0 0 0 / 15%);
    }
}
