/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    color: #1e2329;
    background: #f5f6f8;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
.cortex-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Navigation ──────────────────────────────────────────────────────────── */
.cortex-nav {
    width: 240px;
    min-width: 240px;
    background: #1a1f2e;
    color: #a8b2c4;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.cortex-nav-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.cortex-nav-brand {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: #fff;
    text-decoration: none;
}

.cortex-nav-items {
    list-style: none;
    margin: 0;
    padding: 12px 0;
}

.cortex-nav-section-label {
    padding: 16px 20px 4px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #5a6478;
}

.cortex-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: #8a95a8;
    text-decoration: none;
    transition: color 0.15s, background 0.15s;
    font-size: 13.5px;
}

.cortex-nav-link:hover {
    color: #e0e6f0;
    background: rgba(255,255,255,0.05);
}

.cortex-nav-link.active {
    color: #6c8aff;
    background: rgba(108, 138, 255, 0.1);
}

.cortex-nav-icon {
    font-size: 11px;
    width: 16px;
    text-align: center;
    opacity: 0.6;
}

/* ── Main ────────────────────────────────────────────────────────────────── */
.cortex-main {
    flex: 1;
    margin-left: 240px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Topbar ──────────────────────────────────────────────────────────────── */
.cortex-topbar {
    height: 56px;
    background: #fff;
    border-bottom: 1px solid #e8eaed;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.cortex-topbar-brand {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.cortex-logo {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #1a1f2e;
}

.cortex-tagline {
    font-size: 12px;
    color: #8a95a8;
}

.cortex-topbar-user {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13px;
    color: #5a6478;
}

.cortex-topbar-user span {
    font-weight: 500;
}

/* ── Content ─────────────────────────────────────────────────────────────── */
.cortex-content {
    flex: 1;
    padding: 28px;
}

/* ── Error ───────────────────────────────────────────────────────────────── */
.cortex-error {
    background: #fff0f0;
    border: 1px solid #ffa8a8;
    border-radius: 6px;
    padding: 16px;
    color: #c0392b;
}

/* ── Page header ─────────────────────────────────────────────────────────── */
.cortex-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.cortex-page-header h1 {
    font-size: 22px;
    font-weight: 600;
    color: #1e2329;
    margin: 0;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.cortex-card {
    background: #fff;
    border: 1px solid #e8eaed;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 20px;
}

/* ── Dashboard ───────────────────────────────────────────────────────────── */
.cortex-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.cortex-stat-card {
    background: #fff;
    border: 1px solid #e8eaed;
    border-radius: 8px;
    padding: 20px;
}

.cortex-stat-label {
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}

.cortex-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #1e2329;
    line-height: 1;
}

.cortex-section h2 {
    font-size: 16px;
    font-weight: 600;
    color: #1e2329;
    margin-bottom: 12px;
}

/* ── Tables ──────────────────────────────────────────────────────────────── */
.cortex-table-wrapper {
    background: #fff;
    border: 1px solid #e8eaed;
    border-radius: 8px;
    overflow: hidden;
}

.cortex-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.cortex-table thead {
    background: #f9fafb;
}

.cortex-table th {
    padding: 10px 16px;
    text-align: left;
    font-size: 11.5px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid #e8eaed;
}

.cortex-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f2f5;
    color: #374151;
    vertical-align: middle;
}

.cortex-table tr:last-child td { border-bottom: none; }
.cortex-table tr:hover td { background: #f9fafb; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.cortex-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.cortex-badge-success  { background: #d1fae5; color: #065f46; }
.cortex-badge-muted    { background: #f3f4f6; color: #6b7280; }
.cortex-badge-info     { background: #dbeafe; color: #1e40af; }
.cortex-badge-warning  { background: #fffbeb; color: #92400e; }
.cortex-badge-danger   { background: #fef2f2; color: #b91c1c; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.cortex-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
    line-height: 1.4;
}

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

.cortex-btn-primary { background: #3b5bdb; color: #fff; border-color: #3b5bdb; }
.cortex-btn-primary:hover:not(:disabled) { background: #2f4ec7; border-color: #2f4ec7; }

.cortex-btn-outline { background: transparent; color: #374151; border-color: #d1d5db; }
.cortex-btn-outline:hover:not(:disabled) { background: #f9fafb; }

.cortex-btn-danger { background: transparent; color: #dc2626; border-color: #fca5a5; }
.cortex-btn-danger:hover:not(:disabled) { background: #fef2f2; }

.cortex-btn-sm { padding: 4px 10px; font-size: 12px; }
.cortex-btn-full { width: 100%; }

.cortex-btn-link {
    background: none;
    border: none;
    color: #3b5bdb;
    padding: 0;
    font-size: inherit;
    cursor: pointer;
    text-decoration: none;
}

.cortex-btn-link:hover { text-decoration: underline; color: #2f4ec7; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.cortex-form-group { margin-bottom: 16px; }

.cortex-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 5px;
}

.cortex-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    color: #1e2329;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.cortex-input:focus {
    border-color: #3b5bdb;
    box-shadow: 0 0 0 3px rgba(59, 91, 219, 0.12);
}

.cortex-validation { font-size: 12px; color: #dc2626; margin-top: 4px; display: block; }

.cortex-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.cortex-alert {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13.5px;
    margin-bottom: 16px;
}

.cortex-alert-error   { background: #fef2f2; border: 1px solid #fca5a5; color: #b91c1c; }
.cortex-alert-success { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }
.cortex-alert-warning { background: #fffbeb; border: 1px solid #fcd34d; color: #92400e; }

/* ── Login ───────────────────────────────────────────────────────────────── */
.cortex-login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f6f8;
    padding: 24px;
}

.cortex-login-card {
    background: #fff;
    border: 1px solid #e8eaed;
    border-radius: 12px;
    padding: 36px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}

.cortex-login-header {
    text-align: center;
    margin-bottom: 28px;
}

.cortex-login-logo {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: #1a1f2e;
    margin: 0 0 6px;
}

.cortex-login-subtitle {
    font-size: 13px;
    color: #8a95a8;
    margin: 0;
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.cortex-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.cortex-modal {
    background: #fff;
    border-radius: 10px;
    padding: 28px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
}

.cortex-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.cortex-modal-header h2 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: #1e2329;
}

.cortex-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid #f0f2f5;
}

/* ── Settings ────────────────────────────────────────────────────────────── */
.cortex-settings-section { margin-bottom: 32px; }

.cortex-settings-section h2 {
    font-size: 15px;
    font-weight: 600;
    color: #1e2329;
    margin: 0 0 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f2f5;
}

.cortex-settings-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #f9fafb;
}

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

.cortex-settings-label { font-size: 13.5px; font-weight: 500; color: #374151; }
.cortex-settings-value { font-size: 13px; color: #6b7280; text-align: right; }

/* ── Utility ─────────────────────────────────────────────────────────────── */
.text-muted   { color: #8a95a8; }
.text-danger  { color: #dc2626; }
.text-success { color: #059669; }
.text-sm      { font-size: 12px; }

.cortex-empty {
    padding: 40px 20px;
    text-align: center;
    color: #8a95a8;
    font-size: 14px;
}

.cortex-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #8a95a8;
}
