:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #d9e0e8;
    --accent: #2563eb;
    --accent-soft: #eaf1ff;
    --footer: #eef2f7;
    --danger-bg: #fef2f2;
    --danger-border: #fecaca;
    --danger-text: #b91c1c;
    --shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
    --radius: 14px;
    --topbar-height: 68px;
    --mobile-nav-height: 64px;
    --content-width: 1180px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: Inter, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
}

body {
    font-size: 16px;
}

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

input,
button {
    font: inherit;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.topbar__left,
.topbar__right {
    display: flex;
    align-items: center;
    gap: 18px;
}

.logo {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: 0.02em;
}

.desktop-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.desktop-nav a,
.mobile-nav a {
    padding: 10px 14px;
    border-radius: 10px;
    color: var(--text);
    font-weight: 600;
    transition: 0.2s ease;
}

.desktop-nav a:hover,
.mobile-nav a:hover {
    background: var(--accent-soft);
    color: var(--accent);
}

.desktop-nav a.active,
.mobile-nav a.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.user-box {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 0.95rem;
}

.user-box__label {
    color: var(--muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-weight: 600;
    transition: 0.2s ease;
    background: #fff;
    cursor: pointer;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn--primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn--ghost {
    background: #fff;
    color: var(--text);
}

.btn--full {
    width: 100%;
}

.main-content {
    flex: 1;
    width: 100%;
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 24px 20px 88px;
}

.view {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    min-height: 280px;
}

.view h1 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 1.8rem;
}

.view p {
    margin: 0;
    color: var(--muted);
    line-height: 1.65;
}

.view-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.view-subtitle {
    color: var(--muted);
}

.placeholder-box {
    min-height: 180px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: var(--surface-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
}

.footer {
    background: var(--footer);
    border-top: 1px solid var(--border);
    padding: 14px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 0.95rem;
}

.mobile-nav {
    display: none;
}

.login-page {
    background: var(--bg);
}

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

.login-card__header {
    margin-bottom: 20px;
}

.login-card__header h1 {
    margin: 0 0 8px;
    font-size: 1.8rem;
}

.login-card__header p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-row label {
    font-weight: 600;
    color: var(--text);
}

.form-row input {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
}

.form-row input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-errors {
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: var(--danger-text);
    font-size: 0.95rem;
}

@media (max-width: 768px) {
    .desktop-nav {
        display: none;
    }

    .topbar {
        padding: 12px 16px;
    }

    .topbar__left {
        min-width: 0;
    }

    .topbar__right {
        margin-left: auto;
    }

    .user-box {
        display: none;
    }

    .main-content {
        padding: 16px 16px 92px;
    }

    .view {
        padding: 18px;
        min-height: 220px;
    }

    .view h1 {
        font-size: 1.5rem;
    }

    .mobile-nav {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        height: var(--mobile-nav-height);
        background: #fff;
        border-top: 1px solid var(--border);
        z-index: 120;
    }

    .mobile-nav a {
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 600;
        color: var(--muted);
    }

    .footer {
        margin-bottom: var(--mobile-nav-height);
    }

    .login-wrapper {
        padding: 16px;
    }

    .login-card {
        padding: 18px;
    }
}

.logout-form {
    margin: 0;
}

.logout-form button {
    cursor: pointer;
}

.messages {
    margin-bottom: 1rem;
}

.message {
    padding: 0.85rem 1rem;
    border-radius: 10px;
    margin-bottom: 0.75rem;
    border: 1px solid transparent;
}

.message--success {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #065f46;
}

.message--error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.field-with-action {
    display: flex;
    gap: 10px;
    align-items: center;
}

.field-with-action select,
.field-with-action input {
    flex: 1;
    margin 10px;
}

.form-actions {
    margin-top: 10px;
}

.stats-header {
    align-items: center;
}

.stats-updated-box {
    min-width: 220px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-soft);
    text-align: right;
}

.stats-updated-label {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 6px;
}

.stats-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stats-card {
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stats-card--accent {
    background: var(--accent-soft);
    border-color: rgba(37, 99, 235, 0.18);
}

.stats-card__label {
    font-size: 0.95rem;
    color: var(--muted);
    font-weight: 600;
}

.stats-card__value {
    font-size: 2rem;
    line-height: 1;
    font-weight: 800;
    color: var(--text);
}

.stats-card__hint {
    font-size: 0.9rem;
    color: var(--muted);
    line-height: 1.5;
}

.stats-section {
    margin-top: 12px;
}

.stats-section__header {
    margin-bottom: 14px;
}

.stats-section__header h2 {
    margin: 0 0 6px;
    font-size: 1.2rem;
}

.stats-section__header p {
    margin: 0;
    color: var(--muted);
}

.stats-table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

.stats-table th,
.stats-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.stats-table th {
    font-size: 0.92rem;
    color: var(--muted);
    font-weight: 700;
    background: var(--surface-soft);
}

.stats-table tbody tr:hover {
    background: #fafcff;
}

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

.status-name-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--accent);
    flex-shrink: 0;
}

.stats-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 800;
}

.table-muted {
    color: var(--muted);
}

@media (max-width: 992px) {
    .stats-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stats-header {
        flex-direction: column;
        align-items: stretch;
    }

    .stats-updated-box {
        text-align: left;
        min-width: auto;
    }
}

@media (max-width: 640px) {
    .stats-summary-grid {
        grid-template-columns: 1fr;
    }

    .stats-card__value {
        font-size: 1.7rem;
    }
}