/* ===== CSS Custom Properties (Theme) ===== */
:root {
    /* Colors - Corporate Palette */
    /* Primary: Steel Blue #2563EB */
    /* Secondary: Cool Grey #94A3B8 */
    /* Surface: Pure White #FFFFFF */
    /* Background: Pale Cloud #F1F5F9 */
    /* Focus: Navy Accent #172554 */

    --background: 210 40% 96%;
    --foreground: 224 71% 21%;
    --card: 0 0% 100%;
    --card-foreground: 224 71% 21%;
    --popover: 0 0% 100%;
    --popover-foreground: 224 71% 21%;
    --primary: 217 91% 53%;
    --primary-foreground: 0 0% 100%;
    --secondary: 215 16% 65%;
    --secondary-foreground: 224 71% 21%;
    --muted: 210 40% 96%;
    --muted-foreground: 215 16% 47%;
    --accent: 217 91% 53%;
    --accent-foreground: 0 0% 100%;
    --border: 215 20% 85%;
    --input: 215 20% 85%;
    --ring: 217 91% 53%;
    --radius: 0.375rem;
    --destructive: 0 84% 50%;
    --destructive-foreground: 0 0% 100%;
    --warning: 38 92% 50%;

    /* Shadows - Subtle */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.08), 0 1px 2px -1px rgb(0 0 0 / 0.08);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.08), 0 8px 10px -6px rgb(0 0 0 / 0.04);
}

.dark {
    --background: 224 71% 10%;
    --foreground: 210 40% 96%;
    --card: 224 71% 14%;
    --card-foreground: 210 40% 96%;
    --popover: 224 71% 14%;
    --popover-foreground: 210 40% 96%;
    --primary: 217 91% 60%;
    --primary-foreground: 224 71% 10%;
    --secondary: 215 16% 35%;
    --secondary-foreground: 210 40% 96%;
    --muted: 224 71% 18%;
    --muted-foreground: 215 16% 60%;
    --accent: 217 91% 60%;
    --accent-foreground: 224 71% 10%;
    --border: 224 71% 25%;
    --input: 224 71% 25%;
    --ring: 217 91% 60%;
    --destructive: 0 84% 60%;
    --destructive-foreground: 0 0% 100%;
    --warning: 38 92% 55%;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.875rem;
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: inherit;
    text-decoration: none;
}

img, svg {
    display: block;
    max-width: 100%;
}

button {
    font-family: inherit;
    cursor: pointer;
}

input, select, textarea {
    font-family: inherit;
}

/* ===== Layout ===== */
.app-container {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: 220px;
    background: hsl(var(--card));
    border-right: 1px solid hsl(var(--border));
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
}

/* Sidebar transitions - only after page has loaded to prevent flash */
html.sidebar-ready .app-sidebar {
    transition: width 0.2s ease;
}

html.sidebar-ready .app-main {
    transition: margin-left 0.2s ease;
}

.app-sidebar.collapsed {
    width: 56px;
}

