:root {
    --bg: #0f1115;
    --surface: #171923;
    --surface-2: #1d2230;
    --sidebar: #11131a;
    --border: #252938;
    --text: #f5f7fb;
    --muted: #9ca3af;
    --accent: #4f46e5;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --shadow: 0 24px 80px rgba(0, 0, 0, .28);
}

[data-bs-theme="light"] {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #eef2f8;
    --sidebar: #ffffff;
    --border: #d9deea;
    --text: #151821;
    --muted: #647084;
    --shadow: 0 24px 80px rgba(32, 45, 80, .12);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, sans-serif;
    letter-spacing: 0;
}

button, input, select, textarea { font: inherit; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 280px minmax(0, 1fr); }
.app-shell.is-locked { filter: blur(10px); pointer-events: none; user-select: none; }

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: color-mix(in srgb, var(--sidebar) 92%, transparent);
    border-right: 1px solid var(--border);
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.brand-block { display: flex; align-items: center; gap: 12px; padding: 0 6px; }
.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    color: white;
    background: linear-gradient(135deg, var(--accent), #0ea5e9);
    font: 700 13px Poppins, sans-serif;
    box-shadow: 0 12px 32px rgba(79, 70, 229, .35);
}
.brand-name { font-weight: 800; font-family: Poppins, sans-serif; }
.brand-subtitle { color: var(--muted); font-size: 12px; }

.nav-stack { display: grid; gap: 6px; }
.nav-item, .command-hint, .theme-toggle, .icon-button, .search-pill, .avatar-button {
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    border-radius: 12px;
    transition: 180ms ease;
}
.nav-item {
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    text-align: left;
}
.nav-item:hover, .nav-item.active { color: var(--text); background: var(--surface-2); border-color: var(--border); }
.nav-item i { font-size: 17px; }

.sidebar-footer { margin-top: auto; display: grid; grid-template-columns: 1fr 44px; gap: 8px; }
.command-hint { min-height: 44px; display: flex; align-items: center; gap: 8px; justify-content: center; background: var(--surface); border-color: var(--border); }
kbd { background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); font: 500 11px "JetBrains Mono", monospace; }
.theme-toggle, .icon-button { min-width: 44px; min-height: 44px; background: var(--surface); border-color: var(--border); }

.workspace { min-width: 0; padding: 22px; display: grid; gap: 20px; align-content: start; }
.topbar { display: flex; align-items: center; gap: 16px; }
.title-cluster { margin-right: auto; }
.title-cluster p, .section-heading p { margin: 0 0 4px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0; }
.title-cluster h1 { margin: 0; font: 700 24px Poppins, sans-serif; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.search-pill {
    min-height: 42px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border-color: var(--border);
    min-width: 300px;
}
.btn { border-radius: 12px; min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.avatar-button { width: 42px; height: 42px; background: var(--surface-2); border-color: var(--border); color: var(--text); font-weight: 800; }

.insight-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.insight-strip article, .ops-panel, .task-card, .auth-panel {
    background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 96%, white 4%), var(--surface));
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
}
.insight-strip article { min-height: 100px; padding: 16px; position: relative; overflow: hidden; }
.insight-strip span { color: var(--muted); font-size: 13px; }
.insight-strip strong { display: block; margin-top: 8px; font-size: 28px; font-weight: 800; }
.insight-strip i { position: absolute; right: 16px; bottom: 14px; color: var(--muted); font-size: 22px; }

.view-panel { display: none; animation: lift .18s ease; }
.view-panel.active { display: grid; gap: 16px; }
@keyframes lift { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.section-heading h2 { margin: 0; font: 700 22px Poppins, sans-serif; max-width: 820px; }

.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 14px; }
.ops-panel { padding: 18px; min-height: 180px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel-head h3 { margin: 0; font-size: 15px; font-weight: 800; }
.panel-head span, .muted-copy { color: var(--muted); }
.health-ring { width: 132px; height: 132px; margin: 10px auto; border-radius: 50%; display: grid; place-items: center; border: 12px solid color-mix(in srgb, var(--success) 70%, var(--surface)); }
.health-ring span { font-size: 34px; font-weight: 800; }
.health-ring small { margin-top: -32px; color: var(--muted); }

.quick-capture, .task-toolbar { display: flex; gap: 10px; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 12px;
    min-height: 44px;
    padding: 10px 12px;
    outline: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent); }
