:root {
    --app-bg: #f4f7fb;
    --app-surface: #ffffff;
    --app-surface-raised: #ffffff;
    --app-text: #182233;
    --app-muted: #64748b;
    --app-border: #e5eaf2;
    --app-primary: #2f6fed;
    --app-primary-dark: #1a4fc4;
    --app-primary-soft: #eaf1ff;
    --app-success: #0f9d63;
    --app-success-soft: #e6f7ef;
    --app-danger: #e34a4a;
    --app-danger-soft: #fdeaea;
    --app-warning: #d68a11;
    --app-warning-soft: #fdf3e0;
    --app-sidebar-width: 264px;
    --app-sidebar-width-collapsed: 76px;
    --app-radius: 10px;
    --app-radius-lg: 14px;
    --app-shadow-sm: 0 1px 2px rgba(17, 24, 55, 0.05), 0 1px 1px rgba(17, 24, 55, 0.03);
    --app-shadow-md: 0 8px 20px -6px rgba(17, 24, 55, 0.12);
    --app-shadow-lg: 0 20px 45px -14px rgba(17, 24, 55, 0.22);
    --app-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
    --app-bg: #0b1220;
    --app-surface: #131c2e;
    --app-surface-raised: #17223a;
    --app-text: #eef2f9;
    --app-muted: #93a1b8;
    --app-border: #253355;
    --app-primary-soft: rgba(47, 111, 237, 0.16);
    --app-success-soft: rgba(15, 157, 99, 0.16);
    --app-danger-soft: rgba(227, 74, 74, 0.16);
    --app-warning-soft: rgba(214, 138, 17, 0.16);
    --app-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
    --app-shadow-md: 0 8px 20px -6px rgba(0, 0, 0, 0.45);
    --app-shadow-lg: 0 20px 45px -14px rgba(0, 0, 0, 0.55);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Geist', system-ui, sans-serif;
    background-color: var(--app-bg);
    color: var(--app-text);
    font-size: 0.9375rem;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
}

:focus-visible {
    outline: 2px solid var(--app-primary);
    outline-offset: 2px;
}

/* ---------- App shell ---------- */

.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    margin-left: var(--app-sidebar-width);
    transition: margin-left 0.15s ease;
}

.app-shell.is-collapsed .app-main {
    margin-left: var(--app-sidebar-width-collapsed);
}

.app-content {
    flex: 1;
    padding: 1.75rem 2rem 2.5rem;
}

/* ---------- Sidebar ---------- */

.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--app-sidebar-width);
    background-color: var(--app-surface);
    border-right: 1px solid var(--app-border);
    display: flex;
    flex-direction: column;
    z-index: 1030;
    transition: width 0.15s ease;
    overflow: hidden;
}

.app-shell.is-collapsed .app-sidebar {
    width: var(--app-sidebar-width-collapsed);
}

.app-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border-bottom: 1px solid var(--app-border);
    min-height: 64px;
}

.app-sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    color: var(--app-text);
    font-weight: 700;
    font-size: 1.0625rem;
}

.app-sidebar-brand i {
    color: var(--app-primary);
    flex-shrink: 0;
}

.app-sidebar-header {
    box-shadow: inset 0 -1px 0 var(--app-border);
}

.app-shell.is-collapsed .app-sidebar-brand-text,
.app-shell.is-collapsed .app-sidebar-section-label,
.app-shell.is-collapsed .app-sidebar-link-text {
    display: none;
}

.app-shell.is-collapsed .app-sidebar-header {
    padding: 1rem 0.5rem;
    justify-content: center;
}

.app-sidebar-brand-fav {
    display: none;
}

.app-shell.is-collapsed .app-sidebar-brand-full {
    display: none;
}

.app-shell.is-collapsed .app-sidebar-brand-fav {
    display: block;
}

.app-sidebar-toggle {
    position: fixed;
    top: 32px;
    left: var(--app-sidebar-width);
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    color: var(--app-muted);
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    z-index: 1030;
    transition: left 0.2s ease;
}

.app-sidebar-toggle i {
    width: 16px;
    height: 16px;
}

.app-sidebar-toggle:hover {
    background-color: var(--app-bg);
    color: var(--app-text);
}

.app-shell.is-collapsed .app-sidebar-toggle {
    left: var(--app-sidebar-width-collapsed);
}

.app-sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0.5rem;
}

.app-sidebar-section {
    margin-bottom: 1rem;
}

.app-sidebar-section-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--app-muted);
    padding: 0.5rem 0.75rem 0.25rem;
}

