/* ============================================================
   Saitama Dashboard — Design System
   2026 Premium Dark theme — Hextech inspired, deep blacks
   ============================================================ */

/* --- Tokens --- */
:root {
    /* Surfaces — Premium dark */
    --bg-base: #111113;
    --bg-surface: #16161a;
    --bg-elevated: #1e1e24;
    --bg-hover: rgba(249, 115, 22, 0.06);
    --bg-active: rgba(249, 115, 22, 0.12);

    /* Borders — Dark subtle borders */
    --border-subtle: #1e1e24;
    --border-default: #2a2a32;
    --border-strong: #3f3f46;

    /* Text — Light on Dark */
    --text-primary: #f1f5f9;
    --text-secondary: #a1a1aa;
    --text-muted: #52525b;
    --text-inverse: #09090b;

    /* Orange primary — WellPlayed brand */
    --primary-50: #fff7ed;
    --primary-100: #ffedd5;
    --primary-200: #fed7aa;
    --primary-300: #fdba74;
    --primary-400: #fb923c;
    --primary-500: #f97316;
    --primary-600: #ea580c;
    --primary-700: #c2410c;
    --primary-800: #9a3412;
    --primary-900: #7c2d12;

    /* Semantic aliases for orange */
    --accent-orange: var(--primary-600);
    --accent-orange-hover: var(--primary-700);
    --accent-orange-light: rgba(249, 115, 22, 0.10);

    /* Gold — kept for LoL rank/special accents */
    --gold-50: #fdf8e8;
    --gold-200: #e8d5a0;
    --gold-400: #c8aa6e;
    --gold-500: #b8952e;
    --gold-600: #9e7c1f;

    /* Accent — Emerald (success) */
    --accent-400: #34d399;
    --accent-500: #10b981;
    --accent-600: #059669;

    /* Semantic */
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-info: #3b82f6;

    /* Shadows — soft, light-theme appropriate */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.05), 0 8px 24px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.06), 0 16px 48px rgba(0, 0, 0, 0.06);
    --shadow-card:
        0 1px 3px rgba(0, 0, 0, 0.05),
        0 10px 40px rgba(0, 0, 0, 0.04);
    --shadow-card-hover:
        0 4px 12px rgba(0, 0, 0, 0.08),
        0 20px 56px rgba(0, 0, 0, 0.07);
    --shadow-glow-gold:
        0 0 0 1px rgba(200, 170, 110, 0.20),
        0 4px 16px rgba(200, 170, 110, 0.12);
    --shadow-glow-accent:
        0 0 0 1px rgba(16, 185, 129, 0.20),
        0 4px 16px rgba(16, 185, 129, 0.10);
    --shadow-orange-glow:
        0 2px 12px rgba(249, 115, 22, 0.25);

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    /* Spacing scale (4px base) */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;
    --sp-10: 40px;
    --sp-12: 48px;
    --sp-16: 64px;

    /* Typography */
    --font-sans: 'Geist', 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --gradient-cta: linear-gradient(to left, #dc2626, #ea580c);
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed: 64px;
    --header-height: 64px;
    --content-max-width: 1440px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms cubic-bezier(.4, 0, .2, 1);
}

/* --- Alpine cloak (hide until Alpine initializes) --- */
[x-cloak] {
    display: none !important;
}

.header-search-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

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

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    scroll-behavior: smooth;
}

/* --- Custom scrollbar — thin, orange thumb --- */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 999px;
    transition: background var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-500);
}