.app-main {
    flex: 1;
    margin-left: 220px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

html.sidebar-collapsed .app-main {
    margin-left: 56px;
}

.app-content {
    flex: 1;
    padding: 20px 24px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    overflow-x: hidden;
}

@media (max-width: 1024px) {
    .app-sidebar {
        transform: translateX(-100%);
    }
    .app-sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    .app-main,
    html.sidebar-collapsed .app-main {
        margin-left: 0;
    }
    .app-content {
        padding: 16px;
    }
    .sidebar-toggle {
        display: none;
    }
}

/* ===== Sidebar ===== */
.sidebar-brand {
    height: 48px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid hsl(var(--border));
    flex-shrink: 0;
}

.sidebar-brand-icon {
    width: 28px;
    height: 28px;
    background: hsl(var(--primary));
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.sidebar-brand-text {
    font-weight: 600;
    font-size: 0.9375rem;
    color: hsl(var(--foreground));
    letter-spacing: -0.01em;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
}

.sidebar-section {
    margin-bottom: 16px;
}

.sidebar-section:last-child {
    margin-bottom: 0;
}

.sidebar-section-title {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: hsl(var(--muted-foreground));
    padding: 0 10px;
    margin-bottom: 6px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 5px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    transition: all 0.15s ease;
    margin-bottom: 2px;
}

.sidebar-link:last-child {
    margin-bottom: 0;
}

.sidebar-link:hover {
    background: hsl(var(--muted));
    color: hsl(var(--foreground));
}

.sidebar-link.active {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

.sidebar-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.8;
}

.sidebar-link.active svg {
    opacity: 1;
}

.sidebar-footer {
    padding: 10px;
    border-top: 1px solid hsl(var(--border));
    flex-shrink: 0;
}

/* ===== Sidebar Toggle ===== */
.sidebar-toggle {
    position: absolute;
    top: 14px;
    right: -10px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    display: flex;
    align-items: center;
    justify-content: center;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
    z-index: 50;
    transition: all 0.15s ease;
    box-shadow: var(--shadow-sm);
}

.sidebar-toggle:hover {
    background: hsl(var(--muted));
    color: hsl(var(--foreground));
}

.sidebar-toggle svg {
    width: 12px;
    height: 12px;
    transition: transform 0.2s ease;
}

.app-sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

/* ===== Sidebar Collapsed States ===== */
.app-sidebar.collapsed .sidebar-brand {
    padding: 0;
    justify-content: center;
}

.app-sidebar.collapsed .sidebar-brand-text {
    display: none;
}

.app-sidebar.collapsed .sidebar-nav {
    padding: 12px 8px;
}

.app-sidebar.collapsed .sidebar-section-title {
    opacity: 0;
    height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.app-sidebar.collapsed .sidebar-link {
    justify-content: center;
    padding: 10px;
}

.app-sidebar.collapsed .sidebar-link-text {
    display: none;
}

.app-sidebar.collapsed .sidebar-footer {
    padding: 8px;
}

/* Sidebar User Button */
.sidebar-user-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 5px;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

.sidebar-user-btn:hover {
    background: hsl(var(--muted));
}

.sidebar-user-btn.collapsed {
    justify-content: center;
    padding: 6px;
}

.sidebar-user-btn.collapsed .sidebar-user-info,
.sidebar-user-btn.collapsed .sidebar-user-chevron {
    display: none;
}

.sidebar-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 5px;
    background: hsl(var(--primary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 5px;
    object-fit: cover;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: hsl(var(--foreground));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.6875rem;
    color: hsl(var(--muted-foreground));
}

.sidebar-user-chevron {
    color: hsl(var(--muted-foreground));
    flex-shrink: 0;
}

.sidebar-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    margin-bottom: 6px;
    z-index: 100;
}

.sidebar-dropdown.collapsed-position {
    left: 100%;
    bottom: 0;
    right: auto;
    margin-left: 8px;
    margin-bottom: 0;
}

/* Sidebar Login Button */
.sidebar-login-btn {
    width: 100%;
}

.sidebar-login-btn.collapsed {
    padding: 8px;
    width: auto;
}

.sidebar-login-btn.collapsed .sidebar-login-text {
    display: none;
}

/* Tooltip for collapsed state */
.app-sidebar.collapsed .sidebar-link:hover::after {
    content: attr(title);
    position: absolute;
    left: 100%;
    margin-left: 8px;
    padding: 4px 8px;
    background: hsl(var(--popover));
    border: 1px solid hsl(var(--border));
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    color: hsl(var(--foreground));
    white-space: nowrap;
    box-shadow: var(--shadow);
    z-index: 100;
}

.app-sidebar.collapsed .sidebar-link {
    position: relative;
}

/* ===== Header ===== */
.header-search {
    flex: 1;
    max-width: 360px;
    position: relative;
}

.header-search input {
    width: 100%;
    height: 32px;
    padding: 0 12px 0 32px;
    border: 1px solid hsl(var(--border));
    border-radius: 5px;
    background: hsl(var(--background));
    font-size: 0.8125rem;
    color: hsl(var(--foreground));
    transition: all 0.15s ease;
}

.header-search input::placeholder {
    color: hsl(var(--muted-foreground));
}

.header-search input:focus {
    outline: none;
    border-color: hsl(var(--primary));
    background: hsl(var(--card));
    box-shadow: 0 0 0 2px hsl(var(--primary) / 0.1);
}

.header-search svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: hsl(var(--muted-foreground));
    pointer-events: none;
    width: 14px;
    height: 14px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.header-icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 5px;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    color: hsl(var(--muted-foreground));
    transition: all 0.1s ease;
}

.header-icon-btn:hover {
    background: hsl(var(--muted));
    color: hsl(var(--foreground));
}

.header-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px 4px 4px;
    border-radius: 5px;
    border: none;
    background: transparent;
    transition: background 0.1s ease;
    cursor: pointer;
}

.header-user:hover {
    background: hsl(var(--muted));
}

.header-user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 5px;
    background: hsl(var(--primary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 600;
}

.header-user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 5px;
    object-fit: cover;
}

.header-user-info {
    display: none;
    text-align: left;
}

@media (min-width: 640px) {
    .header-user-info {
        display: block;
    }
}

.header-user-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: hsl(var(--foreground));
    line-height: 1.3;
}

.header-user-role {
    font-size: 0.6875rem;
    color: hsl(var(--muted-foreground));
    line-height: 1.3;
}

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

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.page-description {
    font-size: 0.8125rem;
    color: hsl(var(--muted-foreground));
    margin-top: 4px;
    line-height: 1.4;
}

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

/* ===== Cards ===== */
.card {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: 6px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 12px 16px;
    border-bottom: 1px solid hsl(var(--border));
}

.card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    line-height: 1.3;
}

.card-description {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    margin-top: 2px;
    line-height: 1.4;
}

.card-body {
    padding: 16px;
}

.card-footer {
    padding: 10px 16px;
    border-top: 1px solid hsl(var(--border));
    background: hsl(var(--muted) / 0.3);
}

