:root {
    --color-bg: #f4f5f7;
    --color-surface: #ffffff;
    --color-border: #e4e6ea;
    --color-sidebar: #14181f;
    --color-sidebar-hover: #1e242e;
    --color-sidebar-text: #9aa2b1;
    --color-sidebar-text-active: #ffffff;
    --color-primary: #3b5bdb;
    --color-primary-hover: #3151c9;
    --color-text: #1f2430;
    --color-text-muted: #6b7280;
    --color-danger: #e03131;
    --color-blue: #3b5bdb;
    --color-green: #2f9e44;
    --color-amber: #e8890c;
    --color-red: #e03131;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(16, 20, 30, 0.06);
    --shadow-md: 0 4px 16px rgba(16, 20, 30, 0.08);
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    font-size: 13px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}

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

button {
    font-family: inherit;
}

/* ===== Admin shell ===== */

.admin-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 232px;
    flex-shrink: 0;
    background: var(--color-sidebar);
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    margin-bottom: 14px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: var(--color-primary);
    color: #fff;
    font-size: 14px;
}

.brand-text {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.2px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--color-sidebar-text);
    font-size: 12.5px;
    font-weight: 500;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-item i {
    font-size: 14px;
    width: 16px;
    text-align: center;
}

.nav-item:hover {
    background: var(--color-sidebar-hover);
    color: var(--color-sidebar-text-active);
}

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

.module-switch-link {
    margin-bottom: 12px;
    border: 1px dashed rgba(255, 255, 255, 0.12);
}

.nav-section-label {
    margin-top: 18px;
    padding: 0 10px 6px;
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #565e6c;
}

.nav-placeholder {
    padding: 8px 10px;
    font-size: 12px;
    color: #565e6c;
    font-style: italic;
}

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: 56px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.topbar-title {
    font-size: 14px;
    font-weight: 600;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 14px;
}

.user-name {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--color-text-muted);
}

.logout-form {
    margin: 0;
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-muted);
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-logout:hover {
    color: var(--color-danger);
    border-color: var(--color-danger);
    background: rgba(224, 49, 49, 0.05);
}

.content-area {
    flex: 1;
    padding: 24px;
}

/* ===== Page header ===== */

.page-header {
    margin-bottom: 20px;
}

.page-header h1 {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 4px;
}

.page-header p {
    font-size: 12.5px;
    color: var(--color-text-muted);
    margin: 0;
}

/* ===== Stat cards ===== */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 14px;
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    font-size: 16px;
    flex-shrink: 0;
}

.stat-icon-blue { background: rgba(59, 91, 219, 0.1); color: var(--color-blue); }
.stat-icon-green { background: rgba(47, 158, 68, 0.1); color: var(--color-green); }
.stat-icon-amber { background: rgba(232, 137, 12, 0.1); color: var(--color-amber); }
.stat-icon-red { background: rgba(224, 49, 49, 0.1); color: var(--color-red); }

.stat-body {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 11.5px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* ===== Card ===== */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

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

.card-header h2 {
    font-size: 13.5px;
    font-weight: 600;
    margin: 0;
}

.card-body {
    padding: 16px;
}

.muted-text {
    font-size: 12.5px;
    color: var(--color-text-muted);
    margin: 0;
}

/* ===== Login page ===== */

.login-body {
    background: linear-gradient(160deg, #14181f 0%, #1c2333 45%, #232b41 100%);
    min-height: 100vh;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 32px 28px 28px;
}

.login-brand {
    text-align: center;
    margin-bottom: 22px;
}

.login-brand .brand-mark {
    width: 40px;
    height: 40px;
    font-size: 18px;
    margin: 0 auto 12px;
}

.login-brand h1 {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 4px;
    color: var(--color-text);
}

.login-brand p {
    font-size: 12px;
    color: var(--color-text-muted);
    margin: 0;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 6px;
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrap i {
    position: absolute;
    left: 12px;
    font-size: 13px;
    color: var(--color-text-muted);
}

.input-wrap input {
    width: 100%;
    padding: 9px 12px 9px 34px;
    font-size: 12.5px;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-wrap input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 91, 219, 0.12);
}

.field-error {
    display: block;
    font-size: 11px;
    color: var(--color-danger);
    margin-top: 4px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
}

.form-check-input {
    width: 15px;
    height: 15px;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.form-check-label {
    font-size: 12.5px;
    color: var(--color-text);
    cursor: pointer;
    margin: 0;
}

.validation-summary ul {
    list-style: none;
    margin: 0 0 14px;
    padding: 9px 12px;
    background: rgba(224, 49, 49, 0.06);
    border: 1px solid rgba(224, 49, 49, 0.25);
    border-radius: var(--radius-sm);
    color: var(--color-danger);
    font-size: 12px;
}

.validation-summary ul:empty {
    display: none;
}

.validation-summary-valid {
    display: none;
}

.btn-primary {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 6px;
    padding: 10px 14px;
    font-size: 12.5px;
    font-weight: 600;
    color: #fff;
    background: var(--color-primary);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

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

/* ===== Module picker ===== */

.module-picker-body {
    min-height: 100vh;
    background: var(--color-bg);
}

.module-picker-topbar {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.module-picker-topbar .sidebar-brand {
    border-bottom: none;
    padding: 0;
    margin-bottom: 0;
}

.module-picker-topbar .brand-text {
    color: var(--color-text);
}

.module-picker-page {
    max-width: 960px;
    margin: 0 auto;
    padding: 48px 24px;
}

.module-picker-header {
    text-align: center;
    margin-bottom: 28px;
}

.module-picker-header h1 {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 6px;
}

.module-picker-header p {
    font-size: 13px;
    color: var(--color-text-muted);
    margin: 0;
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.module-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 28px 20px;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

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

.module-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    background: rgba(59, 91, 219, 0.1);
    color: var(--color-primary);
    font-size: 22px;
}

.module-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
}

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

.module-card-disabled {
    opacity: 0.55;
    cursor: not-allowed;
    filter: grayscale(0.4);
}

.module-card-disabled:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
    border-color: var(--color-border);
}

.module-card-license {
    font-size: 11px;
    color: var(--color-text-muted);
}

.module-card-license-none {
    color: var(--color-danger, #d9534f);
    font-weight: 600;
}

/* ===== Page loading overlay ===== */

.page-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 18, 25, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.page-loading-overlay .loading-progress {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 32px 44px;
}

/* ===== Responsive ===== */

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

@media (max-width: 640px) {
    .sidebar {
        display: none;
    }

    .stat-grid {
        grid-template-columns: 1fr;
    }
}