.task-toolbar select { max-width: 220px; }
.task-list { display: grid; gap: 10px; }
.task-card { padding: 14px; display: grid; gap: 10px; cursor: pointer; box-shadow: none; }
.task-card:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); }
.task-card-header { display: flex; gap: 10px; align-items: start; justify-content: space-between; }
.task-card h3 { margin: 0; font-size: 15px; font-weight: 800; }
.task-card p { margin: 0; color: var(--muted); font-size: 13px; }
.task-meta { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--border); border-radius: 999px; padding: 4px 8px; color: var(--muted); font-size: 12px; }
.priority-Critical { color: var(--danger); }
.priority-High { color: var(--warning); }
.priority-Medium { color: var(--info); }
.priority-Low { color: var(--success); }

.kanban-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(280px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kanban-column { min-height: 420px; background: color-mix(in srgb, var(--surface) 80%, transparent); border: 1px solid var(--border); border-radius: 16px; padding: 12px; }
.kanban-column h3 { margin: 0 0 12px; font-size: 14px; }
.kanban-column.is-over { border-color: var(--accent); }

.calendar-list, .activity-feed, .settings-grid, .analytics-layout { display: grid; gap: 12px; }
.analytics-layout { grid-template-columns: 1fr 1fr; }
.calendar-item, .activity-item {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
}
.settings-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.settings-grid label, .task-form-grid label { display: grid; gap: 7px; color: var(--muted); }

.auth-screen { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(15, 17, 21, .88); z-index: 2000; padding: 18px; }
.auth-panel { width: min(420px, 100%); padding: 28px; text-align: center; }
.auth-panel h2 { margin: 14px 0 4px; font: 800 28px Poppins, sans-serif; }
.auth-panel p { color: var(--muted); }
.auth-panel form { display: grid; gap: 12px; margin-top: 20px; }
.auth-panel small { min-height: 20px; color: var(--muted); }

.modal-content { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }
.task-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.task-form-grid .full { grid-column: 1 / -1; }

.command-palette { position: fixed; inset: 0; background: rgba(0,0,0,.42); display: none; place-items: start center; padding-top: 12vh; z-index: 1500; }
.command-palette.open { display: grid; }
.command-box { width: min(680px, calc(100% - 24px)); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 10px; }
#commandResults { display: grid; gap: 6px; margin-top: 8px; max-height: 360px; overflow: auto; }
.command-result { border: 0; width: 100%; text-align: left; background: transparent; color: var(--text); padding: 10px; border-radius: 10px; }
.command-result:hover { background: var(--surface-2); }
.floating-action { display: none; position: fixed; right: 18px; bottom: 18px; width: 54px; height: 54px; border-radius: 18px; border: 0; background: var(--accent); color: white; box-shadow: var(--shadow); z-index: 1200; }

@media (max-width: 1100px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 1300; transform: translateX(-100%); transition: 220ms ease; }
    .sidebar.open { transform: translateX(0); }
    .search-pill { min-width: 0; }
    .search-pill span, .search-pill kbd { display: none; }
    .insight-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-grid, .analytics-layout, .settings-grid { grid-template-columns: 1fr; }
    .floating-action { display: grid; place-items: center; }
}

@media (max-width: 640px) {
    .workspace { padding: 14px; }
    .topbar { flex-wrap: wrap; }
    .topbar-actions { width: 100%; justify-content: space-between; }
    .title-cluster h1 { font-size: 20px; }
    .insight-strip { grid-template-columns: 1fr; }
    .quick-capture, .task-toolbar { flex-direction: column; }
    .task-form-grid { grid-template-columns: 1fr; }
    .btn span { display: none; }
}
