:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-muted: #eef3f8;
    --text: #1d2733;
    --muted: #6b7785;
    --border: #dbe3ec;
    --brand: #2166c2;
    --brand-dark: #184f98;
    --ok: #188557;
    --warning: #a96f00;
    --danger: #b83a3a;
    --shadow: 0 10px 30px rgba(29, 39, 51, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

.app-shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    min-height: 100vh;
}

.topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand-name {
    font-size: 18px;
    font-weight: 700;
}

.brand-note {
    color: var(--muted);
    font-size: 13px;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px 18px;
    background: #152033;
    color: #ffffff;
}

.sidebar .brand {
    margin-bottom: 28px;
}

.sidebar .brand-note {
    color: #aebbd0;
}

.nav-list {
    display: grid;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.nav-link {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 9px 12px;
    border-radius: 6px;
    color: #d9e2ef;
    font-weight: 600;
}

.nav-link:hover,
.nav-link.is-active {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.logout-form {
    margin-top: 18px;
}

.logout-button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 16px;
    border: 0;
    border-radius: 6px;
    background: var(--brand);
    color: #ffffff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.logout-button {
    width: 100%;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.logout-button:hover,
.button:hover {
    background: var(--brand-dark);
}

.danger-button {
    background: var(--danger);
}

.danger-button:hover {
    background: #8f2d2d;
}

.main-area {
    min-width: 0;
}

.content {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 34px;
}

.page-header {
    margin-bottom: 26px;
}

.page-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.section-heading-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.section-heading-row h2 {
    margin-bottom: 0;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--brand);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 8px;
    font-size: 32px;
    line-height: 1.2;
}

.page-header p:last-child {
    max-width: 680px;
    color: var(--muted);
}

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

.metric {
    min-height: 132px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.metric-label {
    margin-bottom: 14px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.metric-value {
    margin-bottom: 6px;
    font-size: 30px;
    font-weight: 700;
    line-height: 1.1;
}

.metric-note {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.small-value {
    font-size: 22px;
    text-transform: capitalize;
}

.panel {
    margin-top: 18px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.panel h2 {
    margin-bottom: 10px;
    font-size: 20px;
}

.panel p {
    margin-bottom: 0;
    color: var(--muted);
}

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

.login-panel {
    width: min(420px, 100%);
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.login-brand {
    margin-bottom: 22px;
}

.form {
    display: grid;
    gap: 16px;
}

.field {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.field input {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
}

.field select,
.field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
}

.field textarea {
    resize: vertical;
}

.field-helper {
    color: var(--brand);
    font-size: 13px;
    font-weight: 700;
}

.field-helper.is-disabled {
    color: var(--muted);
    pointer-events: none;
}

.field input:focus {
    border-color: var(--brand);
    outline: 3px solid rgba(33, 102, 194, 0.15);
}

.field select:focus,
.field textarea:focus {
    border-color: var(--brand);
    outline: 3px solid rgba(33, 102, 194, 0.15);
}

.wide-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-full,
.form-actions {
    grid-column: 1 / -1;
}

.form-actions,
.button-row,
.actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

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

.filter-form .form-actions {
    grid-column: 1 / -1;
}

.inline-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.inline-form select {
    min-height: 34px;
    max-width: 170px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
}

.compact-field {
    max-width: 260px;
}

.secondary-link,
.table-link,
.actions a,
.link-button {
    color: var(--brand);
    font-weight: 700;
}

.link-button {
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    font: inherit;
}

.danger {
    color: var(--danger);
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    line-height: 1.3;
}

.data-table th,
.data-table td {
    padding: 9px 8px;
    border-bottom: 1px solid #e4ebf3;
    text-align: left;
    vertical-align: middle;
}

.data-table th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.table-compact th,
.table-compact td {
    padding: 7px 8px;
    font-size: 13px;
    line-height: 1.25;
    border-bottom: 1px solid #e4ebf3;
}

.table-compact {
    table-layout: fixed;
}

.table-compact th {
    font-size: 11px;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.table-compact .status-pill {
    min-height: 20px;
    padding: 1px 7px;
    font-size: 11px;
}

.table-compact .task-title-col {
    width: 220px;
}

.table-compact .task-title-link {
    display: inline-block;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: top;
}

.table-compact .task-actions-col {
    width: 128px;
    white-space: nowrap;
}

.table-compact .task-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}

.table-compact .task-edit-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    min-width: 24px;
    padding: 2px 5px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 12px;
    line-height: 1;
}

.table-compact .task-status-inline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
}

.table-compact .task-status-inline select {
    min-height: 24px;
    height: 24px;
    max-width: 86px;
    padding: 1px 4px;
    font-size: 12px;
    line-height: 1.1;
}

.table-compact .task-status-inline .link-button {
    min-height: 24px;
    min-width: 24px;
    padding: 2px 5px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 12px;
    line-height: 1;
    color: var(--brand);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    text-transform: capitalize;
}

.actions {
    gap: 8px;
}

.actions .link-button,
.actions a {
    font-size: 13px;
    line-height: 1.2;
}

.inline-form select {
    min-height: 30px;
    max-width: 160px;
    padding: 2px 7px;
    font-size: 13px;
}

.details-panel h2 {
    margin-bottom: 18px;
}

.details-list {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
    gap: 12px 18px;
    margin: 0;
}

.details-list dt {
    color: var(--muted);
    font-weight: 700;
}

.details-list dd {
    margin: 0;
}

.tabs-placeholder {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.tabs-placeholder span {
    display: inline-flex;
    min-height: 36px;
    align-items: center;
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--muted);
    font-weight: 700;
}

.alert {
    margin-bottom: 16px;
    padding: 11px 12px;
    border: 1px solid rgba(184, 58, 58, 0.28);
    border-radius: 6px;
    background: rgba(184, 58, 58, 0.08);
    color: var(--danger);
    font-weight: 700;
}

.footer {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 0 34px 28px;
    color: var(--muted);
    font-size: 14px;
}

@media (max-width: 900px) {
    .app-shell {
        display: block;
    }

    .topbar {
        display: flex;
    }

    .sidebar {
        position: static;
        height: auto;
        padding: 10px 14px;
    }

    .sidebar .brand {
        display: none;
    }

    .nav-list {
        grid-auto-flow: column;
        grid-auto-columns: max-content;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .content {
        padding: 24px 18px;
    }

    .page-header-row {
        display: grid;
    }

    .section-heading-row {
        align-items: flex-start;
        display: grid;
    }

    .filter-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .footer {
        padding: 0 18px 22px;
    }
}

@media (max-width: 560px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .wide-form,
    .details-list,
    .filter-form {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 26px;
    }
}
