:root {
    --bg: #f7f3ea;
    --paper: #fffdf7;
    --ink: #050505;
    --yellow: #ffd93d;
    --blue: #5fd3e8;
    --mint: #a9e6cf;
    --pink: #ff6680;
    --muted: #606060;
    --line: 3px solid var(--ink);
    --shadow: 7px 7px 0 var(--ink);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 0;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(rgba(0,0,0,.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,0,0,.035) 1px, transparent 1px),
        var(--bg);
    background-size: 24px 24px;
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
}

body:not(.login) {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
}

aside {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: auto;
    padding: 18px;
    background: var(--paper);
    border-right: 5px solid var(--ink);
}

.sidebar-brand {
    display: grid;
    grid-template-columns: 64px 1fr;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    padding: 12px;
    background: var(--yellow);
    border: var(--line);
    box-shadow: 5px 5px 0 var(--ink);
}

.brand-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: var(--blue);
    border: var(--line);
    box-shadow: 4px 4px 0 var(--ink);
    color: var(--ink);
    font-size: 1.05rem;
    font-weight: 900;
}

aside strong {
    font-size: 1.2rem;
    line-height: 1.05;
}

aside nav,
.sidebar-actions {
    display: grid;
    gap: 8px;
}

.sidebar-actions {
    margin-top: 16px;
    padding-top: 16px;
    border-top: var(--line);
}

aside a {
    display: grid;
    grid-template-columns: 24px 1fr;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 9px 10px;
    background: #fff;
    border: 2px solid var(--ink);
    color: var(--ink);
    text-decoration: none;
    font-weight: 900;
}

aside a:hover,
aside a.active {
    background: var(--blue);
    box-shadow: 4px 4px 0 var(--ink);
}

aside i {
    width: 22px;
    text-align: center;
}

main {
    min-width: 0;
    padding: 26px 30px 46px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 26px;
    padding: 18px 22px;
    background: var(--yellow);
    border: var(--line);
    box-shadow: var(--shadow);
}

.eyebrow {
    display: block;
    margin-bottom: 5px;
    font-family: Consolas, "Courier New", monospace;
    font-weight: 900;
}

h1,
h2 {
    margin: 0;
    line-height: 1.05;
}

h1 {
    font-size: clamp(2rem, 3vw, 3rem);
}

.panel,
.card {
    background: var(--paper);
    border: var(--line);
    box-shadow: var(--shadow);
}

.panel {
    margin-bottom: 26px;
    padding: 22px;
}

.login {
    display: grid;
    place-items: center;
    min-height: 100vh;
}

.login-panel {
    width: min(430px, 92vw);
    display: grid;
    gap: 16px;
    padding: 28px;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 18px;
    margin-bottom: 26px;
}

.card {
    padding: 20px;
}

.stat-card {
    min-height: 120px;
}

.stat-card b {
    display: block;
    font-size: 2.7rem;
    line-height: 1;
}

.stat-card span,
.intro-panel p,
small {
    color: var(--muted);
    font-weight: 800;
}

.intro-panel p {
    margin-bottom: 0;
    font-size: 1.05rem;
}

.editor-panel {
    padding: 0;
    overflow: hidden;
}

.editor-panel summary {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px;
    background: #fff;
    border-bottom: var(--line);
    font-size: 1.05rem;
    font-weight: 900;
}

.editor-panel:not([open]) summary {
    border-bottom: 0;
}

.editor-panel .form-grid {
    padding: 22px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

label {
    display: grid;
    gap: 7px;
    font-weight: 900;
}

.form-section-title {
    grid-column: 1 / -1;
    border: var(--line);
    background: var(--yellow);
    box-shadow: var(--shadow-sm);
    padding: 14px 16px;
    font-weight: 950;
    font-size: 1.05rem;
}

input,
textarea,
select {
    width: 100%;
    min-width: 0;
    border: var(--line);
    background: #fff;
    padding: 11px 12px;
    font: inherit;
}

textarea {
    font-family: Consolas, "Courier New", monospace;
    resize: vertical;
}

select[multiple] {
    min-height: 150px;
}

button,
.btn-primary,
.btn-secondary,
.btn-mini,
.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: fit-content;
    border: var(--line);
    box-shadow: 4px 4px 0 var(--ink);
    color: var(--ink);
    padding: 10px 14px;
    background: var(--yellow);
    font-weight: 900;
    text-decoration: none;
    cursor: pointer;
}

.btn-secondary {
    background: var(--blue);
}

.btn-mini {
    background: var(--mint);
    padding: 7px 10px;
}

.btn-danger {
    background: var(--pink);
    padding: 7px 10px;
}

.ok,
.alert {
    width: fit-content;
    margin: 0 0 20px;
    border: var(--line);
    box-shadow: 5px 5px 0 var(--ink);
    padding: 10px 14px;
    font-weight: 900;
}

.ok {
    background: var(--mint);
}

.alert {
    background: var(--pink);
}

.list-panel {
    padding: 0;
    overflow: hidden;
}

.list-toolbar {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) auto;
    align-items: center;
    gap: 18px;
    padding: 18px;
    background: #fff;
    border-bottom: var(--line);
}

.search-form {
    display: flex;
    gap: 10px;
    align-items: stretch;
    min-width: 0;
}

.search-form input {
    max-width: 520px;
}

.record-chip,
.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 7px 10px;
    border: var(--line);
    background: var(--mint);
    box-shadow: 4px 4px 0 var(--ink);
    font-family: Consolas, "Courier New", monospace;
    font-weight: 900;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    background: #fff;
}

table {
    width: 100%;
    min-width: 860px;
    border-collapse: collapse;
    background: #fff;
}

th,
td {
    border-bottom: 2px solid var(--ink);
    padding: 13px 12px;
    text-align: left;
    vertical-align: top;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--yellow);
    font-weight: 900;
}

td strong {
    display: block;
    line-height: 1.15;
}

td small {
    display: block;
    margin-top: 6px;
    overflow-wrap: anywhere;
    font-family: Consolas, "Courier New", monospace;
}

.actions {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.inline {
    display: inline-flex;
    margin: 0;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 18px;
    border-top: var(--line);
    background: #fff;
}

.pagination a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    border: var(--line);
    background: #fff;
    box-shadow: 4px 4px 0 var(--ink);
    color: var(--ink);
    font-weight: 900;
    text-decoration: none;
}

.pagination a.is-active {
    background: var(--blue);
}

.switch-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.switch-row input {
    width: auto;
}

@media (max-width: 1050px) {
    body:not(.login) {
        grid-template-columns: 1fr;
    }

    aside {
        position: static;
        height: auto;
        border-right: 0;
        border-bottom: 5px solid var(--ink);
    }

    aside nav,
    .sidebar-actions {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    main {
        padding: 18px;
    }

    .form-grid,
    .list-toolbar {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }
}
