:root {
    --color-bg: #eaf4fc;
    --color-surface: #ffffff;
    --color-surface-alt: #f4faff;
    --color-border: #c5dff5;
    --color-text: #1a3a5c;
    --color-text-muted: #5a7a9a;
    --color-primary: #4a9fe8;
    --color-primary-hover: #2d8ad4;
    --color-primary-light: #dceeff;
    --color-accent: #6eb6f0;
    --color-accent-hover: #4a9fe8;
    --color-danger: #e05252;
    --color-danger-hover: #c73e3e;
    --color-success: #3da876;
    --color-warning: #e8a838;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 3px rgba(30, 80, 140, 0.08);
    --shadow-md: 0 8px 24px rgba(30, 80, 140, 0.12);
    --shadow-lg: 0 20px 50px rgba(30, 80, 140, 0.18);
    --font: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
    --header-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 15px; }

body.app-body {
    margin: 0;
    font-family: var(--font);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.5;
    min-height: 100vh;
}

body.modal-open { overflow: hidden; }

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

/* Header */
.app-header {
    background: linear-gradient(135deg, #0f2847 0%, #1a3a5c 55%, #1e4976 100%);
    color: #fff;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header__inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 24px;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.05rem;
    white-space: nowrap;
}

.app-brand:hover { text-decoration: none; opacity: 0.95; }

.app-brand__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.2);
    border-radius: var(--radius-sm);
    font-size: 1.4rem;
    font-weight: 300;
    line-height: 1;
}

.app-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    flex-wrap: wrap;
}

.app-nav__link {
    color: rgba(255,255,255,0.85);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.93rem;
    text-decoration: none;
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
}

.app-nav__link:hover,
.app-nav__btn:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
    text-decoration: none;
}

.app-nav__link.is-active {
    background: rgba(255,255,255,0.22);
    color: #fff;
    font-weight: 600;
}

.app-nav__dropdown {
    position: relative;
}

.app-nav__dropdown::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: 10px;
}

.app-nav__dropdown.is-active > .app-nav__dropdown-toggle {
    background: rgba(255,255,255,0.22);
    color: #fff;
    font-weight: 600;
}

.app-nav__dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 200px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 6px 0;
    z-index: 200;
}

.app-nav__dropdown-menu::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: -4px;
    height: 4px;
}

.app-nav__dropdown:hover .app-nav__dropdown-menu,
.app-nav__dropdown.is-open .app-nav__dropdown-menu {
    display: block;
}

.app-nav__dropdown-menu a {
    display: block;
    padding: 10px 16px;
    color: var(--color-text);
    font-size: 0.93rem;
    text-decoration: none;
}

.app-nav__dropdown-menu a:hover {
    background: var(--color-primary-light);
    color: var(--color-primary-hover);
    text-decoration: none;
}

.app-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.app-user__name {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.9);
}

