/* ============================================================
   CSS VARIABLES & RESET
   ============================================================ */
:root {
    --bg-primary: #0f0f14;
    --bg-secondary: #1a1a24;
    --bg-card: #1e1e2e;
    --bg-hover: #272738;
    --bg-input: #252535;
    --border-color: #2d2d42;
    --text-primary: #e4e4ed;
    --text-secondary: #8888a4;
    --text-muted: #5c5c7a;
    --accent-color: #6c5ce7;
    --accent-hover: #5a4bd1;
    --success: #00b894;
    --warning: #fdcb6e;
    --danger: #e17055;
    --info: #0984e3;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --transition: all 0.3s ease;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

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

html {
    font-size: 14px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--accent-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--accent-hover);
}

input,
textarea,
select,
button {
    font-family: inherit;
    font-size: inherit;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

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

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

/* ============================================================
   LOADER
   ============================================================ */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 15, 20, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.spinner {
    width: 44px;
    height: 44px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================================
   TOAST
   ============================================================ */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    left: 20px;
    max-width: 380px;
    margin-left: auto;
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    color: #fff;
    font-weight: 500;
    z-index: 10001;
    transform: translateY(-120%);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55),
        opacity 0.3s ease;
    box-shadow: var(--shadow);
    font-size: 0.93rem;
    word-wrap: break-word;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

.toast.warning {
    background: var(--warning);
    color: #222;
}

.toast.info {
    background: var(--info);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 22px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.93rem;
    transition: var(--transition);
    gap: 8px;
    outline: none;
    text-decoration: none;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--accent-color);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
}

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

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

.btn-danger:hover {
    background: #c0392b;
}

.btn-small {
    padding: 6px 14px;
    font-size: 0.82rem;
    min-height: 36px;
}

.btn-full {
    width: 100%;
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.form-group {
    margin-bottom: 20px;
}

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

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: var(--transition);
    outline: none;
    min-height: 44px;
    -webkit-appearance: none;
    appearance: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

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

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

.input-wrapper input {
    padding-left: 40px;
    padding-right: 40px;
}

.input-icon {
    position: absolute;
    left: 12px;
    font-size: 1rem;
    color: var(--text-muted);
    pointer-events: none;
    z-index: 1;
}

.toggle-password {
    position: absolute;
    right: 12px;
    cursor: pointer;
    font-size: 1rem;
    user-select: none;
    z-index: 1;
    padding: 8px;
    -webkit-tap-highlight-color: transparent;
}

.error-msg {
    display: block;
    color: var(--danger);
    font-size: 0.8rem;
    margin-top: 4px;
    min-height: 1rem;
}

.form-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

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

.form-actions {
    display: flex;
    gap: 12px;
    padding-top: 10px;
    flex-wrap: wrap;
}

/* Checkbox */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--text-secondary);
    position: relative;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
}

.checkbox-wrapper input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.checkbox-wrapper input:checked+.checkmark {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.checkbox-wrapper input:checked+.checkmark::after {
    content: '✓';
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
}

.forgot-link {
    font-size: 0.88rem;
    color: var(--accent-color);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--border-color);
    border-radius: 26px;
    transition: var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    bottom: 3px;
    background: var(--text-primary);
    border-radius: 50%;
    transition: var(--transition);
}

.toggle-switch input:checked+.toggle-slider {
    background: var(--accent-color);
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(22px);
}

/* Select Small */
.select-small {
    padding: 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.82rem;
    outline: none;
    cursor: pointer;
    min-height: 36px;
    -webkit-appearance: none;
}

.select-small:focus {
    border-color: var(--accent-color);
}

/* Range */
.range-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.custom-range {
    -webkit-appearance: none;
    width: 160px;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    outline: none;
}

.custom-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.custom-range::-moz-range-thumb {
    width: 22px;
    height: 22px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.range-value {
    color: var(--text-secondary);
    font-size: 0.88rem;
    min-width: 40px;
}

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

.strength-bar {
    height: 100%;
    width: 0;
    border-radius: 2px;
    transition: var(--transition);
}

.strength-text {
    font-size: 0.78rem;
    margin-top: 4px;
    display: block;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(108, 92, 231, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(9, 132, 227, 0.06) 0%, transparent 50%);
    padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}

.login-container {
    width: 100%;
    max-width: 440px;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 40px 36px;
    box-shadow: var(--shadow);
}

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

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
}

