/* ENTERPRISE CORE THEME */
:root {
    /* Colors */
    --c-bg: #0f172a;
    /* Slate 900 */
    --c-surface: #1e293b;
    /* Slate 800 */
    --c-surface-hover: #334155;
    --c-border: #334155;

    --c-txt-main: #f8fafc;
    --c-txt-sec: #94a3b8;
    --c-txt-dim: #64748b;

    --c-crm: #3b82f6;
    /* Blue */
    --c-hr: #8b5cf6;
    /* Purple */
    --c-inv: #10b981;
    /* Emerald */
    --c-danger: #ef4444;
    --c-warn: #f59e0b;

    /* Spacing */
    --sp-xs: 4px;
    --sp-sm: 8px;
    --sp-md: 16px;
    --sp-lg: 24px;
    --sp-xl: 32px;

    /* Components */
    --h-header: 60px;
    --w-sidebar: 260px;
    --r-std: 6px;
}

/* RESET */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    outline: none;
    font-family: 'Inter', sans-serif;
}

html {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

body {
    background: var(--c-bg);
    color: var(--c-txt-main);
    height: 100vh;
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    -webkit-font-smoothing: antialiased;
}

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

/* LAYOUT */
#app-root {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    display: flex;
    position: relative;
    overflow: hidden;
}

/* UTILS */
.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

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

.auth-center {
    align-items: center;
    justify-content: center;
}

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

.w-full {
    width: 100%;
}

.text-sec {
    color: var(--c-txt-sec);
}

.text-sm {
    font-size: 0.85rem;
}

/* COMPONENTS: BUTTONS */
.btn {
    padding: 8px 16px;
    border-radius: var(--r-std);
    border: 1px solid var(--c-border);
    background: var(--c-surface);
    color: var(--c-txt-main);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    background: var(--c-surface-hover);
}

.btn-primary {
    background: var(--theme-color, --c-crm);
    border-color: transparent;
    color: white;
}

.btn-primary:hover {
    opacity: 0.9;
}

/* COMPONENTS: TABLES */
.mobile-scroll-table {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: block;
}

.data-grid {
    width: 100%;
    min-width: 560px;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-grid th {
    text-align: left;
    padding: 12px 16px;
    color: var(--c-txt-sec);
    border-bottom: 1px solid var(--c-border);
    background: rgba(255, 255, 255, 0.02);
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
    white-space: nowrap;
}

.data-grid td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--c-border);
    color: var(--c-txt-main);
}

.data-grid tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* COMPONENTS: BADGES */
.badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.badge-blue {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.badge-green {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.badge-red {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.badge-gray {
    background: rgba(148, 163, 184, 0.15);
    color: #cbd5e1;
}

/* Login box (shell pages) */
.login-box {
    width: 100%;
    max-width: 300px;
    padding: 0 20px;
}

/* VIEW: HUB */
.hub-container {
    background: radial-gradient(circle at top, #1e293b 0%, #0f172a 100%);
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow-y: auto;
    overflow-x: hidden;
    padding: clamp(16px, 4vw, 60px);
    padding-top: clamp(20px, 5vw, 40px);
    min-width: 0;
}

.hub-title {
    font-size: clamp(1.5rem, 5vw, 2rem);
    font-weight: 700;
    margin-bottom: clamp(30px, 6vw, 50px);
    letter-spacing: -1px;
    word-break: break-word;
    text-align: center;
}

.hub-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(16px, 4vw, 30px);
    max-width: 1000px;
    width: 100%;
    min-width: 0;
}

.hub-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    padding: clamp(24px, 5vw, 40px);
    text-align: center;
    cursor: pointer;
    transition: 0.3s;
    min-width: 0;
    min-height: 44px;
}

.hub-card:hover {
    transform: translateY(-5px);
    border-color: var(--c-txt-sec);
}

.hub-icon {
    font-size: clamp(2rem, 5vw, 2.5rem);
    margin-bottom: clamp(12px, 2vw, 20px);
    color: var(--c-txt-sec);
}

.hub-card:hover .hub-icon {
    color: white;
}

/* Hub: Trust strip */
.hub-trust {
    margin-top: clamp(40px, 8vw, 60px);
    padding-top: clamp(30px, 6vw, 50px);
    border-top: 1px solid var(--c-border);
    width: 100%;
    max-width: 1000px;
}

.hub-trust-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
    gap: clamp(12px, 3vw, 20px);
    text-align: center;
}

.hub-trust-item {
    padding: clamp(16px, 3vw, 24px);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--c-border);
    border-radius: 8px;
    transition: 0.2s;
}

.hub-trust-item:hover {
    border-color: var(--c-txt-sec);
}

.hub-trust-item strong {
    display: block;
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    color: var(--c-txt-main);
    margin-bottom: 4px;
}

.hub-trust-item span {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--c-txt-dim);
}

/* Hub: FAQ */
.hub-faq {
    margin-top: clamp(40px, 8vw, 60px);
    width: 100%;
    max-width: 640px;
}

.hub-faq h3 {
    font-size: clamp(0.9rem, 2vw, 1rem);
    font-weight: 600;
    color: var(--c-txt-sec);
    margin-bottom: clamp(20px, 4vw, 28px);
}