/* Main layout */
.app-main { padding: 28px 0 48px; }

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Page head */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.page-title {
    margin: 0 0 4px;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.page-subtitle {
    margin: 0;
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

.page-head__actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Panels */
.panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.panel--filters {
    padding: 16px 20px;
    margin-bottom: 20px;
    background: var(--color-surface-alt);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 0.93rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-primary {
    background: var(--color-primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(74, 159, 232, 0.35);
}

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

.btn-accent {
    background: var(--color-accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(110, 182, 240, 0.35);
}

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

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border);
}

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

.btn-outline {
    background: transparent;
    border-color: var(--color-border);
    color: var(--color-text);
}

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

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

.btn-ghost {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.25);
}

.btn-ghost:hover { background: rgba(255,255,255,0.2); color: #fff; }

.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn__icon { font-size: 1.1rem; line-height: 1; }

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    background: #f1f5f9;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

.btn-icon:hover { background: var(--color-primary-light); color: var(--color-primary); border-color: #a8cff0; }
.btn-icon--accent:hover { background: var(--color-primary-light); color: var(--color-accent-hover); border-color: #a8cff0; }
.btn-icon--danger:hover { background: #fef2f2; color: var(--color-danger); border-color: #fecaca; }

.link-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--color-primary-hover);
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
}

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

.action-group { display: flex; gap: 6px; }

/* Filters */
.filter-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.filter-tab {
    padding: 7px 16px;
    border-radius: 999px;
    background: var(--color-primary-light);
    color: var(--color-text-muted);
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
    transition: all 0.15s;
}

.filter-tab:hover { background: var(--color-primary-light); color: var(--color-primary); text-decoration: none; }

.filter-tab.is-active {
    background: var(--color-primary);
    color: #fff;
}

.filter-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-form,
.filter-search {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-form--audit { padding: 4px 0; }

.filter-form__label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

.filter-form__sep { color: var(--color-text-muted); }

.filter-search { flex: 1; min-width: 280px; }
.filter-search .form-control { flex: 1; min-width: 200px; }

.panel--filters--journal {
    padding: 10px 14px;
    margin-bottom: 16px;
}

.panel--filters--journal .filter-tabs {
    margin-bottom: 8px;
    gap: 4px;
}

.panel--filters--journal .filter-tab {
    padding: 4px 11px;
    font-size: 0.82rem;
}

.panel--filters--journal .filter-row {
    gap: 8px;
    align-items: center;
}

.panel--filters--journal .filter-form,
.panel--filters--journal .filter-search {
    gap: 6px;
    flex-wrap: nowrap;
}

.panel--filters--journal .filter-form__label {
    font-size: 0.8rem;
    white-space: nowrap;
}

.panel--filters--journal .filter-form__sep {
    font-size: 0.85rem;
}

.panel--filters--journal .form-control--sm {
    width: auto;
    min-width: 0;
    max-width: 132px;
    padding: 5px 8px;
    font-size: 0.82rem;
}

.panel--filters--journal .filter-search {
    flex: 1;
    min-width: 180px;
}

.panel--filters--journal .filter-search .form-control {
    flex: 1;
    min-width: 120px;
    padding: 5px 10px;
    font-size: 0.82rem;
}

.panel--filters--journal .btn-sm {
    padding: 5px 10px;
    font-size: 0.82rem;
}

@media (max-width: 768px) {
    .panel--filters--journal .filter-form,
    .panel--filters--journal .filter-search {
        flex-wrap: wrap;
    }

    .panel--filters--journal .form-control--sm {
        max-width: none;
        flex: 1;
    }
}

/* Forms */
.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text);
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font: inherit;
    color: var(--color-text);
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(74, 159, 232, 0.2);
}

.form-control--sm { padding: 7px 10px; font-size: 0.88rem; }

.form-group { margin-bottom: 16px; }

.password-field {
    position: relative;
}

.password-field .form-control {
    padding-right: 92px;
}

.password-field__toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 6px 8px;
    font: inherit;
    font-size: 0.78rem;
    line-height: 1;
    border-radius: var(--radius-sm);
}

.password-field__toggle:hover {
    color: var(--color-primary-hover);
    background: var(--color-primary-light);
}

.password-field__toggle.is-visible [data-label-show] {
    display: none;
}

.password-field__toggle.is-visible [data-label-hide] {
    display: inline;
}

.password-field__toggle:not(.is-visible) [data-label-hide] {
    display: none;
}

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

.form-error {
    display: block;
    color: var(--color-danger);
    font-size: 0.82rem;
    margin-top: 4px;
}

.form-hint {
    display: block;
    color: var(--color-text-muted);
    font-size: 0.82rem;
    margin-top: 4px;
}

.form-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding-top: 8px;
    margin-top: 8px;
    border-top: 1px solid var(--color-border);
}

.form-footer__actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-left: auto;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: normal;
}