.logo-icon {
    font-size: 1.8rem;
    color: var(--accent-color);
}

.logo-text {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.93rem;
}

.signup-text {
    text-align: center;
    margin-top: 20px;
    color: var(--text-muted);
    font-size: 0.88rem;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 22px;
    border-bottom: 1px solid var(--border-color);
    min-height: var(--topbar-height);
    flex-shrink: 0;
}

.sidebar-close {
    display: none;
    margin-left: auto;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
    padding: 8px;
    -webkit-tap-highlight-color: transparent;
}

.sidebar-close:hover {
    color: var(--text-primary);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.nav-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    padding: 16px 14px 8px;
    margin-top: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.93rem;
    font-weight: 500;
    margin-bottom: 4px;
    transition: var(--transition);
    position: relative;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}

.nav-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-link.active {
    background: rgba(108, 92, 231, 0.12);
    color: var(--accent-color);
}

.nav-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.nav-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-badge {
    margin-left: auto;
    font-size: 0.7rem;
    font-weight: 700;
    background: var(--danger);
    color: #fff;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 18px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.88rem;
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.76rem;
    color: var(--text-muted);
}

.btn-logout {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.btn-logout:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(225, 112, 85, 0.08);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    -webkit-tap-highlight-color: transparent;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    min-height: 100dvh;
    transition: margin-left 0.3s ease;
    display: flex;
    flex-direction: column;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    height: var(--topbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
    gap: 12px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.page-title {
    font-size: 1.2rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px 4px;
    -webkit-tap-highlight-color: transparent;
    min-width: 30px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition);
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box input {
    padding: 8px 14px 8px 34px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    width: 220px;
    outline: none;
    transition: var(--transition);
    font-size: 0.88rem;
    min-height: 38px;
}

.search-box input:focus {
    border-color: var(--accent-color);
    width: 280px;
}

.search-icon {
    position: absolute;
    left: 10px;
    font-size: 0.9rem;
    color: var(--text-muted);
    pointer-events: none;
}

.notification-bell {
    position: relative;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--danger);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================
   CONTENT AREA
   ============================================================ */
.content-area {
    padding: 28px;
    flex: 1;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    padding: 22px;
}

.link-small {
    font-size: 0.82rem;
    color: var(--accent-color);
    white-space: nowrap;
}

/* ============================================================
   STATS GRID
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 22px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.stat-card.fade-in {
    opacity: 1;
    transform: translateY(0);
}

.stat-card:hover {
    border-color: var(--text-muted);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

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

.stat-trend {
    font-size: 0.8rem;
    font-weight: 600;
}

.trend-up {
    color: var(--success);
}

.trend-down {
    color: var(--danger);
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 4px;
    word-break: break-word;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.82rem;
}

/* ============================================================
   GRID LAYOUTS
   ============================================================ */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

/* ============================================================
   BAR CHART
   ============================================================ */
.chart-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    height: 220px;
    padding-top: 10px;
    min-width: 250px;
}

.bar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
    max-width: 50px;
    min-width: 28px;
}

.bar {
    width: 100%;
    max-width: 28px;
    min-width: 14px;
    background: var(--accent-color);
    border-radius: 4px 4px 0 0;
    height: 0;
    transition: height 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    position: relative;
}

.bar:hover {
    opacity: 0.85;
}

.bar-value {
    font-size: 0.65rem;
    color: var(--text-muted);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s;
    text-align: center;
}

.bar-group:hover .bar-value {
    opacity: 1;
}

.bar-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-align: center;
    white-space: nowrap;
}

/* ============================================================
   DONUT CHART
   ============================================================ */
.donut-chart-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.donut-svg {
    width: 160px;
    height: 160px;
    max-width: 100%;
    transform: rotate(-90deg);
    flex-shrink: 0;
}

.donut-segment {
    animation: donutFadeIn 0.8s ease forwards;
    opacity: 0;
}

@keyframes donutFadeIn {
    to {
        opacity: 1;
    }
}

.donut-total {
    fill: var(--text-primary);
    font-size: 1.6rem;
    font-weight: 700;
    transform: rotate(90deg);
    transform-origin: 100px 100px;
}

.donut-total-label {
    fill: var(--text-muted);
    font-size: 0.85rem;
    transform: rotate(90deg);
    transform-origin: 100px 100px;
}

