:root {
    --primary: #2563eb;
    --primary-soft: #e8f0ff;
    --dark: #0f172a;
    --sidebar: #0b1b35;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --bg: #f6f8fc;
    --card: #ffffff;
    --green: #16a34a;
    --orange: #f97316;
    --red: #dc2626;
    --purple: #7c3aed;
    --radius: 18px;
    --sidebar-width: 270px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
}

/* ── Icons ───────────────────────────────────────────── */

.icon {
    width: 1.25em;
    height: 1.25em;
    flex-shrink: 0;
    display: block;
}

.icon--sm {
    width: 16px;
    height: 16px;
}

.icon--md {
    width: 20px;
    height: 20px;
}

.icon--lg {
    width: 24px;
    height: 24px;
}

.nav-item .icon {
    opacity: 0.85;
}

.nav-item.active .icon,
.nav-item:hover .icon {
    opacity: 1;
}

.tenant-icon .icon,
.kpi-icon .icon,
.activity-icon .icon,
.timeline__icon .icon,
.document-card__icon .icon,
.empty-state__icon .icon {
    width: 20px;
    height: 20px;
}

.empty-state__icon .icon {
    width: 28px;
    height: 28px;
}

.icon-btn .icon {
    width: 18px;
    height: 18px;
}

.alert__icon .icon {
    width: 18px;
    height: 18px;
}

/* ── Sidebar ─────────────────────────────────────────── */

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #0b1b35 0%, #071225 100%);
    color: white;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 100;
    transition: transform 0.25s ease;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 90;
}

.sidebar-overlay.is-visible {
    display: block;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 28px;
}

.logo-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    display: grid;
    place-items: center;
    font-weight: 900;
    color: white;
    font-size: 18px;
}

.tenant-box {
    background: white;
    color: var(--dark);
    border-radius: 14px;
    padding: 14px;
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 28px;
}

.tenant-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--primary-soft);
    display: grid;
    place-items: center;
    color: var(--primary);
    font-weight: 800;
    font-size: 20px;
    flex-shrink: 0;
}

.tenant-box small {
    color: var(--muted);
    font-size: 13px;
}

.nav-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-title {
    margin: 24px 10px 8px;
    font-size: 11px;
    letter-spacing: 0.08em;
    color: #94a3b8;
    text-transform: uppercase;
}

.nav-item {
    padding: 12px 14px;
    border-radius: 12px;
    color: #dbeafe;
    text-decoration: none;
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 15px;
    transition: background 0.15s, color 0.15s;
}

.nav-item.active,
.nav-item:hover {
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    color: white;
}

.sidebar-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    color: var(--dark);
    display: grid;
    place-items: center;
    font-weight: 800;
    flex-shrink: 0;
    font-size: 14px;
}

.sidebar-footer small {
    color: #94a3b8;
    font-size: 13px;
}

/* ── App shell ───────────────────────────────────────── */

.app {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 70px;
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 16px;
}

.topbar-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    place-items: center;
    color: var(--text);
}

.search {
    width: 520px;
    max-width: 50vw;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 12px 18px;
    color: var(--text);
    font-size: 14px;
    flex: 1;
}

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

.search:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.top-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-shrink: 0;
}

.topbar-logout {
    margin: 0;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 50%;
    display: grid;
    place-items: center;
    cursor: pointer;
    position: relative;
    font-size: 16px;
    color: var(--text);
    transition: background 0.15s;
}

.icon-btn:hover {
    background: #f8fafc;
}

.icon-btn.primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    font-size: 22px;
    font-weight: 300;
}

.icon-btn.primary:hover {
    background: #1d4ed8;
}

.badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--red);
    color: white;
    font-size: 10px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 700;
}

.content {
    padding: 28px;
    flex: 1;
}

/* ── Page header ───────────────────────────────────────── */

.page-title {
    margin-bottom: 24px;
}

.page-title h1 {
    font-size: 30px;
    color: var(--dark);
    font-weight: 800;
}

.page-title p {
    color: var(--muted);
    margin-top: 4px;
    font-size: 15px;
}

/* ── KPI grid ──────────────────────────────────────────── */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 18px;
    margin-bottom: 22px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
}

.kpi-card {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-size: 22px;
    flex-shrink: 0;
}

