:root {
    color-scheme: light;
    --bg: #f5f8fb;
    --panel: #ffffff;
    --line: #dde7ef;
    --line-strong: #cfdae5;
    --text: #172033;
    --muted: #687789;
    --soft: #eef5f5;
    --teal: #0f8a7d;
    --teal-dark: #087467;
    --green: #29a84a;
    --violet: #7c5cf6;
    --orange: #f59e2e;
    --shadow: 0 16px 40px rgba(21, 38, 63, 0.08);
    font-family: Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    margin: 0;
}

a {
    color: inherit;
}

button,
input,
select,
textarea {
    font: inherit;
}

button:disabled,
input:disabled,
.is-disabled {
    cursor: not-allowed;
}

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

.sidebar {
    background: rgba(255, 255, 255, 0.84);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 28px;
    padding: 24px 18px;
}

.brand {
    align-items: center;
    color: var(--teal);
    display: flex;
    font-size: 24px;
    font-weight: 800;
    gap: 10px;
    letter-spacing: 0;
    text-decoration: none;
}

.brand-mark {
    align-items: center;
    background: linear-gradient(145deg, #e8f8f5, #d9f0ec);
    border: 2px solid var(--teal);
    border-radius: 50%;
    display: inline-flex;
    font-size: 14px;
    height: 32px;
    justify-content: center;
    width: 32px;
}

.side-nav {
    display: grid;
    gap: 8px;
}

.nav-item {
    align-items: center;
    border-radius: 10px;
    color: #425066;
    display: flex;
    gap: 12px;
    min-height: 46px;
    padding: 0 14px;
    text-decoration: none;
}

.nav-item.is-active {
    background: #e7f4f1;
    color: var(--teal-dark);
    font-weight: 700;
}

.nav-item.is-disabled {
    opacity: 0.82;
    user-select: none;
}

.nav-icon {
    align-items: center;
    color: currentColor;
    display: inline-flex;
    font-size: 18px;
    justify-content: center;
    width: 24px;
}

.nav-separator {
    border-top: 1px solid var(--line);
    margin: 14px 12px;
}

.sidebar-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
    margin-top: auto;
    padding: 18px;
    text-align: center;
}

.sidebar-card p {
    color: #526174;
    font-size: 13px;
    line-height: 1.35;
    margin: 10px 0 16px;
}

.sidebar-illustration {
    align-items: center;
    background: #e9f6f4;
    border-radius: 50%;
    color: var(--teal);
    display: inline-flex;
    font-size: 13px;
    font-weight: 800;
    height: 68px;
    justify-content: center;
    width: 68px;
}

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

.topbar {
    align-items: center;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 22px;
    justify-content: space-between;
    min-height: 76px;
    padding: 0 28px;
}

.top-search {
    align-items: center;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: #7a8797;
    display: flex;
    gap: 10px;
    height: 44px;
    max-width: 540px;
    padding: 0 12px;
    width: min(42vw, 540px);
}

.top-search input {
    background: transparent;
    border: 0;
    color: #7a8797;
    min-width: 0;
    outline: 0;
    width: 100%;
}

.shortcut {
    border: 1px solid var(--line);
    border-radius: 7px;
    color: #687789;
    font-size: 12px;
    padding: 3px 6px;
    white-space: nowrap;
}

.top-actions,
.top-tabs,
.profile-button {
    align-items: center;
    display: flex;
}

.top-actions {
    gap: 14px;
}

.top-tabs {
    background: #eef2f6;
    border-radius: 12px;
    padding: 4px;
}

.top-tabs a {
    border-radius: 9px;
    color: #596779;
    font-weight: 700;
    padding: 10px 18px;
    text-decoration: none;
}

.top-tabs a.is-active {
    background: var(--panel);
    color: var(--teal-dark);
    box-shadow: 0 6px 14px rgba(21, 38, 63, 0.08);
}

.icon-button {
    background: transparent;
    border: 0;
    color: #526174;
    height: 38px;
    position: relative;
    width: 38px;
}

.icon-button strong {
    align-items: center;
    background: var(--teal);
    border-radius: 50%;
    color: #fff;
    display: inline-flex;
    font-size: 10px;
    height: 18px;
    justify-content: center;
    position: absolute;
    right: 0;
    top: 0;
    width: 18px;
}

.profile-form {
    margin: 0;
}

