:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --text: #182333;
    --muted: #6a7685;
    --line: #dce4ec;
    --primary: #123f5f;
    --primary-hover: #0d314b;
    --accent: #0f766e;
    --danger-bg: #fff1ee;
    --danger-text: #a0271c;
    --success-bg: #e9f8f2;
    --success-text: #08654f;
    --shadow: 0 18px 42px rgba(20, 36, 51, 0.08);
}

* {
    box-sizing: border-box;
}

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

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

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

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

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

.login-brand,
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--accent);
    color: #ffffff;
    font-weight: 700;
}

.login-card h1 {
    margin: 28px 0 6px;
    font-size: 1.7rem;
}

.login-card p,
.login-brand small,
.topbar span,
.welcome-panel span,
.card span,
.user-box small {
    color: var(--muted);
}

.form-stack {
    display: grid;
    gap: 16px;
    margin-top: 22px;
}

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

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 12px;
    background: #ffffff;
    color: var(--text);
    outline: none;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
}

.button-primary {
    background: var(--primary);
    color: #ffffff;
}

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

.button-secondary {
    background: #ffffff;
    color: var(--primary);
    border-color: var(--line);
}

.alert {
    margin-top: 16px;
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid #ffd0c7;
    border-radius: 8px;
    background: var(--danger-bg);
    color: var(--danger-text);
}

.alert-success {
    border-color: #bfead8;
    background: var(--success-bg);
    color: var(--success-text);
}

.alert-warning {
    border-color: #f2d58a;
    background: #fff8df;
    color: #76540a;
}

.alert-info {
    border-color: #b9dbea;
    background: #edf8fc;
    color: #17566f;
}

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

.sidebar {
    background: #102638;
    color: #ffffff;
    padding: 24px 18px;
}

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

.sidebar-nav a {
    padding: 11px 12px;
    border-radius: 8px;
    color: #d9e5ee;
}

.sidebar-nav a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.sidebar-nav a.active {
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    font-weight: 700;
}

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

.topbar {
    min-height: 84px;
    padding: 18px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    background: #ffffff;
    border-bottom: 1px solid var(--line);
}

.topbar h1 {
    margin: 2px 0 0;
    font-size: 1.8rem;
}

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

.user-box strong,
.user-box small {
    display: block;
}

.content {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: 28px 30px 44px;
}

.welcome-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    padding: 22px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.welcome-panel h2 {
    margin: 4px 0 0;
}

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

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

.card strong {
    display: block;
    margin-top: 8px;
    color: var(--primary);
    font-size: 2rem;
}

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

.card-link {
    display: inline-block;
    margin-top: 12px;
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 700;
}

.panel {
    max-width: 720px;
    padding: 22px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel-heading {
    margin-bottom: 18px;
}

.panel-heading h2 {
    margin: 0;
    font-size: 1.15rem;
}

.panel-heading p,
.page-actions p {
    margin: 4px 0 0;
    color: var(--muted);
}

.panel-wide {
    width: 100%;
    max-width: none;
}

.page-actions,
.panel-heading-actions,
.button-group,
.form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.page-actions {
    margin-bottom: 20px;
}

.page-actions h2 {
    margin: 4px 0 0;
}

.button-group,
.form-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
}

.button-group form,
.table-actions form {
    margin: 0;
}

.filters-form {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) 180px auto auto;
    align-items: end;
    gap: 12px;
    margin-bottom: 20px;
}

.table-responsive {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

th,
td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    background: #f7f9fb;
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
}

.badge-active {
    background: var(--success-bg);
    color: var(--success-text);
}

.badge-inactive {
    background: #eef1f4;
    color: #52606d;
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 700;
}

.link-button {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--danger-text);
    cursor: pointer;
    font-weight: 700;
}

.empty-state {
    padding: 34px 18px;
    color: var(--muted);
    text-align: center;
}

.empty-state h3,
.empty-state p {
    margin: 0;
}

.empty-state h3 + p {
    margin-top: 5px;
}

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

.form-field {
    display: grid;
    align-content: start;
    gap: 7px;
}

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

.field-error {
    color: var(--danger-text);
    font-weight: 700;
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 9px;
}

.checkbox-field input {
    width: auto;
}

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

.profile-panel,
.history-panel,
.dashboard-panel {
    margin-top: 20px;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 28px;
    margin: 0;
}

.details-grid div {
    min-width: 0;
}

.details-grid dt {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 700;
}

.details-grid dd {
    margin: 4px 0 0;
    overflow-wrap: anywhere;
}

.detail-wide {
    grid-column: 1 / -1;
}

.recent-list {
    display: grid;
}

.recent-list a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 13px 0;
    border-bottom: 1px solid var(--line);
}

.recent-list a:last-child {
    border-bottom: 0;
}

.recent-list span,
.recent-list strong,
.recent-list small {
    display: block;
}

.recent-list small,
.recent-list time {
    color: var(--muted);
}

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

    .sidebar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 18px;
    }

    .sidebar-nav {
        display: flex;
        margin-top: 0;
    }

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

    .filters-form {
        grid-template-columns: minmax(0, 1fr) minmax(160px, 0.4fr);
    }
}

@media (max-width: 640px) {
    .topbar,
    .welcome-panel,
    .sidebar {
        align-items: stretch;
        flex-direction: column;
    }

    .content,
    .topbar {
        padding-left: 18px;
        padding-right: 18px;
    }

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

    .summary-grid,
    .client-form,
    .details-grid,
    .filters-form {
        grid-template-columns: 1fr;
    }

    .page-actions,
    .panel-heading-actions,
    .button-group,
    .form-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .button-group form,
    .button-group form .button {
        width: 100%;
    }

    .recent-list a {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }

    .button {
        width: 100%;
    }

    .user-box {
        text-align: left;
    }
}
