/* ============================================================
   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);
    /* hidden by default — JS sets display:flex when showing
       (avoid CSS display:flex fighting inline hide) */
    display: none;
    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: 12px;
    margin-bottom: 12px;
}

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

.logo-svg {
    display: block;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 10px;
    box-shadow: 0 0 0 1px rgba(0, 200, 150, 0.15),
                0 4px 14px rgba(0, 200, 150, 0.12);
}

.logo-svg-lg {
    width: 56px;
    height: 56px;
    border-radius: 14px;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-decoration: none;
    min-width: 0;
}

.brand-link:hover {
    color: inherit;
}

.brand-link:hover .logo-text {
    color: var(--accent-color);
}

.brand-text-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.15;
    gap: 2px;
}

.logo-text {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.login-header .logo-text {
    font-size: 1.75rem;
    letter-spacing: 0.1em;
    color: var(--accent-color);
}

.logo-tag {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.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: 10px;
    flex-shrink: 1;
    min-width: 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;
}

.badge-success {
    background: rgba(60, 135, 58, 0.18);
    color: #7dce78;
    border: 1px solid rgba(60, 135, 58, 0.35);
}

.badge-danger {
    background: rgba(231, 76, 60, 0.15);
    color: #f07178;
    border: 1px solid rgba(231, 76, 60, 0.35);
}

/* ============================================================
   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;
    }
}
/* ============================================================
   STK MARKET ANALYSIS — theme extensions
   ============================================================ */
:root {
    --accent-color: #00c896;
    --accent-hover: #00a87e;
    --up: #00c896;
    --down: #ff5c5c;
    --chart-grid: #1e2a32;
    --ticker-bg: #0a1218;
    --panel-glow: 0 0 0 1px rgba(0, 200, 150, 0.08);
}

body {
    font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
    background: radial-gradient(1200px 600px at 10% -10%, #12202a 0%, var(--bg-primary) 55%);
}

.sidebar {
    background: linear-gradient(180deg, #0d151c 0%, #0a1016 100%);
    border-right: 1px solid #1a2832;
}

.logo-text { letter-spacing: 0.08em; font-weight: 800; }
.logo-icon { color: var(--accent-color); }
.sidebar-header .logo-text {
    font-size: 1.05rem;
    background: linear-gradient(90deg, #e4e4ed 0%, #00c896 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    /* fallback if clip unsupported */
}
@supports not (background-clip: text) {
    .sidebar-header .logo-text { color: var(--accent-color); }
}

.nav-link.active {
    background: rgba(0, 200, 150, 0.12);
    color: var(--accent-color);
    border-left: 3px solid var(--accent-color);
}

.card {
    background: #121c24;
    border: 1px solid #1e2d38;
    box-shadow: var(--panel-glow);
}

.stat-card {
    background: linear-gradient(145deg, #132029, #101820);
    border: 1px solid #1e2d38;
}
.stat-card .stat-value { font-variant-numeric: tabular-nums; font-size: 1.45rem; }
.stat-card.up .stat-value { color: var(--up); }
.stat-card.down .stat-value { color: var(--down); }

.ticker-bar {
    display: flex;
    gap: 18px;
    overflow-x: auto;
    padding: 10px 14px;
    margin-bottom: 16px;
    background: var(--ticker-bg);
    border: 1px solid #1e2d38;
    border-radius: var(--radius);
    font-size: 0.85rem;
    white-space: nowrap;
}
.ticker-item { display: inline-flex; gap: 8px; align-items: center; }
.ticker-item .sym { font-weight: 700; color: var(--text-primary); }
.ticker-item .px { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.ticker-item .chg.up { color: var(--up); }
.ticker-item .chg.down { color: var(--down); }

.chart-canvas {
    width: 100%;
    height: 320px;
    background: #0b1218;
    border: 1px solid #1a2832;
    border-radius: var(--radius-sm);
    position: relative;
}
.chart-canvas canvas { width: 100%; height: 100%; display: block; }

.toolbar-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
    margin-bottom: 14px;
}
.toolbar-row .form-group { margin: 0; min-width: 120px; }
.toolbar-row label { font-size: 0.75rem; color: var(--text-muted); display: block; margin-bottom: 4px; }
.toolbar-row input, .toolbar-row select {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    min-height: 40px;
    width: 100%;
}

.btn-buy { background: var(--up); color: #04110c; }
.btn-buy:hover { background: #00e0a8; }
.btn-sell { background: var(--down); color: #fff; }
.btn-sell:hover { background: #ff7070; }

.badge-live {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(0,200,150,0.12);
    color: var(--accent-color);
    border: 1px solid rgba(0,200,150,0.25);
}
.badge-live::before {
    content: "";
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--accent-color);
    box-shadow: 0 0 8px var(--accent-color);
    animation: pulse-dot 1.4s infinite;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}
.badge-offline {
    background: rgba(255,92,92,0.12);
    color: var(--down);
    border-color: rgba(255,92,92,0.25);
}
.badge-offline::before { background: var(--down); box-shadow: none; animation: none; }
.badge-warn {
    background: rgba(253,203,110,0.15);
    color: #fdcb6e;
    border-color: rgba(253,203,110,0.35);
}
.badge-warn::before { background: #fdcb6e; box-shadow: none; animation: none; }

.table.market td, .table.market th {
    font-variant-numeric: tabular-nums;
    font-size: 0.88rem;
}
.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.85rem; }

.order-ticket {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
@media (max-width: 720px) {
    .order-ticket { grid-template-columns: 1fr; }
}

.login-card .logo-text {
    color: var(--accent-color);
    background: none;
    -webkit-text-fill-color: unset;
}
.login-subtitle { color: var(--text-secondary); }

.raw-json {
    max-height: 280px;
    overflow: auto;
    background: #0b1218;
    border: 1px solid #1a2832;
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: ui-monospace, monospace;
    font-size: 0.78rem;
    color: #9ecbb8;
    white-space: pre-wrap;
    word-break: break-word;
}

.page-hint {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 14px;
}

/* Setup checklist + required fields */
.setup-checklist {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 0;
}
.setup-item {
    display: grid;
    grid-template-columns: 14px 160px 1fr;
    gap: 10px;
    align-items: start;
    padding: 10px 12px;
    border-radius: 8px;
    background: #0b1218;
    border: 1px solid #1e2d38;
    font-size: 0.9rem;
}
.setup-item.done { border-color: rgba(0,200,150,0.35); }
.setup-item.missing { border-color: rgba(255,92,92,0.35); }
.setup-dot {
    width: 10px; height: 10px; border-radius: 50%;
    margin-top: 5px;
    background: var(--text-muted);
}
.setup-item.done .setup-dot { background: var(--up); box-shadow: 0 0 8px var(--up); }
.setup-item.missing .setup-dot { background: var(--down); }
.setup-label { font-weight: 600; }
.setup-help { color: var(--text-muted); font-size: 0.8rem; }

.req-star { color: var(--down); font-weight: 700; }
.req-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
@media (max-width: 720px) {
    .req-grid { grid-template-columns: 1fr; }
    .setup-item { grid-template-columns: 14px 1fr; }
    .setup-help { grid-column: 2; }
}
.field-hint {
    display: block;
    margin-top: 4px;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.35;
}
.field-badge {
    display: inline-block;
    margin-left: 6px;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(0,200,150,0.12);
    color: var(--accent-color);
    vertical-align: middle;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.input-with-toggle {
    display: flex;
    gap: 8px;
    align-items: center;
}
.input-with-toggle input { flex: 1; }
.adv-details {
    border: 1px dashed #1e2d38;
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text-secondary);
}
.adv-details summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ============================================================
   STOCK CARDS — market instrument grid
   ============================================================ */
.stock-search-panel {
    margin-bottom: 18px;
}
.stock-toolbar {
    margin-bottom: 8px;
}
.stock-meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 4px;
}
.exch-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.exch-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    background: rgba(0, 200, 150, 0.08);
    border: 1px solid rgba(0, 200, 150, 0.2);
    color: var(--text-secondary);
}
.exch-pill strong {
    color: var(--accent-color);
    font-variant-numeric: tabular-nums;
}
.exch-pill.muted {
    background: #121a20;
    border-color: #1e2d38;
    color: var(--text-muted);
}

.stock-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

/* Compact cards — desktop + mobile */
.stock-cards-grid.stock-cards-compact {
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 8px;
}

.stock-card {
    position: relative;
    background: linear-gradient(160deg, #132029 0%, #0e161c 55%, #0b1218 100%);
    border: 1px solid #1e2d38;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
    overflow: hidden;
}

.stock-card.stock-card-sm {
    padding: 10px 10px 10px 12px;
    gap: 8px;
    border-radius: 10px;
    min-height: 0;
}
.stock-card::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--accent-color);
    opacity: 0.85;
}
.stock-card.ex-nse::before { background: #00c896; }
.stock-card.ex-bse::before { background: #4dabf7; }
.stock-card.ex-fno::before { background: #fcc419; }
.stock-card.ex-other::before { background: #868e96; }

.stock-card:hover {
    transform: translateY(-2px);
    border-color: rgba(0, 200, 150, 0.35);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35),
                0 0 0 1px rgba(0, 200, 150, 0.08);
}

.stock-card-top {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.stock-card-sm .stock-card-top {
    gap: 8px;
}
.stock-avatar {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.05rem;
    color: #04110c;
    background: linear-gradient(135deg, #00e0a8, #00a87e);
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 200, 150, 0.25);
}
.stock-avatar.stock-avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 0.85rem;
    box-shadow: 0 2px 8px rgba(0, 200, 150, 0.2);
}
.stock-card.ex-bse .stock-avatar {
    background: linear-gradient(135deg, #74c0fc, #1c7ed6);
    color: #031525;
}
.stock-card.ex-fno .stock-avatar {
    background: linear-gradient(135deg, #ffe066, #fab005);
    color: #2b1d00;
}
.stock-card-titles {
    flex: 1;
    min-width: 0;
}
.stock-sym {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent-color);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stock-name {
    font-size: 1.0rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-top: 4px;
    line-height: 1.3;
    letter-spacing: 0.01em;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
    word-break: break-word;
    max-height: 4em;
}
.stock-card-sm .stock-name {
    font-size: 0.82rem;
    font-weight: 700;
    margin-top: 0;
    -webkit-line-clamp: 2;
    max-height: 2.5em;
    line-height: 1.25;
}
.stock-card-sm .stock-sym {
    font-size: 0.68rem;
    letter-spacing: 0.04em;
}
.stock-card-sm .stock-exch-badge {
    font-size: 0.6rem;
    padding: 2px 6px;
}
.stock-exch-badge {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(255,255,255,0.04);
    border: 1px solid #2a3a45;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.stock-card.ex-nse .stock-exch-badge {
    color: #00c896;
    border-color: rgba(0,200,150,0.3);
    background: rgba(0,200,150,0.08);
}
.stock-card.ex-bse .stock-exch-badge {
    color: #74c0fc;
    border-color: rgba(116,192,252,0.3);
    background: rgba(28,126,214,0.12);
}

.stock-card-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 10px;
    padding: 10px;
    border-radius: 10px;
    background: rgba(0,0,0,0.22);
    border: 1px solid #1a2832;
}
.stock-card-meta.stock-card-meta-sm {
    gap: 4px 8px;
    padding: 6px 8px;
    border-radius: 8px;
}
.stock-card-sm .stock-meta-item .k {
    font-size: 0.58rem;
}
.stock-card-sm .stock-meta-item .v {
    font-size: 0.72rem;
}
.stock-card-sm .stock-meta-item .v.mono {
    font-size: 0.68rem;
}
.stock-meta-item.stock-meta-wide {
    grid-column: 1 / -1;
}
.stock-meta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.stock-meta-item .k {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}
.stock-meta-item .v {
    font-size: 0.82rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stock-meta-item .v.mono {
    font-family: ui-monospace, "IBM Plex Mono", monospace;
    font-size: 0.78rem;
    color: #9ecbb8;
}

.stock-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: auto;
}
.stock-card-actions .btn {
    flex: 1;
    min-width: 72px;
    text-align: center;
    text-decoration: none;
}
.stock-card-actions.stock-card-actions-sm {
    gap: 4px;
}
.stock-card-actions.stock-card-actions-sm .btn {
    min-width: 0;
    padding: 5px 6px;
    font-size: 0.72rem;
}

/* Pagination bar */
.stock-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px 12px;
    margin: 8px 0 28px;
    padding: 12px 14px;
    background: var(--bg-card, #121a20);
    border: 1px solid var(--border-color, #1e2d38);
    border-radius: 12px;
}
.stock-page-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    min-width: 140px;
    text-align: center;
}
.stock-page-jump {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.stock-page-input {
    width: 56px;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid var(--border-color, #1e2d38);
    background: var(--bg-primary, #0b1218);
    color: var(--text-primary, #e8eef2);
    font-size: 0.85rem;
    text-align: center;
}
.stock-pagination .btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.stock-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px 20px;
    border: 1px dashed #1e2d38;
    border-radius: 14px;
    background: #0b1218;
    color: var(--text-muted);
}
.stock-empty-icon {
    font-size: 2rem;
    color: var(--accent-color);
    margin-bottom: 8px;
    opacity: 0.7;
}
.stock-empty p {
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 4px;
}

@media (max-width: 600px) {
    .stock-cards-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }
    .stock-cards-grid.stock-cards-compact {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .stock-card-meta {
        grid-template-columns: 1fr 1fr;
    }
    .stock-pagination {
        gap: 8px;
        padding: 10px;
    }
    .stock-page-info {
        width: 100%;
        order: -1;
        min-width: 0;
        font-size: 0.8rem;
    }
}

@media (max-width: 380px) {
    .stock-cards-grid,
    .stock-cards-grid.stock-cards-compact {
        grid-template-columns: 1fr;
    }
}

/* Stock groups */
.group-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.group-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(0, 200, 150, 0.28);
    background: rgba(0, 200, 150, 0.08);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.88rem;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.group-chip:hover {
    background: rgba(0, 200, 150, 0.16);
    border-color: rgba(0, 200, 150, 0.5);
}
.group-chip-name {
    font-weight: 700;
}
.group-chip-count {
    min-width: 1.4em;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    background: rgba(0,0,0,0.35);
    color: var(--accent-color);
}
.stock-name-inline {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-primary);
}
.stock-group-modal {
    max-width: 420px;
    width: 92%;
}
.modal-overlay {
    display: none;
    align-items: center;
    justify-content: center;
}
.modal-overlay[style*="flex"] {
    display: flex !important;
}

/* History progress */
.hist-progress-bar {
    height: 8px;
    border-radius: 999px;
    background: #1a2832;
    overflow: hidden;
    border: 1px solid #243440;
}
.hist-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #00a87e, #00e0a8);
    transition: width 0.4s ease;
    border-radius: 999px;
}

/* M1 stock multi-select (settings) */
.m1-search-results {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 40;
    max-height: 240px;
    overflow-y: auto;
    margin-top: 4px;
    background: #121c24;
    border: 1px solid #2a3c48;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.m1-search-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border: none;
    border-bottom: 1px solid #1e2d38;
    background: transparent;
    color: var(--text, #e8eef2);
    cursor: pointer;
    font-size: 0.85rem;
}
.m1-search-item:hover,
.m1-search-item:focus {
    background: #1a2a34;
    outline: none;
}
.m1-search-item .m1-sym {
    font-weight: 600;
    font-family: ui-monospace, monospace;
}
.m1-search-item .m1-meta {
    font-size: 0.75rem;
    color: var(--text-muted, #8aa0ad);
}
.m1-selected-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 36px;
    padding: 8px;
    border: 1px solid #243440;
    border-radius: 8px;
    background: #0f171c;
}
.m1-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px 4px 10px;
    border-radius: 999px;
    background: #1a2f3a;
    border: 1px solid #2a4a58;
    font-size: 0.8rem;
    color: #d7e6ee;
}
.m1-chip .m1-chip-x {
    border: none;
    background: transparent;
    color: #8aa0ad;
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1;
    padding: 0 2px;
}
.m1-chip .m1-chip-x:hover {
    color: #ff6b6b;
}

/* Training register */
.tr-selected-card {
    padding: 12px;
    border: 1px solid #2a4a58;
    border-radius: 10px;
    background: #121c24;
}
.tr-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.tr-status-active { background: #0d3d32; color: #00e0a8; }
.tr-status-paused { background: #3d320d; color: #f0c040; }
.tr-status-done { background: #1a2832; color: #8aa0ad; }
.tr-actions { white-space: nowrap; }

/* Query lab saved list */
.saved-query-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 280px;
    overflow-y: auto;
    margin-top: 8px;
}
.saved-query-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid #243440;
    border-radius: 8px;
    background: #0f171c;
    cursor: pointer;
}
.saved-query-item:hover {
    border-color: #3a5a68;
    background: #152028;
}
.saved-query-item.active {
    border-color: #00a87e;
}
.saved-query-item .sq-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: #e8eef2;
}
.saved-query-item .sq-meta {
    font-size: 0.72rem;
    color: #8aa0ad;
    margin-top: 2px;
}
.saved-query-item .sq-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.saved-query-item .sq-actions button {
    font-size: 0.7rem;
    padding: 2px 6px;
}

/* Query lab param controls */
.param-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    border: 1px solid #243440;
    border-radius: 8px;
    background: #0f171c;
    max-height: 280px;
    overflow-y: auto;
}
.param-row {
    display: grid;
    grid-template-columns: minmax(100px, 160px) 1fr;
    gap: 10px;
    align-items: center;
}
.param-row label {
    font-size: 0.8rem;
    color: #9ab;
}
.param-input {
    width: 100%;
}
#qrySql {
    width: 100%;
    min-height: 200px;
    font-size: 0.82rem;
    line-height: 1.45;
    resize: vertical;
}
.table-wrap .data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}
.table-wrap .data-table th,
.table-wrap .data-table td {
    border-bottom: 1px solid #1e2d38;
    padding: 6px 8px;
    text-align: left;
    white-space: nowrap;
}
.table-wrap .data-table th {
    position: sticky;
    top: 0;
    background: #121c24;
    z-index: 1;
}

/* Live quote cards (analytics stream) */
.live-quote-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}
.live-quote-card {
    background: #121c24;
    border: 1px solid #243440;
    border-radius: 10px;
    padding: 10px 12px;
}
.live-quote-card .lq-sym {
    font-family: ui-monospace, monospace;
    font-weight: 600;
    font-size: 0.85rem;
    color: #c5d8e4;
}
.live-quote-card .lq-ltp {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 4px 0;
    color: #e8eef2;
}
.live-quote-card .lq-chg.up { color: #00e0a8; }
.live-quote-card .lq-chg.down { color: #ff6b6b; }
.live-quote-card .lq-meta {
    font-size: 0.72rem;
    color: var(--text-muted, #8aa0ad);
}

/* ============================================================
   Global status strip + mobile bottom nav (Phase 0–1)
   ============================================================ */
.sys-status-strip {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 16px;
    background: var(--bg-secondary, #1a1a24);
    border-bottom: 1px solid var(--border-color, #2d2d42);
    scrollbar-width: none;
}
.sys-status-strip::-webkit-scrollbar { display: none; }
.sys-chip {
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color, #2d2d42);
    color: var(--text-secondary, #8888a4);
    white-space: nowrap;
}
.sys-chip.ok {
    color: var(--success, #00b894);
    border-color: rgba(0, 184, 148, 0.35);
    background: rgba(0, 184, 148, 0.1);
}
.sys-chip.off {
    color: #e17055;
    border-color: rgba(225, 112, 85, 0.35);
    background: rgba(225, 112, 85, 0.08);
}
.sys-chip.warn {
    color: #fdcb6e;
    border-color: rgba(253, 203, 110, 0.4);
    background: rgba(253, 203, 110, 0.1);
}
.sys-chip.info {
    color: #74c0fc;
    border-color: rgba(116, 192, 252, 0.35);
    background: rgba(116, 192, 252, 0.08);
}

.mobile-bottom-nav {
    display: none;
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 900;
        background: var(--bg-secondary, #1a1a24);
        border-top: 1px solid var(--border-color, #2d2d42);
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
        justify-content: space-around;
        align-items: stretch;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.35);
    }
    .mob-tab {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-height: 48px;
        text-decoration: none;
        color: var(--text-muted, #5c5c7a);
        font-size: 10px;
        font-weight: 700;
        border-radius: 10px;
        padding: 4px 2px;
    }
    .mob-tab.active {
        color: var(--accent-color, #6c5ce7);
        background: rgba(108, 92, 231, 0.12);
    }
    .mob-icon { font-size: 16px; line-height: 1.2; }
    .mob-label { letter-spacing: 0.02em; }

    /* Room for bottom nav */
    .main-content {
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    }
    .content-area {
        padding-bottom: 24px;
    }
    .sys-status-strip {
        padding: 6px 12px;
    }
    /* Prefer bottom nav over hamburger for primary routes */
    .topbar .page-title {
        font-size: 1rem;
    }
}
