:root {
    --cp-bg-body: #f5f6f8;
    --cp-bg-surface: #ffffff;
    --cp-bg-surface-soft: #f8fafc;
    --cp-bg-surface-muted: #f3f6fa;
    --cp-bg-hero-start: #f8fbff;
    --cp-bg-hero-end: #ffffff;
    --cp-bg-info-soft: #eff6ff;
    --cp-bg-success-soft: #ecfdf3;
    --cp-bg-warning-soft: #fff7ed;
    --cp-bg-warning-soft-2: #fef9c3;
    --cp-bg-danger-soft: #fff1f2;
    --cp-bg-selected: #eef6ff;
    --cp-bg-hover: #f6f9fb;
    --cp-text-strong: #0f172a;
    --cp-text-body: #1f2933;
    --cp-text-muted: #6b7280;
    --cp-text-muted-2: #475569;
    --cp-border: #e5e7eb;
    --cp-border-strong: #d5d8de;
    --cp-border-info: #bfdbfe;
    --cp-border-success: #a7f3d0;
    --cp-border-warning: #fdba74;
    --cp-border-warning-2: #fde68a;
    --cp-border-danger: #fecdd3;
    --cp-border-hero: #dbeafe;
    --cp-accent-info: #1d4ed8;
    --cp-accent-info-strong: #1e3a8a;
    --cp-accent-success: #166534;
    --cp-accent-warning: #c2410c;
    --cp-accent-warning-2: #92400e;
    --cp-accent-danger: #9f1239;
    --cp-accent-danger-2: #881337;
    --cp-shadow-soft: 0 12px 32px rgba(15, 23, 42, 0.05);
    --cp-shadow-hero: 0 18px 44px rgba(15, 23, 42, 0.07);
    --cp-shadow-drawer: 0 20px 48px rgba(15, 23, 42, 0.16);
    --cp-shadow-modal: 0 24px 60px rgba(15, 23, 42, 0.28);
    --bg-body: var(--cp-bg-body);
    --bg-card: var(--cp-bg-surface);
    --bg-card-soft: var(--cp-bg-surface-soft);
    --border: var(--cp-border);
    --border-strong: var(--cp-border-strong);
    --text: var(--cp-text-body);
    --text-strong: var(--cp-text-strong);
    --muted: var(--cp-text-muted);
    --accent: var(--cp-accent-info);
    --accent-strong: var(--cp-accent-info-strong);
    --sidebar: #1e293b;
    --sidebar-muted: #94a3b8;
    --sidebar-active: rgba(59, 130, 246, 0.18);
    --shadow-soft: var(--cp-shadow-soft);
    --ui-font-primary: "Inter","Segoe UI","Noto Sans","Noto Sans Devanagari","Noto Sans Tamil","Noto Sans Telugu","Noto Sans Kannada","Noto Sans Bengali","Noto Sans Gujarati","Noto Sans Arabic",system-ui,-apple-system,sans-serif;
    --ui-font-secondary: "Inter","Segoe UI","Noto Sans","Noto Sans Devanagari","Noto Sans Tamil","Noto Sans Telugu","Noto Sans Kannada","Noto Sans Bengali","Noto Sans Gujarati","Noto Sans Arabic",system-ui,-apple-system,sans-serif;
    --ui-base-font-size: 15px;
}

* { box-sizing: border-box; }

body {
    background: var(--bg-body);
    font-family: var(--ui-font-primary);
    font-size: var(--ui-base-font-size);
    color: var(--text);
    margin: 0;
}

body[data-ui-theme-mode="dark"] {
    --bg-body: #0f172a;
    --bg-card: #111827;
    --bg-card-soft: #172233;
    --border: #334155;
    --border-strong: #475569;
    --text: #e5edf7;
    --text-strong: #f8fafc;
    --muted: #94a3b8;
    --sidebar: #020617;
    --sidebar-muted: #94a3b8;
    --shadow-soft: 0 18px 34px rgba(2, 6, 23, 0.35);
}

