:root {
    --bg: #eef3f8;
    --bg-strong: #0f172a;
    --sidebar: #ffffff;
    --sidebar-hover: #f3f5f7;
    --surface: #ffffff;
    --surface-alt: #f7fafc;
    --line: #d7dee7;
    --ink: #18283f;
    --muted: #76879a;
    --primary: #2e87c8;
    --primary-strong: #226b9f;
    --accent: #ef3d3d;
    --success: #1f9d63;
    --danger: #db5a5a;
    --warning-bg: #fff3e6;
    --shadow: 0 10px 28px rgba(17, 35, 58, 0.08);
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

a {
    color: inherit;
}

.guest-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top right, rgba(40, 145, 214, 0.35), transparent 28%),
        linear-gradient(135deg, #17314b 0%, #1e4261 36%, #2a86c3 100%);
}

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

.login-card {
    width: min(440px, 100%);
    background: rgba(255, 255, 255, 0.98);
    border-radius: 22px;
    box-shadow: var(--shadow);
    padding: 32px;
    border: 1px solid rgba(255, 255, 255, 0.35);
}

.login-brand {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 22px;
}

.brand-badge {
    width: 54px;
    height: 54px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary), #4cb2f2);
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
}

.login-brand strong,
.brand strong {
    display: block;
    font-size: 1.1rem;
    line-height: 1.2;
}

.login-brand span,
.brand span,
.topbar p,
.muted {
    color: var(--muted);
}

.brand span,
.login-brand span {
    font-size: 0.88rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.panel-title {
    margin: 0 0 6px;
    font-size: 1.7rem;
}

.panel-copy {
    margin: 0 0 24px;
    color: var(--muted);
    line-height: 1.6;
}

.stack {
    display: grid;
    gap: 18px;
}

.field {
    display: grid;
    gap: 8px;
}

.field label {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #4b5b70;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(40, 145, 214, 0.12);
}

.field textarea {
    min-height: 112px;
    resize: vertical;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 46px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: var(--primary);
    color: #fff;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.button:hover {
    background: var(--primary-strong);
}

.button.ghost {
    background: #fff;
    color: var(--ink);
    border-color: var(--line);
}

.button.ghost:hover {
    background: var(--surface-alt);
}

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

.button.block {
    width: 100%;
}

.notice {
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
}

.notice.warning {
    background: var(--warning-bg);
}

.notice.success {
    background: #effaf5;
    color: #0f7a4a;
}

.shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 272px 1fr;
}

.sidebar {
    background: var(--sidebar);
    color: var(--ink);
    padding: 10px 0 16px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    border-right: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 100px;
    padding: 8px 22px 14px;
    margin: 0;
    border-bottom: 1px solid var(--line);
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary), #52b8f5);
    color: #fff;
    font-weight: 700;
}

.brand-logo-wrap {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: #f4f7fa;
    display: grid;
    place-items: center;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid #e7edf3;
}

.brand-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.login-logo-wrap {
    width: 56px;
    height: 56px;
    background: #f4f8fb;
}

.login-logo {
    padding: 6px;
}

.nav {
    display: grid;
    gap: 2px;
    padding: 0;
}

.nav a {
    position: relative;
    padding: 16px 22px 16px 30px;
    text-decoration: none;
    color: #4f5f72;
    font-weight: 500;
    border-radius: 0;
}

.nav a::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: transparent;
}

.nav a:hover {
    background: var(--sidebar-hover);
    color: var(--ink);
}

.nav a.active {
    background: #e9edf2;
    color: var(--ink);
    font-weight: 600;
}

.nav a.active::before {
    background: var(--accent);
}

.main-area {
    display: grid;
    grid-template-rows: auto 1fr;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 100px;
    padding: 14px 30px 12px;
    background: #fff;
    border-bottom: 1px solid #e7edf3;
}

.topbar h1 {
    margin: 0 0 4px;
    font-size: 1.75rem;
    letter-spacing: -0.03em;
}