.hub-faq-list {
    list-style: none;
}

.hub-faq-item {
    border-bottom: 1px solid var(--c-border);
    padding: clamp(14px, 3vw, 18px) 0;
}

.hub-faq-item summary {
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--c-txt-main);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    list-style: none;
}

.hub-faq-item summary::-webkit-details-marker {
    display: none;
}

.hub-faq-item summary::after {
    content: '+';
    font-size: 1.1rem;
    color: var(--c-txt-dim);
    flex-shrink: 0;
}

.hub-faq-item details[open] summary::after {
    content: '−';
}

.hub-faq-item .hub-faq-answer {
    padding-top: 10px;
    font-size: 0.85rem;
    color: var(--c-txt-sec);
    line-height: 1.6;
}

/* Hub: Header (back link + title) */
.hub-header {
    width: 100%;
    max-width: 1000px;
    margin-bottom: clamp(24px, 5vw, 40px);
}

.hub-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: clamp(0.75rem, 2vw, 0.85rem);
    color: var(--c-txt-dim);
    margin-bottom: clamp(12px, 3vw, 20px);
    transition: color 0.2s;
}

.hub-back:hover {
    color: var(--c-txt-main);
}

.hub-header .hub-title {
    margin-bottom: 0;
}

/* VIEW: SHELL */
.shell {
    display: flex;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.sidebar {
    width: var(--w-sidebar);
    background: var(--c-bg);
    /* Darker than body */
    border-right: 1px solid var(--c-border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    height: var(--h-header);
    min-height: 56px;
    display: flex;
    align-items: center;
    padding: 0 clamp(12px, 3vw, 20px);
    border-bottom: 1px solid var(--c-border);
    font-weight: 700;
    gap: 10px;
}

.nav-list {
    flex: 1;
    padding: 20px 10px;
    overflow-y: auto;
}

.nav-item {
    padding: 12px 14px;
    min-height: 44px;
    margin-bottom: 4px;
    border-radius: 6px;
    color: var(--c-txt-sec);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    -webkit-tap-highlight-color: transparent;
}

.nav-item:hover {
    background: var(--c-surface);
    color: white;
}

.nav-item.active {
    background: var(--theme-color-bg, rgba(255, 255, 255, 0.1));
    color: var(--theme-color, white);
}

.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--c-bg);
    overflow: hidden;
}

.top-bar {
    height: var(--h-header);
    min-height: 56px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--c-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 clamp(12px, 3vw, 30px);
    background: var(--c-bg);
    flex-wrap: wrap;
    gap: 8px;
}

.top-bar-left {
    min-width: 0;
    flex: 1;
}

.top-bar-title {
    font-size: clamp(0.95rem, 2.5vw, 1.2rem);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.top-bar-search {
    width: 200px;
    max-width: 100%;
}

.workspace {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: clamp(12px, 3vw, 30px);
    -webkit-overflow-scrolling: touch;
}

/* RESPONSIVE */
.mobile-toggle {
    display: none;
    margin-right: 15px;
    cursor: pointer;
}

/* RESPONSIVE UTILS */
.grid-responsive-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.grid-responsive-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.grid-responsive-dashboard {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
}

.mobile-scroll-table {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

    .grid-responsive-dashboard {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .grid-responsive-4 {
        grid-template-columns: 1fr;
    }

    .grid-responsive-2 {
        grid-template-columns: 1fr;
    }
}

/* Sidebar overlay when open on mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
    opacity: 0;
    transition: opacity 0.3s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}

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

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        height: 100vh;
        width: min(280px, 85vw);
        transform: translateX(-100%);
        transition: transform 0.3s;
        z-index: 2000;
        border-right: 1px solid var(--c-border);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        padding: 0;
    }

    .top-bar-search {
        max-width: 140px;
    }
}

@media (max-width: 600px) {
    .top-bar {
        padding: 8px clamp(12px, 3vw, 20px);
    }

    .top-bar-right {
        flex-wrap: wrap;
    }

    .data-grid th,
    .data-grid td {
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    .data-grid {
        min-width: 500px;
    }
}

@media (max-width: 480px) {
    .hub-container {
        justify-content: flex-start;
    }

    .hub-header {
        text-align: center;
    }

    .hub-title {
        text-align: center;
    }

    .hub-grid {
        width: 100%;
    }

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

    .top-bar-search {
        display: none !important;
    }

    .top-bar .btn {
        padding: 6px 10px;
        font-size: 0.65rem;
    }

    .sidebar-header,
    .nav-list {
        padding: 12px;
    }

    .workspace {
        padding: 12px;
    }
}

@media (max-width: 360px) {
    .hub-container {
        padding: 12px;
    }

    .hub-title {
        font-size: 1.35rem;
    }

    .hub-card h3 {
        font-size: 1rem;
    }

    .hub-trust-item strong {
        font-size: 0.95rem;
    }

    .data-grid {
        min-width: 440px;
    }

    .data-grid th,
    .data-grid td {
        padding: 8px 10px;
        font-size: 0.8rem;
    }
}