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

:root {
    --navy:       #2d3250;
    --navy-dark:  #1e2238;
    --navy-mid:   #3a4068;
    --purple:     #6c66d5;
    --purple-light: #857fd9;
    --purple-dim: rgba(108,102,213,0.12);
    --text:       #1a1d2e;
    --text-muted: #6b7280;
    --text-light: #9ca3af;
    --border:     #e5e7eb;
    --bg:         #f6f7fb;
    --bg-card:    #ffffff;
    --success:    #10b981;
    --success-bg: #ecfdf5;
    --error:      #ef4444;
    --error-bg:   #fef2f2;
    --warning:    #f59e0b;
    --sidebar-w:  240px;
    --radius:     8px;
    --shadow:     0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:  0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg:  0 10px 15px rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.04);
}

html { font-size: 15px; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── App Layout ───────────────────────────────────────────── */
.app-body {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--navy);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}

/* Brand / logo block */
.sidebar-brand {
    padding: 28px 24px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}

.sidebar-logo-img {
    display: block;
    width: 100%;
    height: auto;
    max-width: 168px;
    object-fit: contain;
}

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: 16px 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    color: rgba(255,255,255,0.55);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: 7px;
    transition: color 0.15s, background 0.15s;
    letter-spacing: 0.01em;
}

.nav-item:hover {
    color: rgba(255,255,255,0.9);
    background: rgba(255,255,255,0.06);
}

.nav-item.active {
    color: #fff;
    background: rgba(108,102,213,0.75);
}

.nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.85;
}

.nav-item.active .nav-icon { opacity: 1; }
.nav-icon svg { display: block; }
.nav-label { flex: 1; }

/* Footer */
.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.07);
    padding: 12px 10px 10px;
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 10px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--purple);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    letter-spacing: 0;
}

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

.user-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.user-company {
    font-size: 0.6875rem;
    color: rgba(255,255,255,0.38);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
    margin-top: 1px;
}

.nav-logout { color: rgba(255,255,255,0.38); }
.nav-logout:hover { color: rgba(255,255,255,0.65); background: rgba(255,255,255,0.04); }

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    padding: 32px;
    min-width: 0;
}

/* ── Page Header ──────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.page-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-header {
    padding: 18px 24px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text);
}

.card-body { padding: 24px; }

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1;
}

.stat-value.purple { color: var(--purple); }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
}

table.amc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.amc-table th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.amc-table td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

.amc-table tbody tr:hover { background: var(--bg); }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-green  { background: #d1fae5; color: #065f46; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-gray   { background: #f3f4f6; color: #374151; }
.badge-purple { background: var(--purple-dim); color: var(--purple); }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
    white-space: nowrap;
    line-height: 1;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--purple);
    color: #fff;
    border-color: var(--purple);
}
.btn-primary:hover { background: var(--purple-light); border-color: var(--purple-light); }

.btn-secondary {
    background: var(--bg-card);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg); }

.btn-danger {
    background: var(--bg-card);
    color: var(--error);
    border-color: var(--border);
}
.btn-danger:hover { background: var(--error-bg); border-color: var(--error); }

.btn-sm { padding: 5px 12px; font-size: 0.8125rem; }

.btn-icon {
    padding: 6px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    transition: background 0.15s, color 0.15s;
}
.btn-icon:hover { background: var(--bg); color: var(--text); border-color: var(--border); }

/* ── Forms ────────────────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.span-2 { grid-column: span 2; }

label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text);
    background: var(--bg-card);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.form-control:focus {
    border-color: var(--purple);
    box-shadow: 0 0 0 3px var(--purple-dim);
}

.form-control::placeholder { color: var(--text-light); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

/* ── Checkboxes ───────────────────────────────────────────── */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.875rem;
}

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

/* ── Module Permission Grid ───────────────────────────────── */
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}

.module-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    user-select: none;
}

.module-toggle:hover { border-color: var(--purple); background: var(--purple-dim); }

.module-toggle input[type="checkbox"] {
    accent-color: var(--purple);
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    cursor: pointer;
}

.module-toggle-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text);
}

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success { background: var(--success-bg); color: #065f46; border: 1px solid #a7f3d0; }
.alert-error   { background: var(--error-bg);   color: #991b1b; border: 1px solid #fecaca; }
.alert-info    { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.empty-state p { font-size: 0.875rem; }

/* ── Dashboard Welcome ────────────────────────────────────── */
.welcome-banner {
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
    border-radius: 12px;
    padding: 32px;
    color: #fff;
    margin-bottom: 28px;
    position: relative;
    overflow: hidden;
}

.welcome-banner::before {
    content: '';
    position: absolute;
    top: -40px;
    right: -40px;
    width: 200px;
    height: 200px;
    background: rgba(108,102,213,0.2);
    border-radius: 50%;
}

.welcome-banner::after {
    content: '';
    position: absolute;
    bottom: -60px;
    right: 60px;
    width: 150px;
    height: 150px;
    background: rgba(108,102,213,0.1);
    border-radius: 50%;
}

.welcome-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
    position: relative;
    z-index: 1;
}

.welcome-sub {
    font-size: 0.9375rem;
    color: rgba(255,255,255,0.7);
    position: relative;
    z-index: 1;
}

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

.module-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: box-shadow 0.15s, border-color 0.15s, transform 0.15s;
    box-shadow: var(--shadow);
}

.module-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--purple);
    transform: translateY(-1px);
}

.module-card-icon {
    width: 40px;
    height: 40px;
    background: var(--purple-dim);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
}

.module-card-name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text);
}

.module-card-desc {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* ── Login Page ───────────────────────────────────────────── */
#bg-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.login-body {
    background: #000;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
}

.login-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.login-card {
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35), 0 1px 0 rgba(255,255,255,0.1) inset;
    border: 1px solid rgba(255,255,255,0.12);
    padding: 40px;
    width: 100%;
}

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

.login-logo img {
    max-width: 200px;
    height: auto;
}

.login-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.login-sub {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.login-footer {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.3);
}

/* ── Search / Filter Bar ──────────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text);
    background: var(--bg-card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 10px center;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input:focus {
    border-color: var(--purple);
    box-shadow: 0 0 0 3px var(--purple-dim);
}

/* ── Misc helpers ─────────────────────────────────────────── */
.text-muted   { color: var(--text-muted); }
.text-sm      { font-size: 0.8125rem; }
.fw-600       { font-weight: 600; }
.mb-0         { margin-bottom: 0; }
.mt-4         { margin-top: 16px; }
.mt-6         { margin-top: 24px; }
.flex         { display: flex; }
.items-center { align-items: center; }
.gap-2        { gap: 8px; }
.gap-3        { gap: 12px; }

/* ── Divider ──────────────────────────────────────────────── */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}

/* ── Password Strength ────────────────────────────────────── */
.pw-strength {
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    margin-top: 6px;
    overflow: hidden;
}

.pw-strength-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s, background 0.3s;
}