.donut-legend {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-label {
    color: var(--text-secondary);
    flex: 1;
}

.legend-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* ============================================================
   ACTIVITY LIST
   ============================================================ */
.activity-item {
    display: flex;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.activity-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 6px;
}

.activity-content {
    min-width: 0;
    flex: 1;
}

.activity-text {
    font-size: 0.88rem;
    color: var(--text-primary);
    margin-bottom: 2px;
    word-wrap: break-word;
}

.activity-time {
    font-size: 0.76rem;
    color: var(--text-muted);
}

/* ============================================================
   TABLE
   ============================================================ */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: -2px;
    padding: 2px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    min-width: 400px;
}

.table th,
.table td {
    padding: 12px 14px;
    text-align: left;
    white-space: nowrap;
}

.table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--bg-card);
}

.table td {
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

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

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

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.76rem;
    font-weight: 600;
    white-space: nowrap;
}

/* ============================================================
   SETTINGS TABS
   ============================================================ */
.settings-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.settings-tabs::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    padding: 10px 20px;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.88rem;
    transition: var(--transition);
    white-space: nowrap;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}

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

.tab-btn.active {
    background: var(--accent-color);
    color: #fff;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeUp 0.3s ease;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================
   SETTINGS SPECIFIC
   ============================================================ */
.profile-avatar-section {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 28px;
}

.profile-avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--accent-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    flex-shrink: 0;
}

.profile-avatar-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 0;
    border-bottom: 1px solid var(--border-color);
    gap: 20px;
}

.setting-item:last-of-type {
    border-bottom: none;
}

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

.setting-info h4 {
    font-size: 0.93rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.setting-info p {
    color: var(--text-muted);
    font-size: 0.82rem;
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.88rem;
}

.danger-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.danger-section h4 {
    font-size: 0.93rem;
    color: var(--danger);
    margin-bottom: 4px;
}

.color-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-option {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    outline: none;
    -webkit-tap-highlight-color: transparent;
    min-width: 36px;
}

.color-option:hover {
    transform: scale(1.15);
}

.color-option.active {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px var(--bg-primary);
}

/* ============================================================
   PROJECTS PAGE
   ============================================================ */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.project-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
}

.project-card:hover {
    border-color: var(--text-muted);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.project-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 10px;
}

.project-header h4 {
    font-size: 1rem;
    font-weight: 600;
    word-break: break-word;
}

.progress-section {
    margin-bottom: 16px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.progress-bar-track {
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}

.project-meta {
    display: flex;
    gap: 16px;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.project-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow);
    animation: modalIn 0.3s ease;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.05rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 22px;
    color: var(--text-secondary);
    word-wrap: break-word;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 22px;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
}

/* ============================================================
   RESPONSIVE — LARGE DESKTOP (1400px+)
   ============================================================ */
@media (min-width: 1400px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .content-area {
        max-width: 1400px;
    }
}

/* ============================================================
   RESPONSIVE — SMALL DESKTOP / TABLET LANDSCAPE (1024px)
   ============================================================ */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .search-box input {
        width: 160px;
    }

    .search-box input:focus {
        width: 200px;
    }

    .bar-chart {
        height: 180px;
    }
}

/* ============================================================
   RESPONSIVE — TABLET PORTRAIT (768px)
   ============================================================ */
@media (max-width: 768px) {

    /* Sidebar */
    .sidebar {
        transform: translateX(-100%);
    }

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

    .sidebar-close {
        display: block;
    }

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

    /* Main */
    .main-content {
        margin-left: 0;
    }

    .hamburger {
        display: flex;
    }

    /* Content */
    .content-area {
        padding: 20px 16px;
    }

    .topbar {
        padding: 0 16px;
    }

    /* Stats */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 1.3rem;
    }

    /* Forms */
    .form-row-2 {
        grid-template-columns: 1fr;
    }

    /* Charts */
    .bar-chart {
        height: 160px;
    }

    .bar {
        max-width: 22px;
    }

    .donut-chart-container {
        flex-direction: column;
    }

    .donut-svg {
        width: 140px;
        height: 140px;
    }

    /* Settings */
    .profile-avatar-section {
        flex-direction: column;
        align-items: flex-start;
    }

    .setting-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .danger-section {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Projects */
    .projects-grid {
        grid-template-columns: 1fr;
    }

    /* Card */
    .card-header {
        padding: 14px 16px;
    }

    .card-body {
        padding: 16px;
    }

    /* Login */
    .login-card {
        padding: 28px 22px;
    }

    /* Modal */
    .modal {
        margin: 16px;
        max-width: calc(100% - 32px);
    }

    .modal-footer {
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
    }

    /* Form actions */
    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }
}