::-webkit-scrollbar-corner {
    background: transparent;
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

/* --- Text selection color — orange tint --- */
::selection {
    background: rgba(249, 115, 22, 0.18);
    color: var(--primary-800);
}

::-moz-selection {
    background: rgba(249, 115, 22, 0.18);
    color: var(--primary-800);
}

body {
    font-family: var(--font-sans);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    background-color: var(--bg-base);
}

/* --- Page fade-in on load --- */
@keyframes page-fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.main-content {
    animation: page-fade-in 320ms cubic-bezier(.4, 0, .2, 1) both;
}

/* --- Card stagger entrance --- */
@keyframes card-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card,
.stat-card {
    animation: card-in 0.4s cubic-bezier(.4, 0, .2, 1) both;
}

.card:nth-child(2),
.stat-card:nth-child(2) {
    animation-delay: 60ms;
}

.card:nth-child(3),
.stat-card:nth-child(3) {
    animation-delay: 120ms;
}

.card:nth-child(4),
.stat-card:nth-child(4) {
    animation-delay: 180ms;
}

.card:nth-child(5),
.stat-card:nth-child(5) {
    animation-delay: 240ms;
}

.card:nth-child(6),
.stat-card:nth-child(6) {
    animation-delay: 300ms;
}

a {
    color: var(--primary-600);
    text-decoration: none;
    text-decoration-color: transparent;
    transition: color var(--transition-fast), text-decoration-color var(--transition-fast);
}

a:hover {
    color: var(--primary-700);
    text-decoration: underline;
    text-decoration-color: rgba(234, 88, 12, 0.35);
}


/* ============================================================
   Layout: sidebar + header + main
   ============================================================ */

.layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: var(--header-height) 1fr;
    grid-template-areas:
        "sidebar header"
        "sidebar main";
    height: 100vh;
    transition: grid-template-columns var(--transition-base);
}

.layout.sidebar-collapsed {
    grid-template-columns: var(--sidebar-collapsed) 1fr;
}


/* --- Sidebar --- */

.sidebar {
    grid-area: sidebar;
    /* Deep orange gradient — WellPlayed brand identity */
    background: linear-gradient(180deg, var(--primary-600) 0%, var(--primary-700) 100%);
    border-right: none;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: visible;
    z-index: 40;
    transition: width var(--transition-base);
    box-shadow: 2px 0 12px rgba(194, 65, 12, 0.18);
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 var(--sp-5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    gap: var(--sp-3);
    flex-shrink: 0;
}

.sidebar-brand .logo {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    color: var(--primary-600);
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.sidebar-brand .brand-text {
    font-weight: 700;
    font-size: 15px;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--transition-fast), width var(--transition-base);
}

.sidebar-collapsed .brand-text {
    opacity: 0;
    width: 0;
}

/* Toggle button — circular, sits on sidebar right edge */
.sidebar-toggle {
    position: absolute;
    right: 0;
    top: 56px;
    /* aligned with brand bottom / header bottom */
    transform: translate(50%, -50%);
    z-index: 50;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #1a1a1f;
    border: 2px solid #2a2a32;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
    padding: 0;
}

.sidebar-toggle:hover {
    background: #2a2a32;
    color: #ffffff;
    border-color: #3a3a44;
}

.sidebar-toggle-icon {
    display: block;
    transition: transform 200ms ease;
}

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

.sidebar-nav {
    flex: 1;
    padding: var(--sp-4) var(--sp-2);
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-section {
    margin-top: var(--sp-6);
}

.nav-section:first-child {
    margin-top: 0;
}

.nav-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255, 255, 255, 0.50);
    padding: var(--sp-2) var(--sp-3) var(--sp-2);
    margin-bottom: var(--sp-1);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-collapsed .nav-section-title {
    font-size: 0;
    padding: var(--sp-2) 0;
    text-align: center;
    margin-bottom: 0;
}

.sidebar-collapsed .nav-section-title::after {
    content: '···';
    font-size: 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-md);
    color: rgba(255, 255, 255, 0.75);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
    position: relative;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    text-decoration: none;
}

.nav-item.active {
    /* White pill — active state */
    background: #ffffff;
    color: var(--primary-600);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.nav-item .icon {
    width: 20px;
    min-width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 14px;
    line-height: 1;
}

.nav-item .label {
    overflow: hidden;
    transition: opacity var(--transition-fast), width var(--transition-base);
}

.sidebar-collapsed .nav-item .label {
    display: none;
}

.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: var(--sp-2);
    gap: 0;
}

.sidebar-collapsed .nav-item.active {
    background: #ffffff;
    color: var(--primary-600);
}