.segmented {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.segmented__item {
    cursor: pointer;
}

.segmented__item input { display: none; }

.segmented__item span {
    display: block;
    padding: 8px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.15s;
}

.segmented__item input:checked + span {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.segmented__item:hover span {
    border-color: var(--color-primary);
}

.entity-form { padding: 4px 0; }

/* Table */
.table-responsive { overflow-x: auto; }

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

.data-table th,
.data-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.data-table th {
    background: var(--color-surface-alt);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
}

.data-table tbody tr:hover { background: var(--color-surface-alt); }
.data-table tbody tr:last-child td { border-bottom: none; }

.data-table--compact th,
.data-table--compact td { padding: 10px 14px; }

.col-num { width: 56px; text-align: center; }
.col-actions { width: 100px; text-align: right; }

.row-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    background: var(--color-primary-light);
    color: var(--color-primary-hover);
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.85rem;
}

.row-num--card {
    border-radius: var(--radius-sm);
    min-width: 48px;
}

.cell-notes {
    max-width: 220px;
    color: var(--color-text-muted);
    font-size: 0.88rem;
    word-break: break-word;
}

.text-muted { color: var(--color-text-muted); font-size: 0.88rem; }

.code-tag {
    font-family: "Consolas", "Monaco", monospace;
    font-size: 0.85rem;
    background: var(--color-primary-light);
    padding: 2px 8px;
    border-radius: 4px;
    color: #1e5a8a;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.badge--primary { background: var(--color-primary-light); color: #1e5a8a; }
.badge--repeat { background: #fff3d6; color: #92660a; }
.badge--success { background: #d1fae5; color: #065f46; }
.badge--muted { background: #f1f5f9; color: #64748b; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    background: var(--color-surface);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-lg);
}

.empty-state__icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { color: var(--color-text-muted); margin: 0 0 20px; }
.empty-state--compact { padding: 24px 16px; }
.empty-state--compact p { margin: 0; }

/* Form tabs (patient card) */
.form-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 16px;
}

.form-tabs__tab {
    padding: 10px 16px;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    background: none;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.form-tabs__tab:hover {
    color: var(--color-primary-hover);
}

.form-tabs__tab.is-active {
    color: var(--color-primary-hover);
    border-bottom-color: var(--color-primary);
}

.form-tab-panel[hidden] {
    display: none !important;
}

.form-tab-panel .audit-cell {
    max-width: 280px;
    min-width: 180px;
}

/* Reports */
.report-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.report-card {
    display: block;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.15s, border-color 0.15s;
}

.report-card:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}

.report-card__title {
    margin: 0 0 8px;
    font-size: 1.05rem;
    color: var(--color-text);
}

.report-card__desc {
    margin: 0 0 12px;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    line-height: 1.45;
}

.report-card__link {
    color: var(--color-primary-hover);
    font-weight: 600;
    font-size: 0.88rem;
}

.report-filters { margin-bottom: 20px; }

.report-section {
    padding: 20px;
    margin-bottom: 16px;
}

.report-section__title {
    margin: 0 0 16px;
    font-size: 1rem;
}

.report-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.report-stat {
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
}

.report-stat__label {
    display: block;
    font-size: 0.82rem;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

.report-stat__value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-primary-hover);
}

.report-generated {
    margin-top: 8px;
    font-size: 0.85rem;
}

/* Toast */
.toast-root {
    position: fixed;
    top: calc(var(--header-h) + 16px);
    right: 24px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    max-width: min(480px, calc(100vw - 48px));
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 300px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 0.97rem;
    line-height: 1.45;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.35s ease;
    pointer-events: auto;
}

.toast__icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1;
}

.toast__text {
    flex: 1;
    padding-top: 5px;
}

.toast--hide {
    animation: toastOut 0.35s ease forwards;
}

.toast--success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.toast--success .toast__icon {
    background: rgba(6, 95, 70, 0.16);
    color: #047857;
}

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

.toast--error .toast__icon {
    background: rgba(153, 27, 27, 0.14);
    color: #b91c1c;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(24px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(24px); }
}

/* Modal */
.modal-root {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-root[hidden] { display: none !important; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(30, 80, 140, 0.4);
    backdrop-filter: blur(4px);
}

.modal-dialog {
    position: relative;
    width: 100%;
    max-width: 640px;
    max-height: calc(100vh - 48px);
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    animation: modalIn 0.25s ease;
}

.modal-dialog__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.modal-dialog__title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
}

.modal-dialog__close {
    width: 36px;
    height: 36px;
    border: none;
    background: #f1f5f9;
    border-radius: var(--radius-sm);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: all 0.15s;
}

.modal-dialog__close:hover { background: #fee2e2; color: var(--color-danger); }

.modal-dialog__body {
    padding: 20px 24px 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-loading {
    text-align: center;
    padding: 40px;
    color: var(--color-text-muted);
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.96) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Confirm dialog */
.modal-root--confirm { z-index: 1100; }

.confirm-dialog {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 28px 24px 24px;
    text-align: center;
    animation: modalIn 0.25s ease;
}

.confirm-dialog__icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 16px;
    background: #fef3c7;
    color: #d97706;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
}

.confirm-dialog__title {
    margin: 0 0 8px;
    font-size: 1.15rem;
}

.confirm-dialog__text {
    margin: 0 0 24px;
    color: var(--color-text-muted);
    line-height: 1.5;
}

.confirm-dialog__actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.confirm-dialog__actions .btn { min-width: 120px; }

/* Search dropdown */
.search-dropdown {
    position: absolute;
    z-index: 50;
    width: 100%;
    max-height: 220px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    margin-top: 4px;
}

.form-group { position: relative; }

.search-dropdown__item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    border-bottom: 1px solid #f1f5f9;
}

.search-dropdown__item:hover { background: var(--color-primary-light); }
.search-dropdown__item:last-child { border-bottom: none; }

/* Audit */
.audit-cell { max-width: 360px; min-width: 220px; }

.audit-details summary {
    cursor: pointer;
    color: var(--color-primary-hover);
    font-size: 0.88rem;
    font-weight: 600;
}

.audit-changes {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    font-size: 0.88rem;
}

.audit-changes__item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    margin-bottom: 6px;
    border-radius: var(--radius-sm);
    background: var(--color-surface-alt);
    border-left: 3px solid var(--color-border);
}