.app-sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
    margin-bottom: 0.125rem;
    border-radius: var(--app-radius);
    color: var(--app-muted);
    font-weight: 500;
    font-size: 0.875rem;
    border-left: 3px solid transparent;
    white-space: nowrap;
    transition: background-color 0.15s var(--app-ease), color 0.15s var(--app-ease);
}

.app-shell.is-collapsed .app-sidebar-link {
    justify-content: center;
}

.app-sidebar-link i {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.app-sidebar-link-icon {
    width: 28px;
    height: 28px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s var(--app-ease);
}

.app-sidebar-link:hover .app-sidebar-link-icon {
    transform: scale(1.06);
}

.app-sidebar-link-icon.is-pastel-1 { background: #ffe1ee; color: #d6336c; }
.app-sidebar-link-icon.is-pastel-2 { background: #e5ddff; color: #6741d9; }
.app-sidebar-link-icon.is-pastel-3 { background: #d8f5ff; color: #0c8599; }
.app-sidebar-link-icon.is-pastel-4 { background: #dcffe9; color: #2f9e44; }
.app-sidebar-link-icon.is-pastel-5 { background: #fff3bf; color: #e8590c; }
.app-sidebar-link-icon.is-pastel-6 { background: #ffe0ec; color: #e64980; }
.app-sidebar-link-icon.is-pastel-7 { background: #e0f2ff; color: #1971c2; }
.app-sidebar-link-icon.is-pastel-8 { background: #f3e0ff; color: #9c36b5; }

[data-theme="dark"] .app-sidebar-link-icon.is-pastel-1 { background: rgba(214, 51, 108, 0.22); color: #ff8fb3; }
[data-theme="dark"] .app-sidebar-link-icon.is-pastel-2 { background: rgba(103, 65, 217, 0.22); color: #b8a1ff; }
[data-theme="dark"] .app-sidebar-link-icon.is-pastel-3 { background: rgba(12, 133, 153, 0.22); color: #66d9e8; }
[data-theme="dark"] .app-sidebar-link-icon.is-pastel-4 { background: rgba(47, 158, 68, 0.22); color: #8ce99a; }
[data-theme="dark"] .app-sidebar-link-icon.is-pastel-5 { background: rgba(232, 89, 12, 0.22); color: #ffc078; }
[data-theme="dark"] .app-sidebar-link-icon.is-pastel-6 { background: rgba(230, 73, 128, 0.22); color: #ffa8c5; }
[data-theme="dark"] .app-sidebar-link-icon.is-pastel-7 { background: rgba(25, 113, 194, 0.22); color: #74c0fc; }
[data-theme="dark"] .app-sidebar-link-icon.is-pastel-8 { background: rgba(156, 54, 181, 0.22); color: #e599f7; }

.app-sidebar-link.is-active .app-sidebar-link-icon {
    box-shadow: 0 0 0 2px var(--app-surface);
}

.app-shell.is-collapsed .app-sidebar-link-icon {
    margin: 0 auto;
}

.app-sidebar-link:hover {
    background-color: var(--app-bg);
    color: var(--app-text);
}

.app-sidebar-link.is-active i {
    color: var(--app-primary-dark);
}

.app-sidebar-link.is-active {
    background-color: var(--app-primary-soft);
    color: var(--app-primary-dark);
    border-left-color: var(--app-primary);
    border-radius: 0 var(--app-radius) var(--app-radius) 0;
    font-weight: 600;
}

.app-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 1020;
}

/* ---------- Topbar ---------- */

.app-topbar {
    height: 64px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    background-color: var(--app-surface);
    border-bottom: 1px solid var(--app-border);
    box-shadow: var(--app-shadow-sm);
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 1010;
}

.app-topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.app-topbar-context {
    font-weight: 600;
    color: var(--app-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-topbar-mobile-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    padding: 0.35rem 0.5rem;
    color: var(--app-text);
}

.app-topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.app-theme-switch {
    position: relative;
    width: 52px;
    height: 30px;
    padding: 3px;
    background: var(--app-bg);
    border: 1px solid var(--app-border);
    border-radius: 999px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    cursor: pointer;
    transition: background-color 0.2s var(--app-ease);
}

.app-theme-switch:hover {
    border-color: var(--app-danger);
}

.app-theme-switch-knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--app-surface);
    box-shadow: var(--app-shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e8590c;
    transition: transform 0.2s var(--app-ease);
}

.app-theme-switch-icon-svg {
    width: 13px;
    height: 13px;
    pointer-events: none;
}

[data-theme="dark"] .app-theme-switch-knob {
    transform: translateX(22px);
    color: #a5b4fc;
}

.app-user-menu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: var(--app-radius);
    color: var(--app-text);
}

.app-user-menu:hover {
    background-color: var(--app-bg);
}

.app-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--app-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.app-user-name {
    font-weight: 500;
    font-size: 0.875rem;
}

.app-user-dropdown {
    min-width: 260px;
    padding: 0.5rem;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-lg);
    box-shadow: var(--app-shadow-lg);
}

.app-user-dropdown-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.6rem 0.75rem;
}

.app-user-avatar-lg {
    width: 40px;
    height: 40px;
    font-size: 0.9375rem;
    background: linear-gradient(135deg, var(--app-primary), var(--app-primary-dark));
}

.app-user-dropdown-email {
    color: var(--app-muted);
}

.app-user-dropdown .dropdown-divider {
    margin: 0.25rem 0;
    border-color: var(--app-border);
}

.app-user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    background: transparent;
    border: none;
    padding: 0.5rem 0.6rem;
    border-radius: var(--app-radius);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--app-text);
    transition: background-color 0.15s var(--app-ease);
}

.app-user-dropdown-item:hover {
    background-color: var(--app-bg);
    color: var(--app-text);
}

.app-user-dropdown-item-danger {
    color: var(--app-danger);
}

.app-user-dropdown-item-danger:hover {
    background-color: var(--app-danger-soft);
    color: var(--app-danger);
}

.app-user-dropdown-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--app-primary-soft);
    color: var(--app-primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.app-user-dropdown-icon i {
    width: 15px;
    height: 15px;
}

.app-user-dropdown-icon.is-danger {
    background: var(--app-danger-soft);
    color: var(--app-danger);
}

/* ---------- Breadcrumb ---------- */

.app-breadcrumb {
    margin-bottom: 1rem;
}

.app-breadcrumb .breadcrumb {
    font-size: 0.8125rem;
}

/* ---------- Page header ---------- */

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

.app-page-title {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    margin: 0;
    color: var(--app-text);
}

.app-page-description {
    color: var(--app-muted);
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
}

.app-page-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ---------- Surfaces / cards ---------- */

.app-surface {
    background-color: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-lg);
    box-shadow: var(--app-shadow-sm);
    transition: box-shadow 0.2s var(--app-ease);
}

.app-info-banner {
    border-left: 3px solid var(--app-primary);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.card {
    border-color: var(--app-border);
    border-radius: var(--app-radius-lg);
    box-shadow: var(--app-shadow-sm);
}

.card-header {
    background-color: transparent;
    border-bottom-color: var(--app-border);
    font-weight: 700;
}

/* ---------- Stat cards ---------- */

.app-stat-card {
    background-color: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-lg);
    box-shadow: var(--app-shadow-sm);
    padding: 1.25rem 1.4rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    width: 100%;
    transition: transform 0.2s var(--app-ease), box-shadow 0.2s var(--app-ease);
}

.app-stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--app-shadow-md);
}

.app-stat-icon {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: var(--app-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--app-primary-soft);
    color: var(--app-primary-dark);
}

.app-stat-icon i {
    width: 22px;
    height: 22px;
}

.app-stat-icon.is-success { background: var(--app-success-soft); color: var(--app-success); }
.app-stat-icon.is-danger { background: var(--app-danger-soft); color: var(--app-danger); }
.app-stat-icon.is-warning { background: var(--app-warning-soft); color: var(--app-warning); }

.app-stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.1;
}

.app-stat-label {
    font-size: 0.8rem;
    color: var(--app-muted);
    font-weight: 600;
}

/* ---------- Tables ---------- */

.table {
    --bs-table-bg: transparent;
    font-size: 0.875rem;
    margin-bottom: 0;
}

.table > thead > tr > th {
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    font-weight: 700;
    color: var(--app-muted);
    border-bottom-width: 1px;
    background-color: var(--app-bg);
    padding: 0.65rem 1rem;
}

.table > tbody > tr > td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
}

.table > tbody > tr:hover {
    background-color: var(--app-primary-soft);
}

.table-zebra > tbody > tr:nth-of-type(odd) > td {
    background-color: var(--app-bg);
}

.table-zebra > tbody > tr:hover > td {
    background-color: var(--app-primary-soft);
}

.app-matrix-table th,
.app-matrix-table td {
    padding: 0.6rem 0.85rem;
    border-bottom: 1px solid var(--app-border);
    border-right: 1px solid var(--app-border);
}

.app-matrix-table th:last-child,
.app-matrix-table td:last-child {
    border-right: none;
}

/* Surface wrapping a table flush: kill the double-border look */
.app-surface-flush {
    background-color: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-lg);
    box-shadow: var(--app-shadow-sm);
    overflow: hidden;
}

.app-surface-flush .table-responsive {
    margin: 0;
}

.app-surface-flush .table {
    border: none;
}

.app-surface-flush .table > tbody > tr:last-child > td {
    border-bottom: none;
}

/* ---------- Buttons ---------- */

.btn {
    border-radius: var(--app-radius);
    font-weight: 600;
}

.btn-primary {
    background-color: var(--app-primary);
    border-color: var(--app-primary);
}

.btn-primary:hover {
    background-color: var(--app-primary-dark);
    border-color: var(--app-primary-dark);
    box-shadow: var(--app-shadow-sm);
}

.btn-outline-secondary {
    border-color: var(--app-border);
    color: var(--app-muted);
}

.btn-outline-secondary:hover {
    background-color: var(--app-bg);
    border-color: var(--app-border);
    color: var(--app-text);
}

/* Icon-only action button clusters (table row actions, toolbar icons) */
.app-icon-btn-group {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.app-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--app-radius);
    border: 1px solid transparent;
    background: transparent;
    color: var(--app-muted);
    transition: background-color 0.15s var(--app-ease), color 0.15s var(--app-ease), border-color 0.15s var(--app-ease);
}

.app-icon-btn i {
    width: 16px;
    height: 16px;
}

.app-icon-btn:hover {
    background-color: var(--app-bg);
    border-color: var(--app-border);
    color: var(--app-text);
}

.app-icon-btn.is-danger:hover {
    background-color: var(--app-danger-soft);
    border-color: transparent;
    color: var(--app-danger);
}

.app-icon-btn.is-primary:hover {
    background-color: var(--app-primary-soft);
    border-color: transparent;
    color: var(--app-primary-dark);
}

/* ---------- Soft badges ---------- */

.app-badge-soft {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    line-height: 1;
}

.app-badge-soft i {
    width: 12px;
    height: 12px;
}

.app-badge-soft.is-success { background: var(--app-success-soft); color: var(--app-success); }
.app-badge-soft.is-danger { background: var(--app-danger-soft); color: var(--app-danger); }
.app-badge-soft.is-warning { background: var(--app-warning-soft); color: var(--app-warning); }
.app-badge-soft.is-primary { background: var(--app-primary-soft); color: var(--app-primary-dark); }
.app-badge-soft.is-muted { background: var(--app-bg); color: var(--app-muted); }

/* ---------- Section label ---------- */

.app-section-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--app-muted);
    margin-bottom: 0.75rem;
}

/* ---------- Forms ---------- */

.app-form-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--app-text);
    margin-bottom: 0.35rem;
}