/* Sidebar bottom area — slightly deeper orange */
.sidebar::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.12) 0%, transparent 100%);
    pointer-events: none;
}


/* --- Header --- */

.header {
    grid-area: header;
    background: #ffffff;
    border-bottom: none;
    box-shadow: 0 3px 0 var(--primary-500);
    display: flex;
    align-items: center;
    padding: 0 var(--sp-6);
    gap: var(--sp-4);
    position: sticky;
    top: 0;
    z-index: 30;
}

.header-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
    padding: var(--sp-2);
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), background var(--transition-fast);
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.header-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.header-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -.01em;
}

.header-spacer {
    flex: 1;
}

.header-search {
    display: flex;
    align-items: center;
    background: var(--bg-base);
    border: 1px solid var(--border-default);
    border-radius: 999px;
    padding: 0 var(--sp-3);
    gap: var(--sp-2);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.header-search:focus-within {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.12);
    background: var(--bg-hover);
}

.header-search input {
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 13px;
    padding: var(--sp-2) 0;
    width: 200px;
    font-family: var(--font-sans);
}

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

.header-search .icon {
    color: var(--text-muted);
    font-size: 14px;
}


/* --- Main content --- */

.main {
    grid-area: main;
    position: relative;
    padding: var(--sp-8) var(--sp-10);
    overflow: hidden;
    min-height: 0;
}

.main-content {
    max-width: var(--content-max-width);
    margin: 0;
    /* Aligned LEFT, not centered */
}


/* ============================================================
   Components
   ============================================================ */

/* --- Cards --- */

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: var(--sp-6);
    transition: box-shadow .2s, transform .2s, border-color .2s;
    box-shadow: var(--shadow-sm);
}

.card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-default);
}

/* ── Orange card variant ── */
.card-orange {
    background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
    border: none;
    color: #ffffff;
    box-shadow: 0 4px 16px rgba(234, 88, 12, 0.20), 0 12px 40px rgba(234, 88, 12, 0.10);
}

.card-orange:hover {
    box-shadow: 0 6px 24px rgba(234, 88, 12, 0.30), 0 16px 48px rgba(234, 88, 12, 0.15);
    transform: translateY(-3px);
}

.card-orange .card-title,
.card-orange .stat-value,
.card-orange .stat-label {
    color: #ffffff;
}

.card-orange .stat-label {
    opacity: 0.8;
}

/* ── Light orange tint card ── */
.card-orange-light {
    background: var(--primary-50);
    border-color: var(--primary-200);
}

.card-orange-light:hover {
    border-color: var(--primary-300);
    background: var(--primary-100);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-5);
    padding-bottom: var(--sp-4);
    border-bottom: 1px solid var(--border-subtle);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -.01em;
}

.card-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: var(--sp-1);
}

.card-body {}

.card-footer {
    margin-top: var(--sp-5);
    padding-top: var(--sp-4);
    border-top: 1px solid var(--border-subtle);
}


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

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--sp-4);
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-left: 4px solid var(--primary-500);
    border-radius: var(--radius-lg);
    padding: var(--sp-8);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 6px 24px rgba(0, 0, 0, 0.04);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

/* Subtle orange tint in top-right corner */
.stat-card::before {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 80px;
    height: 80px;
    background: radial-gradient(circle, rgba(249, 115, 22, 0.07) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

/* Clean bottom edge line */
.stat-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg,
            var(--primary-400),
            transparent 80%);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    opacity: 0;
    transition: opacity var(--transition-fast);
    pointer-events: none;
}

.stat-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.stat-card:hover::after {
    opacity: 1;
}

.stat-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: var(--sp-2);
}

.stat-value {
    font-size: 34px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    letter-spacing: -.03em;
}

.stat-trend {
    font-size: 12px;
    font-weight: 500;
    margin-top: var(--sp-2);
    display: flex;
    align-items: center;
    gap: var(--sp-1);
}

.stat-trend.up {
    color: var(--color-success);
}

.stat-trend.down {
    color: var(--color-danger);
}


