:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --text: #172033;
    --muted: #667085;
    --line: #e3e8ef;
    --primary: #1f5eff;
    --primary-dark: #1648c7;
    --secondary: #eef4ff;
    --danger: #c2410c;
    --success: #047857;
    --warning: #b45309;
    --shadow: 0 20px 45px rgba(15, 23, 42, 0.08);
    --radius: 20px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    color: var(--primary-dark);
}

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 24px 18px;
    background: #0f172a;
    color: #fff;
}

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

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, #3b82f6, #22c55e);
    color: #fff;
    font-weight: 800;
    box-shadow: 0 14px 30px rgba(59, 130, 246, 0.32);
}

.brand-mark.large {
    width: 54px;
    height: 54px;
    border-radius: 18px;
    font-size: 24px;
}

.brand-title {
    font-weight: 800;
    letter-spacing: -0.02em;
}

.brand-subtitle {
    margin-top: 3px;
    color: #94a3b8;
    font-size: 13px;
}

.nav {
    display: grid;
    gap: 8px;
    margin-top: 34px;
}

.nav-link {
    padding: 12px 14px;
    border-radius: 14px;
    color: #cbd5e1;
    font-weight: 650;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover,
.nav-link.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-footer {
    margin-top: auto;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.08);
}

.user-avatar {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #1d4ed8;
    color: #fff;
    font-weight: 800;
}

.user-name {
    font-weight: 700;
}

.logout-link {
    display: inline-block;
    margin-top: 2px;
    color: #cbd5e1;
    font-size: 13px;
}

.main {
    min-width: 0;
    padding: 28px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 24px;
}