/* ===== Stats Cards ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

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

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

.stats-card {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: 6px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s ease;
}

.stats-card:hover {
    box-shadow: var(--shadow);
}

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

.stats-card-icon {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stats-card-icon svg {
    width: 18px;
    height: 18px;
}

.stats-card-icon {
    background: hsl(var(--primary) / 0.1);
    color: hsl(var(--primary));
}

.stats-card-label {
    font-size: 0.6875rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stats-card-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    line-height: 1;
    margin-bottom: 6px;
    letter-spacing: -0.01em;
}

.stats-card-change {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.6875rem;
    color: hsl(var(--muted-foreground));
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    line-height: 1.3;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

.btn-primary:hover:not(:disabled) {
    background: hsl(217 91% 45%);
}

.btn-primary:active:not(:disabled) {
    background: hsl(217 91% 40%);
}

.btn-secondary {
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
}

.btn-secondary:hover:not(:disabled) {
    background: hsl(215 16% 55%);
}

.btn-outline {
    border: 1px solid hsl(var(--border));
    background: transparent;
    color: hsl(var(--foreground));
}

.btn-outline:hover:not(:disabled) {
    background: hsl(var(--muted));
}

.btn-ghost {
    background: transparent;
    color: hsl(var(--muted-foreground));
}

.btn-ghost:hover:not(:disabled) {
    background: hsl(var(--muted));
    color: hsl(var(--foreground));
}

.btn-destructive {
    background: hsl(var(--muted-foreground));
    color: hsl(0 0% 100%);
}

.btn-destructive:hover:not(:disabled) {
    background: hsl(var(--foreground));
}

.btn-success {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

.btn-success:hover:not(:disabled) {
    background: hsl(217 91% 45%);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.75rem;
    border-radius: 4px;
}

.btn-lg {
    padding: 10px 20px;
    font-size: 0.875rem;
}

.btn-icon {
    padding: 7px;
    width: 32px;
    height: 32px;
}

.btn-icon.btn-sm {
    padding: 4px;
    width: 26px;
    height: 26px;
}

.w-full {
    width: 100%;
}

/* ===== Form Controls ===== */
.form-group {
    margin-bottom: 14px;
}

.form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: hsl(var(--foreground));
    margin-bottom: 5px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 8px 10px;
    font-size: 0.8125rem;
    border: 1px solid hsl(var(--border));
    border-radius: 5px;
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    transition: all 0.15s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: hsl(var(--primary));
    background: hsl(var(--card));
    box-shadow: 0 0 0 2px hsl(var(--primary) / 0.1);
}

.form-input::placeholder {
    color: hsl(var(--muted-foreground));
}

.form-input:disabled,
.form-select:disabled {
    background: hsl(var(--muted));
    cursor: not-allowed;
    opacity: 0.7;
}

.form-hint {
    font-size: 0.6875rem;
    color: hsl(var(--muted-foreground));
    margin-top: 4px;
}

.form-error {
    font-size: 0.6875rem;
    color: hsl(var(--foreground));
    margin-top: 4px;
    font-weight: 500;
}

/* ===== Tables ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: hsl(var(--muted) / 0.5);
}

.data-table th {
    text-align: left;
    padding: 8px 12px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: hsl(var(--muted-foreground));
    border-bottom: 1px solid hsl(var(--border));
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid hsl(var(--border));
    vertical-align: middle;
    font-size: 0.8125rem;
}

.data-table tbody tr {
    transition: background 0.1s ease;
}

.data-table tbody tr:hover {
    background: hsl(var(--muted) / 0.3);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ===== Status Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 500;
}

.badge-draft,
.status-badge-draft {
    background: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
}

.badge-processing,
.status-badge-processing {
    background: hsl(var(--muted-foreground) / 0.1);
    color: hsl(var(--muted-foreground));
}

.badge-pending_validation,
.badge-pending,
.status-badge-pending_validation {
    background: hsl(var(--primary) / 0.1);
    color: hsl(var(--primary));
}

.badge-registered,
.badge-success,
.status-badge-registered {
    background: hsl(142 71% 45% / 0.12);
    color: hsl(142 71% 45%);
}

.badge-failed,
.badge-error,
.status-badge-failed {
    background: hsl(var(--foreground) / 0.1);
    color: hsl(var(--foreground));
}

/* Legacy class support */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: capitalize;
}

/* ===== Progress Bar ===== */
.progress-bar {
    height: 4px;
    border-radius: 2px;
    background: hsl(var(--muted));
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 2px;
    background: hsl(var(--primary));
    transition: width 0.3s ease;
}

.progress-bar-success .progress-bar-fill {
    background: hsl(var(--accent));
}

/* ===== Alerts ===== */
.alert {
    display: flex;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 5px;
    font-size: 0.8125rem;
    line-height: 1.4;
}

.alert-icon {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin-top: 1px;
}

.alert-info {
    background: hsl(var(--accent) / 0.08);
    color: hsl(var(--primary));
    border: 1px solid hsl(var(--accent) / 0.2);
}

.alert-success {
    background: hsl(var(--accent) / 0.08);
    color: hsl(var(--primary));
    border: 1px solid hsl(var(--accent) / 0.12);
}

.alert-warning {
    background: hsl(var(--muted) / 0.5);
    color: hsl(var(--foreground));
    border: 1px solid hsl(var(--border));
}

.alert-error {
    background: hsl(var(--foreground) / 0.05);
    color: hsl(var(--foreground));
    border: 1px solid hsl(var(--foreground) / 0.15);
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
}

.empty-state-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 14px;
    color: hsl(var(--muted-foreground));
    opacity: 0.4;
}

.empty-state-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    margin-bottom: 6px;
}

.empty-state-description {
    font-size: 0.8125rem;
    color: hsl(var(--muted-foreground));
    max-width: 300px;
    margin: 0 auto 20px;
    line-height: 1.4;
}