.kpi-icon.blue { background: #e8f0ff; color: #2563eb; }
.kpi-icon.purple { background: #f1e8ff; color: #7c3aed; }
.kpi-icon.orange { background: #fff3e4; color: #f97316; }
.kpi-icon.green { background: #e8f9ef; color: #16a34a; }
.kpi-icon.cyan { background: #e6faff; color: #0891b2; }

.kpi-label {
    color: var(--muted);
    font-size: 14px;
}

.kpi-value {
    font-size: 30px;
    font-weight: 800;
    color: var(--dark);
    margin: 4px 0;
    line-height: 1.1;
}

.kpi-note {
    font-size: 13px;
}

.positive { color: var(--green); }
.warning { color: var(--orange); }
.danger { color: var(--red); }
.info { color: var(--primary); }

/* ── Dashboard grid ────────────────────────────────────── */

.dashboard-grid {
    display: grid;
    grid-template-columns: 1.3fr 1.3fr 1fr;
    gap: 18px;
    margin-bottom: 18px;
}

.dashboard-grid.bottom {
    grid-template-columns: 1.2fr 1.2fr 1fr;
}

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

.card-header h3 {
    font-size: 18px;
    color: var(--dark);
    font-weight: 700;
}

.link {
    color: var(--primary);
    font-size: 14px;
    text-decoration: none;
    font-weight: 600;
    white-space: nowrap;
}

.link:hover {
    text-decoration: underline;
}

.select {
    border: 1px solid var(--border);
    background: #f8fafc;
    border-radius: 10px;
    padding: 8px 12px;
    color: var(--dark);
    font-size: 13px;
    cursor: pointer;
}

/* Donut chart */
.donut-wrap {
    display: flex;
    align-items: center;
    gap: 28px;
}

.donut {
    width: 190px;
    height: 190px;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
}

.donut::after {
    content: "";
    position: absolute;
    inset: 38px;
    border-radius: 50%;
    background: white;
}

.donut__total {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    z-index: 2;
    font-size: 28px;
    font-weight: 800;
    color: var(--dark);
    transform: translateY(-10px);
    pointer-events: none;
}

.donut__label {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    z-index: 2;
    font-size: 14px;
    color: var(--muted);
    font-weight: 500;
    transform: translateY(18px);
    pointer-events: none;
}

.legend {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: 14px;
    min-width: 0;
}

.legend-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
}

/* Line chart placeholder */
.chart-placeholder {
    height: 230px;
    background:
        linear-gradient(to right, #e2e8f0 1px, transparent 1px),
        linear-gradient(to bottom, #e2e8f0 1px, transparent 1px);
    background-size: 42px 42px;
    border-radius: 14px;
    position: relative;
    overflow: hidden;
}

.line {
    position: absolute;
    inset: 40px 24px;
}

.line svg {
    width: 100%;
    height: 100%;
}

/* Hearings */
.event-list,
.activity-list,
.task-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.event-item {
    display: grid;
    grid-template-columns: 45px 1fr auto;
    gap: 14px;
    align-items: center;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.event-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.event-date strong {
    display: block;
    font-size: 22px;
    color: var(--red);
    line-height: 1;
}

.event-date span {
    font-size: 12px;
    color: var(--muted);
}

.event-title {
    font-weight: 700;
    color: var(--dark);
    font-size: 14px;
}

.event-place {
    color: var(--muted);
    font-size: 13px;
    margin-top: 3px;
}

.event-time {
    color: var(--primary);
    font-weight: 700;
    font-size: 13px;
}

/* Bar chart */
.bar-row {
    display: grid;
    grid-template-columns: 120px 1fr 70px;
    gap: 14px;
    align-items: center;
    margin-bottom: 18px;
    font-size: 14px;
}

.bar-row:last-child {
    margin-bottom: 0;
}

.bar {
    height: 8px;
    background: #eef2ff;
    border-radius: 999px;
    overflow: hidden;
}

.bar span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #4f46e5, #a78bfa);
    border-radius: 999px;
}

/* Tasks */
.task-item {
    display: grid;
    grid-template-columns: 22px 1fr auto;
    gap: 12px;
    align-items: start;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.task-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.check {
    width: 18px;
    height: 18px;
    border: 1.5px solid #cbd5e1;
    border-radius: 50%;
    margin-top: 3px;
}

.task-title {
    font-weight: 700;
    font-size: 14px;
}

.task-case,
.task-date {
    color: var(--muted);
    font-size: 13px;
    margin-top: 3px;
}

.priority {
    font-size: 13px;
    font-weight: 700;
    text-align: right;
}

/* Activity */
.activity-item {
    display: grid;
    grid-template-columns: 38px 1fr auto;
    gap: 12px;
    align-items: start;
}

.activity-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--primary-soft);
    display: grid;
    place-items: center;
    font-size: 16px;
}

.activity-title {
    font-weight: 700;
    font-size: 14px;
}

.activity-desc,
.activity-time {
    color: var(--muted);
    font-size: 13px;
    margin-top: 3px;
}

.activity-time {
    white-space: nowrap;
}

/* Footer */
.page-footer {
    color: var(--muted);
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    padding: 10px 2px;
    margin-top: 8px;
    flex-wrap: wrap;
    gap: 8px;
}

/* ── Auth layout ───────────────────────────────────────── */

.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0b1b35 0%, #071225 100%);
}

.auth-wrapper {
    width: 100%;
    max-width: 400px;
    padding: 1rem;
}

.auth-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

.auth-card__header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-card__logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: #fff;
    border-radius: 12px;
    font-weight: 900;
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.auth-card__title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--dark);
}

.auth-card__subtitle {
    color: var(--muted);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.auth-form {
    margin-top: 0.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
}

.form-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.9rem;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}

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

.btn--primary:hover {
    background: #1d4ed8;
}

.btn--block {
    width: 100%;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.alert--error {
    background: #fef2f2;
    color: var(--red);
    border: 1px solid #fecaca;
}

/* ── Responsive ────────────────────────────────────────── */

@media (max-width: 1300px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-grid,
    .dashboard-grid.bottom {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 800px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .sidebar-overlay.is-visible {
        display: block;
    }

    .app {
        margin-left: 0;
        width: 100%;
    }

    .topbar-toggle {
        display: grid;
        place-items: center;
    }

    .search {
        width: 100%;
        max-width: none;
    }

    .top-actions .icon-btn:not(.primary) {
        display: none;
    }

    .top-actions .topbar-logout {
        display: block;
    }

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

    .donut-wrap {
        flex-direction: column;
        align-items: flex-start;
    }

    .bar-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .content {
        padding: 16px;
    }

    .topbar {
        padding: 0 16px;
    }
}

@media (min-width: 801px) {
    .top-actions .topbar-logout {
        display: none;
    }
}

/* ── Tenant management / forms ─────────────────────────── */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.page-header__actions {
    display: flex;
    gap: 0.5rem;
}

.card--form,
.card--table {
    padding: 0;
    overflow: hidden;
}

.card--form {
    padding: 1.5rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem 1.25rem;
}

.form-group--full {
    grid-column: 1 / -1;
}

.form-group > label,
.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--dark);
}

.form-group input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.form-group select,
.form-group textarea,
.form-input:not(.form-input--file) {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.9rem;
    background: #fff;
    font-family: inherit;
    box-sizing: border-box;
}

.form-group input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):focus,
.form-group select:focus,
.form-group textarea:focus,
.form-input:not(.form-input--file):focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-input.is-invalid {
    border-color: var(--red);
}

textarea.form-input {
    min-height: 5rem;
    resize: vertical;
    line-height: 1.5;
}

.form-input--file,
.form-group input[type="file"] {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px dashed var(--border);
    border-radius: 10px;
    font-size: 0.9rem;
    background: #f8fafc;
    font-family: inherit;
    box-sizing: border-box;
    cursor: pointer;
}

.form-input--file:focus,
.form-group input[type="file"]:focus {
    outline: none;
    border-color: var(--primary);
    border-style: solid;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-input--file::file-selector-button,
.form-group input[type="file"]::file-selector-button {
    margin-right: 0.75rem;
    padding: 0.45rem 0.9rem;
    border: none;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
}

.form-error {
    display: block;
    color: var(--red);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.form-hint {
    display: block;
    color: var(--muted);
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.btn--danger {
    background: #fff;
    color: var(--red);
    border: 1px solid #fecaca;
}

.btn--danger:hover {
    background: var(--color-danger-bg, #fef2f2);
}

.alert--success {
    background: #f0fdf4;
    color: var(--green);
    border: 1px solid #bbf7d0;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert--error {
    background: #fef2f2;
    color: var(--red);
    border: 1px solid #fecaca;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 0.85rem 1.25rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: #f8fafc;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    font-weight: 600;
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.data-table__actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    white-space: nowrap;
}

.inline-form {
    display: inline;
    margin: 0;
}

.status-badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge--active {
    background: #f0fdf4;
    color: var(--green);
}

.status-badge--inactive {
    background: #f1f5f9;
    color: var(--muted);
}

.status-badge--suspended {
    background: #fffbeb;
    color: var(--orange);
}

.empty-state {
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--muted);
}

.empty-state p {
    margin-bottom: 1rem;
}

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

    .data-table__actions {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ── Cases module ──────────────────────────────────────── */

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.priority-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
}

.priority-badge--low { background: #f1f5f9; color: var(--muted); }
.priority-badge--medium { background: #e8f0ff; color: var(--primary); }
.priority-badge--high { background: #fffbeb; color: var(--orange); }
.priority-badge--urgent { background: #fef2f2; color: var(--red); }

.case-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.case-tabs__item {
    padding: 0.65rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    margin-bottom: -1px;
}

.case-tabs__item:hover {
    color: var(--primary);
}

.case-tabs__item.is-active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.card--tab-content {
    padding: 1.5rem;
}

.case-overview__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.case-meta__label {
    display: block;
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.25rem;
}

.case-meta__value {
    font-weight: 600;
    font-size: 0.95rem;
}

.case-description h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.case-description p {
    color: var(--muted);
    line-height: 1.6;
}

.case-list {
    list-style: none;
}

.case-list__item {
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border);
}

.case-list__item:last-child {
    border-bottom: none;
}

.case-list__meta {
    display: block;
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

.timeline {
    list-style: none;
}

.timeline__item {
    display: flex;
    gap: 0.75rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border);
    align-items: flex-start;
}

.timeline__icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--primary-soft);
    display: grid;
    place-items: center;
    font-size: 14px;
}

.timeline__date {
    flex-shrink: 0;
    width: 110px;
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 600;
}

.timeline__content p {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

.case-delete-form {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Tasks */
.status-badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge--pending { background: #f1f5f9; color: var(--muted); }
.status-badge--in_progress { background: #e8f0ff; color: var(--primary); }
.status-badge--completed { background: #ecfdf5; color: #059669; }
.status-badge--cancelled { background: #fef2f2; color: var(--red); }

.case-tasks__new {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.case-tasks__new h3,
.case-tasks__heading {
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.task-card-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.task-card {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.task-card:last-child {
    border-bottom: none;
}

.task-card__main p {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0.35rem 0;
}

.task-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.5rem;
}

.task-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    flex-shrink: 0;
}

.task-edit-row td {
    background: var(--surface-2, #f8fafc);
    padding: 1rem !important;
}

.table-sub {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

.task-form .form-actions,
.comment-form .form-actions,
.event-form .form-actions,
.document-upload-form .form-actions {
    margin-top: 0.75rem;
    padding-top: 0;
    border-top: none;
}

/* Documents */
.case-documents__upload {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.case-documents__upload h3,
.case-documents__heading {
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.document-upload-form .form-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

.document-card-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.document-card {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.document-card__main {
    flex: 1;
    min-width: 0;
}

.document-card:last-child {
    border-bottom: none;
}

.document-card__icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--primary-soft);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.document-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.35rem;
}

.document-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    flex-shrink: 0;
    margin-left: auto;
}

.visibility-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
}

.visibility-badge--internal { background: #f1f5f9; color: var(--muted); }
.visibility-badge--lawyers { background: #e8f0ff; color: var(--primary); }
.visibility-badge--all { background: #ecfdf5; color: #059669; }

.case-comments__new,
.case-events__new {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.case-comments__new h3,
.case-comments__heading,
.case-events__new h3,
.case-events__heading {
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.comment-card-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.comment-card {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.comment-card:last-child {
    border-bottom: none;
}

.comment-card__main p {
    font-size: 0.9rem;
    margin: 0.35rem 0;
}

.comment-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.35rem;
}

.comment-card__actions {
    flex-shrink: 0;
}

/* Calendar */
.calendar-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.25rem;
    align-items: start;
}

.calendar-nav {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.calendar-grid__head {
    background: var(--surface-2, #f8fafc);
    padding: 0.5rem;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--muted);
}

.calendar-grid__cell {
    background: #fff;
    min-height: 90px;
    padding: 0.35rem;
    vertical-align: top;
}

.calendar-grid__cell.is-empty {
    background: #fafbfc;
}

.calendar-grid__cell.is-today {
    box-shadow: inset 0 0 0 2px var(--primary);
}

.calendar-grid__day {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.calendar-grid__events {
    list-style: none;
    margin: 0;
    padding: 0;
}

.calendar-event {
    font-size: 0.65rem;
    padding: 0.15rem 0.3rem;
    border-radius: 4px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: var(--primary-soft);
    color: var(--primary);
}

.calendar-event--hearing { background: #fef2f2; color: #dc2626; }
.calendar-event--deadline { background: #fffbeb; color: #d97706; }
.calendar-event--meeting { background: #e8f0ff; color: var(--primary); }
.calendar-event--reminder { background: #f1f5f9; color: var(--muted); }
.calendar-event--more { background: transparent; color: var(--muted); }

.calendar-event-list {
    list-style: none;
    margin: 0;
    padding: 0 1rem 1rem;
}

.calendar-event-item {
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border);
}

.calendar-event-item:last-child {
    border-bottom: none;
}

.calendar-event-item__date {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.25rem;
}

.calendar-event-item__meta {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

.calendar-event-item__case {
    display: inline-block;
    font-size: 0.8rem;
    margin-top: 0.35rem;
}

.calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.event-type-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
}

.event-type-badge--hearing { background: #fef2f2; color: #dc2626; }
.event-type-badge--deadline { background: #fffbeb; color: #d97706; }
.event-type-badge--meeting { background: #e8f0ff; color: var(--primary); }
.event-type-badge--reminder { background: #f1f5f9; color: var(--muted); }

.form-group select,
select.form-input {
    appearance: none;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.25rem;
}

input[type="date"].form-input,
input[type="time"].form-input,
.form-group input[type="date"],
.form-group input[type="time"] {
    min-height: 2.75rem;
    color: var(--dark);
}

.case-events__new .event-form,
.event-edit-panel .event-form {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
}

.event-card-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.event-card-wrap {
    border-bottom: 1px solid var(--border);
}

.event-card-wrap:last-child {
    border-bottom: none;
}

.event-card {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    padding: 1rem 0;
}

.event-card__main {
    flex: 1;
    min-width: 0;
}

.event-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.35rem;
}

.event-card__main p {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0.35rem 0 0;
}

.event-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    flex-shrink: 0;
}

.event-edit-panel {
    padding: 0 0 1rem;
}

@media (max-width: 1100px) {
    .calendar-layout {
        grid-template-columns: 1fr;
    }
}

.dashboard-tenant-filter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.dashboard-tenant-filter select {
    min-width: 200px;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

/* ── UI polish ─────────────────────────────────────────── */

.btn--sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 8px;
}

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

.btn--ghost:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.btn--secondary {
    background: var(--primary-soft);
    color: var(--primary);
    border: 1px solid #bfdbfe;
}

.btn--secondary:hover {
    background: #dbeafe;
}

/* Alerts */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    line-height: 1.45;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
}

.alert__icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 0.75rem;
    font-weight: 800;
    flex-shrink: 0;
    margin-top: 1px;
}

.alert--success .alert__icon {
    background: #bbf7d0;
    color: var(--green);
}

.alert--error .alert__icon {
    background: #fecaca;
    color: var(--red);
}

.alert__message {
    flex: 1;
    min-width: 0;
}

.alert__list {
    margin: 0.35rem 0 0 1.1rem;
    padding: 0;
}

.alert__close {
    border: none;
    background: transparent;
    color: inherit;
    opacity: 0.55;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0 0.15rem;
    flex-shrink: 0;
}

.alert__close:hover {
    opacity: 1;
}

/* Empty states */
.empty-state {
    padding: 3.5rem 1.5rem;
    text-align: center;
    color: var(--muted);
}

.empty-state--compact {
    padding: 2rem 1rem;
}

.empty-state__icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    border-radius: 16px;
    background: var(--primary-soft);
    display: grid;
    place-items: center;
    font-size: 1.5rem;
}

.empty-state__title {
    font-size: 1rem;
    color: var(--dark);
    margin-bottom: 0.35rem;
    font-weight: 700;
}

.empty-state__message {
    margin-bottom: 1rem;
    max-width: 360px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.5;
}

/* Action dropdown */
.action-dropdown {
    position: relative;
    display: inline-flex;
}

.action-dropdown__toggle {
    min-width: 36px;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.action-dropdown__menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
    padding: 0.35rem;
    z-index: 60;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
}

.action-dropdown.is-open .action-dropdown__menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.action-dropdown__item {
    display: block;
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: none;
    background: transparent;
    text-align: left;
    text-decoration: none;
    color: var(--text);
    font-size: 0.85rem;
    border-radius: 8px;
    cursor: pointer;
}

.action-dropdown__item:hover {
    background: #f8fafc;
}

.action-dropdown__item--danger {
    color: var(--red);
}

.action-dropdown__item--danger:hover {
    background: #fef2f2;
}

.action-dropdown__divider {
    height: 1px;
    background: var(--border);
    margin: 0.25rem 0;
}

.action-dropdown__form {
    margin: 0;
}

.data-table__actions-col {
    width: 72px;
    text-align: right;
}

.data-table td.data-table__actions-col {
    text-align: right;
    white-space: nowrap;
}

.data-table td.data-table__actions-col .action-dropdown,
.data-table td.data-table__actions-col .btn {
    vertical-align: middle;
}

.card--table .card-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: #fafbfc;
}

.card--table .card-toolbar__meta {
    font-size: 0.85rem;
    color: var(--muted);
}

/* Case status badges */
.status-badge--open,
.status-badge--in_progress,
.status-badge--pending_review {
    background: #e8f0ff;
    color: var(--primary);
}

.status-badge--completed,
.status-badge--closed {
    background: #ecfdf5;
    color: #059669;
}

.status-badge--archived {
    background: #f1f5f9;
    color: var(--muted);
}

.status-badge--on_hold {
    background: #fffbeb;
    color: var(--orange);
}

.stage-badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #f1f5f9;
    color: var(--text);
}

/* Form validation */
.form-input.is-invalid,
.form-input:invalid:not(:focus):not(:placeholder-shown) {
    border-color: var(--red);
}

.form-group.has-error .form-label {
    color: var(--red);
}

.validation-summary {
    margin-bottom: 1rem;
}

/* Sidebar mobile polish */
@media (max-width: 800px) {
    .sidebar {
        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.25);
    }

    .nav-item {
        min-height: 44px;
    }

    .data-table th,
    .data-table td {
        padding: 0.75rem 1rem;
    }
}

@media (max-width: 640px) {
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .page-header__actions {
        width: 100%;
    }

    .page-header__actions .btn {
        width: 100%;
        justify-content: center;
    }

    .action-dropdown__menu {
        min-width: 160px;
    }
}

.info-banner {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    margin-bottom: 1.25rem;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    color: #1e40af;
    font-size: 0.9rem;
}

.info-banner p {
    margin: 0;
    line-height: 1.5;
}

.kpi-value--currency {
    font-size: 1.5rem;
}

.communication-feed {
    display: flex;
    flex-direction: column;
}

.communication-item {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.communication-item:last-child {
    border-bottom: none;
}

.communication-item__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.communication-item__meta {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 400;
    margin-left: 0.5rem;
}

.communication-item__body {
    margin: 0 0 0.75rem;
    color: var(--text);
    line-height: 1.55;
    font-size: 0.92rem;
}

.communication-item__case {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
}

.finance-note {
    padding: 0 1.25rem;
    margin: 0 0 0.5rem;
    color: var(--muted);
    font-size: 0.88rem;
}

.settings-info {
    padding: 0.5rem 1.25rem 1.25rem;
}

.settings-info__row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.settings-info__row:last-child {
    border-bottom: none;
}

.settings-info__row span {
    color: var(--muted);
}