/* --- Buttons --- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-4);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    user-select: none;
    text-decoration: none;
}

.btn:disabled,
.btn[disabled] {
    opacity: .40;
    cursor: not-allowed;
    pointer-events: none;
}

.btn:active {
    transform: scale(.965) translateY(1px);
    transition-duration: 60ms;
}

/* Size scale */
.btn-xs {
    padding: 2px var(--sp-2);
    font-size: 11px;
    border-radius: 6px;
}

.btn-sm {
    padding: var(--sp-1) var(--sp-3);
    font-size: 12px;
    border-radius: 10px;
}

/* .btn  = md (default) */
.btn-lg {
    padding: var(--sp-3) var(--sp-6);
    font-size: 14px;
    border-radius: 14px;
}

.btn-xl {
    padding: var(--sp-4) var(--sp-8);
    font-size: 15px;
    border-radius: 14px;
}

/* Icon-only square variant */
.btn-icon {
    padding: var(--sp-2);
    aspect-ratio: 1;
    gap: 0;
}

.btn-icon.btn-sm {
    padding: var(--sp-1);
}

.btn-icon.btn-lg {
    padding: var(--sp-3);
}

/* Primary — solid orange */
.btn-primary {
    background: var(--gradient-cta);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 2px 12px rgba(234, 88, 12, 0.25);
    outline: 1px solid rgba(251, 146, 60, 0.4);
    outline-offset: -1px;
}

.btn-primary:hover {
    box-shadow: 0 4px 20px rgba(234, 88, 12, 0.35), 0 0 0 1px rgba(251, 146, 60, 0.5);
    transform: translateY(-1px) scale(1.01);
    transform: translateY(-1px);
}

.btn-primary:active {
    background: var(--primary-700);
    box-shadow: none;
    transform: translateY(0);
}

/* Secondary */
.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-secondary);
    border-color: var(--border-default);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.btn-secondary:active {
    background: var(--bg-active);
    transform: translateY(0);
}

/* Gold */
.btn-gold {
    background: var(--gradient-cta);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 2px 12px rgba(234, 88, 12, 0.25);
    outline: 1px solid rgba(251, 146, 60, 0.4);
    outline-offset: -1px;
}

.btn-gold:hover {
    background: var(--gold-500);
    border-color: var(--gold-500);
    box-shadow: 0 4px 16px rgba(200, 170, 110, 0.40);
    transform: translateY(-1px);
}

.btn-gold:active {
    background: var(--gold-600);
    transform: translateY(0);
}

/* Ghost */
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.btn-ghost:active {
    background: var(--bg-active);
    transform: translateY(0);
}

/* Danger */
.btn-danger {
    background: transparent;
    color: var(--color-danger);
    border-color: rgba(239, 68, 68, 0.30);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.08);
    border-color: var(--color-danger);
    transform: translateY(-1px);
}

.btn-danger:active {
    background: rgba(239, 68, 68, 0.15);
    transform: translateY(0);
}


/* --- Badges --- */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
    letter-spacing: .02em;
    line-height: 1.5;
    white-space: nowrap;
}

.badge-sm {
    padding: 2px 8px;
    font-size: 11px;
}

.badge-lg {
    padding: 4px 12px;
    font-size: 13px;
}

.badge-success {
    background: rgba(16, 185, 129, 0.12);
    color: var(--color-success);
    animation: badge-success-pulse 2s ease-out 0.5s 1 both;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.12);
    color: var(--color-warning);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.12);
    color: var(--color-danger);
}

.badge-info {
    background: rgba(59, 130, 246, 0.12);
    color: var(--color-info);
}

.badge-gold {
    background: rgba(200, 170, 110, 0.15);
    color: var(--gold-500);
}

.badge-neutral {
    background: var(--bg-base);
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
}

@keyframes badge-success-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.40);
    }

    60% {
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}


/* --- Tables --- */

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-surface);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead {
    background: var(--bg-surface);
    position: sticky;
    top: 0;
    z-index: 1;
}

th {
    text-align: left;
    padding: var(--sp-3) var(--sp-5);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-default);
    white-space: nowrap;
}