.audit-changes__item--changed { border-left-color: var(--color-primary); }
.audit-changes__item--added { border-left-color: var(--color-success); }
.audit-changes__item--removed { border-left-color: var(--color-danger); }

.audit-changes__label {
    font-weight: 600;
    color: var(--color-text);
    font-size: 0.82rem;
}

.audit-changes__values {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.audit-changes__old {
    color: var(--color-danger);
    text-decoration: line-through;
    opacity: 0.85;
}

.audit-changes__arrow {
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

.audit-changes__new {
    color: var(--color-success);
    font-weight: 600;
}

.audit-changes__value {
    color: var(--color-text);
    word-break: break-word;
}

.audit-changes__item--added .audit-changes__value { color: var(--color-success); }
.audit-changes__item--removed .audit-changes__value { color: var(--color-danger); }

/* Auth */
body.app-body--auth {
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    background: linear-gradient(145deg, #6eb6f0 0%, #89c4f4 40%, #c5e4fa 100%);
}

.auth-layout {
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 36px 32px;
    box-shadow: var(--shadow-lg);
}

.auth-card__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--color-primary);
    font-weight: 700;
    margin-bottom: 24px;
}

.auth-card__title {
    margin: 0 0 6px;
    font-size: 1.5rem;
}

.auth-card__subtitle {
    margin: 0 0 28px;
    color: var(--color-text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .app-header__inner { padding: 0 16px; height: auto; min-height: var(--header-h); flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
    .app-nav { order: 3; width: 100%; }
    .app-container { padding: 0 16px; }
    .page-head { flex-direction: column; }
    .modal-dialog { max-height: calc(100vh - 24px); }
    .confirm-dialog__actions { flex-direction: column; }
    .confirm-dialog__actions .btn { width: 100%; }
    .toast-root { right: 16px; top: 88px; max-width: calc(100vw - 32px); }
    .toast { min-width: 0; width: 100%; }
}