@media (prefers-color-scheme: dark) {
    body[data-ui-theme-mode="system"] {
        --bg-body: #0f172a;
        --bg-card: #111827;
        --bg-card-soft: #172233;
        --border: #334155;
        --border-strong: #475569;
        --text: #e5edf7;
        --text-strong: #f8fafc;
        --muted: #94a3b8;
        --sidebar: #020617;
        --sidebar-muted: #94a3b8;
        --shadow-soft: 0 18px 34px rgba(2, 6, 23, 0.35);
    }
}

a { color: inherit; text-decoration: none; }
a:hover { color: inherit; text-decoration: none; }

.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.app-content { flex: 1; padding: 24px 24px 32px; width: 100%; max-width: 1380px; margin: 0 auto; }
.app-content--fluid { max-width: none; margin: 0; }
.app-footer { padding: 14px 24px 18px; color: var(--muted); font-size: 13px; }

.side-panel {
    width: 240px;
    background: var(--sidebar);
    color: #e8ecf2;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,0.04);
}
.side-panel .brand {
    padding: 18px 20px;
    font-weight: 700;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.side-panel .brand .brand-logo {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    object-fit: cover;
}
.topbar-logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    object-fit: cover;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}
.side-panel .brand .env {
    background: rgba(255,255,255,0.08);
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 12px;
}
.side-nav { padding: 12px 8px; flex: 1; overflow-y: auto; }
.side-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: #d5d9e1;
    border-radius: 10px;
    font-size: 14px;
    transition: background 0.12s ease, color 0.12s ease;
}
.nav-label-stack {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.nav-label-primary {
    line-height: 1.3;
}
.nav-label-secondary {
    font-family: var(--ui-font-secondary);
    font-size: 11px;
    line-height: 1.2;
    color: var(--sidebar-muted);
}
.side-nav a .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.35);
}
.side-nav a.active {
    background: var(--sidebar-active);
    color: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.45);
}
.side-nav a.active .dot { background: var(--accent); }
.side-nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.side-nav a.sub {
    padding-left: 26px;
    font-size: 13px;
}
.side-nav a.sub .dot {
    width: 6px;
    height: 6px;
}

.side-nav details.nav-group {
    margin: 2px 0;
}
.side-nav details.nav-group summary {
    list-style: none;
}
.side-nav details.nav-group summary::-webkit-details-marker { display: none; }
.side-nav .nav-group-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: #d5d9e1;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}
.side-nav .nav-group-summary .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.35);
}
.side-nav .nav-group-summary .chev {
    margin-left: auto;
    opacity: 0.75;
    font-size: 12px;
    transition: transform 0.12s ease;
}
.side-nav details.nav-group[open] .nav-group-summary .chev {
    transform: rotate(180deg);
}
.side-nav .nav-group-summary:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}
.side-nav details.nav-group.active > .nav-group-summary {
    background: var(--sidebar-active);
    color: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.45);
}
.side-nav details.nav-group.active > .nav-group-summary .dot {
    background: var(--accent);
}
.side-nav .nav-children {
    padding-left: 8px;
    padding-bottom: 6px;
}
.side-panel .side-footer {
    padding: 12px 14px;
    border-top: 1px solid rgba(255,255,255,0.05);
    font-size: 13px;
    color: var(--sidebar-muted);
}

.top-bar {
    height: 64px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}
.top-bar .title { font-weight: 700; }
.ui-help-menu {
    max-width: 320px;
    padding: 0.35rem 0;
}
.top-bar .badge-env {
    background: var(--cp-bg-info-soft);
    color: var(--accent-strong);
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 12px;
}

.notif-dropdown-menu {
    width: 360px;
    max-width: calc(100vw - 2rem);
}

.notif-bell-list {
    max-height: 320px;
    overflow: auto;
}

.notification-shell {
    position: relative;
    z-index: 1040;
}

.notification-banner-rail {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.notification-toast-stack {
    position: fixed;
    inset-inline-end: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: min(360px, calc(100vw - 32px));
    z-index: 1080;
}

.notification-banner,
.notification-toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 14px;
    box-shadow: var(--shadow-soft);
    padding: 14px 16px;
}