.page-eyebrow {
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

h1 {
    margin: 0;
    font-size: 30px;
    line-height: 1.15;
    letter-spacing: -0.03em;
}

h2 {
    margin: 0;
    font-size: 18px;
    letter-spacing: -0.02em;
}

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

.btn {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 14px;
    font-weight: 750;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
}

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

.btn.primary:hover {
    color: #fff;
    background: var(--primary-dark);
}

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

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

.btn.full {
    width: 100%;
}

.panel {
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.stat-card {
    display: grid;
    gap: 8px;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.stat-card strong {
    color: var(--text);
    font-size: 38px;
    line-height: 1;
}

.stat-label {
    color: var(--muted);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-size: 12px;
}

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

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

.status-list,
.compact-list,
.comment-list {
    display: grid;
    gap: 10px;
}

.status-row,
.compact-item {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    padding: 13px 14px;
    border-radius: 14px;
    background: var(--panel-soft);
    color: var(--text);
}

.status-row strong {
    min-width: 34px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: #fff;
    color: var(--primary);
    border: 1px solid var(--line);
}

.compact-item div {
    display: grid;
    gap: 4px;
}

.compact-item span {
    color: var(--muted);
    font-size: 14px;
}

.compact-item em {
    font-style: normal;
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.field,
.search-field,
.select-field {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
}

.search-field {
    min-width: 280px;
    flex: 1;
}

.search-field.wide {
    min-width: 360px;
}

input,
select {
    width: 100%;
    min-height: 42px;
    padding: 0 13px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: #fff;
    color: var(--text);
    font: inherit;
    outline: none;
}

input:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(31, 94, 255, 0.12);
}

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

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

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

th,
td {
    padding: 15px 18px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    background: #f8fafc;
    font-size: 12px;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tbody tr:hover {
    background: #fbfdff;
}

.table-main-link {
    color: var(--text);
    font-weight: 800;
}

.badge,
.priority {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.badge {
    color: #1d4ed8;
    background: #dbeafe;
}

.priority.low {
    color: var(--success);
    background: #d1fae5;
}

.priority.medium {
    color: #1d4ed8;
    background: #dbeafe;
}

.priority.high {
    color: var(--warning);
    background: #ffedd5;
}

.priority.critical {
    color: #b91c1c;
    background: #fee2e2;
}

.details {
    display: grid;
    gap: 12px;
    margin: 0;
}

.details div {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.details div:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

dt {
    color: var(--muted);
    font-weight: 800;
}

dd {
    margin: 0;
    min-width: 0;
}

.text-block {
    margin: 0;
    color: #344054;
    line-height: 1.65;
    white-space: pre-line;
}

.comment {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel-soft);
}

.comment-meta {
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
}

.empty-state {
    padding: 16px;
    color: var(--muted);
    border-radius: 14px;
    background: var(--panel-soft);
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14px;
    padding: 16px;
}

.pagination a {
    padding: 9px 13px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    font-weight: 750;
}

.login-body {
    background:
        radial-gradient(circle at 20% 20%, rgba(59, 130, 246, 0.20), transparent 32%),
        radial-gradient(circle at 85% 15%, rgba(34, 197, 94, 0.18), transparent 28%),
        #eef4ff;
}

.login-page {
    display: grid;
    grid-template-columns: minmax(0, 480px) minmax(0, 1fr);
    gap: 32px;
    align-items: center;
    width: min(1120px, calc(100% - 36px));
    min-height: 100vh;
    margin: 0 auto;
    padding: 32px 0;
}

.login-panel,
.login-visual {
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.login-panel {
    padding: 34px;
}

.login-copy {
    margin: 34px 0 24px;
}

.login-copy h1 {
    font-size: 34px;
}

.login-copy p {
    margin: 12px 0 0;
    color: var(--muted);
    line-height: 1.55;
}

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

.form-error {
    padding: 12px 14px;
    border-radius: 14px;
    color: #b91c1c;
    background: #fee2e2;
    font-weight: 700;
}

.login-visual {
    min-height: 520px;
    display: grid;
    align-items: end;
    padding: 34px;
    background:
        linear-gradient(135deg, rgba(15, 23, 42, 0.92), rgba(30, 64, 175, 0.76)),
        linear-gradient(135deg, #0f172a, #1d4ed8);
    color: #fff;
    overflow: hidden;
}

.visual-card {
    max-width: 540px;
}

.visual-kicker {
    margin-bottom: 14px;
    color: #bfdbfe;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 12px;
}

.visual-card h2 {
    font-size: 34px;
    line-height: 1.12;
}

.visual-card p {
    color: #dbeafe;
    line-height: 1.65;
}

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

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

    .nav {
        display: flex;
        overflow-x: auto;
        margin-top: 18px;
        padding-bottom: 4px;
    }

    .nav-link {
        white-space: nowrap;
    }

    .sidebar-footer {
        display: none;
    }

    .main {
        padding: 20px;
    }

    .stats-grid,
    .dashboard-grid,
    .detail-grid,
    .login-page {
        grid-template-columns: 1fr;
    }

    .login-visual {
        min-height: 320px;
    }
}

@media (max-width: 720px) {
    .topbar {
        display: grid;
    }

    h1 {
        font-size: 24px;
    }

    .panel {
        padding: 16px;
        border-radius: 18px;
    }

    .table-panel {
        padding: 0;
    }

    .filters {
        display: grid;
    }

    .search-field,
    .search-field.wide,
    .select-field {
        min-width: 0;
        width: 100%;
    }

    .btn {
        width: 100%;
    }

    .responsive-table,
    .responsive-table table,
    .responsive-table thead,
    .responsive-table tbody,
    .responsive-table th,
    .responsive-table td,
    .responsive-table tr {
        display: block;
    }

    .responsive-table thead {
        display: none;
    }

    .responsive-table tr {
        padding: 12px;
        border-bottom: 1px solid var(--line);
    }

    .responsive-table td {
        display: grid;
        grid-template-columns: 120px minmax(0, 1fr);
        gap: 12px;
        padding: 10px 0;
        border-bottom: 0;
    }

    .responsive-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-weight: 850;
    }

    .details div {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .login-page {
        width: min(100% - 24px, 560px);
        padding: 18px 0;
    }

    .login-panel {
        padding: 22px;
    }

    .login-visual {
        display: none;
    }
}

/* Forms and CRUD layer */
.messages {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.message {
    padding: 13px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    box-shadow: var(--shadow);
    font-weight: 750;
}

.message.success {
    color: var(--success);
    background: #ecfdf5;
    border-color: #a7f3d0;
}

.form-panel {
    max-width: 980px;
}

.crm-form {
    display: grid;
    gap: 20px;
}

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

.form-field {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.form-field.wide {
    grid-column: 1 / -1;
}

textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px 13px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: #fff;
    color: var(--text);
    font: inherit;
    line-height: 1.5;
    resize: vertical;
    outline: none;
}

textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(31, 94, 255, 0.12);
}

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

.field-error {
    display: block;
    color: #b91c1c;
    font-style: normal;
    font-weight: 750;
}

.comment-form {
    display: grid;
    gap: 12px;
    margin-bottom: 18px;
}

.comment-form textarea {
    min-height: 96px;
}

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

    .form-actions {
        display: grid;
    }
}

/* Change history */
.history-list {
    display: grid;
    gap: 12px;
}

.history-item {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel-soft);
}

.history-meta {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
}

.history-title {
    font-weight: 850;
    color: var(--text);
}

.history-change {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 12px;
    align-items: stretch;
    margin-top: 10px;
}

.history-change div:not(.history-arrow) {
    display: grid;
    gap: 5px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.history-change span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.history-change strong {
    font-weight: 700;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.history-arrow {
    display: grid;
    place-items: center;
    color: var(--muted);
    font-weight: 900;
}

@media (max-width: 720px) {
    .history-change {
        grid-template-columns: 1fr;
    }

    .history-arrow {
        transform: rotate(90deg);
    }
}

/* Project groups */
.stats-grid.four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.badge.muted {
    color: #475569;
    background: #e2e8f0;
}

.panel-header.padded {
    padding: 20px 20px 0;
}

.panel-link {
    font-weight: 800;
    font-size: 14px;
}

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

@media (max-width: 720px) {
    .stats-grid.four,
    .dashboard-grid.three {
        grid-template-columns: 1fr;
    }
}
