:root {
    --bg: #0a0a0f;
    --sf: #12121a;
    --sf2: #1a1a26;
    --bd: #2a2a3a;
    --ac: #00e5a0;
    --acd: #00e5a020;
    --acm: #00e5a060;
    --dn: #ff4466;
    --tx: #e8e8f0;
    --txd: #8888a0;
    --txb: #fff;
    --or: #ffaa00;
    --r: 12px;
    --blue: #4488ff;
    --purple: #aa66ff;
    --pink: #ff66aa;
    --sidebar-w: 260px;
}

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

/* ── Scrollbar (dark theme, 75% length) ── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--bd);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--txd); }

/* Shrink scrollbar to ~75% and center it */
::-webkit-scrollbar-track:vertical {
    margin-top: 12.5%; margin-bottom: 12.5%;
}
::-webkit-scrollbar-track:horizontal {
    margin-left: 12.5%; margin-right: 12.5%;
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--bd) transparent;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--tx);
    min-height: 100vh;
}

/* ── Layout Grid ── */
.layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    background: var(--sf);
    border-right: 1px solid var(--bd);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-brand {
    padding: 16px 20px;
    border-bottom: 1px solid var(--bd);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-brand a {
    text-decoration: none;
    color: var(--txb);
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.sidebar-close {
    background: none;
    border: none;
    color: var(--txd);
    font-size: 22px;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 6px;
    line-height: 1;
}

.sidebar-close:hover {
    background: var(--sf2);
    color: var(--tx);
}

.sidebar-brand .brand-dot {
    color: var(--ac);
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.nav-section {
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--txd);
    padding: 8px 12px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--r);
    color: var(--txd);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
    cursor: pointer;
}

.nav-item:hover {
    background: var(--sf2);
    color: var(--tx);
}

.nav-item.active {
    background: var(--acd);
    color: var(--ac);
}

.nav-item .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
    flex-shrink: 0;
}

.nav-item .nav-label {
    flex: 1;
}

.nav-item .nav-arrow {
    font-size: 10px;
    transition: transform 0.2s ease;
    padding: 6px;
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
}

.nav-item .nav-arrow:hover {
    background: var(--sf2);
}

.nav-item .nav-arrow.open {
    transform: rotate(90deg);
}

/* Sub-items (level 2) */
.nav-sub {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.25s ease;
}

.nav-sub.open {
    max-height: 800px;
}

.nav-sub .nav-item {
    padding-left: 44px;
    font-size: 13px;
}

/* Level 2 parent (project with tools) */
.nav-parent-l2 {
    padding-left: 44px;
    font-size: 13px;
}

/* Sub-items (level 3 — tools) */
.nav-sub-l3 {
    transition: max-height 0.2s ease;
}

.nav-sub-l3 .nav-item {
    padding-left: 58px;
    font-size: 12px;
    gap: 6px;
    padding-top: 7px;
    padding-bottom: 7px;
}

.nav-sub-l3 .nav-item .nav-icon {
    width: 16px;
    font-size: 13px;
}

/* ── Sidebar user ── */
.sidebar-user {
    padding: 16px 20px;
    border-top: 1px solid var(--bd);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: auto;
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--tx);
    font-size: 14px;
    min-width: 0;
}

.sidebar-user-info strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── User menu dropdown ── */
.user-menu-wrapper {
    position: relative;
    width: 100%;
}

.user-menu-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0;
    background: none;
    border: none;
    color: var(--tx);
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    text-align: left;
    border-radius: 8px;
    transition: opacity 0.15s ease;
}

.user-menu-btn:hover {
    opacity: 0.85;
}

.user-menu-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--ac);
    color: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.user-menu-name {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.user-menu-name strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu-arrow {
    font-size: 10px;
    color: var(--txd);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.user-menu-wrapper.open .user-menu-arrow {
    transform: rotate(180deg);
}

.user-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--sf2);
    border: 1px solid var(--bd);
    border-radius: var(--r);
    padding: 4px;
    display: none;
    z-index: 200;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4);
}

.user-menu-wrapper.open .user-menu {
    display: block;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--tx);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    background: none;
    border: none;
    width: 100%;
    cursor: pointer;
    transition: background 0.15s ease;
}

.user-menu-item:hover {
    background: var(--sf);
}

.user-menu-icon {
    width: 18px;
    text-align: center;
    font-size: 14px;
    flex-shrink: 0;
}

.user-menu-logout {
    color: var(--dn);
}

.user-menu-logout:hover {
    background: rgba(255, 68, 102, 0.1);
}

.user-menu-divider {
    height: 1px;
    background: var(--bd);
    margin: 4px 8px;
}