.notification-banner--danger,
.notification-toast--danger,
.notif-item--danger {
    border-left-color: #c0392b;
}

.notification-banner--warning,
.notification-toast--warning,
.notif-item--warning {
    border-left-color: #d4a017;
}

.notification-banner--info,
.notification-toast--info,
.notif-item--info {
    border-left-color: #2563eb;
}

.notification-banner__head,
.notification-toast__head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.notification-banner__title,
.notification-toast__title,
.notif-item__title {
    font-weight: 700;
    color: var(--text);
}

.notification-banner__meta,
.notification-toast__meta,
.notif-item__meta {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.notification-banner__body,
.notification-toast__body,
.notif-item__body {
    color: var(--text);
    margin-top: 8px;
    white-space: normal;
}

.notification-banner__actions,
.notification-toast__actions,
.notif-item__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.notification-close-link {
    color: var(--muted);
    text-decoration: none;
    padding: 0 2px;
}

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

.notif-item__badge {
    flex-shrink: 0;
}

@media (max-width: 767px) {
    .notification-toast-stack {
        inset-inline-end: 12px;
        bottom: 12px;
        width: calc(100vw - 24px);
    }
}

.card-surface {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-soft);
}
.text-muted { color: var(--muted) !important; }
.soft-muted { color: #9aa3b5; }

.btn-ghost {
    border: 1px solid var(--border);
    background: var(--cp-bg-surface-soft);
    color: var(--text);
}
.btn-ghost:hover { background: var(--cp-bg-hover); }

.btn-accent {
    background: var(--accent);
    border: 1px solid var(--accent-strong);
    color: #fff;
}
.btn-accent:hover { background: var(--accent-strong); color: #fff; }

.table-clean {
    width: 100%;
    border-collapse: collapse;
}
.table-clean thead {
    background: var(--cp-bg-surface-muted);
    border-bottom: 1px solid var(--border);
}
.table-clean th, .table-clean td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    vertical-align: middle;
}
.table-clean tbody tr:hover { background: #f6f9fb; }
.table-clean tbody tr.selected { background: var(--cp-bg-selected); }
body[data-ui-theme-mode="dark"] .table-clean tbody tr:hover,
body[data-ui-theme-mode="system"] .table-clean tbody tr:hover {
    background: rgba(148, 163, 184, 0.08);
}

.badge-perm {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--cp-bg-surface-soft);
    color: var(--cp-text-muted-2);
    border-radius: 999px;
    padding: 4px 10px;
    font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
}

.fm-shell { display: flex; flex-direction: column; gap: 16px; }
.fm-head {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}
.fm-path {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.fm-path .crumb {
    background: var(--cp-bg-surface-muted);
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 13px;
}
.fm-path a.crumb { color: inherit; text-decoration: none; }
.fm-path a.crumb:hover { background: var(--cp-bg-hover); }
.fm-path .crumb-link { color: var(--accent); text-decoration: none; font-weight: 700; }
.fm-path .crumb-link:hover { text-decoration: underline; }
.fm-path .crumb-sep { color: #94a3b8; padding: 0 4px; }
.fm-path .crumb-current { color: var(--text-strong); font-weight: 700; }
.fm-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
    position: relative;
}
.fm-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--cp-bg-surface-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-weight: 600;
    font-size: 13px;
    color: #364152;
    box-shadow: inset 0 -1px 0 rgba(255,255,255,0.6);
}
.fm-btn:hover { background: var(--cp-bg-hover); }
.fm-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent-strong); }
.fm-btn.primary:hover { background: var(--accent-strong); }

.fm-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 12px;
}
@media (max-width: 1199px) { .fm-grid { grid-template-columns: 1fr; } }

.fm-side {
    border-right: 1px solid var(--border);
    min-height: 380px;
}
.file-tree { max-height: 70vh; overflow-y: auto; font-size: 13px; }
.file-tree .node { padding: 8px 10px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.file-tree .node.active { background: var(--cp-bg-selected); color: var(--accent); }
.file-tree .name { cursor: pointer; }

.fm-table-card { overflow: hidden; }
.fm-table-card .table-responsive { max-height: 520px; }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--cp-bg-surface-soft);
    padding: 6px 10px;
    border-radius: 12px;
    font-size: 12px;
}

