/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: var(--font-size-sm);
    font-weight: 600;
    font-family: inherit;
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.4;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-appearance: none;
    appearance: none;
    user-select: none;
    -webkit-user-select: none;
    /* Ensure min tap target for accessibility */
    min-height: 2.5rem;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn-primary   { background: var(--primary); color: var(--text-on-primary); border-color: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); border-color: var(--primary-dark); box-shadow: 0 0 0 3px rgba(245,158,11,0.2); }
.btn-secondary { background: var(--bg-hover); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-success   { background: var(--success); color: #fff; border-color: var(--success); }
.btn-ghost     { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }
.btn-outline   { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover:not(:disabled) { background: var(--primary-50); }
.btn-info      { background: var(--info); color: #fff; border-color: var(--info); }

.btn-sm  { padding: 0.3rem 0.625rem; font-size: var(--font-size-xs); }
.btn-sm svg { width: 13px; height: 13px; }
.btn-xs  { padding: 0.15rem 0.35rem; font-size: 11px; line-height: 1; border-radius: var(--radius-sm); }
.btn-xs svg { width: 12px; height: 12px; }
.btn-lg { padding: 0.7rem 1.5rem; font-size: var(--font-size-md); }
.btn-icon { padding: 0.45rem; border-radius: var(--radius-sm); }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group  { margin-bottom: 1rem; }
.form-label  { display: block; font-size: var(--font-size-sm); font-weight: 600; color: var(--text-secondary); margin-bottom: 0.35rem; }
.form-control {
    display: block; width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: var(--font-size-sm);
    font-family: inherit;
    color: var(--text);
    background: var(--bg-input);
    border: 1.5px solid var(--border-input);
    border-radius: var(--radius);
    transition: border-color var(--transition), box-shadow var(--transition);
    line-height: 1.5;
    min-height: 2.625rem;
    -webkit-appearance: none;
    appearance: none;
    /* Prevent number input spinners */
    -moz-appearance: textfield;
}
.form-control:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(245,158,11,0.15);
}
.form-control::placeholder { color: var(--text-muted); font-weight: 400; }
select.form-control {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 14px;
    padding-right: 2.25rem;
}
[dir="rtl"] select.form-control {
    background-position: left 0.75rem center;
    padding-right: 0.75rem;
    padding-left: 2.25rem;
}
textarea.form-control { resize: vertical; min-height: 80px; -moz-appearance: auto; appearance: auto; }

/* Hide number spinners */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.form-control-sm { padding: 0.35rem 0.6rem; font-size: var(--font-size-xs); }
.form-hint { font-size: var(--font-size-xs); color: var(--text-muted); margin-top: 0.3rem; }
.form-error { font-size: var(--font-size-xs); color: var(--danger); margin-top: 0.3rem; }
.form-row { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.card-title { font-size: var(--font-size-md); font-weight: 700; }
.card-body  { padding: 1.25rem; }
.card-footer { padding: 0.875rem 1.25rem; border-top: 1px solid var(--border); background: var(--bg-hover); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ── Stats cards ─────────────────────────────────────────────── */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    display: flex; align-items: center; gap: 1rem;
    transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-icon {
    width: 48px; height: 48px; border-radius: var(--radius-lg);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-icon svg { width: 24px; height: 24px; }
.stat-info { min-width: 0; }
.stat-label { font-size: var(--font-size-xs); color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: var(--font-size-2xl); font-weight: 700; line-height: 1.2; margin: 0.15rem 0; }
.stat-sub   { font-size: var(--font-size-xs); color: var(--text-secondary); }

.stat-icon.primary { background: var(--primary-100); color: var(--primary-dark); }
.stat-icon.success { background: var(--success-bg);  color: var(--success); }
.stat-icon.info    { background: var(--info-bg);     color: var(--info); }
.stat-icon.warning { background: var(--warning-bg);  color: var(--warning); }
.stat-icon.danger  { background: var(--danger-bg);   color: var(--danger); }

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table {
    width: 100%; border-collapse: collapse;
    font-size: var(--font-size-sm);
}
.table th, .table td { padding: 0.7rem 1rem; text-align: start; vertical-align: middle; }
.table th {
    font-weight: 600; color: var(--text-secondary);
    font-size: var(--font-size-xs); text-transform: uppercase; letter-spacing: 0.06em;
    background: var(--bg-hover); white-space: nowrap;
    border-bottom: 1px solid var(--border);
}
.table td { border-top: 1px solid var(--border); }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover td { background: var(--bg-hover); }
.table .actions { display: flex; gap: 0.375rem; }

/* ── Skeleton loader ─────────────────────────────────────────── */
@keyframes shimmer {
    0%   { background-position: -600px 0; }
    100% { background-position: 600px 0; }
}
.skeleton {
    background: linear-gradient(90deg, var(--bg-hover) 25%, var(--border) 50%, var(--bg-hover) 75%);
    background-size: 600px 100%;
    animation: shimmer 1.4s infinite linear;
    border-radius: var(--radius);
}
.skeleton-text  { height: 0.875rem; margin-bottom: 0.5rem; }
.skeleton-title { height: 1.25rem; width: 60%; margin-bottom: 0.75rem; }
.skeleton-card  {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 1.25rem;
    display: flex; flex-direction: column; gap: 0.5rem;
}
.skeleton-row   { display: flex; gap: 1rem; padding: 0.875rem 1rem; border-top: 1px solid var(--border); }
.skeleton-row .skeleton { flex: 1; height: 0.75rem; }

/* ── Mobile-responsive cards on small screens ────────────────── */
@media (max-width: 640px) {
    .form-row { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .page-header .btn { width: 100%; justify-content: center; }
    .stats-grid { grid-template-columns: 1fr 1fr !important; gap: 0.75rem !important; }
    .stat-card { padding: 0.875rem; }
    .stat-value { font-size: var(--font-size-xl) !important; }
    .card-body { padding: 1rem; }
    .modal-body { padding: 1rem; }
    .modal-header { padding: 1rem; }
    .modal-footer { padding: 0.75rem 1rem; flex-wrap: wrap; }
    .modal-footer .btn { flex: 1; }
    .tabs { gap: 0; }
    .tab-item { padding: 0.55rem 0.75rem; font-size: 0.72rem; }
}

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: 0.25rem;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1.4;
}
.badge-primary { background: var(--primary-100); color: var(--primary-dark); }
.badge-success { background: var(--success-bg);  color: var(--success); }
.badge-warning { background: var(--warning-bg);  color: var(--warning); }
.badge-danger  { background: var(--danger-bg);   color: var(--danger); }
.badge-info    { background: var(--info-bg);     color: var(--info); }
.badge-ghost   { background: var(--bg-hover);    color: var(--text-secondary); }
.badge-dark    { background: var(--bg-sidebar);  color: #fff; }
.badge-dot::before { content:''; width:6px;height:6px;border-radius:50%;background:currentColor;display:inline-block; }

/* ── Modal overlay ───────────────────────────────────────────── */
/* Backdrop sits above everything including sidebar (z 200) */
.dialog-overlay {
    position: fixed; inset: 0;
    background: rgba(10,18,40,0.68);
    z-index: 2100;
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
    overflow-y: auto;
}
@keyframes backdropIn { from { opacity:0; } to { opacity:1; } }

/* Centered modal box */
.modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: 0 24px 64px rgba(0,0,0,0.28), 0 4px 16px rgba(0,0,0,0.18);
    width: 100%;
    max-height: 88vh;
    max-height: calc(100dvh - 3rem);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}
@keyframes modalIn {
    from { opacity:0; transform: scale(0.94) translateY(12px); }
    to   { opacity:1; transform: scale(1)    translateY(0); }
}
.modal-sm  { max-width: 440px; }
.modal-md  { max-width: 620px; }
.modal-lg  { max-width: 880px; }
.modal-xl  { max-width: 1100px; }
.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
    background: var(--bg-card);
}
.modal-title { font-size: var(--font-size-lg); font-weight: 700; color: var(--text); }
.modal-body  { padding: 1.5rem; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: flex-end; gap: 0.75rem;
    flex-shrink: 0;
    background: var(--bg-card);
}

/* ── Panel (right-side drawer) ───────────────────────────────── */
.drawer-overlay {
    position: fixed; inset: 0;
    background: rgba(10,18,40,0.55);
    z-index: 2000;
    animation: backdropIn 0.2s ease both;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}
.panel {
    position: fixed; top: 0; right: 0; bottom: 0;
    height: 100vh; height: 100dvh;
    /* Account for iOS notch */
    padding-top: env(safe-area-inset-top, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    width: min(520px, 100vw);
    background: var(--bg-card);
    z-index: 2001;
    display: flex; flex-direction: column;
    box-shadow: -8px 0 48px rgba(0,0,0,0.18);
    animation: panelIn 0.25s cubic-bezier(.32,.72,0,1) both;
}
[dir="rtl"] .panel {
    right: auto; left: 0;
    padding-right: 0;
    padding-left: env(safe-area-inset-left, 0px);
    box-shadow: 8px 0 48px rgba(0,0,0,0.18);
    animation: panelInRtl 0.25s cubic-bezier(.32,.72,0,1) both;
}
@keyframes panelInRtl {
    from { transform: translateX(-100%); opacity: 0.4; }
    to   { transform: translateX(0);     opacity: 1; }
}
@keyframes panelIn {
    from { transform: translateX(100%); opacity: 0.4; }
    to   { transform: translateX(0);    opacity: 1; }
}
.panel-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
}
.panel-title { font-size: var(--font-size-lg); font-weight: 700; color: var(--text); }
.panel-body  { padding: 1.5rem; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.panel-footer {
    padding: 1rem 1.5rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom, 1rem));
    border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: flex-end; gap: 0.75rem;
    flex-shrink: 0;
}

/* ── Confirm / Delete dialog ─────────────────────────────────── */
.confirm-overlay {
    position: fixed; inset: 0; z-index: 9000;
    background: rgba(0,0,0,0.52);
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
    animation: backdropIn 0.18s ease both;
}
.confirm-overlay.confirm-out {
    animation: backdropIn 0.18s ease reverse both;
}
.confirm-overlay.confirm-out .confirm-box {
    animation: confirmBoxIn 0.18s ease reverse both;
}
.confirm-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    box-shadow: 0 32px 80px rgba(0,0,0,0.28), 0 8px 32px rgba(0,0,0,0.18);
    padding: 2rem 1.75rem 1.75rem;
    max-width: 400px; width: 100%;
    text-align: center;
    animation: confirmBoxIn 0.26s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes confirmBoxIn {
    from { opacity:0; transform: scale(0.78) translateY(20px); }
    to   { opacity:1; transform: scale(1)    translateY(0); }
}
.confirm-icon-wrap {
    width: 72px; height: 72px;
    background: #fee2e2;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1.25rem;
}
[data-theme="dark"] .confirm-icon-wrap { background: rgba(239,68,68,0.15); }
.confirm-icon { color: #ef4444; display: flex; align-items: center; justify-content: center; }
.confirm-icon svg { width: 32px; height: 32px; stroke-width: 2; }
.confirm-title {
    font-size: 1.125rem; font-weight: 700;
    color: var(--text); margin: 0 0 0.625rem;
}
.confirm-body {
    font-size: var(--font-size-sm); color: var(--text-muted);
    line-height: 1.65; margin: 0 0 1.75rem;
}
.confirm-btns { display: flex; gap: 0.75rem; }
.confirm-btns .btn { flex: 1; justify-content: center; }
.confirm-btns .btn-danger {
    background: #ef4444; border-color: #ef4444;
    box-shadow: 0 4px 14px rgba(239,68,68,0.3);
}
.confirm-btns .btn-danger:hover:not(:disabled) {
    background: #dc2626; border-color: #dc2626;
    box-shadow: 0 6px 20px rgba(239,68,68,0.45);
    transform: translateY(-1px);
}

/* ── Close button ────────────────────────────────────────────── */
.close-btn {
    background: none; border: none; padding: 0.375rem;
    border-radius: var(--radius-sm); color: var(--text-muted);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.close-btn:hover { background: var(--bg-hover); color: var(--text); }
.close-btn svg   { width: 18px; height: 18px; }

/* Lock scroll on body when a modal/panel is open */
body.modal-open {
    overflow: hidden;
    /* iOS Safari scroll-lock fix */
    touch-action: none;
    -webkit-overflow-scrolling: none;
    overscroll-behavior: none;
}

/* Mobile adjustments */
@media (max-width: 640px) {
    /* Full-width panel on mobile */
    .panel { width: 100vw; height: 100dvh; padding-top: env(safe-area-inset-top, 0px); padding-bottom: 0; }
    /* Bottom-sheet modal */
    .dialog-overlay { padding: 0.5rem 0.5rem 0 0.5rem; align-items: flex-end; }
    .modal { max-height: calc(100dvh - 0.5rem); border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
    /* Safe-area bottom padding for footer buttons */
    .panel-footer, .modal-footer {
        flex-wrap: wrap;
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0.75rem));
    }
    .panel-footer .btn, .modal-footer .btn { flex: 1; }
    /* Minimum touch target size (48x48 per Apple HIG) */
    .btn:not(.btn-xs) { min-height: 2.75rem; }
    .btn-icon { min-width: 2.75rem; min-height: 2.75rem; }
    /* Nav items need bigger tap area */
    .nav-item { min-height: 2.75rem; }
    /* dropdown items */
    .dropdown-item { min-height: 2.75rem; }
}

/* ── iOS: prevent auto-zoom on input focus (font-size must be ≥16px) ── */
@media screen and (max-width: 768px) {
    .form-control,
    .form-control-sm,
    .search-input,
    .search-bar input,
    select.form-control,
    textarea.form-control {
        font-size: 16px !important;
    }
    /* Make sm inputs full-size on mobile — easier to see & tap */
    .form-control-sm {
        padding: 0.5rem 0.75rem !important;
        min-height: 2.75rem !important;
        line-height: 1.5 !important;
    }
}

/* ── Guard hover states for touch-only devices ───────────────── */
@media (hover: none) {
    .btn-primary:hover:not(:disabled),
    .btn-secondary:hover:not(:disabled),
    .btn-danger:hover:not(:disabled),
    .btn-ghost:hover:not(:disabled),
    .btn-outline:hover:not(:disabled) { box-shadow: none; transform: none; }
    .nav-item:hover { background: transparent; color: var(--text-sidebar); }
    .dropdown-item:hover { background: transparent; }
    .table tbody tr:hover td { background: transparent; }
}

/* ── Toast ───────────────────────────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    right: max(1.5rem, env(safe-area-inset-right, 1.5rem));
    z-index: 9999; pointer-events: none; display: flex; flex-direction: column; gap: 0.625rem;
    /* Constrain width on small screens */
    max-width: calc(100vw - 3rem);
}
[dir="rtl"] #toast-container { right: auto; left: max(1.5rem, env(safe-area-inset-left, 1.5rem)); }
.toast {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.875rem 1.125rem;
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    min-width: 240px; max-width: 400px;
    animation: toastIn 0.25s ease;
    font-size: var(--font-size-sm); font-weight: 500;
    word-break: break-word;
}
[dir="rtl"] .toast { border-left: none; border-right: 4px solid var(--primary); }
.toast.success { border-color: var(--success); }
.toast.warning { border-color: var(--warning); }
.toast.error   { border-color: var(--danger); }
.toast.info    { border-color: var(--info); }
.toast svg     { width: 18px; height: 18px; flex-shrink: 0; }
.toast.success svg { color: var(--success); }
.toast.warning svg { color: var(--warning); }
.toast.error   svg { color: var(--danger); }
.toast.info    svg { color: var(--info); }

/* ── Search bar ──────────────────────────────────────────────── */
.search-bar {
    display: flex; align-items: center;
    background: var(--bg-input);
    border: 1.5px solid var(--border-input);
    border-radius: var(--radius);
    padding: 0 0.75rem;
    gap: 0.5rem;
    transition: border-color var(--transition);
}
.search-bar:focus-within { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(245,158,11,0.12); }
.search-bar svg  { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.search-bar input {
    border: none; background: transparent; outline: none;
    font-family: inherit; font-size: var(--font-size-sm); color: var(--text);
    flex: 1; padding: 0.5rem 0; min-width: 160px;
}
.search-bar input::placeholder { color: var(--text-muted); }

/* ── Page header ─────────────────────────────────────────────── */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 1rem;
    margin-bottom: 1.5rem;
}
.page-header-title { font-size: var(--font-size-xl); font-weight: 700; }
.page-header-sub   { font-size: var(--font-size-sm); color: var(--text-muted); margin-top: 0.2rem; }
.page-toolbar {
    display: flex; align-items: center; flex-wrap: wrap; gap: 0.625rem;
    margin-bottom: 1rem;
}

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab-item {
    padding: 0.65rem 1rem;
    font-size: var(--font-size-sm); font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer; white-space: nowrap;
    border: none; border-bottom: 2px solid transparent; margin-bottom: -2px;
    background: transparent; border-radius: 0; outline: none;
    display: inline-flex; align-items: center; gap: 0.375rem;
    transition: color var(--transition);
}
.tab-item:hover  { color: var(--text); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
    text-align: center; padding: 4rem 2rem; color: var(--text-muted);
}
.empty-state svg  { width: 48px; height: 48px; margin: 0 auto 1rem; opacity: 0.4; }
.empty-state h3   { font-size: var(--font-size-lg); color: var(--text-secondary); margin-bottom: 0.5rem; }
.empty-state p    { font-size: var(--font-size-sm); }

/* ── Loading ─────────────────────────────────────────────────── */
.spinner {
    width: 24px; height: 24px;
    border: 2.5px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}
.page-spinner {
    display: flex; align-items: center; justify-content: center;
    min-height: 320px; width: 100%;
}
.page-spinner::after {
    content: '';
    width: 40px; height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}
.loading-overlay {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 4rem; gap: 1rem;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

/* ── Avatar upload ───────────────────────────────────────────── */
.avatar-upload { position: relative; width: 80px; height: 80px; }
.avatar-upload img,.avatar-upload .avatar-placeholder {
    width: 80px; height: 80px; border-radius: 50%;
    object-fit: cover;
    background: linear-gradient(135deg, var(--primary-100), var(--primary-200));
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; font-weight: 700;
    color: var(--primary-dark);
}
.avatar-upload-btn {
    position: absolute; bottom: 0; right: 0;
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--primary); border: 2px solid var(--bg-card);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-on-primary);
}
.avatar-upload-btn svg { width: 12px; height: 12px; }

/* ── Progress bar ────────────────────────────────────────────── */
.progress { height: 6px; background: var(--bg-hover); border-radius: var(--radius-full); overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: var(--radius-full); transition: width var(--transition-slow); }
.progress-bar.success { background: var(--success); }
.progress-bar.info    { background: var(--info); }

/* ── Pipeline steps ──────────────────────────────────────────── */
.pipeline {
    display: flex; align-items: center; gap: 0; overflow-x: auto;
    padding: 0.5rem 0; margin-bottom: 1.5rem;
}
.pipeline-step {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.45rem 0.875rem; font-size: var(--font-size-xs);
    font-weight: 600; white-space: nowrap; color: var(--text-muted);
    border-radius: var(--radius); cursor: pointer;
    transition: background var(--transition), color var(--transition);
    flex-shrink: 0;
}
.pipeline-step svg { width: 14px; height: 14px; }
.pipeline-step.active { background: var(--primary-100); color: var(--primary-dark); }
.pipeline-step.done   { background: var(--success-bg);  color: var(--success); }
.pipeline-step.danger { background: var(--danger-bg);   color: var(--danger); }

/* ── Dropdown ────────────────────────────────────────────────── */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
    position: absolute; top: calc(100% + 4px); right: 0;
    min-width: 180px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 500;
    overflow: hidden;
    animation: fadeIn 0.12s ease;
}
[dir="rtl"] .dropdown-menu { right: auto; left: 0; }
.dropdown-item {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.6rem 1rem; font-size: var(--font-size-sm);
    color: var(--text); cursor: pointer;
    transition: background var(--transition);
}
.dropdown-item:hover  { background: var(--bg-hover); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item svg    { width: 15px; height: 15px; color: var(--text-muted); }
.dropdown-item.danger svg { color: var(--danger); }
.dropdown-divider { height: 1px; background: var(--border); margin: 0.25rem 0; }

/* ── Detail view ─────────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.detail-item label { font-size: var(--font-size-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); display: block; margin-bottom: 0.2rem; }
.detail-item span  { font-size: var(--font-size-sm); font-weight: 500; color: var(--text); }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
    padding: 0.875rem 1rem; border-radius: var(--radius);
    font-size: var(--font-size-sm); display: flex; align-items: flex-start; gap: 0.75rem;
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 0.1rem; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-light); }
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger-light); }
.alert-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid var(--info-light); }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-light); }

/* ── Animations ──────────────────────────────────────────────── */
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes fadeIn  { from { opacity:0; } to { opacity:1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity:0; } to { transform: translateY(0); opacity:1; } }
@keyframes toastIn { from { transform: translateX(20px); opacity:0; } to { transform: translateX(0); opacity:1; } }
