:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --text: #172033;
    --muted: #667085;
    --line: #d9e0ea;
    --primary: #176b87;
    --primary-dark: #0f4f65;
    --danger-bg: #fff1f1;
    --danger-text: #9f1d1d;
    --success-bg: #eaf7ee;
    --shadow: 0 14px 36px rgba(23, 32, 51, 0.08);
}

* {
    box-sizing: border-box;
}

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

a {
    color: inherit;
}

.topbar {
    align-items: center;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 20px;
    justify-content: space-between;
    min-height: 64px;
    padding: 12px clamp(16px, 4vw, 40px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    color: var(--primary-dark);
    font-size: 1.05rem;
    font-weight: 700;
    text-decoration: none;
}

.nav {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.nav a {
    border-radius: 6px;
    color: var(--text);
    padding: 8px 10px;
    text-decoration: none;
}

.nav a:hover {
    background: #eef4f7;
}

.nav-form {
    margin: 0;
}

.container {
    margin: 0 auto;
    max-width: 1120px;
    padding: 28px clamp(16px, 4vw, 40px) 48px;
}

.auth-shell {
    display: grid;
    min-height: calc(100vh - 120px);
    place-items: center;
}

.auth-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    max-width: 420px;
    padding: 28px;
    width: 100%;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    font-size: clamp(1.55rem, 3vw, 2.2rem);
    line-height: 1.15;
    margin-bottom: 8px;
}

h2 {
    font-size: 1.2rem;
}

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

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

label {
    font-weight: 700;
}

input,
select,
textarea {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    min-height: 44px;
    padding: 10px 12px;
    width: 100%;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.16);
    outline: none;
}

.button {
    align-items: center;
    background: var(--primary);
    border: 1px solid var(--primary);
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 700;
    justify-content: center;
    min-height: 42px;
    padding: 9px 14px;
    text-decoration: none;
}

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

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

.button-light:hover {
    background: #eef4f7;
    border-color: var(--line);
}

.alert {
    border-radius: 6px;
    margin: 16px 0;
    padding: 12px 14px;
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.page-heading {
    align-items: center;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 24px;
}

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

.card,
.empty-state {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 20px;
}

.card-label {
    color: var(--muted);
    display: block;
    font-weight: 700;
    margin-bottom: 10px;
}

.card-number {
    display: block;
    font-size: 2rem;
    line-height: 1;
}

.card-value {
    display: block;
    font-size: 1.15rem;
    line-height: 1.25;
}

.panel-section {
    margin-top: 28px;
}

.toolbar {
    align-items: center;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(180px, 1fr) auto auto;
    margin-bottom: 18px;
}

.toolbar-filters {
    grid-template-columns: minmax(180px, 1.4fr) repeat(3, minmax(140px, 1fr)) auto;
}

.filter-actions {
    align-items: end;
    display: flex;
    gap: 8px;
    padding-top: 29px;
}

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow-x: auto;
}

table {
    border-collapse: collapse;
    min-width: 820px;
    width: 100%;
}

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

th {
    background: #f0f5f8;
    color: #344054;
    font-size: 0.88rem;
}

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

.status {
    background: var(--success-bg);
    border-radius: 999px;
    color: #20603d;
    display: inline-flex;
    font-size: 0.86rem;
    font-weight: 700;
    padding: 4px 9px;
}

.status-inactive {
    background: #eef1f5;
    color: #475467;
}

.alert-success {
    background: var(--success-bg);
    color: #20603d;
}

.form-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    max-width: 680px;
    padding: 24px;
}

.form-group {
    display: grid;
    gap: 6px;
}

.form-actions,
.table-actions,
.pagination {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.inline-form {
    margin: 0;
}

.button-small {
    min-height: 36px;
    padding: 6px 10px;
}

.button-danger {
    background: #b42318;
    border-color: #b42318;
}

.button-danger:hover {
    background: #912018;
    border-color: #912018;
}

.field-error {
    color: var(--danger-text);
    font-size: 0.9rem;
    margin: 0;
}

.field-help {
    color: var(--muted);
    font-size: 0.9rem;
    margin: 0;
}

.pagination {
    justify-content: center;
    margin-top: 18px;
}

.policy-detail {
    display: grid;
    gap: 1rem;
}

.policy-detail > div {
    display: grid;
    grid-template-columns: minmax(10rem, 14rem) 1fr;
    gap: 1rem;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: .75rem;
}

.policy-detail span {
    overflow-wrap: anywhere;
}

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

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

.client-record-grid .card {
    box-shadow: none;
}

.client-record-list {
    display: grid;
    gap: 10px;
    margin: 0;
}

.client-record-list > div {
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 6px;
    grid-template-columns: minmax(9rem, 0.7fr) 1.3fr;
    padding-bottom: 10px;
}

.client-record-list > div:last-child {
    border-bottom: 0;
}

.client-record-list dt {
    font-weight: 700;
}

.client-record-list dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.client-record-wide {
    grid-column: 1 / -1;
}

.next-expiration {
    margin-top: 28px;
}

.sr-only {
    height: 1px;
    margin: -1px;
    overflow: hidden;
    position: absolute;
    width: 1px;
}

@media (max-width: 760px) {
    .topbar,
    .page-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .nav {
        width: 100%;
    }

    .cards-grid,
    .client-summary,
    .client-record-grid,
    .toolbar,
    .toolbar-filters {
        grid-template-columns: 1fr;
    }

    .filter-actions {
        align-items: stretch;
        flex-direction: column;
        padding-top: 0;
    }

    .button {
        width: 100%;
    }

    .client-record-list > div {
        grid-template-columns: 1fr;
    }
}
