:root {
    --bg: #ffffff;
    --surface: #f6f6f6;
    --text: #111111;
    --muted: #666666;
    --border: #cccccc;
    --accent: #0066cc;
    --danger: #c00000;
    --success: #006600;
}

* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    margin: 0 auto;
    padding: 1rem;
    max-width: 1100px;
    min-height: 100vh;
    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        "Helvetica Neue",
        Arial,
        sans-serif;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

h1,
h2,
h3,
h4 {
    line-height: 1.2;
    margin: 1.5rem 0 0.75rem;
}

h1:first-child,
h2:first-child,
h3:first-child {
    margin-top: 0;
}

p {
    margin: 0.5rem 0;
}

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

a:hover,
a:focus {
    text-decoration: none;
}

button,
input[type="submit"],
input[type="button"] {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    background: var(--bg);
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

button:hover,
button:focus,
input[type="submit"]:hover,
input[type="submit"]:focus {
    background: var(--surface);
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 500;
}

input,
select,
textarea {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

select[multiple] {
    min-height: 6rem;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus,
a:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

nav a {
    padding: 0.5rem 0.75rem;
    border: 1px solid transparent;
    border-radius: 0.25rem;
    text-decoration: none;
    color: var(--text);
    background: var(--surface);
}

nav a:hover,
nav a:focus {
    border-color: var(--border);
    background: var(--bg);
}

nav a.active {
    border-color: var(--text);
    background: var(--bg);
    font-weight: 600;
}

nav .logout {
    margin-left: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

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

th {
    background: var(--surface);
    font-weight: 600;
}

tr:hover {
    background: var(--surface);
}

dialog {
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    padding: 1rem;
    width: min(600px, 95vw);
    max-width: 95vw;
    max-height: 95vh;
    overflow: auto;
    background: var(--bg);
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
}

.table-wrapper {
    max-width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 0.25rem;
}

.table-wrapper table {
    margin: 0;
    border: none;
}

.table-wrapper th,
.table-wrapper td {
    white-space: normal;
    word-break: break-word;
}

.status {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    background: var(--surface);
    margin: 1rem 0;
}

.status.error {
    background: #ffe6e6;
    border-color: var(--danger);
    color: var(--danger);
}

.status.success {
    background: #e6f3e6;
    border-color: var(--success);
    color: var(--success);
}

.hidden {
    display: none !important;
}

@media (max-width: 600px) {
    body {
        padding: 0.75rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    table {
        font-size: 0.9rem;
    }

    .table-wrapper th,
    .table-wrapper td {
        white-space: nowrap;
    }

    dialog {
        padding: 0.75rem;
    }
}
