:root {
    --bg: #eef2f7;
    --panel: #ffffff;
    --panel-soft: #f7f9fc;
    --text: #111827;
    --muted: #64748b;
    --border: #d9e2ef;
    --shadow: 0 18px 50px rgba(15, 23, 42, .13);
    --sidebar: #0f172a;
    --sidebar-2: #111c33;
    --accent: #2563eb;
    --danger: #dc2626;
    --ok: #15803d;
    --warn: #b45309;
    --taskbar-height: 46px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: radial-gradient(circle at top left, #dbeafe 0, #eef2f7 31%, #edf1f6 100%);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.intra-app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px 1fr;
    transition: opacity .2s ease;
}
.intra-app.is-loading { opacity: .55; }

.intra-sidebar {
    min-height: 100vh;
    background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
    color: #e5e7eb;
    display: flex;
    flex-direction: column;
    padding: 18px;
    position: sticky;
    top: 0;
}
.intra-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 8px 22px;
}
.intra-brand__mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: #2563eb;
    color: white;
    font-weight: 800;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.25);
}
.intra-brand strong { display: block; font-size: 16px; }
.intra-brand span { display: block; color: #9ca3af; font-size: 12px; margin-top: 2px; }

.intra-nav { display: flex; flex-direction: column; gap: 7px; }
.intra-nav button {
    border: 0;
    background: transparent;
    color: #cbd5e1;
    text-align: left;
    border-radius: 12px;
    padding: 11px 12px;
    display: flex;
    gap: 10px;
    align-items: center;
}
.intra-nav button:hover { background: rgba(255,255,255,.08); color: #fff; }
.intra-nav button.is-active { background: #2563eb; color: #fff; }
.intra-nav small { margin-left: auto; color: rgba(255,255,255,.7); }

.intra-sidebar-footer {
    margin-top: auto;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 16px;
    padding: 12px;
    color: #cbd5e1;
    font-size: 12px;
}
.intra-sidebar-footer strong { color: #fff; display: block; margin-bottom: 4px; }
.intra-badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.intra-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border-radius: 999px;
    padding: 3px 8px;
    background: rgba(37, 99, 235, .13);
    color: #bfdbfe;
    border: 1px solid rgba(147,197,253,.2);
    font-size: 11px;
}
.intra-badge.ok { background: rgba(21,128,61,.15); color: #bbf7d0; }
.intra-badge.warn { background: rgba(180,83,9,.15); color: #fde68a; }

.intra-main {
    min-width: 0;
    padding: 26px 30px calc(var(--taskbar-height) + 26px);
}
.intra-topbar {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
    margin-bottom: 22px;
}
.intra-topbar h1 { margin: 0; font-size: 34px; letter-spacing: -.04em; }
.intra-topbar p { margin: 6px 0 0; color: var(--muted); }
.intra-status {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}
.intra-status-pill {
    background: rgba(255,255,255,.76);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 12px;
    box-shadow: 0 5px 18px rgba(15,23,42,.06);
    font-size: 12px;
    color: #334155;
}

.intra-card {
    background: rgba(255,255,255,.86);
    border: 1px solid rgba(217,226,239,.86);
    border-radius: 24px;
    padding: 22px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}
.intra-grid { display: grid; gap: 18px; }
.intra-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.intra-kpi {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 18px;
}
.intra-kpi span { color: var(--muted); font-size: 13px; }
.intra-kpi strong { display: block; font-size: 30px; margin-top: 8px; }

.intra-button {
    border: 1px solid var(--border);
    background: #fff;
    color: #111827;
    border-radius: 12px;
    padding: 9px 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.intra-button:hover { border-color: #bfdbfe; background: #f8fbff; }
.intra-button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.intra-button.danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.intra-button.small { padding: 6px 9px; font-size: 12px; border-radius: 9px; }
.intra-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.intra-form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.intra-field { display: grid; gap: 6px; }
.intra-field label { color: #475569; font-size: 12px; font-weight: 650; }
.intra-field input, .intra-field select, .intra-field textarea {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 12px;
    padding: 10px 11px;
    min-width: 0;
}
.intra-field input:focus, .intra-field select:focus, .intra-field textarea:focus { outline: 2px solid #bfdbfe; border-color: #60a5fa; }

.cvd-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 14px;
}
.cvd-area-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.cvd-area-tabs button {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 999px;
    padding: 8px 12px;
}
.cvd-area-tabs button.is-active { background: #111827; color: #fff; border-color: #111827; }
.cvd-calendar {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 10px 28px rgba(15,23,42,.08);
    user-select: none;
}
.cvd-calendar-head, .cvd-calendar-row {
    display: grid;
    grid-template-columns: 78px repeat(7, minmax(120px, 1fr));
}
.cvd-calendar-head {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}
.cvd-calendar-head div {
    padding: 13px 10px;
    font-weight: 700;
    font-size: 12px;
    color: #475569;
    border-right: 1px solid var(--border);
}
.cvd-calendar-head div:last-child { border-right: 0; }
.cvd-calendar-body { max-height: calc(100vh - 240px); overflow: auto; }
.cvd-time {
    background: #f8fafc;
    color: #64748b;
    font-weight: 700;
    font-size: 12px;
    padding: 12px 10px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.cvd-slot {
    min-height: 58px;
    padding: 7px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: #fff;
    position: relative;
}
.cvd-slot:hover { background: #f8fbff; }
.cvd-slot.is-selected { outline: 2px solid #2563eb; outline-offset: -2px; background: #eff6ff; }
.cvd-slot.has-assignment { background: #f0fdf4; }
.cvd-slot.has-assignment.is-selected { background: #dcfce7; }
.cvd-assignment-pill {
    display: block;
    border-radius: 12px;
    padding: 7px 8px;
    background: rgba(21,128,61,.11);
    color: #166534;
    border: 1px solid rgba(21,128,61,.2);
    font-size: 12px;
    line-height: 1.25;
}
.cvd-assignment-pill strong { display: block; font-size: 12px; }
.cvd-slot-empty { color: #cbd5e1; font-size: 12px; }

.intra-context-menu {
    position: fixed;
    z-index: 200000;
    min-width: 220px;
    background: rgba(15,23,42,.97);
    color: #e5e7eb;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,.35);
    padding: 7px;
    backdrop-filter: blur(16px);
}
.intra-context-item {
    position: relative;
    border-radius: 10px;
    padding: 9px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    white-space: nowrap;
    color: #e5e7eb;
}
.intra-context-item:hover { background: rgba(255,255,255,.1); }
.intra-context-item.danger { color: #fecaca; }
.intra-context-separator { height: 1px; background: rgba(255,255,255,.12); margin: 6px 4px; }
.intra-context-submenu {
    position: absolute;
    top: -7px;
    left: calc(100% + 7px);
    display: none;
    min-width: 240px;
    background: rgba(15,23,42,.98);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 14px;
    padding: 7px;
    box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.intra-context-item:hover > .intra-context-submenu { display: block; }
.intra-context-subbutton {
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    color: #e5e7eb;
    border-radius: 10px;
    padding: 9px 10px;
}
.intra-context-subbutton:hover { background: rgba(255,255,255,.1); }
.intra-context-hint { color: #94a3b8; font-size: 12px; padding: 7px 10px; }

.intra-table { width: 100%; border-collapse: collapse; }
.intra-table th, .intra-table td { padding: 11px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.intra-table th { font-size: 12px; color: #64748b; background: #f8fafc; }
.intra-table tr:last-child td { border-bottom: 0; }

.intra-debug-window {
    position: fixed;
    z-index: 100000;
    min-width: 380px;
    min-height: 220px;
    width: 540px;
    height: 520px;
    background: rgba(15, 23, 42, .90);
    color: #e5e7eb;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 16px;
    box-shadow: 0 20px 70px rgba(0,0,0,.4);
    overflow: hidden;
    resize: both;
    backdrop-filter: blur(18px);
}
.intra-debug-window.is-minimized { display: none; }
.intra-debug-titlebar {
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 10px 0 14px;
    background: rgba(255,255,255,.08);
    border-bottom: 1px solid rgba(255,255,255,.11);
    cursor: move;
}
.intra-debug-titlebar strong { font-size: 13px; }
.intra-window-controls { display: flex; gap: 6px; }
.intra-window-controls button {
    width: 28px;
    height: 26px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 8px;
    background: rgba(255,255,255,.08);
    color: #e5e7eb;
}
.intra-window-controls button:hover { background: rgba(255,255,255,.18); }
.intra-debug-body {
    height: calc(100% - 42px);
    overflow: auto;
    padding: 14px;
}
.intra-debug-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.intra-debug-tabs button {
    border: 1px solid rgba(255,255,255,.12);
    background: rgba(255,255,255,.07);
    color: #cbd5e1;
    border-radius: 999px;
    padding: 7px 10px;
    font-size: 12px;
}
.intra-debug-tabs button.is-active { background: #2563eb; color: #fff; border-color: #2563eb; }
.intra-debug-panel { display: grid; gap: 12px; }
.intra-debug-window label { color: #cbd5e1; font-size: 12px; display: block; margin-bottom: 6px; }
.intra-debug-window select, .intra-debug-window input {
    width: 100%;
    border: 1px solid rgba(255,255,255,.16);
    background: rgba(255,255,255,.08);
    color: #fff;
    border-radius: 10px;
    padding: 9px 10px;
}
.intra-debug-window option { background: #111827; color: #fff; }
.intra-debug-checklist {
    display: grid;
    gap: 7px;
    max-height: 190px;
    overflow: auto;
    border: 1px solid rgba(255,255,255,.11);
    border-radius: 12px;
    padding: 8px;
    background: rgba(0,0,0,.12);
}
.intra-debug-checklist label { display: flex; gap: 8px; align-items: center; margin: 0; }
.intra-debug-checklist input { width: auto; }
.intra-debug-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.intra-debug-button {
    border: 1px solid rgba(255,255,255,.14);
    background: #2563eb;
    color: #fff;
    border-radius: 10px;
    padding: 9px 11px;
}
.intra-debug-button.secondary { background: rgba(255,255,255,.08); }
.intra-debug-code {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    background: rgba(0,0,0,.20);
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 12px;
    padding: 10px;
}

.intra-taskbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--taskbar-height);
    z-index: 99999;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: rgba(15, 23, 42, .88);
    border-top: 1px solid rgba(255,255,255,.14);
    backdrop-filter: blur(18px);
}
.intra-taskbar[hidden] { display: none; }
.intra-taskbar button {
    height: 32px;
    border: 1px solid rgba(255,255,255,.16);
    background: rgba(255,255,255,.09);
    color: #e5e7eb;
    border-radius: 10px;
    padding: 0 12px;
}
.intra-taskbar button:hover { background: rgba(255,255,255,.18); }

.intra-toast {
    position: fixed;
    right: 18px;
    bottom: calc(var(--taskbar-height) + 18px);
    z-index: 300000;
    max-width: 420px;
    background: rgba(15,23,42,.95);
    color: #fff;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,.32);
}
.intra-toast[hidden] { display: none; }

@media (max-width: 980px) {
    .intra-app { grid-template-columns: 1fr; }
    .intra-sidebar { min-height: auto; position: relative; }
    .intra-main { padding: 18px 14px calc(var(--taskbar-height) + 18px); }
    .intra-grid.cols-3, .intra-form-grid { grid-template-columns: 1fr; }
    .cvd-calendar-head, .cvd-calendar-row { grid-template-columns: 64px repeat(7, 150px); }
    .intra-debug-window { width: calc(100vw - 24px); left: 12px !important; }
}