td {
    padding: var(--sp-3) var(--sp-5);
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

/* Light orange hover on rows */
tbody tr {
    transition: background var(--transition-fast);
    position: relative;
}

tbody tr:hover {
    background: rgba(249, 115, 22, 0.04) !important;
}

tbody tr:hover td {
    color: var(--text-primary);
}

tbody tr:hover td:first-child {
    box-shadow: inset 3px 0 0 var(--primary-500);
}


/* --- Forms --- */

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.form-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: .02em;
    text-transform: uppercase;
}

.form-input,
.form-select,
.form-textarea {
    background: var(--bg-base);
    border: 1px solid var(--border-default);
    border-radius: 10px;
    padding: var(--sp-2) var(--sp-3);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    outline: none;
    transition: border-color var(--transition-fast),
        box-shadow var(--transition-fast);
    width: 100%;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.12);
}

.form-input:hover:not(:focus),
.form-select:hover:not(:focus),
.form-textarea:hover:not(:focus) {
    border-color: var(--border-strong);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2394a3b8' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--sp-3) center;
    padding-right: var(--sp-8);
    cursor: pointer;
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}

.form-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.form-error {
    font-size: 11px;
    color: var(--color-danger);
    margin-top: 2px;
}

/* Smooth focus transitions on all interactive elements */
button,
input,
select,
textarea,
a,
[tabindex] {
    transition-property: color, background-color, border-color, box-shadow, outline, transform, opacity;
    transition-duration: var(--transition-fast);
    transition-timing-function: ease;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
    outline: 2px solid rgba(249, 115, 22, 0.50);
    outline-offset: 2px;
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}


/* --- Toast (HTMX feedback) --- */

.toast-container {
    position: fixed;
    bottom: var(--sp-6);
    right: var(--sp-6);
    z-index: 300;
    display: flex;
    flex-direction: column-reverse;
    gap: var(--sp-3);
    pointer-events: none;
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-left: 4px solid var(--primary-500);
    border-radius: var(--radius-md);
    padding: var(--sp-3) var(--sp-5);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    animation: toast-slide-in .3s cubic-bezier(.34, 1.56, .64, 1);
    min-width: 260px;
    max-width: 380px;
    pointer-events: auto;
}

.toast.success {
    border-left-color: var(--color-success);
}

.toast.error {
    border-left-color: var(--color-danger);
}

.toast.warning {
    border-left-color: var(--color-warning);
}

.toast.info {
    border-left-color: var(--color-info);
}

@keyframes toast-slide-in {
    from {
        opacity: 0;
        transform: translateX(24px) scale(.95);
    }

    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}


/* --- Page-level helpers --- */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: var(--sp-8);
    padding-bottom: var(--sp-5);
    border-bottom: 1px solid var(--border-default);
    gap: var(--sp-4);
}

.page-header-left {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}

.page-title {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -.03em;
    line-height: 1.15;
    /* Subtle orange gradient */
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--primary-500) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-description {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: var(--sp-1);
    line-height: 1.5;
}

.section-gap {
    margin-top: var(--sp-8);
}

.section-gap-lg {
    margin-top: var(--sp-12);
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-4);
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-4);
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--sp-4);
}

/* Named grid-cols utilities (use with display:grid) */
.grid-cols-1 {
    grid-template-columns: repeat(1, 1fr);
}

.grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Gap utilities */
.gap-1 {
    gap: var(--sp-1);
}

.gap-2 {
    gap: var(--sp-2);
}

.gap-3 {
    gap: var(--sp-3);
}

.gap-4 {
    gap: var(--sp-4);
}

.gap-6 {
    gap: var(--sp-6);
}

.gap-8 {
    gap: var(--sp-8);
}

/* Color utilities */
.text-gold {
    color: var(--gold-600);
}

.text-gold-2 {
    color: var(--gold-500);
}

.text-accent {
    color: var(--accent-500);
}

.text-success {
    color: var(--color-success);
}

.text-warning {
    color: var(--color-warning);
}

