/* =============================================================
 * DMS Dashboard - Stylesheet
 * ============================================================= */

        :root {
            --primary: #2563eb;
            --primary-dark: #1d4ed8;
            --primary-light: #dbeafe;
            --primary-rgb: 37, 99, 235;
            --secondary: #3b82f6;
            --success: #10b981;
            --danger: #ef4444;
            --warning: #f59e0b;
            --purple: #8b5cf6;
            --teal: #14b8a6;
            --bg: #f8fafc;
            --bg-card: #ffffff;
            --bg-card2: #f1f5f9;
            --border: #e2e8f0;
            --text: #0f172a;
            --text-muted: #475569;
            --text-dim: #64748b;
            --glow: rgba(37, 99, 235, 0.15);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        }

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

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

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

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

        /* ═══════════════ LOGIN ═══════════════ */
        #login-screen {
            width: 100vw; min-height: 100vh;
            display: grid;
            grid-template-columns: 1fr 460px;
        }

        /* Remove .login-split wrapper — #login-screen is the grid now */
        .login-split { display: contents; }

        /* Left: photo panel */
        .login-left {
            position: relative;
            background: url('../img/hacom-tower.jpg') center center / cover no-repeat;
            overflow: hidden;
            min-height: 100vh;
        }
        .login-left-overlay {
            position: absolute; inset: 0;
            background: linear-gradient(to bottom,
                rgba(0,0,0,0.45) 0%,
                rgba(0,0,0,0.15) 50%,
                rgba(37,99,235,0.55) 100%);
        }
        .login-left-logo {
            position: absolute;
            top: 2.5rem; left: 2.5rem;
            height: 44px;
            z-index: 2;
        }

        /* Right: form panel */
        .login-form-panel {
            background: #F6F3EC;
            display: flex; align-items: center; justify-content: center;
            padding: 3rem 2.5rem;
            min-height: 100vh;
        }
        .login-form-wrap { width: 100%; max-width: 360px; }
        .login-form-header { margin-bottom: 2.25rem; }
        .login-form-tag {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            font-size: 0.67rem; font-weight: 700;
            letter-spacing: 0.14em; color: #2563eb;
            margin-bottom: 0.75rem;
        }
        .login-form-header h2 {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            font-size: 1.65rem; font-weight: 800;
            color: #1a1a1a; margin-bottom: 0.35rem;
            letter-spacing: -0.02em;
        }
        .login-form-header p {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            font-size: 0.84rem; color: #8A8A8A;
        }

        .lf-group { margin-bottom: 1.25rem; }
        .lf-label {
            display: block;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            font-size: 0.64rem; font-weight: 700;
            letter-spacing: 0.1em; color: #4B4B4B;
            margin-bottom: 0.5rem;
        }
        .login-field {
            display: flex; align-items: center; gap: 0.65rem;
            background: #fff;
            border: 1px solid #DDD;
            border-bottom: 2px solid #CCC;
            padding: 0 1rem;
            transition: border-color 0.15s;
        }
        .login-field:focus-within {
            border-color: #2563eb;
            border-bottom-color: #2563eb;
        }
        .login-field input {
            flex: 1; border: none; outline: none;
            background: transparent;
            padding: 0.8rem 0;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            font-size: 0.875rem; color: #1a1a1a;
        }
        .login-field input::placeholder { color: #ABABAB; font-weight: 400; }

        .lf-btn {
            width: 100%;
            display: flex; align-items: center; justify-content: center; gap: 0.6rem;
            background: #2563eb; color: #fff;
            border: none; border-radius: 0;
            padding: 1rem 1.5rem;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            font-size: 0.78rem; font-weight: 700;
            letter-spacing: 0.1em; cursor: pointer;
            transition: background 0.2s;
            margin-top: 0.25rem;
        }
        .lf-btn:hover { background: #1d4ed8; }

        .lf-copy {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            font-size: 0.7rem; color: #ABABAB;
            text-align: center; margin-top: 1.75rem; line-height: 1.6;
        }

        @media (max-width: 768px) {
            #login-screen { grid-template-columns: 1fr; }
            .login-left { display: none; }
        }

        .section-label {
            color: var(--text-dim);
            font-size: 0.7rem;
            font-weight: 700;
            letter-spacing: 0.08em;
            text-transform: uppercase;
            margin: 1.5rem 0 0.625rem;
            padding-left: 0.25rem;
        }

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

        /* ═══════════════ LAYOUT ═══════════════ */
        #dashboard {
            display: none;
            height: 100vh;
            overflow: hidden;
        }

        .app-layout {
            display: flex;
            height: 100vh;
            overflow: hidden;
        }

        /* Sidebar */
        .sidebar {
            width: 240px;
            flex-shrink: 0;
            background: var(--bg-card);
            border-right: 1px solid var(--border);
            display: flex;
            flex-direction: column;
            position: sticky;
            top: 0;
            height: 100vh;
            overflow-y: auto;
        }

        .sidebar-logo {
            padding: 1.25rem 1.25rem 1rem;
            border-bottom: 1px solid var(--border);
            font-size: 1.2rem;
            font-weight: 800;
            text-align: center;
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        .user-card {
            padding: 1rem 1.25rem;
            border-bottom: 1px solid var(--border);
            background: var(--bg-card2);
        }

        .user-card .name {
            font-weight: 600;
            font-size: 0.875rem;
            line-height: 1.2;
        }

        .user-card .email {
            color: var(--text-muted);
            font-size: 0.7rem;
            margin-top: 0.2rem;
        }

        .user-card .scope {
            margin-top: 0.625rem;
            display: flex;
            flex-direction: column;
            gap: 0.25rem;
        }

        .scope-item {
            font-size: 0.7rem;
            color: var(--text-dim);
            display: flex;
            align-items: center;
            gap: 0.375rem;
        }

        .nav {
            flex: 1;
            padding: 0.75rem 0.625rem;
        }

        .nav-item {
            display: flex;
            align-items: center;
            gap: 0.625rem;
            padding: 0.625rem 0.75rem;
            border-radius: 8px;
            cursor: pointer;
            font-size: 0.85rem;
            font-weight: 500;
            color: var(--text-muted);
            transition: all 0.15s;
            border: none;
            background: none;
            width: 100%;
            text-align: left;
        }

        .nav-badge {
            margin-left: auto;
            min-width: 22px;
            height: 22px;
            padding: 0 0.35rem;
            border-radius: 999px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            background: linear-gradient(135deg, #ef4444, #dc2626);
            color: #fff;
            font-size: 0.72rem;
            font-weight: 800;
            line-height: 1;
            box-shadow: 0 8px 18px rgba(239, 68, 68, 0.22);
        }

        .nav-item:hover {
            color: var(--text);
            background: var(--bg-card2);
        }

        .nav-item.active {
            color: var(--primary);
            background: var(--primary-light);
            --primary-light: rgba(37, 99, 235, 0.15);
            font-weight: 600;
            border-left: 3px solid var(--primary);
        }

        .nav-item .nav-icon {
            font-size: 1rem;
            width: 20px;
            text-align: center;
        }

        .nav-section-title {
            font-size: 0.65rem;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.08em;
            color: var(--text-dim);
            padding: 0.875rem 0.75rem 0.375rem;
        }

        .sidebar-footer {
            padding: 0.875rem 1.25rem;
            border-top: 1px solid var(--border);
        }

        .btn-logout {
            width: 100%;
            padding: 0.5rem;
            background: rgba(37, 99, 235, 0.1);
            color: #2563eb;
            border: 1px solid rgba(37, 99, 235, 0.3);
            border-radius: 8px;
            cursor: pointer;
            font-size: 0.8rem;
            font-weight: 600;
            transition: all 0.2s;
        }

        .btn-logout:hover {
            background: rgba(37, 99, 235, 0.2);
        }

        /* Main content */
        .main {
            flex: 1;
            height: 100vh;
            overflow-y: auto;
            overflow-x: hidden;
            position: relative;
            scroll-padding-top: 110px;
        }

        .page-header {
            padding: 1.5rem 2rem 1rem;
            border-bottom: 1px solid var(--border);
            position: sticky;
            top: 0;
            background: rgba(255, 255, 255, 0.96);
            backdrop-filter: blur(10px) saturate(180%);
            -webkit-backdrop-filter: blur(10px) saturate(180%);
            z-index: 30;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 1rem;
            flex-wrap: wrap;
            box-shadow: 0 1px 0 rgba(148, 163, 184, 0.18);
        }

        .page-header > :first-child {
            min-width: 0;
            flex: 1 1 320px;
        }

        .page-header > :last-child {
            margin-left: auto;
        }

        .page-title {
            font-size: 1.25rem;
            font-weight: 700;
        }

        .page-subtitle {
            color: var(--text-muted);
            font-size: 0.8rem;
            margin-top: 0.2rem;
        }

        .content {
            padding: 1.5rem 2rem;
        }

        /* Tabs */
        .tab-pane {
            display: none;
        }

        .tab-pane.active {
            display: block;
        }

        /* ═══════════════ COMPONENTS ═══════════════ */
        .card {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 1.5rem;
            margin-bottom: 1.25rem;
        }

        .card-title {
            font-size: 1rem;
            font-weight: 600;
            margin-bottom: 1rem;
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .btn {
            display: inline-flex;
            align-items: center;
            gap: 0.375rem;
            padding: 0.5rem 1rem;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            font-size: 0.85rem;
            font-weight: 600;
            transition: all 0.2s;
            text-decoration: none;
        }

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

        .btn-primary:hover {
            background: var(--primary-dark);
            box-shadow: 0 0 16px var(--glow);
        }

        .btn-success {
            background: var(--success);
            color: white;
        }

        .btn-success:hover {
            background: #059669;
        }

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

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

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

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

        .btn-secondary {
            background: var(--bg-card2);
            color: var(--text);
            border: 1px solid var(--border);
        }

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

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

        .btn-ghost:hover {
            color: var(--text);
            background: var(--bg-card2);
        }

        .btn-sm {
            padding: 0.35rem 0.75rem;
            font-size: 0.78rem;
        }

        .btn-xs {
            padding: 0.25rem 0.5rem;
            font-size: 0.72rem;
            border-radius: 6px;
        }

        .form-group {
            margin-bottom: 1rem;
        }

        .label {
            display: block;
            font-size: 0.8rem;
            font-weight: 600;
            color: var(--text-muted);
            margin-bottom: 0.4rem;
            text-transform: uppercase;
            letter-spacing: 0.04em;
        }

        .input,
        .select,
        .textarea {
            width: 100%;
            background: var(--bg);
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 0.625rem 0.875rem;
            color: var(--text);
            font-size: 0.875rem;
            transition: border-color 0.15s;
        }

        .input:focus,
        .select:focus,
        .textarea:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px var(--glow);
        }

        .select option {
            background: var(--bg-card);
        }

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

        .user-search-dropdown {
            display: none;
            position: absolute;
            top: calc(100% + 0.45rem);
            left: 0;
            right: 0;
            background: var(--bg-card);
            border: 1px solid rgba(148, 163, 184, 0.26);
            border-radius: 16px;
            z-index: 100;
            max-height: 260px;
            overflow-y: auto;
            box-shadow: 0 20px 40px rgba(15, 23, 42, 0.12);
            padding: 0.4rem;
        }

        .user-search-option {
            padding: 0.75rem 0.85rem;
            cursor: pointer;
            font-size: 0.85rem;
            border-radius: 12px;
            transition: background 0.18s ease, transform 0.18s ease;
        }

        .user-search-option:hover {
            background: rgba(var(--primary-rgb), 0.08);
            transform: translateX(2px);
        }

        .user-search-option strong {
            display: block;
            color: var(--text);
            font-size: 0.88rem;
            margin-bottom: 0.12rem;
        }

        .user-search-option span {
            color: var(--text-dim);
            font-size: 0.76rem;
        }

        .user-search-empty {
            padding: 0.8rem 0.9rem;
            color: var(--text-dim);
            font-size: 0.84rem;
        }

        /* Grid */
        .grid-2 {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 1rem;
        }

        .grid-3 {
            display: grid;
            grid-template-columns: 1fr 1fr 1fr;
            gap: 1rem;
        }

        @media(max-width:768px) {

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

        /* Transfer */
        .transfer-content {
            background:
                radial-gradient(circle at top right, rgba(37, 99, 235, 0.08), transparent 28%),
                linear-gradient(180deg, #f8fbff 0%, var(--bg) 28%);
            min-height: calc(100vh - 86px);
        }

        .transfer-hero {
            display: grid;
            grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.85fr);
            gap: 1rem;
            margin-bottom: 1.5rem;
        }

        .transfer-hero-copy,
        .transfer-hero-note,
        .transfer-panel {
            background: rgba(255, 255, 255, 0.88);
            border: 1px solid rgba(148, 163, 184, 0.18);
            border-radius: 24px;
            box-shadow: 0 18px 45px rgba(15, 23, 42, 0.06);
            backdrop-filter: blur(14px);
        }

        .transfer-hero-copy {
            padding: 1.5rem 1.65rem;
        }

        .transfer-eyebrow,
        .transfer-section-tag {
            display: inline-flex;
            align-items: center;
            gap: 0.35rem;
            font-size: 0.72rem;
            font-weight: 700;
            letter-spacing: 0.08em;
            text-transform: uppercase;
            color: var(--primary);
        }

        .transfer-hero-copy h2 {
            margin-top: 0.85rem;
            font-size: 1.65rem;
            line-height: 1.18;
            letter-spacing: -0.03em;
        }

        .transfer-hero-copy p {
            margin-top: 0.75rem;
            color: var(--text-muted);
            font-size: 0.92rem;
            line-height: 1.7;
            max-width: 60ch;
        }

        .transfer-hero-note {
            padding: 1.3rem 1.35rem;
            display: flex;
            gap: 0.9rem;
            align-items: flex-start;
            background: linear-gradient(180deg, rgba(255, 249, 235, 0.96), rgba(255, 255, 255, 0.92));
            border-color: rgba(245, 158, 11, 0.22);
        }

        .transfer-note-icon {
            width: 2.4rem;
            height: 2.4rem;
            border-radius: 14px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            background: rgba(245, 158, 11, 0.15);
            color: #c27d0a;
            flex-shrink: 0;
        }

        .transfer-hero-note strong {
            display: block;
            font-size: 0.95rem;
            color: #8a5b05;
        }

        .transfer-hero-note p {
            margin-top: 0.35rem;
            color: #a16207;
            font-size: 0.84rem;
            line-height: 1.65;
        }

        .transfer-layout {
            display: grid;
            grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.8fr);
            gap: 1.25rem;
            align-items: start;
        }

        .transfer-panel {
            padding: 1.45rem;
        }

        .transfer-panel-head h3,
        .transfer-side-block h3 {
            margin-top: 0.55rem;
            font-size: 1.18rem;
            letter-spacing: -0.02em;
        }

        .transfer-panel-head p {
            margin-top: 0.45rem;
            color: var(--text-muted);
            font-size: 0.88rem;
        }

        .transfer-flow {
            display: grid;
            grid-template-columns: minmax(0, 1fr) 68px minmax(0, 1fr);
            gap: 0.9rem;
            align-items: stretch;
            margin: 1.35rem 0 1.1rem;
        }

        .transfer-party {
            padding: 1.1rem;
            border-radius: 20px;
            border: 1px solid rgba(148, 163, 184, 0.16);
            background: linear-gradient(180deg, rgba(248, 250, 252, 0.94), rgba(255, 255, 255, 0.98));
            min-width: 0;
        }

        .transfer-party-source {
            box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.08);
        }

        .transfer-party-target {
            box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.08);
        }

        .transfer-party-top {
            margin-bottom: 0.85rem;
        }

        .transfer-party-label {
            display: block;
            font-size: 0.86rem;
            font-weight: 700;
            color: var(--text);
        }

        .transfer-party-hint {
            display: block;
            margin-top: 0.2rem;
            font-size: 0.76rem;
            color: var(--text-dim);
        }

        .transfer-search {
            position: relative;
            margin-bottom: 0.8rem;
        }

        .transfer-search-input {
            min-height: 46px;
            border-radius: 14px;
            background: #fff;
        }

        .transfer-flow-arrow {
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--primary);
            background: linear-gradient(180deg, rgba(37, 99, 235, 0.14), rgba(37, 99, 235, 0.04));
            border: 1px solid rgba(37, 99, 235, 0.12);
            border-radius: 20px;
            min-height: 100%;
        }

        .transfer-user-summary {
            border-radius: 16px;
            border: 1px dashed rgba(148, 163, 184, 0.38);
            background: rgba(255, 255, 255, 0.7);
            padding: 0.9rem 1rem;
            min-height: 92px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            gap: 0.28rem;
        }

        .transfer-user-summary.is-empty {
            color: var(--text-dim);
            font-size: 0.83rem;
        }

        .transfer-user-summary strong {
            display: block;
            font-size: 0.92rem;
            color: var(--text);
        }

        .transfer-user-summary .meta {
            color: var(--text-dim);
            font-size: 0.78rem;
            line-height: 1.55;
        }

        .transfer-user-summary .tag-row {
            display: flex;
            flex-wrap: wrap;
            gap: 0.45rem;
            margin-top: 0.15rem;
        }

        .transfer-user-summary .tag {
            display: inline-flex;
            align-items: center;
            border-radius: 999px;
            padding: 0.28rem 0.58rem;
            font-size: 0.72rem;
            font-weight: 600;
            background: rgba(37, 99, 235, 0.08);
            color: var(--primary-dark);
        }

        .transfer-reason {
            min-height: 120px;
            border-radius: 16px;
            background: rgba(255, 255, 255, 0.92);
        }

        .transfer-actions {
            display: flex;
            align-items: center;
            gap: 1rem;
            flex-wrap: wrap;
        }

        .transfer-actions .btn {
            min-height: 46px;
            padding-inline: 1.15rem;
            border-radius: 14px;
        }

        .transfer-actions-note {
            color: var(--text-dim);
            font-size: 0.82rem;
            line-height: 1.6;
            max-width: 34rem;
        }

        .transfer-status {
            margin-top: 1rem;
        }

        .transfer-panel-side {
            display: flex;
            flex-direction: column;
            gap: 1rem;
        }

        .transfer-side-block {
            padding: 0.25rem;
        }

        .transfer-side-block h4 {
            font-size: 0.96rem;
            margin-bottom: 0.85rem;
        }

        .transfer-checklist {
            list-style: none;
            display: flex;
            flex-direction: column;
            gap: 0.72rem;
            margin-top: 1rem;
        }

        .transfer-checklist li {
            position: relative;
            padding-left: 1.45rem;
            color: var(--text-muted);
            font-size: 0.86rem;
            line-height: 1.65;
        }

        .transfer-checklist li::before {
            content: "";
            position: absolute;
            left: 0;
            top: 0.45rem;
            width: 0.52rem;
            height: 0.52rem;
            border-radius: 999px;
            background: linear-gradient(135deg, var(--primary), #60a5fa);
            box-shadow: 0 0 0 5px rgba(var(--primary-rgb), 0.1);
        }

        .transfer-side-block-muted {
            background: linear-gradient(180deg, rgba(241, 245, 249, 0.78), rgba(255, 255, 255, 0.94));
            border-radius: 18px;
            padding: 1rem;
            border: 1px solid rgba(148, 163, 184, 0.18);
        }

        .transfer-mini-stat + .transfer-mini-stat {
            margin-top: 0.9rem;
            padding-top: 0.9rem;
            border-top: 1px solid rgba(148, 163, 184, 0.18);
        }

        .transfer-mini-stat strong {
            display: block;
            font-size: 0.84rem;
            color: var(--text);
            margin-bottom: 0.22rem;
        }

        .transfer-mini-stat span {
            display: block;
            font-size: 0.8rem;
            color: var(--text-muted);
            line-height: 1.6;
        }

        @media(max-width:1100px) {
            .transfer-hero,
            .transfer-layout {
                grid-template-columns: 1fr;
            }
        }

        @media(max-width:768px) {
            .transfer-content {
                min-height: auto;
                padding-bottom: 2rem;
            }

            .transfer-hero-copy h2 {
                font-size: 1.35rem;
            }

            .transfer-flow {
                grid-template-columns: 1fr;
            }

            .transfer-flow-arrow {
                min-height: 58px;
                transform: rotate(90deg);
            }

            .transfer-panel,
            .transfer-hero-copy,
            .transfer-hero-note {
                border-radius: 20px;
            }
        }

        /* Badges */
        .badge {
            display: inline-flex;
            align-items: center;
            padding: 0.2rem 0.6rem;
            border-radius: 20px;
            font-size: 0.7rem;
            font-weight: 700;
            letter-spacing: 0.03em;
        }

        .badge-superadmin {
            background: rgba(139, 92, 246, 0.2);
            color: #a78bfa;
            border: 1px solid rgba(139, 92, 246, 0.3);
        }

        .badge-company_admin {
            background: rgba(239, 68, 68, 0.2);
            color: #fca5a5;
            border: 1px solid rgba(239, 68, 68, 0.3);
        }

        .badge-company_leader {
            background: rgba(245, 158, 11, 0.2);
            color: #fcd34d;
            border: 1px solid rgba(245, 158, 11, 0.3);
        }

        .badge-user {
            background: rgba(16, 185, 129, 0.2);
            color: #6ee7b7;
            border: 1px solid rgba(16, 185, 129, 0.3);
        }

        /* Alert */
        .alert {
            padding: 0.875rem 1rem;
            border-radius: 8px;
            font-size: 0.85rem;
            margin-bottom: 1rem;
            display: flex;
            align-items: flex-start;
            gap: 0.625rem;
        }

        .alert-info {
            background: rgba(14, 165, 233, 0.1);
            border: 1px solid rgba(14, 165, 233, 0.3);
            color: #7dd3fc;
        }

        .alert-success {
            background: rgba(16, 185, 129, 0.1);
            border: 1px solid rgba(16, 185, 129, 0.3);
            color: #6ee7b7;
        }

        .alert-error {
            background: rgba(239, 68, 68, 0.1);
            border: 1px solid rgba(239, 68, 68, 0.3);
            color: #fca5a5;
        }

        .alert-warning {
            background: rgba(245, 158, 11, 0.1);
            border: 1px solid rgba(245, 158, 11, 0.3);
            color: #fcd34d;
        }

        /* Table */
        .table-wrap {
            overflow-x: auto;
            border: 1px solid var(--border);
            border-radius: 8px;
            background: var(--bg-card);
        }

        table {
            width: 100%;
            border-collapse: separate;
            border-spacing: 0;
            font-size: 0.85rem;
        }

        .files-table {
            width: 100%;
            table-layout: fixed;
        }

        th {
            padding: 0.75rem 1rem;
            text-align: center;
            font-size: 0.75rem;
            font-weight: 500;
            color: var(--text-dim);
            border-bottom: 1px solid var(--border);
            white-space: nowrap;
            background: rgba(0,0,0,0.015);
        }

        td {
            padding: 0.625rem 1rem;
            border-bottom: 1px solid var(--border);
            color: var(--text);
            vertical-align: middle;
        }

        .files-table td {
            min-width: 0;
        }

        .file-name-cell {
            min-width: 0;
        }

        .file-name-content {
            flex: 1 1 auto;
            min-width: 0;
            width: 100%;
        }

        .file-name-text {
            display: block;
            min-width: 0;
            max-width: 100%;
            white-space: normal;
            overflow: visible;
            text-overflow: clip;
            word-break: normal;
            overflow-wrap: break-word;
            line-height: 1.45;
        }

        .file-status-cell,
        .file-actions-cell {
            white-space: nowrap;
        }

        .file-status-wrap {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            gap: 0.25rem;
            min-width: 0;
        }

        .file-actions-cell {
            text-align: right;
        }

        .file-actions {
            display: flex;
            align-items: center;
            justify-content: flex-end;
            gap: 0.35rem;
            flex-wrap: nowrap;
            min-width: max-content;
        }

        .file-actions .btn-ghost.btn-xs {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-width: 32px;
            min-height: 32px;
            padding: 0.35rem;
        }

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

        tr:hover td {
            background: rgba(0, 0, 0, 0.02);
        }

        /* Status indicator */
        #toast {
            position: fixed;
            bottom: 1.5rem;
            right: 1.5rem;
            z-index: 9999;
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
        }

        .toast-item {
            padding: 0.875rem 1.25rem;
            border-radius: 10px;
            font-size: 0.85rem;
            font-weight: 500;
            min-width: 280px;
            max-width: 400px;
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
            animation: slideIn 0.25s ease;
            display: flex;
            align-items: center;
            gap: 0.625rem;
        }

        @keyframes slideIn {
            from {
                transform: translateX(100px);
                opacity: 0;
            }

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

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

        .toast-success {
            background: #064e3b;
            border: 1px solid #10b981;
            color: #6ee7b7;
        }

        .toast-error {
            background: #450a0a;
            border: 1px solid #ef4444;
            color: #fca5a5;
        }

        .toast-info {
            background: #082f49;
            border: 1px solid #0ea5e9;
            color: #7dd3fc;
        }

        /* Upload zone */
        .upload-zone {
            border: 2px dashed rgba(37, 99, 235, 0.4);
            border-radius: 16px;
            padding: 1.5rem 2rem;
            text-align: center;
            cursor: pointer;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            background: linear-gradient(180deg, rgba(255, 255, 255, 1) 0%, rgba(219, 234, 254, 0.4) 100%);
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
            position: relative;
            overflow: hidden;
        }

        .upload-zone::before {
            content: '';
            position: absolute;
            inset: 0;
            background: rgba(37, 99, 235, 0.03);
            opacity: 0;
            transition: opacity 0.3s;
        }

        .upload-zone:hover::before,
        .upload-zone.drag::before {
            opacity: 1;
        }

        .upload-zone:hover,
        .upload-zone.drag {
            border-color: var(--primary);
            transform: translateY(-2px);
            box-shadow: 0 10px 25px var(--glow);
        }

        .upload-zone .icon {
            margin-bottom: 0.6rem;
            color: var(--primary);
            position: relative;
            z-index: 1;
            transition: transform 0.3s;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 52px;
            height: 52px;
            background: rgba(37, 99, 235, 0.08);
            border-radius: 50%;
        }

        .upload-zone:hover .icon {
            transform: scale(1.1) translateY(-3px);
            background: rgba(37, 99, 235, 0.15);
        }

        .upload-zone .main-text {
            font-weight: 700;
            font-size: 1rem;
            color: var(--text);
            margin-bottom: 0.25rem;
            position: relative;
            z-index: 1;
        }

        .upload-zone .hint {
            color: var(--text-muted);
            font-size: 0.82rem;
            position: relative;
            z-index: 1;
        }

        .upload-btn-lg {
            background: linear-gradient(135deg, var(--primary), var(--primary-dark));
            border: none;
            padding: 0.65rem 2.25rem;
            color: white;
            font-weight: 700;
            font-size: 1rem;
            border-radius: 50px;
            cursor: pointer;
            box-shadow: 0 4px 15px var(--glow);
            transition: all 0.3s;
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
        }

        .upload-btn-lg:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 25px rgba(37, 99, 235, 0.4);
        }

        /* ─── Upload pane: compact layout ─────────────────────────── */
        #pane-upload .page-header {
            padding: 0.75rem 1.5rem;
        }

        #pane-upload .page-title {
            font-size: 1.3rem !important;
        }

        #pane-upload .content {
            padding: 0.875rem 1.25rem;
        }

        #upload-cards-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 0.875rem;
            align-items: start;
        }

        #upload-cards-grid .card {
            margin-bottom: 0;
            padding: 1rem;
        }

        #upload-cards-grid .card-title {
            font-size: 0.9rem;
            margin-bottom: 0.6rem;
        }

        @media (max-width: 768px) {
            #upload-cards-grid {
                grid-template-columns: 1fr;
            }
        }

        /* Context Menu */
        #file-context-menu {
            display: none;
            position: fixed;
            z-index: 9999;
            min-width: 210px;
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 10px;
            box-shadow: 0 8px 32px rgba(0,0,0,0.35);
            padding: 0.4rem 0;
            animation: ctx-appear 0.12s ease;
            overflow: hidden;
        }
        @keyframes ctx-appear {
            from { opacity: 0; transform: scale(0.95) translateY(-4px); }
            to   { opacity: 1; transform: scale(1) translateY(0); }
        }
        #file-context-menu .ctx-header {
            padding: 0.5rem 1rem 0.4rem;
            font-size: 0.72rem;
            font-weight: 600;
            letter-spacing: 0.06em;
            color: var(--text-muted);
            text-transform: uppercase;
            border-bottom: 1px solid var(--border);
            margin-bottom: 0.25rem;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 200px;
        }
        #file-context-menu .ctx-item {
            display: flex;
            align-items: center;
            gap: 0.6rem;
            padding: 0.55rem 1rem;
            font-size: 0.875rem;
            color: var(--text);
            cursor: pointer;
            transition: background 0.12s;
        }
        #file-context-menu .ctx-item:hover {
            background: rgba(var(--primary-rgb), 0.12);
            color: var(--primary);
        }
        #file-context-menu .ctx-item.ctx-danger:hover {
            background: rgba(239,68,68,0.1);
            color: #ef4444;
        }
        #file-context-menu .ctx-divider {
            height: 1px;
            background: var(--border);
            margin: 0.3rem 0;
        }

        /* Modal */
        .modal {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.7);
            align-items: center;
            justify-content: center;
            z-index: 100;
            padding: 1rem;
            backdrop-filter: blur(4px);
        }

        .modal.open {
            display: flex;
        }

        .modal-box {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 16px;
            padding: 1.75rem;
            width: 100%;
            max-width: 540px;
            max-height: 90vh;
            overflow-y: auto;
        }

        .modal-box-preview {
            max-width: min(1120px, 96vw);
            width: min(1120px, 96vw);
            height: min(88vh, 920px);
            max-height: 92vh;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            position: relative;
            padding: 1rem;
        }

        .preview-close {
            position: absolute;
            top: 0.75rem;
            right: 0.75rem;
            z-index: 2;
            width: 40px;
            height: 40px;
            border-radius: 999px;
            background: rgba(255, 255, 255, 0.94);
            border: 1px solid rgba(148, 163, 184, 0.3);
            box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            color: var(--text);
            font-size: 1.6rem;
            backdrop-filter: blur(10px);
        }

        .modal-head {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 1.5rem;
        }

        .modal-head h3 {
            font-size: 1.05rem;
            font-weight: 700;
        }

        .modal-close {
            background: none;
            border: none;
            color: var(--text-muted);
            font-size: 1.4rem;
            cursor: pointer;
            line-height: 1;
        }

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

        .request-access-modal {
            max-width: 560px;
            padding: 0;
            overflow: hidden;
            border-radius: 22px;
            box-shadow: 0 28px 70px rgba(15, 23, 42, 0.2);
        }

        .request-access-head {
            margin-bottom: 0;
            padding: 1.35rem 1.5rem 1rem;
            background:
                radial-gradient(circle at top right, rgba(59, 130, 246, 0.14), transparent 42%),
                linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
            border-bottom: 1px solid rgba(148, 163, 184, 0.18);
        }

        .request-access-head h3 {
            font-size: 1.1rem;
            letter-spacing: -0.02em;
            color: var(--text);
        }

        .request-access-subtitle {
            margin-top: 0.35rem;
            color: var(--text-dim);
            font-size: 0.84rem;
            line-height: 1.55;
        }

        .request-access-modal .form-group,
        .request-access-file-card,
        .request-access-actions,
        .request-access-status {
            margin-left: 1.5rem;
            margin-right: 1.5rem;
        }

        .request-access-file-card {
            margin-top: 1.2rem;
            margin-bottom: 1.15rem;
            padding: 1rem 1.05rem;
            display: flex;
            align-items: flex-start;
            gap: 0.9rem;
            border: 1px solid rgba(148, 163, 184, 0.18);
            border-radius: 16px;
            background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
        }

        .request-access-file-icon {
            width: 40px;
            height: 40px;
            flex-shrink: 0;
            border-radius: 12px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            background: rgba(var(--primary-rgb), 0.1);
            color: var(--primary);
        }

        .request-access-file-meta {
            min-width: 0;
        }

        .request-access-file-label {
            font-size: 0.72rem;
            font-weight: 700;
            letter-spacing: 0.08em;
            text-transform: uppercase;
            color: var(--text-dim);
            margin-bottom: 0.35rem;
        }

        .request-access-file-name {
            color: var(--text);
            font-size: 0.98rem;
            font-weight: 600;
            line-height: 1.45;
            word-break: break-word;
        }

        .request-access-options {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 0.85rem;
        }

        .request-access-option {
            display: flex;
            align-items: flex-start;
            gap: 0.65rem;
            padding: 0.9rem 0.95rem;
            border-radius: 14px;
            border: 1px solid rgba(148, 163, 184, 0.22);
            background: #fff;
            transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
            cursor: pointer;
        }

        .request-access-option:hover {
            border-color: rgba(var(--primary-rgb), 0.34);
            box-shadow: 0 10px 24px rgba(37, 99, 235, 0.08);
            transform: translateY(-1px);
        }

        .request-access-option input {
            margin-top: 0.15rem;
            flex-shrink: 0;
        }

        .request-access-option-copy {
            display: flex;
            flex-direction: column;
            gap: 0.18rem;
            color: var(--text);
        }

        .request-access-option-copy strong {
            font-size: 0.92rem;
            font-weight: 700;
        }

        .request-access-option-copy small {
            color: var(--text-dim);
            font-size: 0.76rem;
            line-height: 1.45;
        }

        .request-access-reason {
            min-height: 110px;
            background: #fff;
        }

        .request-access-actions {
            display: flex;
            justify-content: flex-start;
            padding-bottom: 1.35rem;
        }

        .request-access-submit {
            min-width: 164px;
            justify-content: center;
            border-radius: 12px;
            box-shadow: 0 12px 28px rgba(37, 99, 235, 0.2);
        }

        .request-access-status {
            margin-top: -0.35rem;
            padding-bottom: 1.35rem;
        }

        @media (max-width: 640px) {
            .request-access-modal {
                max-width: 100%;
            }

            .request-access-options {
                grid-template-columns: 1fr;
            }

            .request-access-modal .form-group,
            .request-access-file-card,
            .request-access-actions,
            .request-access-status {
                margin-left: 1rem;
                margin-right: 1rem;
            }

            .request-access-head {
                padding-left: 1rem;
                padding-right: 1rem;
            }
        }

        /* Scope info panel */
        .scope-panel {
            background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(14, 165, 233, 0.08));
            border: 1px solid rgba(99, 102, 241, 0.2);
            border-radius: 12px;
            padding: 1.25rem;
            margin-bottom: 1.25rem;
        }

        .scope-panel h4 {
            color: var(--primary);
            font-size: 0.8rem;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.06em;
            margin-bottom: 0.75rem;
        }

        .scope-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0.3rem 0;
            font-size: 0.85rem;
        }

        .scope-row span:first-child {
            color: var(--text-muted);
        }

        .scope-row span:last-child {
            color: var(--text);
            font-weight: 500;
        }

        .file-preview-body {
            min-height: 0;
            height: 100%;
            border: 1px solid var(--border);
            border-radius: 14px;
            background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
            overflow: hidden;
            display: flex;
            flex: 1 1 auto;
        }

        .file-preview-frame,
        .file-preview-image,
        .file-preview-video {
            width: 100%;
            height: 100%;
            min-height: 0;
            flex: 1 1 auto;
            display: block;
            border: none;
            background: #fff;
        }

        .file-preview-image {
            object-fit: contain;
            padding: 1rem;
        }

        .file-preview-audio-wrap,
        .file-preview-text-wrap,
        .file-preview-fallback {
            width: 100%;
            height: 100%;
            padding: 1.25rem;
            flex: 1 1 auto;
        }

        .file-preview-audio-wrap,
        .file-preview-fallback {
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .file-preview-audio-card,
        .file-preview-fallback-card {
            width: min(100%, 720px);
            background: rgba(255, 255, 255, 0.92);
            border: 1px solid rgba(148, 163, 184, 0.28);
            border-radius: 16px;
            box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
            padding: 1.25rem;
        }

        .file-preview-audio-card audio {
            width: 100%;
            margin-top: 1rem;
        }

        .file-preview-text-wrap {
            overflow: auto;
            background: #0f172a;
        }

        .file-preview-text {
            margin: 0;
            min-height: 100%;
            font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
            font-size: 0.82rem;
            line-height: 1.6;
            color: #e2e8f0;
            white-space: pre-wrap;
            word-break: break-word;
        }

        .file-preview-fallback-card p {
            color: var(--text-muted);
            line-height: 1.6;
            margin-bottom: 1rem;
        }

        @media (max-width: 768px) {
            .modal-box-preview {
                height: 92vh;
                max-height: 92vh;
                padding: 0.75rem;
            }

            .file-preview-body {
                height: 100%;
            }
        }

        /* Feature tree */
        .tree-node {
            padding: 0.375rem 0;
        }

        .tree-label {
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            cursor: pointer;
            padding: 0.375rem 0.625rem;
            border-radius: 6px;
            transition: background 0.15s;
            font-size: 0.85rem;
        }

        .tree-label:hover {
            background: var(--bg-card2);
        }

        .tree-children {
            margin-left: 1.25rem;
            border-left: 1px dashed var(--border);
            padding-left: 0.875rem;
        }

        .tree-toggle {
            color: var(--text-dim);
            font-size: 0.7rem;
        }

        /* Permission readonly indicator */
        .perm-readonly {
            display: flex;
            align-items: center;
            gap: 0.375rem;
            padding: 0.5rem 0.875rem;
            background: rgba(245, 158, 11, 0.1);
            border: 1px solid rgba(245, 158, 11, 0.25);
            border-radius: 8px;
            color: #fcd34d;
            font-size: 0.8rem;
            font-weight: 500;
        }

        /* Stats mini */
        .stat-mini {
            background: var(--bg-card2);
            border: 1px solid var(--border);
            border-radius: 10px;
            padding: 1rem 1.25rem;
            text-align: center;
        }

        .stat-mini .num {
            font-size: 1.75rem;
            font-weight: 800;
            line-height: 1;
        }

        .stat-mini .label {
            color: var(--text-muted);
            font-size: 0.75rem;
            margin-top: 0.25rem;
        }

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

        .spinner {
            width: 32px;
            height: 32px;
            border: 3px solid var(--border);
            border-top-color: var(--primary);
            border-radius: 50%;
            animation: spin 0.6s linear infinite;
            margin: 0 auto 1rem;
        }

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

        .empty .icon {
            font-size: 2.5rem;
            margin-bottom: 0.75rem;
        }

        .empty p {
            font-size: 0.9rem;
        }

        /* Chip */
        .chip {
            display: inline-flex;
            align-items: center;
            padding: 0.2rem 0.5rem;
            background: var(--bg-card2);
            border: 1px solid var(--border);
            border-radius: 20px;
            font-size: 0.72rem;
            color: var(--text-muted);
            gap: 0.25rem;
        }

        /* Divider */
        .divider {
            border: none;
            border-top: 1px solid var(--border);
            margin: 1.25rem 0;
        }

        /* Hide Permissions menu */
        #nav-permissions,
        #pane-permissions {
            display: none !important;
        }