.app-form-hint {
    font-size: 0.78rem;
    color: var(--app-muted);
    margin-top: 0.35rem;
}

.form-control,
.form-select {
    border-color: var(--app-border);
    border-radius: var(--app-radius);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 3px var(--app-primary-soft);
}

.app-fieldset {
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--app-border);
}

.app-fieldset:last-child {
    border-bottom: none;
    padding-bottom: 0.5rem;
}

.app-fieldset:first-child {
    padding-top: 0.25rem;
}

.app-fieldset-title {
    font-weight: 700;
    font-size: 0.9375rem;
    margin-bottom: 0.25rem;
}

.app-fieldset-hint {
    font-size: 0.8125rem;
    color: var(--app-muted);
    margin-bottom: 1.1rem;
}

/* ---------- Empty state ---------- */

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

.app-empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: var(--app-bg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-empty-icon i {
    width: 28px;
    height: 28px;
    color: var(--app-muted);
}

.app-empty-state p {
    margin: 0.25rem 0 1rem;
}

.app-empty-state .app-empty-title {
    font-weight: 700;
    color: var(--app-text);
    font-size: 0.9375rem;
    margin-bottom: 0.25rem;
}

/* ---------- Footer ---------- */

.app-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--app-border);
    color: var(--app-muted);
    font-size: 0.8125rem;
    flex-wrap: wrap;
    gap: 0.25rem;
}

