/* ═══════════════════════════════════════════════════════════
   iSeeMore Mobile Portal — Дизайн-система v4.0
   Material Design · aaPanel-style · Light/Dark themes
   ═══════════════════════════════════════════════════════════ */

/* ─── Светлая тема (по умолчанию) ─── */
:root {
    /* Primary */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --primary-subtle: #eff6ff;

    /* Semantic */
    --success: #16a34a;
    --success-light: #f0fdf4;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --danger: #dc2626;
    --danger-light: #fef2f2;

    /* Surfaces */
    --bg: #f0f2f5;
    --surface: #ffffff;
    --surface-hover: #f9fafb;
    --surface-active: #f3f4f6;

    /* Borders */
    --border: #e5e7eb;
    --border-light: #f3f4f6;

    /* Text */
    --text: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --text-inverse: #ffffff;

    /* Sidebar */
    --sidebar-bg: #ffffff;
    --sidebar-text: #6b7280;
    --sidebar-text-active: #2563eb;
    --sidebar-item-active-bg: #eff6ff;
    --sidebar-border: #e5e7eb;
    --sidebar-width: 220px;
    --sidebar-collapsed-width: 64px;

    /* Topbar */
    --topbar-bg: #ffffff;
    --topbar-border: #e5e7eb;
    --topbar-height: 52px;

    /* Misc */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --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.06), 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);
    --transition: 0.2s ease;
    --content-padding: 1.25rem;
    --font: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}

/* ─── Тёмная тема ─── */
[data-theme="dark"] {
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-light: #1e3a5f;
    --primary-subtle: #172554;

    --success: #22c55e;
    --success-light: #14532d;
    --warning: #f59e0b;
    --warning-light: #451a03;
    --danger: #ef4444;
    --danger-light: #450a0a;

    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-hover: #222635;
    --surface-active: #2a2e3d;

    --border: #2e3345;
    --border-light: #252938;

    --text: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-tertiary: #6b7280;
    --text-inverse: #111827;

    --sidebar-bg: #1a1d27;
    --sidebar-text: #9ca3af;
    --sidebar-text-active: #3b82f6;
    --sidebar-item-active-bg: #172554;
    --sidebar-border: #2e3345;

    --topbar-bg: #1a1d27;
    --topbar-border: #2e3345;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.4);
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 14px;
    line-height: 1.5;
}

/* ─── Утилиты ─── */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 12px; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.flex { display: flex; }
.items-center { align-items: center; }

/* ═══════════════════════════════
   LAYOUT: Sidebar + Topbar + Content
   ═══════════════════════════════ */

#app {
    min-height: 100vh;
    background: var(--bg);
    position: relative;
}

/* Обёртка для авторизованного интерфейса */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar (Desktop) ─── */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: width var(--transition), transform var(--transition);
    overflow: hidden;
}

.sidebar-logo {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid var(--sidebar-border);
    gap: 10px;
    flex-shrink: 0;
}

.sidebar-logo-icon {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo-icon svg {
    width: 18px;
    height: 18px;
    color: var(--text-inverse);
}

.sidebar-logo-text {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-nav {
    flex: 1;
    padding: 8px;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-section {
    margin-bottom: 4px;
}

.sidebar-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    padding: 12px 12px 6px;
    white-space: nowrap;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--sidebar-text);
    transition: all var(--transition);
    font-size: 13px;
    font-weight: 500;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    white-space: nowrap;
    position: relative;
}

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

.sidebar-item.active {
    background: var(--sidebar-item-active-bg);
    color: var(--sidebar-text-active);
    font-weight: 600;
}

.sidebar-item svg,
.sidebar-item .sidebar-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke-width: 1.75;
}

.sidebar-item .sidebar-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-item .sidebar-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    line-height: 1.4;
}

.sidebar-item .sidebar-badge-coming {
    margin-left: auto;
    background: var(--surface-active);
    color: var(--text-tertiary);
    font-size: 9px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

/* Нижняя часть sidebar */
.sidebar-footer {
    padding: 8px;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition);
    overflow: hidden;
}

.sidebar-user:hover {
    background: var(--surface-hover);
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: var(--text-inverse);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user-info {
    overflow: hidden;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 11px;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── Main area ─── */
.main-area {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition);
}

/* ─── Topbar ─── */
.top-bar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    display: flex;
    align-items: center;
    padding: 0 var(--content-padding);
    gap: 12px;
    z-index: 100;
    flex-shrink: 0;
}

.top-bar-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    flex-shrink: 0;
}

/* KPI chips in topbar */
.top-bar-kpi {
    flex: 1;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-left: 12px;
}

.top-bar-kpi::-webkit-scrollbar {
    display: none;
}

.kpi-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    white-space: nowrap;
    font-size: 12px;
    transition: all var(--transition);
    flex-shrink: 0;
}

.kpi-chip:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.kpi-code {
    font-weight: 600;
    color: var(--text-secondary);
}

.kpi-value {
    font-weight: 700;
}