.status-success { color: var(--cp-accent-success); }

#feedbackArea {
    position: fixed;
    top: 82px;
    left: 0;
    right: 0;
    z-index: 1055;
    max-width: 960px;
    margin: 0 auto;
    pointer-events: none;
}
#feedbackArea .alert {
    pointer-events: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.card-hero {
    background:
        radial-gradient(circle at top right, rgba(59, 130, 246, 0.16), transparent 32%),
        linear-gradient(180deg, var(--cp-bg-hero-start) 0%, var(--cp-bg-hero-end) 100%);
    border: 1px solid var(--cp-border-hero);
    border-radius: 14px;
    box-shadow: var(--cp-shadow-hero);
    overflow: hidden;
}
.status-badge { font-size: 0.85rem; padding: 0.4em 0.8em; border-radius: 20px; font-weight: 600; }
.bg-success-soft { background-color: #d1fae5; color: #065f46; }
.bg-warning-soft { background-color: #fef3c7; color: #92400e; }
.main-content { min-height: 80vh; padding-bottom: 2rem; }
.guest-body .app-content { padding-top: 80px; }

.cp-root {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cp-grid-main {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.cp-hero-card,
.cp-shell-card {
    background: var(--cp-bg-surface);
    border-radius: 14px;
}

.cp-hero-card {
    background:
        radial-gradient(circle at top right, rgba(59, 130, 246, 0.16), transparent 32%),
        linear-gradient(180deg, var(--cp-bg-hero-start) 0%, var(--cp-bg-hero-end) 100%);
    border: 1px solid var(--cp-border-hero);
    box-shadow: var(--cp-shadow-hero);
    padding: 18px 20px;
}

.cp-shell-card {
    border: 1px solid var(--cp-border);
    box-shadow: var(--cp-shadow-soft);
    padding: 16px 18px;
}

.cp-soft-block {
    background: var(--cp-bg-surface-soft);
    border: 1px solid var(--cp-border);
    border-radius: 12px;
    padding: 10px;
}

.cp-section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.cp-section-title {
    color: var(--cp-text-strong);
    font-size: 18px;
    font-weight: 600;
}

.cp-meta {
    color: var(--cp-text-muted);
    font-size: 12px;
    line-height: 1.5;
}

.cp-status-strip,
.cp-toolbar {
    display: flex;
    gap: 8px 12px;
    flex-wrap: wrap;
    align-items: center;
}

.cp-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 9px;
    font-size: 11px;
    border: 1px solid var(--cp-border);
    border-radius: 999px;
    background: var(--cp-bg-surface-soft);
    color: var(--cp-text-muted-2);
}

.cp-chip-info { background: var(--cp-bg-info-soft); border-color: var(--cp-border-info); color: var(--cp-accent-info); }
.cp-chip-success { background: var(--cp-bg-success-soft); border-color: var(--cp-border-success); color: var(--cp-accent-success); }
.cp-chip-warning { background: var(--cp-bg-warning-soft); border-color: var(--cp-border-warning); color: var(--cp-accent-warning); }
.cp-chip-review { background: var(--cp-bg-warning-soft-2); border-color: var(--cp-border-warning-2); color: var(--cp-accent-warning-2); }
.cp-chip-danger { background: var(--cp-bg-danger-soft); border-color: var(--cp-border-danger); color: var(--cp-accent-danger); }

.cp-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.cp-table-wrap {
    position: relative;
    overflow: auto;
    max-height: 70vh;
    border: 1px solid var(--cp-border);
    border-radius: 12px;
    background: var(--cp-bg-surface);
}

@media (max-width: 1100px) {
    .cp-grid-main {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 767px) {
    .app-content {
        padding: 18px 14px 26px;
    }

    .cp-hero-card,
    .cp-shell-card {
        padding: 14px 16px;
    }

    .cp-section-head {
        flex-direction: column;
        align-items: stretch;
    }
}