/* ---------- Toast ---------- */

.app-toast-container {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 1080;
    max-width: 320px;
}

.app-toast {
    position: relative;
    overflow: hidden;
    background-color: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow-lg);
    padding: 0.75rem 1rem 0.85rem;
    font-size: 0.875rem;
    animation: app-toast-in 0.15s ease;
}

.app-toast-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

@keyframes app-toast-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.app-toast-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 100%;
    background: rgba(255, 255, 255, 0.5);
    transform-origin: left;
    animation: app-toast-progress linear forwards;
    animation-duration: 4000ms;
}

@keyframes app-toast-progress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

.app-toast i:first-child {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.app-toast-message {
    flex: 1;
}

.app-toast-close {
    background: transparent;
    border: none;
    color: var(--app-muted);
    display: flex;
    padding: 0;
}

.app-toast-success {
    background: var(--app-success);
    border-color: var(--app-success);
    color: #fff;
}

.app-toast-error {
    background: var(--app-danger);
    border-color: var(--app-danger);
    color: #fff;
}

.app-toast-warning {
    background: var(--app-warning);
    border-color: var(--app-warning);
    color: #fff;
}

.app-toast-info {
    background: var(--app-primary);
    border-color: var(--app-primary);
    color: #fff;
}

.app-toast-success i:first-child,
.app-toast-error i:first-child,
.app-toast-warning i:first-child,
.app-toast-info i:first-child {
    color: #fff;
}

.app-toast-success .app-toast-close,
.app-toast-error .app-toast-close,
.app-toast-warning .app-toast-close,
.app-toast-info .app-toast-close {
    color: rgba(255, 255, 255, 0.8);
}

.app-toast-success .app-toast-close:hover,
.app-toast-error .app-toast-close:hover,
.app-toast-warning .app-toast-close:hover,
.app-toast-info .app-toast-close:hover {
    color: #fff;
}

/* ---------- Auth pages ---------- */

.auth-body {
    background:
        linear-gradient(165deg, oklch(40% 0.11 236 / 0.5), oklch(20% 0.05 240 / 0.55)),
        url('/img/hero.webp') center / cover no-repeat;
    min-height: 100vh;
}

.auth-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background-color: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-lg);
    box-shadow: var(--app-shadow-lg);
    padding: 2.25rem;
}

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