.text-danger {
    color: var(--color-danger);
}

.text-info {
    color: var(--color-info);
}

/* Flex utilities */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.flex-wrap {
    flex-wrap: wrap;
}

.items-center {
    align-items: center;
}

.items-start {
    align-items: flex-start;
}

.justify-between {
    justify-content: space-between;
}

.justify-end {
    justify-content: flex-end;
}

.flex-1 {
    flex: 1;
}

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

/* Spacing utilities */
.mt-1 {
    margin-top: var(--sp-1);
}

.mt-2 {
    margin-top: var(--sp-2);
}

.mt-3 {
    margin-top: var(--sp-3);
}

.mt-4 {
    margin-top: var(--sp-4);
}

.mt-6 {
    margin-top: var(--sp-6);
}

.mt-8 {
    margin-top: var(--sp-8);
}

.mb-2 {
    margin-bottom: var(--sp-2);
}

.mb-4 {
    margin-bottom: var(--sp-4);
}

.mb-6 {
    margin-bottom: var(--sp-6);
}


/* --- Modal --- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.40);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fade-in var(--transition-fast);
}

.modal {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: modal-in var(--transition-base);
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--sp-2);
}

.modal-description {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: var(--sp-6);
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    gap: var(--sp-3);
    justify-content: flex-end;
    margin-top: var(--sp-6);
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: scale(.96) translateY(-8px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}


/* --- Code / monospace --- */

code,
.code {
    font-family: var(--font-mono);
    font-size: .9em;
    background: var(--primary-50);
    border: 1px solid var(--primary-100);
    border-radius: var(--radius-sm);
    padding: 1px 6px;
    color: var(--primary-700);
}

pre {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: var(--sp-4);
    overflow-x: auto;
    line-height: 1.6;
    color: var(--text-secondary);
}


/* --- Dividers --- */

hr,
.divider {
    border: none;
    border-top: 1px solid var(--border-default);
    margin: var(--sp-4) 0;
}


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

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--sp-16) var(--sp-8);
    text-align: center;
    color: var(--text-muted);
    gap: var(--sp-3);
    border: 2px dashed var(--border-default);
    border-radius: var(--radius-lg);
    animation: empty-border-pulse 3s ease-in-out infinite;
}

@keyframes empty-border-pulse {

    0%,
    100% {
        border-color: var(--border-default);
    }

    50% {
        border-color: var(--primary-200);
    }
}

.empty-state .empty-icon {
    font-size: 40px;
    opacity: .35;
}

.empty-state .empty-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
}

.empty-state .empty-description {
    font-size: 13px;
    max-width: 320px;
    line-height: 1.6;
}


/* --- HTMX loading indicator --- */

.htmx-indicator {
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    opacity: 1;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(249, 115, 22, 0.15);
    border-top-color: var(--primary-500);
    border-right-color: rgba(249, 115, 22, 0.40);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    flex-shrink: 0;
}

.spinner-sm {
    width: 12px;
    height: 12px;
}

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

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


/* --- Responsive --- */

@media (max-width: 1024px) {
    .layout {
        grid-template-columns: var(--sidebar-collapsed) 1fr;
    }

    .sidebar .brand-text,
    .sidebar .nav-item .label,
    .sidebar .nav-section-title {
        opacity: 0;
        width: 0;
    }

    .sidebar .nav-item {
        justify-content: center;
        padding: var(--sp-2);
    }

    .sidebar .nav-item.active {
        background: #ffffff;
        color: var(--primary-600);
    }

    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .layout {
        grid-template-columns: 1fr;
        grid-template-areas: "header" "main";
    }

    .sidebar {
        display: none;
    }

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .header-search input {
        width: 140px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .toast-container {
        left: var(--sp-4);
        right: var(--sp-4);
        bottom: var(--sp-4);
    }

    .toast {
        min-width: 0;
        max-width: 100%;
    }
}

@media (min-width: 1800px) {
    :root {
        --content-max-width: 1600px;
    }
}
/* Palantir: fix scroll */
.main { overflow-y: auto !important; overflow-x: hidden !important; }