/* ===== Upload Zone ===== */
.upload-zone {
    border: 2px dashed hsl(var(--border));
    border-radius: 6px;
    padding: 32px 20px;
    text-align: center;
    transition: all 0.15s ease;
    cursor: pointer;
    background: hsl(var(--muted) / 0.3);
}

.upload-zone:hover {
    border-color: hsl(var(--primary));
    background: hsl(var(--primary) / 0.03);
}

.upload-zone.dragging {
    border-color: hsl(var(--primary));
    background: hsl(var(--primary) / 0.05);
}

.upload-zone-icon {
    width: 40px;
    height: 40px;
    margin: 0 auto 12px;
    color: hsl(var(--muted-foreground));
}

.upload-zone-text {
    font-size: 0.8125rem;
    color: hsl(var(--muted-foreground));
}

.upload-zone-text strong {
    color: hsl(var(--primary));
    font-weight: 500;
}

/* ===== Document Cards ===== */
.document-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid hsl(var(--border));
    border-radius: 5px;
    background: hsl(var(--card));
    transition: all 0.15s ease;
}

.document-card:hover {
    border-color: hsl(var(--primary) / 0.3);
    box-shadow: var(--shadow-sm);
}

.document-card-icon {
    width: 32px;
    height: 32px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.document-card-icon svg {
    width: 16px;
    height: 16px;
}

.document-card-icon.pdf {
    background: hsl(var(--muted));
    color: hsl(var(--foreground));
}

.document-card-icon.image {
    background: hsl(var(--primary) / 0.1);
    color: hsl(var(--primary));
}

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

.document-card-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: hsl(var(--foreground));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.document-card-meta {
    font-size: 0.6875rem;
    color: hsl(var(--muted-foreground));
    margin-top: 2px;
}

/* ===== Modals ===== */
.modal-dialog {
    background: hsl(var(--card));
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    max-width: 480px;
    width: calc(100vw - 32px);
    position: relative;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 20px 20px 0;
}

.modal-title {
    font-size: 1rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    line-height: 1.3;
    margin: 0;
}

.modal-description {
    font-size: 0.8125rem;
    color: hsl(var(--muted-foreground));
    margin: 4px 0 0 0;
    line-height: 1.4;
}

.modal-close {
    padding: 6px;
    color: hsl(var(--muted-foreground));
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s ease;
    flex-shrink: 0;
    margin: -2px -6px 0 0;
}

.modal-close:hover {
    background: hsl(var(--muted));
    color: hsl(var(--foreground));
}

.modal-body {
    padding: 16px 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px 20px;
}

/* ===== Claim Type Selection ===== */
.claim-type-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.claim-type-option {
    width: 100%;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 8px;
    border: 1px solid hsl(var(--border));
    background: hsl(var(--background));
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
}

.claim-type-option:hover {
    border-color: hsl(var(--muted-foreground) / 0.4);
    background: hsl(var(--muted) / 0.3);
}

.claim-type-option.selected {
    border-color: hsl(var(--primary));
    background: hsl(var(--primary) / 0.04);
}

.claim-type-option-radio {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid hsl(var(--border));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
    transition: all 0.15s ease;
}

.claim-type-option.selected .claim-type-option-radio {
    border-color: hsl(var(--primary));
}

.claim-type-option-radio-inner {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: transparent;
    transition: all 0.15s ease;
}

.claim-type-option.selected .claim-type-option-radio-inner {
    background: hsl(var(--primary));
}

.claim-type-option-content {
    flex: 1;
    min-width: 0;
}

.claim-type-option-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--foreground));
    line-height: 1.3;
}

.claim-type-option-desc {
    font-size: 0.8125rem;
    color: hsl(var(--muted-foreground));
    margin-top: 2px;
    line-height: 1.4;
}

/* ===== File Dropzone ===== */
.file-dropzone {
    border: 2px dashed hsl(var(--border));
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s ease;
    background: hsl(var(--background));
}

.file-dropzone:hover {
    border-color: hsl(var(--muted-foreground) / 0.4);
    background: hsl(var(--muted) / 0.3);
}

.file-dropzone.dragging {
    border-color: hsl(var(--primary));
    background: hsl(var(--primary) / 0.04);
}

.file-dropzone.has-files {
    padding: 12px;
    border-style: solid;
    cursor: default;
}

.file-dropzone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.file-dropzone-content svg {
    color: hsl(var(--muted-foreground) / 0.5);
}

.file-dropzone.dragging .file-dropzone-content svg {
    color: hsl(var(--primary));
}

.file-dropzone-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--foreground));
    margin: 0;
}

.file-dropzone-hint {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    margin: 0;
}

/* ===== File List ===== */
.file-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: 6px;
}

.file-item-icon {
    color: hsl(var(--muted-foreground));
    flex-shrink: 0;
}

.file-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.file-item-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: hsl(var(--foreground));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-item-size {
    font-size: 0.6875rem;
    color: hsl(var(--muted-foreground));
}