/* ── Topbar minimal (mobile only) ── */
.topbar-minimal {
    display: none;
    padding: 12px 16px;
}

.hamburger {
    background: none;
    border: none;
    color: var(--tx);
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}

.hamburger:hover {
    background: var(--sf2);
}

.topbar-badge {
    background: var(--acd);
    color: var(--ac);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.btn-logout {
    background: none;
    border: 1px solid var(--bd);
    color: var(--txd);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.15s ease;
}

.btn-logout:hover {
    border-color: var(--dn);
    color: var(--dn);
}

/* ── Main Content ── */
.main {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

.content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    min-width: 0;
}

/* ── Sidebar backdrop ── */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
}

/* ── Sidebar collapsed (all sizes) ── */
body.sidebar-collapsed .layout {
    grid-template-columns: 1fr;
}

body.sidebar-collapsed .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
}

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

body.sidebar-open .sidebar-backdrop {
    display: block;
}

/* Show hamburger when sidebar is collapsed */
body.sidebar-collapsed .topbar-minimal {
    display: block;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: var(--sidebar-w);
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    .topbar-minimal {
        display: block;
    }

    .content {
        padding: 16px;
    }
}

/* ── Auth Forms (for index.php) ── */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-box {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.auth-logo {
    width: 72px;
    height: 72px;
    background: var(--ac);
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    margin-bottom: 20px;
}

.auth-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--txb);
    margin-bottom: 4px;
}

.auth-title span {
    color: var(--ac);
}

.auth-sub {
    color: var(--txd);
    font-size: 14px;
    margin-bottom: 28px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--sf2);
    border: 1px solid var(--bd);
    border-radius: var(--r);
    color: var(--tx);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease;
}

.auth-input:focus {
    border-color: var(--ac);
}

.auth-input::placeholder {
    color: var(--txd);
}

.auth-btn {
    width: 100%;
    padding: 12px;
    background: var(--ac);
    color: var(--bg);
    border: none;
    border-radius: var(--r);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.auth-btn:hover {
    opacity: 0.9;
}

.auth-toggle {
    margin-top: 16px;
    color: var(--txd);
    font-size: 13px;
}

.auth-toggle a {
    color: var(--ac);
    text-decoration: none;
    font-weight: 500;
}

.auth-toggle a:hover {
    text-decoration: underline;
}

.auth-error {
    background: rgba(255, 68, 102, 0.1);
    border: 1px solid rgba(255, 68, 102, 0.3);
    color: var(--dn);
    padding: 10px 14px;
    border-radius: var(--r);
    font-size: 13px;
    text-align: left;
}

.auth-success {
    background: rgba(0, 229, 160, 0.1);
    border: 1px solid rgba(0, 229, 160, 0.3);
    color: var(--ac);
    padding: 10px 14px;
    border-radius: var(--r);
    font-size: 13px;
    text-align: left;
}

/* ── Dashboard Cards ── */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.dash-card {
    background: var(--sf);
    border: 1px solid var(--bd);
    border-radius: var(--r);
    padding: 24px;
    transition: all 0.2s ease;
    text-decoration: none;
    color: inherit;
    display: block;
}

.dash-card:hover {
    border-color: var(--ac);
    transform: translateY(-2px);
}

.dash-card-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.dash-card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--txb);
    margin-bottom: 4px;
}

.dash-card-desc {
    color: var(--txd);
    font-size: 13px;
}

.dash-card-locked {
    opacity: 0.4;
    pointer-events: none;
}

/* Enriched dashboard cards */
.dash-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}
.dash-card-enriched {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.dash-widgets {
    display: flex;
    gap: 12px;
    border-top: 1px solid var(--bd);
    padding-top: 12px;
}
.dash-widget {
    text-align: center;
    flex: 1;
}
.dash-widget-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--ac);
}
.dash-widget-label {
    font-size: 11px;
    color: var(--txd);
    text-transform: uppercase;
}
.dash-projects {
    border-top: 1px solid var(--bd);
    padding-top: 8px;
}
.dash-project-item {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 13px;
    text-decoration: none;
    color: inherit;
}
.dash-project-item:hover { color: var(--ac); }
.dash-project-name { font-weight: 500; }
.dash-project-tasks { color: var(--txd); font-size: 12px; }
.dash-urgent {
    border-top: 1px solid var(--bd);
    padding-top: 8px;
}
.dash-urgent-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--txd);
    margin-bottom: 4px;
}
.dash-urgent-card {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 13px;
}
.dash-urgent-name { flex: 1; }
.dash-urgent-date {
    font-size: 12px;
    color: var(--txd);
    white-space: nowrap;
    margin-left: 8px;
}
.dash-urgent-date.overdue { color: #ef4444; font-weight: 600; }

/* ── Admin styles ── */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--sf);
    border-radius: var(--r);
    overflow: hidden;
}