.profile-button {
    background: transparent;
    border: 0;
    color: var(--text);
    gap: 9px;
    padding: 0;
}

.avatar {
    align-items: center;
    background: #6ec7b7;
    border-radius: 50%;
    color: #fff;
    display: inline-flex;
    font-size: 14px;
    font-weight: 800;
    height: 36px;
    justify-content: center;
    width: 36px;
}

.avatar-small {
    font-size: 12px;
    height: 28px;
    width: 28px;
}

.content {
    padding: 28px;
}

.page-hero,
.panel,
.stat-card,
.login-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.page-hero {
    align-items: center;
    display: flex;
    gap: 18px;
    justify-content: space-between;
    margin-bottom: 24px;
    padding: 28px 32px;
}

.page-hero h1 {
    font-size: 30px;
    line-height: 1.1;
    margin: 0 0 8px;
}

.page-hero p,
.stat-card p,
.stat-card span,
.panel h2 {
    margin: 0;
}

.page-hero p,
.stat-card p,
.stat-card span,
label,
small {
    color: var(--muted);
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

.btn {
    align-items: center;
    border-radius: 8px;
    display: inline-flex;
    font-weight: 800;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    text-decoration: none;
}

.btn-primary {
    background: var(--teal);
    border: 1px solid var(--teal);
    color: #fff;
}

.btn-primary:hover {
    background: var(--teal-dark);
}

.btn-secondary {
    background: #fff;
    border: 1px solid var(--line-strong);
    color: #314155;
}

.btn-muted {
    background: #f4f7fa;
    border: 1px solid var(--line);
    color: #66758a;
}

.btn-small {
    font-size: 12px;
    min-height: 32px;
    padding: 0 12px;
}

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

.stat-card {
    align-items: center;
    display: flex;
    gap: 18px;
    min-height: 120px;
    padding: 22px;
}

.stat-card strong {
    display: block;
    font-size: 28px;
    line-height: 1.05;
    margin: 7px 0;
}

.stat-icon {
    align-items: center;
    border-radius: 50%;
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 24px;
    height: 62px;
    justify-content: center;
    width: 62px;
}

.stat-icon.teal {
    background: #e3f5f2;
    color: var(--teal);
}

.stat-icon.green {
    background: #e9f8ec;
    color: var(--green);
}

.stat-icon.violet {
    background: #eeeafd;
    color: var(--violet);
}

.stat-icon.orange {
    background: #fff0df;
    color: var(--orange);
}

.workspace-grid {
    align-items: start;
    display: grid;
    gap: 22px;
    grid-template-columns: minmax(360px, 0.9fr) minmax(0, 1.35fr);
}

.workspace-grid-single {
    grid-template-columns: minmax(0, 1fr);
}

.panel {
    min-width: 0;
    padding: 20px;
}

.panel-title,
.panel-head {
    align-items: center;
    display: flex;
    gap: 12px;
}

.panel-title {
    margin-bottom: 22px;
}

.panel-title h2,
.panel-head h2 {
    font-size: 18px;
}

.panel-icon {
    align-items: center;
    background: #f4f8fb;
    border: 1px solid var(--line);
    border-radius: 9px;
    display: inline-flex;
    height: 34px;
    justify-content: center;
    width: 34px;
}

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

.form-panel .client-form {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

label {
    display: grid;
    font-size: 12px;
    font-weight: 700;
    gap: 7px;
}

input,
select,
textarea {
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    color: var(--text);
    min-height: 42px;
    outline: 0;
    padding: 10px 12px;
    width: 100%;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(15, 138, 125, 0.12);
}

textarea {
    min-height: 86px;
    resize: vertical;
}

.wide {
    grid-column: span 2;
}

.form-submit {
    align-self: end;
    grid-column: span 2;
    justify-self: start;
    min-width: 190px;
}

.error,
.success {
    border-radius: 10px;
    margin: 0 0 18px;
    padding: 12px 14px;
}

.error {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.success {
    background: #dcfce7;
    border: 1px solid #bbf7d0;
    color: #166534;
}

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

.panel-head {
    justify-content: space-between;
    margin-bottom: 18px;
}

.table-tools {
    display: flex;
    gap: 10px;
}

.table-search {
    align-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    display: flex;
    gap: 8px;
    min-width: 240px;
    padding: 0 11px;
}

.table-search input {
    border: 0;
    min-height: 38px;
    padding: 0;
}

.tool-button {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #526174;
    min-height: 40px;
    padding: 0 12px;
}

.icon-only {
    min-width: 44px;
}

.table-wrap {
    overflow: visible;
}

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

th,
td {
    border-bottom: 1px solid var(--line);
    font-size: 12px;
    line-height: 1.35;
    overflow-wrap: anywhere;
    padding: 18px 10px;
    text-align: left;
    vertical-align: middle;
}

th {
    color: #3c4a5c;
    font-size: 11px;
    font-weight: 800;
}

th:nth-child(1),
td:nth-child(1) {
    width: 16%;
}

th:nth-child(2),
td:nth-child(2) {
    width: 14%;
}

th:nth-child(3),
td:nth-child(3) {
    width: 12%;
}

th:nth-child(4),
td:nth-child(4),
th:nth-child(6),
td:nth-child(6),
th:nth-child(8),
td:nth-child(8),
th:nth-child(9),
td:nth-child(9) {
    width: 9%;
}

th:nth-child(5),
td:nth-child(5),
th:nth-child(7),
td:nth-child(7) {
    width: 11%;
}

.company-cell,
.manager-cell {
    align-items: center;
    display: flex;
    gap: 10px;
    min-width: 0;
}

.company-cell strong,
.cell-main {
    display: block;
    font-weight: 800;
}

.company-cell small,
td small {
    display: block;
    margin-top: 4px;
}

.company-avatar {
    align-items: center;
    background: #e2f4f1;
    border-radius: 50%;
    color: var(--teal);
    display: inline-flex;
    flex: 0 0 auto;
    height: 42px;
    justify-content: center;
    width: 42px;
}

.site-link {
    color: #2563eb;
    text-decoration: none;
}

.status-pill,
.priority-pill {
    border-radius: 8px;
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    padding: 6px 9px;
}

.status-pill {
    background: #e4f7e8;
    color: #23843c;
}

.priority-high {
    background: #fee2d7;
    color: #c24a1f;
}

.priority-medium {
    background: #fff0cc;
    color: #9a6500;
}

.priority-low {
    background: #eef4fb;
    color: #607188;
}

.actions-cell form {
    margin: 0;
}

.table-footer {
    align-items: center;
    color: var(--muted);
    display: flex;
    font-size: 13px;
    justify-content: space-between;
    padding-top: 20px;
}

.pager {
    display: flex;
    gap: 8px;
}

.pager button {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #7a8797;
    height: 36px;
    min-width: 36px;
}

.pager .is-current {
    background: #fff;
    border-color: var(--teal);
    color: var(--teal-dark);
}

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

.login-panel {
    max-width: 420px;
    padding: 28px;
    width: 100%;
}

.import-panel {
    max-width: 720px;
}

.login-panel h1 {
    margin: 0 0 20px;
}

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

.login-form button {
    background: var(--teal);
    border: 1px solid var(--teal);
    border-radius: 8px;
    color: #fff;
    font-weight: 800;
    min-height: 44px;
}

.login-form button:hover {
    background: var(--teal-dark);
}

.auth-links {
    color: var(--muted);
    font-size: 14px;
    margin: 18px 0 0;
    text-align: center;
}

.auth-links a {
    color: var(--teal-dark);
    font-weight: 800;
    text-decoration: none;
}

.auth-actions {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.auth-register-button {
    width: 100%;
}

@media (max-width: 1320px) {
    .workspace-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

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

    .top-search {
        display: none;
    }

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

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

    .sidebar {
        position: static;
    }

    .sidebar-card,
    .nav-separator,
    .side-nav .is-disabled {
        display: none;
    }

    .side-nav {
        display: flex;
    }

    .topbar,
    .page-hero,
    .panel-head,
    .table-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .content {
        padding: 18px;
    }

    .stats-grid,
    .client-form,
    .form-panel .client-form {
        grid-template-columns: 1fr;
    }

    .wide,
    .form-submit {
        grid-column: auto;
    }

    .top-actions {
        flex-wrap: wrap;
        width: 100%;
    }

    .table-tools {
        flex-wrap: wrap;
        width: 100%;
    }

    .table-search {
        min-width: 0;
        width: 100%;
    }

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

    thead {
        display: none;
    }

    tr {
        border-bottom: 1px solid var(--line);
        padding: 14px 0;
    }

    td {
        border-bottom: 0;
        padding: 8px 0;
        width: 100% !important;
    }
}