.file-item-remove {
    padding: 4px;
    color: hsl(var(--muted-foreground));
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.file-item-remove:hover {
    color: hsl(0 84% 60%);
    background: hsl(0 84% 60% / 0.1);
}

.file-add-more {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    width: 100%;
    font-size: 0.8125rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    background: none;
    border: 1px dashed hsl(var(--border));
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.file-add-more:hover {
    color: hsl(var(--foreground));
    border-color: hsl(var(--muted-foreground) / 0.4);
    background: hsl(var(--muted) / 0.3);
}

/* ===== Skeleton Loading ===== */
.skeleton {
    background: linear-gradient(
        90deg,
        hsl(var(--muted)) 25%,
        hsl(var(--muted) / 0.5) 50%,
        hsl(var(--muted)) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== Dropdown ===== */
.dropdown-menu {
    background: hsl(var(--popover));
    border: 1px solid hsl(var(--border));
    border-radius: 5px;
    box-shadow: var(--shadow-md);
    padding: 4px;
    min-width: 160px;
    z-index: 50;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 4px;
    font-size: 0.8125rem;
    color: hsl(var(--foreground));
    transition: background 0.1s ease;
    cursor: pointer;
}

.dropdown-item:hover {
    background: hsl(var(--muted));
}

.dropdown-item.destructive {
    color: hsl(var(--foreground));
    font-weight: 500;
}

.dropdown-item.destructive:hover {
    background: hsl(var(--foreground) / 0.08);
}

.dropdown-divider {
    height: 1px;
    background: hsl(var(--border));
    margin: 4px 0;
}

/* ===== Avatar ===== */
.avatar {
    width: 32px;
    height: 32px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.avatar-sm {
    width: 26px;
    height: 26px;
    font-size: 0.6875rem;
    border-radius: 4px;
}

.avatar-lg {
    width: 40px;
    height: 40px;
    font-size: 0.875rem;
}

.avatar-primary {
    background: hsl(var(--primary) / 0.1);
    color: hsl(var(--primary));
}

/* ===== Tabs ===== */
.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid hsl(var(--border));
    padding-bottom: 0;
}

.tab {
    padding: 8px 12px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.1s ease;
    cursor: pointer;
}

.tab:hover {
    color: hsl(var(--foreground));
}

.tab.active {
    color: hsl(var(--primary));
    border-bottom-color: hsl(var(--primary));
}

/* ===== Quick Actions Grid ===== */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 8px;
}

.quick-action {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-radius: 5px;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    transition: all 0.15s ease;
    cursor: pointer;
    text-decoration: none;
}

.quick-action:hover {
    border-color: hsl(var(--primary) / 0.3);
    box-shadow: var(--shadow-sm);
}

.quick-action-icon {
    width: 32px;
    height: 32px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.quick-action-icon svg {
    width: 16px;
    height: 16px;
}

.quick-action:hover .quick-action-icon {
    background: hsl(var(--primary) / 0.1);
    color: hsl(var(--primary));
}

.quick-action-text {
    font-size: 0.8125rem;
    font-weight: 500;
    color: hsl(var(--foreground));
}

.quick-action-hint {
    font-size: 0.6875rem;
    color: hsl(var(--muted-foreground));
    margin-top: 2px;
}

/* ===== Activity List ===== */
.activity-list {
    display: flex;
    flex-direction: column;
}

.activity-item {
    display: flex;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid hsl(var(--border));
    transition: background 0.1s ease;
}

.activity-item:hover {
    background: hsl(var(--muted) / 0.3);
}

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

.activity-icon {
    width: 28px;
    height: 28px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
    flex-shrink: 0;
}

.activity-icon svg {
    width: 14px;
    height: 14px;
}

.activity-icon.primary {
    background: hsl(var(--primary) / 0.1);
    color: hsl(var(--primary));
}

.activity-icon.success {
    background: hsl(var(--accent) / 0.1);
    color: hsl(var(--accent));
}

.activity-icon.warning {
    background: hsl(var(--muted-foreground) / 0.1);
    color: hsl(var(--muted-foreground));
}

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-title {
    font-size: 0.8125rem;
    font-weight: 500;
    color: hsl(var(--foreground));
}

.activity-meta {
    font-size: 0.6875rem;
    color: hsl(var(--muted-foreground));
    margin-top: 2px;
}

/* ===== Content Grid ===== */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 16px;
}

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

.content-grid-equal {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

@media (max-width: 960px) {
    .content-grid-equal {
        grid-template-columns: 1fr;
    }
}

/* ===== Utilities ===== */
.text-primary { color: hsl(var(--primary)); }
.text-accent { color: hsl(var(--accent)); }
.text-muted-foreground { color: hsl(var(--muted-foreground)); }

.bg-primary { background: hsl(var(--primary)); }
.bg-accent { background: hsl(var(--accent)); }
.bg-muted { background: hsl(var(--muted)); }

.border-primary { border-color: hsl(var(--primary)); }
.border-accent { border-color: hsl(var(--accent)); }

.divide-y > * + * {
    border-top: 1px solid hsl(var(--border));
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ml-auto { margin-left: auto; }
.mt-0\.5 { margin-top: 0.125rem; }

.flex { display: flex; }
.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }

.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }

.w-8 { width: 2rem; }
.w-10 { width: 2.5rem; }
.h-8 { height: 2rem; }
.h-10 { height: 2.5rem; }

.rounded-full { border-radius: 9999px; }
.flex-shrink-0 { flex-shrink: 0; }
.flex-1 { flex: 1; }
.min-w-0 { min-width: 0; }
.relative { position: relative; }

.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.font-medium { font-weight: 500; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .app-content {
        padding: 12px;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .page-actions {
        width: 100%;
    }

    .page-actions .btn {
        flex: 1;
    }

    .modal-dialog {
        margin: 12px;
        max-width: none;
    }
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.animate-fade-in {
    animation: fadeIn 0.2s ease;
}

.animate-slide-up {
    animation: slideUp 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-slide-down {
    animation: slideDown 0.3s ease;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* ===== Print ===== */
@media print {
    .app-sidebar,
    .btn,
    .modal-dialog {
        display: none !important;
    }

    .app-main {
        margin-left: 0 !important;
    }

    .app-content {
        padding: 0 !important;
        max-width: none !important;
    }
}

/* ===== Focus States ===== */
.btn:focus-visible,
.sidebar-link:focus-visible,
.form-input:focus-visible,
.form-select:focus-visible {
    outline: 2px solid hsl(var(--primary));
    outline-offset: 2px;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: hsl(var(--muted) / 0.5);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: hsl(var(--muted-foreground) / 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: hsl(var(--muted-foreground) / 0.5);
}

/* ===== Selection ===== */
::selection {
    background: hsl(var(--primary) / 0.2);
    color: hsl(var(--foreground));
}

/* ===== Split Layout with Edit Panel ===== */
.split-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.split-layout-main {
    flex: 1;
    min-width: 0;
    transition: all 0.3s ease;
}

.split-layout.panel-open .split-layout-main {
    flex: 1;
}

/* ===== Edit Panel ===== */
.edit-panel {
    width: 520px;
    flex-shrink: 0;
}

.edit-panel-card {
    position: sticky;
    top: 24px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.edit-panel-card::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.edit-panel-enter {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.edit-panel-enter-start {
    opacity: 0;
    transform: translateX(16px);
}

.edit-panel-enter-end {
    opacity: 1;
    transform: translateX(0);
}

.edit-panel-leave {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.edit-panel-leave-start {
    opacity: 1;
    transform: translateX(0);
}

.edit-panel-leave-end {
    opacity: 0;
    transform: translateX(16px);
}

.edit-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid hsl(var(--border));
}

.edit-panel-header-content {
    min-width: 0;
}

.edit-panel-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    margin: 0;
    line-height: 1.3;
}

.edit-panel-subtitle {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    margin: 2px 0 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.edit-panel-loading {
    padding: 48px 20px;
    text-align: center;
}

.edit-panel-loading svg {
    margin: 0 auto 12px;
    display: block;
    color: hsl(var(--muted-foreground));
}

.edit-panel-loading p {
    font-size: 0.8125rem;
    color: hsl(var(--muted-foreground));
    margin: 0;
}

.edit-panel-body {
    display: flex;
    flex-direction: column;
}

.edit-panel-section {
    padding: 16px 20px;
    border-bottom: 1px solid hsl(var(--border));
}

.edit-panel-section:last-child {
    border-bottom: none;
}

.edit-panel-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.edit-panel-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: hsl(var(--muted-foreground));
    margin: 0 0 12px 0;
}

.edit-panel-section-header .edit-panel-section-title {
    margin-bottom: 0;
}

/* ===== Edit Panel Tabs ===== */
.edit-panel-tabs {
    display: flex;
    border-bottom: 1px solid hsl(var(--border));
    margin: 0 -20px;
}

.edit-panel-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    font-size: 0.8125rem;
    font-weight: 500;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: transparent;
    color: hsl(var(--muted-foreground));
}

.edit-panel-tab:hover {
    color: hsl(var(--foreground));
    background: hsl(var(--muted) / 0.5);
}

.edit-panel-tab.active {
    color: hsl(var(--primary));
    border-bottom-color: hsl(var(--primary));
}

.edit-panel-tab.active:hover {
    background: transparent;
}

/* ===== Field List ===== */
.field-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: hsl(var(--background));
    border-radius: 6px;
    border: 1px solid hsl(var(--border));
    transition: all 0.15s ease;
}

.field-item:hover {
    border-color: hsl(var(--muted-foreground) / 0.3);
}

.field-item.drag-over {
    border-color: hsl(var(--primary));
    background: hsl(var(--primary) / 0.05);
}

.field-item-drag {
    cursor: grab;
    color: hsl(var(--muted-foreground) / 0.5);
    flex-shrink: 0;
}

.field-item-drag:hover {
    color: hsl(var(--muted-foreground));
}

.field-item-content {
    flex: 1;
    min-width: 0;
}

.field-item-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: hsl(var(--foreground));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.field-item-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.6875rem;
    color: hsl(var(--muted-foreground));
    margin-top: 1px;
}

.field-item-dot {
    opacity: 0.5;
}

.field-item-required {
    color: hsl(32 95% 44%);
    font-weight: 600;
}

.field-item-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.field-item:hover .field-item-actions {
    opacity: 1;
}

.field-item-delete {
    color: hsl(var(--muted-foreground));
}

.field-item-delete:hover:not(:disabled) {
    color: hsl(0 84% 60%);
    background: hsl(0 84% 60% / 0.1);
}

.field-list-empty {
    padding: 24px 16px;
    text-align: center;
    background: hsl(var(--background));
    border-radius: 6px;
    border: 1px dashed hsl(var(--border));
}

.field-list-empty svg {
    margin: 0 auto 8px;
    color: hsl(var(--muted-foreground) / 0.5);
}

.field-list-empty-title {
    font-size: 0.8125rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    margin: 0;
}

.field-list-empty-desc {
    font-size: 0.6875rem;
    color: hsl(var(--muted-foreground) / 0.7);
    margin: 2px 0 0 0;
}

/* ===== Form Checkbox ===== */
.form-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.8125rem;
    color: hsl(var(--foreground));
}

.form-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: hsl(var(--primary));
    cursor: pointer;
}

/* ===== Form Row ===== */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ===== Modal Overlay ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

/* ===== Responsive Edit Panel ===== */
@media (max-width: 1024px) {
    .edit-panel {
        width: 440px;
    }
}

@media (max-width: 768px) {
    .split-layout {
        flex-direction: column;
    }

    .edit-panel {
        width: 100%;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 50;
        background: hsl(var(--card));
        box-shadow: var(--shadow-xl);
    }

    .edit-panel-card {
        position: static;
        max-height: 100vh;
        border-radius: 0;
        box-shadow: none;
    }
}

/* ===== RTL (Right-to-Left) Support ===== */
html[dir="rtl"] {
    /* Font family with Arabic support */
    font-family: 'Noto Sans Arabic', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html[dir="rtl"] .app-sidebar {
    left: auto;
    right: 0;
    border-right: none;
    border-left: 1px solid hsl(var(--border));
}

html[dir="rtl"] .app-main {
    margin-left: 0;
    margin-right: 220px;
}

html[dir="rtl"].sidebar-collapsed .app-main {
    margin-left: 0;
    margin-right: 56px;
}

html[dir="rtl"] .sidebar-toggle {
    right: auto;
    left: -10px;
}

html[dir="rtl"] .sidebar-toggle-icon {
    transform: rotate(180deg);
}

html[dir="rtl"] .app-sidebar.collapsed .sidebar-toggle-icon {
    transform: rotate(0deg);
}

html[dir="rtl"] .sidebar-link {
    text-align: right;
}

html[dir="rtl"] .sidebar-dropdown {
    left: auto;
    right: 0;
}

html[dir="rtl"] .sidebar-dropdown.collapsed-position {
    left: auto;
    right: 100%;
    margin-left: 0;
    margin-right: 8px;
}

html[dir="rtl"] .page-header {
    flex-direction: row-reverse;
}

html[dir="rtl"] .page-actions {
    flex-direction: row-reverse;
}

html[dir="rtl"] .btn {
    flex-direction: row-reverse;
}

html[dir="rtl"] .stats-card-header {
    flex-direction: row-reverse;
}

html[dir="rtl"] .data-table th,
html[dir="rtl"] .data-table td {
    text-align: right;
}

html[dir="rtl"] .dropdown-item {
    flex-direction: row-reverse;
    text-align: right;
}

html[dir="rtl"] .settings-item {
    flex-direction: row-reverse;
}

html[dir="rtl"] .settings-item-info {
    flex-direction: row-reverse;
}

html[dir="rtl"] .card-header,
html[dir="rtl"] .card-body,
html[dir="rtl"] .card-footer {
    text-align: right;
}

html[dir="rtl"] .ml-auto {
    margin-left: 0;
    margin-right: auto;
}

html[dir="rtl"] .alert {
    flex-direction: row-reverse;
}

html[dir="rtl"] .badge {
    flex-direction: row-reverse;
}

/* RTL responsive adjustments */
@media (max-width: 1024px) {
    html[dir="rtl"] .app-sidebar {
        transform: translateX(100%);
    }

    html[dir="rtl"] .app-sidebar.open {
        transform: translateX(0);
    }

    html[dir="rtl"] .app-main,
    html[dir="rtl"].sidebar-collapsed .app-main {
        margin-right: 0;
    }
}

@media (max-width: 768px) {
    html[dir="rtl"] .edit-panel {
        right: auto;
        left: 0;
    }
}

/* ===== CJK Font Support ===== */
html[lang="zh"] {
    font-family: 'Noto Sans SC', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html[lang="th"] {
    font-family: 'Noto Sans Thai', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ========================================
   FWA Alert Styles
   ======================================== */

/* 3-column detail grid */
.detail-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 24px;
}

@media (max-width: 1024px) {
    .detail-grid-3 {
        grid-template-columns: 1fr;
    }
}

/* Score display */
.fwa-score {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
}

.fwa-score-low { color: hsl(var(--success)); }
.fwa-score-medium { color: hsl(var(--warning)); }
.fwa-score-high { color: hsl(25, 95%, 53%); }
.fwa-score-critical { color: hsl(var(--destructive)); }

/* FWA status badges */
.fwa-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.fwa-badge-new_alert {
    background: hsl(var(--warning) / 0.1);
    color: hsl(var(--warning));
}

.fwa-badge-under_qualification {
    background: hsl(var(--primary) / 0.1);
    color: hsl(var(--primary));
}

.fwa-badge-under_investigation {
    background: hsl(217, 91%, 60% / 0.1);
    color: hsl(217, 91%, 60%);
}

.fwa-badge-proven_fwa {
    background: hsl(var(--destructive) / 0.1);
    color: hsl(var(--destructive));
}

.fwa-badge-false_positive {
    background: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
}

.fwa-badge-unproven_fwa {
    background: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
}

.fwa-badge-non_fwa {
    background: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
}

/* Source badge */
.fwa-source-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 500;
}

.fwa-source-ai {
    background: hsl(280 60% 50% / 0.1);
    color: hsl(280 60% 50%);
}

.fwa-source-manual {
    background: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
}

/* Timeline stepper */
.timeline-stepper {
    display: flex;
    align-items: flex-start;
    padding: 24px 16px;
}

.timeline-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex: 0 0 auto;
    min-width: 120px;
}

.timeline-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
    background: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
}

.timeline-step.completed .timeline-dot {
    background: hsl(var(--primary));
    color: white;
}

.timeline-step.active .timeline-dot {
    background: hsl(var(--primary));
    color: white;
    box-shadow: 0 0 0 4px hsl(var(--primary) / 0.2);
}

.timeline-step.future .timeline-dot {
    background: transparent;
    border: 2px dashed hsl(var(--border));
    color: hsl(var(--muted-foreground));
}

.timeline-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: hsl(var(--foreground));
    margin-bottom: 2px;
}

.timeline-date {
    font-size: 0.6875rem;
    color: hsl(var(--muted-foreground));
}

.timeline-connector {
    flex: 1;
    height: 2px;
    background: hsl(var(--border));
    margin-top: 16px;
    min-width: 24px;
}

.timeline-connector.completed {
    background: hsl(var(--primary));
}

/* Key-value detail list */
.detail-kv {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 10px 0;
    gap: 16px;
}

.detail-kv:not(:last-child) {
    border-bottom: 1px solid hsl(var(--border));
}

.detail-kv-label {
    font-size: 0.8125rem;
    color: hsl(var(--muted-foreground));
    flex-shrink: 0;
}

.detail-kv-value {
    font-size: 0.875rem;
    font-weight: 500;
    text-align: right;
    word-break: break-word;
}

/* NPI verification badges */
.npi-verified {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: hsl(var(--success));
    font-size: 0.75rem;
}

.npi-not-found {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: hsl(var(--destructive));
    font-size: 0.75rem;
}

/* Pattern tags */
.pattern-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 500;
    background: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
    white-space: nowrap;
}

.pattern-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

/* Score column in table */
.score-cell {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ===== Date Range Picker ===== */

.date-range-popover {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 50;
    background: hsl(var(--popover));
    border: 1px solid hsl(var(--border));
    border-radius: 10px;
    box-shadow: var(--shadow-xl);
    padding: 12px;
    width: 280px;
    animation: datePickerIn 0.15s ease-out;
}

@keyframes datePickerIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.date-range-header button {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
}

.date-range-header button:hover {
    background: hsl(var(--muted));
    color: hsl(var(--foreground));
}

.date-range-header span {
    font-size: 0.8125rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    letter-spacing: -0.01em;
}

.date-range-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    margin-bottom: 4px;
}

.date-range-weekdays span {
    font-size: 0.6875rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 4px 0;
}

.date-range-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px 0;
}