.admin-table th,
.admin-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--bd);
    font-size: 14px;
}

.admin-table th {
    background: var(--sf2);
    color: var(--txd);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.admin-table td {
    color: var(--tx);
}

.admin-btn {
    padding: 6px 14px;
    border: 1px solid var(--bd);
    border-radius: 8px;
    background: none;
    color: var(--tx);
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    font-weight: 500;
    transition: all 0.15s ease;
}

.admin-btn:hover {
    background: var(--sf2);
}

.admin-btn.primary {
    background: var(--ac);
    color: var(--bg);
    border-color: var(--ac);
}

.admin-btn.primary:hover {
    opacity: 0.9;
}

.admin-btn.danger {
    border-color: var(--dn);
    color: var(--dn);
}

.admin-btn.danger:hover {
    background: rgba(255, 68, 102, 0.1);
}

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

.admin-stat {
    background: var(--sf);
    border: 1px solid var(--bd);
    border-radius: var(--r);
    padding: 20px;
}

.admin-stat-label {
    font-size: 12px;
    color: var(--txd);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.admin-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--ac);
}

.admin-section {
    margin-bottom: 32px;
}

.admin-section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--txb);
    margin-bottom: 16px;
}

/* Toggle switch */
.toggle-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--sf);
    border: 1px solid var(--bd);
    border-radius: var(--r);
    margin-bottom: 8px;
}

.toggle-label {
    font-size: 14px;
    color: var(--tx);
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--bd);
    border-radius: 24px;
    transition: 0.2s;
}

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

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

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

/* Permissions checkboxes */
.perm-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.perm-check {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--sf2);
    border-radius: 6px;
    font-size: 13px;
    color: var(--txd);
}

.perm-check input[type="checkbox"] {
    accent-color: var(--ac);
}

.perm-check.granted {
    color: var(--ac);
    background: var(--acd);
}

/* ── Page header ── */
.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--txb);
}

.page-header p {
    color: var(--txd);
    font-size: 14px;
    margin-top: 4px;
}

/* ── No access message ── */
.no-access {
    text-align: center;
    padding: 60px 20px;
    color: var(--txd);
}

.no-access-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.no-access h2 {
    color: var(--tx);
    margin-bottom: 8px;
}

/* ── Auth extras (2FA, passkey) ── */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
    color: var(--txd);
    font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    border-top: 1px solid var(--bd);
}

.auth-btn-passkey {
    width: 100%;
    padding: 12px;
    background: var(--sf2);
    color: var(--tx);
    border: 1px solid var(--bd);
    border-radius: var(--r);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.auth-btn-passkey:hover {
    border-color: var(--ac);
    color: var(--ac);
}

.auth-btn-secondary {
    width: 100%;
    padding: 10px;
    background: none;
    color: var(--txd);
    border: 1px solid var(--bd);
    border-radius: var(--r);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
}

.auth-btn-secondary:hover {
    border-color: var(--tx);
    color: var(--tx);
}

.totp-input {
    text-align: center;
    font-size: 24px;
    letter-spacing: 6px;
    font-weight: 600;
}

/* ── Security settings page ── */
.security-card {
    background: var(--sf);
    border: 1px solid var(--bd);
    border-radius: var(--r);
    padding: 20px;
    margin-bottom: 12px;
}

.security-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
}

.security-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.security-status.enabled .status-dot {
    background: var(--ac);
}

.security-status.enabled {
    color: var(--ac);
}

.security-status.disabled .status-dot {
    background: var(--txd);
}

.security-status.disabled {
    color: var(--txd);
}

.security-desc {
    color: var(--txd);
    font-size: 13px;
    line-height: 1.5;
}

.security-msg {
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 8px;
}

.security-msg.success {
    background: rgba(0, 229, 160, 0.1);
    border: 1px solid rgba(0, 229, 160, 0.3);
    color: var(--ac);
}

.security-msg.error {
    background: rgba(255, 68, 102, 0.1);
    border: 1px solid rgba(255, 68, 102, 0.3);
    color: var(--dn);
}

.totp-secret-code {
    display: inline-block;
    background: var(--sf2);
    color: var(--ac);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    letter-spacing: 2px;
    margin-top: 4px;
    user-select: all;
}

.totp-steps {
    font-size: 14px;
    color: var(--tx);
    line-height: 1.6;
}

/* ── Settings form ── */
.settings-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 400px;
}

.settings-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.settings-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--txd);
}