.auth-brand-mark {
    display: block;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--app-primary-dark);
}

.auth-brand-sub {
    display: block;
    font-size: 0.8125rem;
    color: var(--app-muted);
    margin-top: 0.125rem;
}

/* ---------- Modal ---------- */

.app-modal-content {
    border: none;
    border-radius: var(--app-radius-lg);
    box-shadow: var(--app-shadow-lg);
}

.app-modal-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.65rem;
    flex-shrink: 0;
}

.app-modal-icon i { width: 18px; height: 18px; }

.app-modal-icon.is-danger { background: var(--app-danger-soft); color: var(--app-danger); }

/* ---------- iOS-style confirm dialog ---------- */

.ios-modal-dialog {
    max-width: 270px;
}

.ios-modal-content {
    border: none;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--app-shadow-lg);
    background: var(--app-surface);
    backdrop-filter: blur(20px);
}

.ios-modal-body {
    padding: 1.25rem 1rem 1rem;
    text-align: center;
}

.ios-modal-icon {
    width: 44px;
    height: 44px;
    margin: 0 auto 0.5rem;
    border-radius: 50%;
    background: var(--app-danger-soft);
    color: var(--app-danger);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ios-modal-icon i {
    width: 22px;
    height: 22px;
}

.ios-modal-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--app-text);
    margin-bottom: 0.25rem;
}

.ios-modal-message {
    font-size: 0.8125rem;
    color: var(--app-muted);
    margin-bottom: 0;
    line-height: 1.4;
}

.ios-modal-actions {
    display: flex;
    border-top: 1px solid var(--app-border);
}

.ios-modal-btn-form {
    flex: 1;
    display: flex;
    margin: 0;
}

.ios-modal-btn {
    flex: 1;
    width: 100%;
    background: transparent;
    border: none;
    border-left: 1px solid var(--app-border);
    padding: 0.7rem 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--app-primary);
    transition: background-color 0.15s ease;
}

.ios-modal-btn:first-child {
    border-left: none;
}

.ios-modal-btn:hover {
    background: var(--app-bg);
}

.ios-modal-btn-danger {
    color: var(--app-danger);
    font-weight: 600;
}

/* ---------- Footer ---------- */

.app-footer-version {
    color: var(--app-border);
    font-weight: 600;
}

/* ---------- Responsive ---------- */

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        width: var(--app-sidebar-width);
    }

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

    .app-shell.is-mobile-open .app-sidebar-backdrop {
        display: block;
    }

    .app-main,
    .app-shell.is-collapsed .app-main {
        margin-left: 0;
    }

    .app-sidebar-toggle {
        display: none;
    }

    .app-topbar-mobile-toggle {
        display: flex;
    }
}

.sticky-start {
    position: sticky;
    left: 0;
    z-index: 2;
}

.leaflet-interactive:focus {
    outline: none;
}