.kpi-green { border-color: #86efac; }
.kpi-green .kpi-value { color: var(--success); }
.kpi-yellow { border-color: #fde68a; }
.kpi-yellow .kpi-value { color: var(--warning); }
.kpi-red { border-color: #fca5a5; }
.kpi-red .kpi-value { color: var(--danger); }

[data-theme="dark"] .kpi-green { border-color: #166534; }
[data-theme="dark"] .kpi-yellow { border-color: #713f12; }
[data-theme="dark"] .kpi-red { border-color: #7f1d1d; }

/* Topbar right actions */
.top-bar-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
}

/* ─── Icon button (topbar, etc.) ─── */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: var(--radius);
    color: var(--text-secondary);
    transition: all var(--transition);
    position: relative;
}

.icon-btn:hover {
    background: var(--surface-active);
    color: var(--text);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 1.75;
}

/* Theme toggle button — серые/белые иконки */
.theme-toggle svg {
    color: var(--text-tertiary);
}

.theme-toggle:hover svg {
    color: var(--text-secondary);
}

/* Badge on icon-btn */
.badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--danger);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 0 5px;
    border-radius: 10px;
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Mobile menu button */
.mobile-menu-btn {
    display: none;
}

/* ─── Page content ─── */
.page-content {
    flex: 1;
    padding: var(--content-padding);
}

/* ─── Page title ─── */
.page-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1.25rem;
}

/* ═══════════════════════════════
   COMPONENTS
   ═══════════════════════════════ */

/* ─── Cards ─── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: box-shadow var(--transition);
}

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

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

.card-header h3 {
    font-size: 14px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    line-height: 1.4;
}

.btn svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

.btn-primary {
    background: var(--primary);
    color: var(--text-inverse);
    border-color: var(--primary);
}

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

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}

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

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

.btn-ghost:hover {
    background: var(--surface-active);
    color: var(--text);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.btn-danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}

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

.btn-lg {
    padding: 10px 20px;
    font-size: 14px;
}

.btn-block {
    width: 100%;
}

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

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

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 13px;
    color: var(--text);
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-control::placeholder {
    color: var(--text-tertiary);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

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

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

.error-message {
    color: var(--danger);
    font-size: 13px;
    margin-top: 6px;
}

/* ─── Tables ─── */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

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

thead th {
    background: var(--surface-hover);
    text-align: left;
    padding: 10px 14px;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text);
}

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

tbody tr:hover {
    background: var(--surface-hover);
}

/* ─── Notification cards ─── */
.notification-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all var(--transition);
}

.notification-card:hover {
    box-shadow: var(--shadow);
}

.notification-card.unread {
    border-left: 3px solid var(--primary);
    background: var(--primary-subtle);
}

.notification-card.type-warning.unread {
    border-left-color: var(--warning);
    background: var(--warning-light);
}

.notification-card.type-action_required.unread {
    border-left-color: var(--danger);
    background: var(--danger-light);
}

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
}

.notification-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
}

.notification-body {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.notification-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}

.notification-source {
    font-size: 11px;
    background: var(--surface-active);
    color: var(--text-tertiary);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.notification-time {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* ─── Module cards ─── */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.module-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 14px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.module-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.module-card.coming-soon {
    opacity: 0.5;
    cursor: default;
}

.module-card.coming-soon:hover {
    border-color: var(--border);
    box-shadow: none;
}

.module-icon {
    width: 40px;
    height: 40px;
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-active);
    border-radius: var(--radius);
    color: var(--text-secondary);
}

.module-icon svg {
    width: 20px;
    height: 20px;
    stroke-width: 1.75;
}

.module-name {
    font-weight: 600;
    font-size: 12px;
    color: var(--text);
}

.module-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 9px;
    background: var(--surface-active);
    color: var(--text-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

/* ─── Profile ─── */
.profile-header {
    text-align: center;
    padding: 2rem var(--content-padding) 1.5rem;
}

.profile-avatar {
    width: 72px;
    height: 72px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-inverse);
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 auto 12px;
}

.profile-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.profile-role {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 2px;
}

.profile-info {
    margin-top: 1.5rem;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

.profile-actions {
    max-width: 400px;
    margin: 1.5rem auto 0;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
}

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

.info-value {
    font-weight: 500;
    color: var(--text);
}

/* ─── Subordinates / Team ─── */
.subordinate-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    margin-bottom: 6px;
    transition: box-shadow var(--transition);
}

.subordinate-card:hover {
    box-shadow: var(--shadow-sm);
}

.subordinate-avatar {
    width: 36px;
    height: 36px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    flex-shrink: 0;
}

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

.subordinate-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
}

.subordinate-role {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ─── Section titles ─── */
.section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 10px;
    margin-top: 1.5rem;
}

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

/* ─── Filter chips ─── */
.filter-row {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 10px;
    margin-bottom: 10px;
    -webkit-overflow-scrolling: touch;
}

.filter-row::-webkit-scrollbar {
    display: none;
}

.filter-chip {
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: all var(--transition);
    color: var(--text-secondary);
}

.filter-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.filter-chip.active {
    background: var(--primary);
    color: var(--text-inverse);
    border-color: var(--primary);
}

/* ─── Loading ─── */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ─── Empty state ─── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-active);
    border-radius: 50%;
    color: var(--text-tertiary);
}