.topbar p {
    margin: 0;
    font-size: 0.92rem;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-chip {
    text-align: right;
}

.user-chip strong {
    display: block;
    font-size: 0.95rem;
}

.user-chip span {
    color: var(--muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.content {
    padding: 28px;
}

.grid {
    display: grid;
    gap: 20px;
}

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

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

.card {
    background: var(--surface);
    border: 1px solid #e7edf3;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px;
}

.card h2,
.card h3 {
    margin-top: 0;
}

.card-subtitle {
    color: var(--muted);
    margin: 0 0 18px;
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 8px 0 4px;
}

.metric-note {
    color: var(--muted);
    font-size: 0.92rem;
}

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

.section-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 22px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
}

.tab-link {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 12px;
    text-decoration: none;
    color: #556579;
    background: #f4f7fa;
    border: 1px solid transparent;
    font-weight: 600;
}

.tab-link:hover {
    background: #eef3f8;
    color: var(--ink);
}

.tab-link.active {
    background: #fff;
    color: var(--ink);
    border-color: var(--line);
    box-shadow: 0 4px 14px rgba(17, 35, 58, 0.05);
}

.metric-box {
    padding: 18px;
    border-radius: 16px;
    background: #fbfdff;
    border: 1px solid #e6edf5;
}

.metric-box strong {
    display: block;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 10px;
}

.metric-box span {
    font-size: 1.6rem;
    font-weight: 700;
}

.toolbar,
.page-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

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

.schedule-builder {
    display: grid;
    gap: 12px;
    margin-bottom: 12px;
}

.schedule-row {
    display: grid;
    grid-template-columns: minmax(150px, 0.9fr) minmax(220px, 1.1fr) minmax(140px, 0.8fr) minmax(140px, 0.8fr) auto;
    gap: 10px;
    align-items: end;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fbfdff;
}

.schedule-remove {
    min-width: 96px;
}

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

.filters-form {
    display: grid;
    gap: 16px;
    margin-bottom: 22px;
}

.filters-row {
    display: grid;
    grid-template-columns: minmax(240px, 1.5fr) minmax(180px, 0.8fr) auto;
    gap: 14px;
    align-items: end;
}

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

th,
td {
    padding: 14px 12px;
    border-bottom: 1px solid #ecf1f5;
    text-align: left;
}

th {
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: #edf7ff;
    color: var(--primary-strong);
    font-size: 0.82rem;
    font-weight: 700;
}

.pill.success {
    background: #eefaf4;
    color: var(--success);
}

.checkbox-field {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    font-weight: 600;
    color: #4b5b70;
}

.checkbox-field input {
    width: 18px;
    height: 18px;
    margin: 0;
}

.color-picker-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 64px;
    gap: 10px;
    align-items: center;
}

.color-picker-input {
    width: 64px;
    min-width: 64px;
    height: 48px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
}

.color-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 999px;
    margin-right: 8px;
    vertical-align: middle;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.empty-state {
    padding: 28px;
    text-align: center;
    color: var(--muted);
    background: var(--surface-alt);
    border: 1px dashed var(--line);
    border-radius: 16px;
}

.footer-note {
    margin-top: 16px;
    color: var(--muted);
    font-size: 0.9rem;
}

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

    .sidebar {
        padding-bottom: 14px;
    }

    .nav {
        padding: 0 18px;
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }

    .nav a {
        padding: 14px 16px;
        border-radius: 12px;
    }

    .nav a::before {
        display: none;
    }

    .grid.cols-3,
    .grid.cols-2 {
        grid-template-columns: 1fr;
    }

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

    .filters-row {
        grid-template-columns: 1fr;
    }

    .schedule-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 680px) {
    .content,
    .topbar {
        padding: 18px;
    }

    .login-card {
        padding: 24px;
    }

    .topbar,
    .toolbar,
    .page-actions {
        align-items: stretch;
    }

    .topbar-actions {
        width: 100%;
        justify-content: space-between;
    }

    .metric-grid {
        grid-template-columns: 1fr;
    }

    .section-tabs {
        flex-wrap: wrap;
    }
}