.date-range-day {
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    border: none;
    background: transparent;
    color: hsl(var(--foreground));
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
    padding: 0;
    border-radius: 0;
    position: relative;
}

.date-range-day:hover:not(.outside):not(.range-start):not(.range-end) {
    background: hsl(var(--muted));
}

.date-range-day.outside {
    color: hsl(var(--muted-foreground) / 0.35);
}

.date-range-day.today {
    font-weight: 600;
}

.date-range-day.today::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: hsl(var(--primary));
}

.date-range-day.range-start,
.date-range-day.range-end {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    font-weight: 500;
}

.date-range-day.range-start {
    border-radius: 6px 0 0 6px;
}

.date-range-day.range-end {
    border-radius: 0 6px 6px 0;
}

.date-range-day.range-start.range-end {
    border-radius: 6px;
}

.date-range-day.in-range {
    background: hsl(var(--primary) / 0.1);
}

.date-range-day.in-range.outside {
    background: hsl(var(--primary) / 0.05);
}

.date-range-day.range-start.today::after,
.date-range-day.range-end.today::after {
    background: hsl(var(--primary-foreground));
}

/* Rendered rich-text explanation / AI summary (FWA alert detail page) */
.fwa-explanation { white-space: pre-line; }  /* honor \n in legacy plain-text AI summaries without breaking <br> from the editor */
.fwa-explanation > *:first-child { margin-top: 0; }
.fwa-explanation > *:last-child { margin-bottom: 0; }
.fwa-explanation p { margin: 0 0 0.75em; }
.fwa-explanation ul, .fwa-explanation ol { margin: 0 0 0.75em; padding-left: 1.75em; }
.fwa-explanation ul ul, .fwa-explanation ol ol, .fwa-explanation ul ol, .fwa-explanation ol ul { margin-bottom: 0; }
.fwa-explanation li { margin-bottom: 0.25em; }
.fwa-explanation a { color: hsl(var(--primary)); text-decoration: underline; }
.fwa-explanation a:hover { text-decoration: none; }
.fwa-explanation blockquote {
    margin: 0 0 0.75em;
    padding: 0.25em 0 0.25em 1em;
    border-left: 3px solid hsl(var(--border));
    color: hsl(var(--muted-foreground));
}
.fwa-explanation h1, .fwa-explanation h2, .fwa-explanation h3 {
    font-size: 1.0625rem;
    font-weight: 600;
    margin: 0.75em 0 0.5em;
}
.fwa-explanation pre, .fwa-explanation code {
    background: hsl(var(--muted));
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.85em;
}
.fwa-explanation pre { padding: 10px 12px; overflow-x: auto; }