.empty-state-icon svg {
    width: 24px;
    height: 24px;
    stroke-width: 1.5;
}

.empty-state p {
    font-size: 13px;
}

/* ─── Toast / Snackbar ─── */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text);
    color: var(--bg);
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    white-space: nowrap;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ─── Modal / Dialog ─── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: 20px;
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    padding: 20px 24px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
}

.modal-body {
    padding: 0 24px 20px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.modal-footer {
    padding: 12px 24px 20px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ─── Tabs ─── */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    gap: 0;
    margin-bottom: 20px;
}

.tab {
    padding: 10px 16px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
    white-space: nowrap;
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

/* ─── Status badges ─── */
.status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.status-success {
    background: var(--success-light);
    color: var(--success);
}

.status-warning {
    background: var(--warning-light);
    color: var(--warning);
}

.status-danger {
    background: var(--danger-light);
    color: var(--danger);
}

.status-info {
    background: var(--primary-light);
    color: var(--primary);
}

.status-neutral {
    background: var(--surface-active);
    color: var(--text-tertiary);
}

/* ═══════════════════════════════
   LOGIN SCREEN
   ═══════════════════════════════ */
.login-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    background: var(--bg);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 32px 28px;
    box-shadow: var(--shadow-md);
}

.login-logo {
    width: 48px;
    height: 48px;
    background: var(--primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.login-logo svg {
    width: 24px;
    height: 24px;
    color: var(--text-inverse);
}

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

.login-subtitle {
    color: var(--text-secondary);
    font-size: 13px;
    text-align: center;
    margin-bottom: 24px;
}

.login-form {
    width: 100%;
}

.login-form .form-group input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 13px;
    color: var(--text);
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.login-form .form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.login-form .form-group input::placeholder {
    color: var(--text-tertiary);
}

/* ─── Bottom Nav (mobile only) ─── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: none;
    z-index: 200;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 0 8px;
    cursor: pointer;
    color: var(--text-tertiary);
    font-size: 10px;
    font-weight: 500;
    border: none;
    background: none;
    transition: color var(--transition);
}

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

.nav-item svg {
    width: 20px;
    height: 20px;
    margin-bottom: 2px;
    stroke-width: 1.75;
}

/* ═══════════════════════════════
   MOBILE OVERLAY
   ═══════════════════════════════ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 199;
}

.sidebar-overlay.show {
    display: block;
}

/* ═══════════════════════════════
   RESPONSIVE
   ═══════════════════════════════ */

/* ─── Mobile (<768px) ─── */
@media (max-width: 767px) {
    .sidebar {
        transform: translateX(-100%);
        width: 260px;
        box-shadow: var(--shadow-lg);
    }

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

    .main-area {
        margin-left: 0;
    }

    .mobile-menu-btn {
        display: inline-flex;
    }

    .bottom-nav {
        display: flex;
    }

    .page-content {
        padding-bottom: 70px;
    }

    .modules-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
    }

    .module-card {
        padding: 14px 8px;
    }

    .profile-avatar {
        width: 64px;
        height: 64px;
        font-size: 1.25rem;
    }

    .subordinates-list {
        display: block;
    }
}

/* ─── Tablet (768px - 1023px) ─── */
@media (min-width: 768px) and (max-width: 1023px) {
    :root {
        --sidebar-width: 64px;
        --content-padding: 1.5rem;
    }

    .sidebar-label,
    .sidebar-section-title,
    .sidebar-logo-text,
    .sidebar-user-info,
    .sidebar-badge-coming {
        display: none;
    }

    .sidebar-item {
        justify-content: center;
        padding: 10px;
    }

    .sidebar-item .sidebar-badge {
        position: absolute;
        top: 2px;
        right: 2px;
        margin-left: 0;
    }

    .sidebar-logo {
        justify-content: center;
        padding: 0;
    }

    .sidebar-user {
        justify-content: center;
    }

    .subordinates-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .subordinates-list .subordinate-card {
        margin-bottom: 0;
    }

    .modules-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}

/* ─── Desktop (1024px+) ─── */
@media (min-width: 1024px) {
    :root {
        --content-padding: 2rem;
    }

    .modules-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }

    .subordinates-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .subordinates-list .subordinate-card {
        margin-bottom: 0;
    }
}

/* Large desktop (1400px+) */
@media (min-width: 1400px) {
    .subordinates-list {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ─── Scrollbar styling ─── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* ─── Selection ─── */
::selection {
    background: var(--primary-light);
    color: var(--primary);
}

/* ═══════════════════════════════
   ADDITIONS v4.0 — Auth via Identity Center
   ═══════════════════════════════ */

/* ─── Login footer (forgot password link) ─── */
.login-footer {
    text-align: center;
    margin-top: 16px;
}

.login-link {
    color: var(--primary);
    font-size: 13px;
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition);
}

.login-link:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* ─── Success message ─── */
.success-message {
    color: var(--success);
    font-size: 13px;
    margin-top: 6px;
    padding: 8px 12px;
    background: var(--success-light);
    border-radius: var(--radius);
    text-align: center;
}