/* ============================================================
   RESPONSIVE — SMALL MOBILE (480px)
   ============================================================ */
@media (max-width: 480px) {

    /* Stats */
    .stats-grid {
        grid-template-columns: 1fr;
    }

    /* Search hide */
    .search-box {
        display: none;
    }

    /* Topbar */
    .topbar-right {
        gap: 4px;
    }

    .page-title {
        font-size: 1.05rem;
    }

    /* Content */
    .content-area {
        padding: 16px 12px;
    }

    .topbar {
        padding: 0 12px;
    }

    /* Form */
    .form-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    /* Settings tabs */
    .tab-btn {
        padding: 10px 14px;
        font-size: 0.82rem;
    }

    /* Color options */
    .color-options {
        gap: 6px;
    }

    .color-option {
        width: 32px;
        height: 32px;
        min-width: 32px;
    }

    /* Range */
    .custom-range {
        width: 120px;
    }

    /* Chart */
    .bar-chart {
        height: 140px;
        min-width: 200px;
    }

    .bar-label {
        font-size: 0.6rem;
    }

    .bar-value {
        font-size: 0.58rem;
    }

    /* Stat */
    .stat-card {
        padding: 14px;
    }

    .stat-value {
        font-size: 1.15rem;
    }

    .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    /* Login */
    .login-card {
        padding: 24px 18px;
    }

    .logo-text {
        font-size: 1.4rem;
    }

    .logo-icon {
        font-size: 1.5rem;
    }

    /* Table */
    .table {
        font-size: 0.82rem;
    }

    .table th,
    .table td {
        padding: 10px 10px;
    }

    /* Project card */
    .project-card {
        padding: 16px;
    }

    /* Activity */
    .activity-text {
        font-size: 0.82rem;
    }
}

/* ============================================================
   RESPONSIVE — VERY SMALL MOBILE (360px)
   ============================================================ */
@media (max-width: 360px) {
    html {
        font-size: 13px;
    }

    .login-card {
        padding: 20px 14px;
    }

    .sidebar {
        width: 100%;
    }

    .content-area {
        padding: 12px 10px;
    }

    .topbar {
        padding: 0 10px;
        height: 56px;
    }

    .stat-value {
        font-size: 1.05rem;
    }

    .card-header {
        padding: 12px 14px;
    }

    .card-body {
        padding: 14px;
    }
}

/* ============================================================
   RESPONSIVE — LANDSCAPE PHONE
   ============================================================ */
@media (max-height: 500px) and (orientation: landscape) {
    .login-body {
        align-items: flex-start;
        padding-top: 20px;
    }

    .login-card {
        padding: 20px;
    }

    .login-header {
        margin-bottom: 16px;
    }

    .sidebar-nav {
        padding: 8px 12px;
    }

    .nav-link {
        padding: 8px 14px;
        min-height: 38px;
    }

    .nav-section-title {
        padding: 10px 14px 4px;
    }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
    .sidebar,
    .sidebar-overlay,
    .topbar,
    .hamburger,
    .toast,
    .loader-overlay,
    .modal-overlay,
    .btn-logout,
    .notification-bell {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    body {
        background: #fff;
        color: #000;
    }

    .card {
        border: 1px solid #ccc;
        box-shadow: none;
    }
}

/* ============================================================
   ACCESSIBILITY — REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .stat-card {
        opacity: 1;
        transform: none;
    }

    .bar {
        transition: none;
    }

    .toast {
        transition: opacity 0.1s;
        transform: none;
    }

    .toast.show {
        transform: none;
        opacity: 1;
    }
}

/* ============================================================
   FOCUS VISIBLE — KEYBOARD ACCESSIBILITY
   ============================================================ */
.btn:focus-visible,
.nav-link:focus-visible,
.tab-btn:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.toggle-switch:focus-within,
.checkbox-wrapper:focus-within {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* ============================================================
   DARK MODE FORCED COLORS (HIGH CONTRAST)
   ============================================================ */
@media (forced-colors: active) {
    .btn-primary {
        border: 2px solid ButtonText;
    }

    .nav-link.active {
        border: 2px solid Highlight;
    }

    .badge {
        border: 1px solid;
    }
}