:root {
    --bg: #f5f7fb;
    --card: #ffffff;
    --text: #172033;
    --muted: #667085;
    --line: #d9dee7;
    --brand-blue: #243f63;
    --accent: #23715f;
    --danger: #a33a3a;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.app-header {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: center;
    padding: 18px 28px;
    background: var(--brand-blue);
    border-bottom: 1px solid #1d3452;
    color: #fff;
}
.app-header h1 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 30px;
    font-weight: 400;
}
.brand-name sup {
    font-size: .5em;
    line-height: 0;
    vertical-align: super;
}
.app-header p { margin: 4px 0 0; color: #dbe5f2; }
nav { display: flex; flex-wrap: wrap; gap: 8px; }
nav a, .button, button {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    padding: 9px 14px;
    text-decoration: none;
    font: inherit;
    cursor: pointer;
}
.app-header nav a {
    border-color: rgba(255, 255, 255, .42);
    background: transparent;
    color: #fff;
}
nav a.active, .primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.primary:disabled {
    background: #98a2b3;
    border-color: #98a2b3;
}
button:disabled {
    cursor: not-allowed;
    opacity: .7;
}
.app-header nav a.active {
    background: #fff;
    border-color: #fff;
    color: var(--brand-blue);
}
.secondary { background: #fff; }
.small { padding: 5px 8px; font-size: 13px; }
.link { border: 0; background: transparent; padding: 0; color: var(--accent); }
.danger { color: var(--danger); }
.danger-button {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}
.page { padding: 22px 28px; }
.landing-page {
    display: grid;
    min-height: calc(100vh - 180px);
    padding: 32px;
    place-items: center;
}
.landing-panel {
    background: var(--card);
    border: 1px solid var(--line);
    max-width: 720px;
    padding: 30px;
    text-align: center;
    width: 100%;
}
.landing-panel h2 {
    font-size: 30px;
    margin: 0 0 12px;
}
.landing-note {
    color: var(--danger);
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 14px;
}
.landing-actions {
    margin: 24px 0 0;
}
.app-footer {
    color: var(--muted);
    font-size: 12px;
    padding: 0 28px 18px;
    text-align: right;
}
.narrow { max-width: 620px; }
.panel, .auth-panel {
    background: var(--card);
    border: 1px solid var(--line);
    padding: 18px;
    margin-bottom: 16px;
}
.auth-panel {
    max-width: 520px;
    margin: 8vh auto;
}
.toolbar, .inline, .actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.toolbar .inline {
    flex-wrap: nowrap;
}
.toolbar input[type="date"] {
    width: 175px;
}
.toolbar input[type="month"] {
    width: 175px;
}
.stack { display: grid; gap: 14px; }
.grid-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr)) auto;
    gap: 14px;
    align-items: end;
}
.entry-form {
    grid-template-columns: minmax(140px, 180px) minmax(0, 2fr) minmax(90px, 120px) minmax(0, 1.4fr) auto;
}
.entry-form .field-project select {
    overflow: hidden;
    text-overflow: ellipsis;
}
.entry-submit {
    min-height: 38px;
    white-space: nowrap;
}
label { display: grid; gap: 6px; font-weight: 600; min-width: 0; }
label.check { display: flex; align-items: center; gap: 8px; margin-top: 28px; }
input, select {
    min-height: 38px;
    width: 100%;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid #aeb6c2;
    font: inherit;
}
input[type="checkbox"] {
    min-height: 0;
    width: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}
th, td {
    border: 1px solid var(--line);
    padding: 8px 10px;
    vertical-align: top;
}
th {
    background: #194c6b;
    color: #fff;
    text-align: left;
}
.sort-link {
    color: inherit;
    display: block;
    text-decoration: none;
}
.sort-link.active {
    text-decoration: underline;
    text-underline-offset: 3px;
}
.users-table td {
    vertical-align: middle;
}
.users-table input {
    width: 100%;
    min-width: 180px;
}
.users-table .actions {
    align-items: center;
    min-width: 520px;
}
.users-table .actions form {
    margin: 0;
}
.users-table .actions button {
    min-height: 38px;
    white-space: nowrap;
}
.muted { color: var(--muted); }
.flash {
    margin: 14px 28px 0;
    padding: 12px 14px;
    border: 1px solid var(--line);
    background: #fff;
}
.flash.error { border-color: #f1b7b7; color: var(--danger); }
.scroll { overflow-x: auto; }
.matrix { min-width: 2200px; }
.matrix th { white-space: pre-line; text-align: center; }
.matrix td { text-align: center; }
.matrix td:first-child, .matrix th:first-child {
    text-align: left;
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 1;
}
.matrix th:first-child { background: #194c6b; }
.empty { background: #f2f4f7; }

@media (max-width: 900px) {
    .app-header { display: block; }
    nav { margin-top: 14px; }
    .grid-form { grid-template-columns: 1fr; }
    .entry-form button { width: 100%; }
}

@media (min-width: 901px) and (max-width: 1250px) {
    .entry-form {
        grid-template-columns: minmax(140px, 180px) minmax(0, 2fr) minmax(90px, 120px) auto;
    }
    .entry-form .field-comment {
        grid-column: 1 / -1;
    }
}

@media (max-width: 760px) {
    .page { padding: 16px; }
    .entry-form {
        grid-template-columns: 1fr;
    }
    .entry-form .field-comment {
        grid-column: auto;
    }
}
