/* Cerebro — light, card-based "liquid glass" theme on top of Bootstrap 5.3 */
:root {
  --ink: #1b1d22;
  --muted: #5a6070;
  --accent: #0a66e8;
  --accent-ink: #ffffff;
  --glass: rgba(255, 255, 255, 0.58);
  --glass-strong: rgba(255, 255, 255, 0.86);
  --stroke: rgba(255, 255, 255, 0.85);
  --hairline: rgba(27, 29, 34, 0.08);
  --radius: 24px;
  --shadow: 0 12px 40px rgba(40, 60, 120, 0.12), 0 2px 6px rgba(40, 60, 120, 0.06);
  --nav-w: 256px;
  /* Row colours from the specification */
  --row-danger: #e74c3c;
  --row-success: #28b463;
  --row-info: #3498db;
  --row-muted: #8a909c;
  --bs-primary: #0a66e8;
  --bs-primary-rgb: 10, 102, 232;
  --bs-body-color: #1b1d22;
  --bs-body-bg: #f2f5fb;
  --bs-border-radius: 14px;
  --bs-font-sans-serif: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body { min-height: 100vh; color: var(--ink); -webkit-font-smoothing: antialiased; }
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(46rem 40rem at 6% -8%, #cfe2ff 0, rgba(207, 226, 255, 0) 62%),
    radial-gradient(40rem 36rem at 102% 4%, #ffd9ea 0, rgba(255, 217, 234, 0) 60%),
    radial-gradient(44rem 40rem at 62% 108%, #d3f4e4 0, rgba(211, 244, 228, 0) 60%),
    radial-gradient(30rem 28rem at 30% 60%, #fff3cf 0, rgba(255, 243, 207, 0) 60%),
    #f2f5fb;
}

/* Glass surfaces */
.glass, .glass-strong, .glass-menu {
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.95), inset 0 -1px 0 rgba(255, 255, 255, 0.35);
}
.glass-strong, .glass-menu { background: var(--glass-strong); }
.card-glass { padding: 1.25rem; transition: transform 0.25s ease, box-shadow 0.25s ease; }
.card-glass.lift:hover { transform: translateY(-3px); box-shadow: 0 18px 48px rgba(40, 60, 120, 0.16), inset 0 1px 0 #fff; }

.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* Sign-in and status screens */
.screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 420px; padding: 2.25rem; text-align: center; }
.brand-mark { width: 64px; height: 64px; margin: 0 auto 1rem; border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #fff 0 12%, transparent 13% 34%, rgba(255,255,255,.9) 35% 42%, transparent 43%), linear-gradient(140deg, #0a66e8, #6aa8ff);
  box-shadow: 0 8px 24px rgba(10, 102, 232, 0.35), inset 0 1px 0 rgba(255,255,255,.6); }
.brand-mark.sm { width: 32px; height: 32px; margin: 0; box-shadow: 0 4px 12px rgba(10, 102, 232, 0.3); }

/* Shell layout */
#shell { display: flex; gap: 16px; padding: 16px; min-height: 100vh; }
#sidebar { position: sticky; top: 16px; align-self: flex-start; width: var(--nav-w); height: calc(100vh - 32px); flex: none; display: flex; flex-direction: column; padding: 16px 12px; overflow-y: auto; transition: width 0.3s cubic-bezier(.2,.8,.2,1), transform 0.3s cubic-bezier(.2,.8,.2,1); z-index: 1040; }
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 14px; }
.brand-name { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; }
.nav-group { padding: 14px 12px 6px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.nav-link-x { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 14px; color: var(--ink); text-decoration: none; font-weight: 500; transition: background 0.2s ease, transform 0.2s ease; }
.nav-link-x:hover { background: rgba(255, 255, 255, 0.7); color: var(--ink); }
.nav-link-x.active { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px rgba(10, 102, 232, 0.35); }
.nav-foot { margin-top: auto; padding: 12px; font-size: 0.75rem; color: var(--muted); }
#scrim { display: none; }

body.nav-collapsed #sidebar { width: 72px; }
body.nav-collapsed .brand-name, body.nav-collapsed .nav-link-x span, body.nav-collapsed .nav-group, body.nav-collapsed .nav-foot { display: none; }
body.nav-collapsed .nav-link-x, body.nav-collapsed .brand { justify-content: center; padding-left: 0; padding-right: 0; }

@media (max-width: 991.98px) {
  #shell { padding: 12px; }
  #sidebar { position: fixed; top: 12px; left: 12px; height: calc(100vh - 24px); transform: translateX(calc(-100% - 24px)); background: var(--glass-strong); }
  body.nav-open #sidebar { transform: none; }
  body.nav-collapsed #sidebar { width: var(--nav-w); }
  body.nav-collapsed .brand-name, body.nav-collapsed .nav-link-x span { display: inline; }
  body.nav-collapsed .nav-group, body.nav-collapsed .nav-foot { display: block; }
  body.nav-collapsed .nav-link-x, body.nav-collapsed .brand { justify-content: flex-start; padding-left: 12px; padding-right: 12px; }
  #scrim { display: block; position: fixed; inset: 0; z-index: 1035; border: 0; background: rgba(20, 30, 60, 0.28); opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }
  body.nav-open #scrim { opacity: 1; pointer-events: auto; }
}

/* Top bar */
#topbar { position: sticky; top: 16px; z-index: 1020; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; }
.page-title { margin: 0 8px 0 4px; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.btn-icon { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 0; border-radius: 14px; background: rgba(255, 255, 255, 0.6); border: 1px solid var(--stroke); color: var(--ink); }
.btn-icon:hover { background: #fff; }
.search-pill { flex: 1 1 200px; max-width: 420px; height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 14px; border-radius: 22px; border: 1px solid var(--stroke); background: rgba(255, 255, 255, 0.6); color: var(--muted); text-align: left; }
.search-pill span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-pill kbd { background: rgba(27, 29, 34, 0.08); color: var(--ink); font-size: 0.72rem; border-radius: 6px; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px 0 4px; border-radius: 22px; background: rgba(255, 255, 255, 0.6); border: 1px solid var(--stroke); }
.avatar { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; font-size: 0.8rem; }

/* Buttons and form controls */
.btn { border-radius: 14px; font-weight: 600; min-height: 44px; padding-left: 1.1rem; padding-right: 1.1rem; }
.btn-sm { min-height: 36px; }
.btn-primary { --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-bg: #0957c6; --bs-btn-hover-border-color: #0957c6; --bs-btn-active-bg: #084fb3; box-shadow: 0 6px 18px rgba(10, 102, 232, 0.3); }
.btn-outline-secondary { --bs-btn-color: var(--ink); --bs-btn-border-color: var(--stroke); --bs-btn-bg: rgba(255, 255, 255, 0.6); --bs-btn-hover-bg: #fff; --bs-btn-hover-color: var(--ink); --bs-btn-hover-border-color: #fff; --bs-btn-active-bg: #fff; --bs-btn-active-color: var(--ink); }
.btn-act { width: 40px; min-height: 40px; height: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 12px; background: transparent; color: inherit; }
.btn-act:hover { background: rgba(27, 29, 34, 0.07); color: inherit; }
.form-control, .form-select { min-height: 44px; border-radius: 14px; border: 1px solid rgba(27, 29, 34, 0.12); background-color: rgba(255, 255, 255, 0.75); }
.form-control:focus, .form-select:focus { background-color: #fff; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(10, 102, 232, 0.15); }
.form-label { font-weight: 600; font-size: 0.85rem; margin-bottom: 0.3rem; }
.form-section { margin: 1.25rem 0 0.25rem; padding-top: 1rem; border-top: 1px solid var(--hairline); font-size: 1rem; font-weight: 700; }
.segmented { display: inline-flex; gap: 4px; padding: 4px; border-radius: 18px; background: rgba(255, 255, 255, 0.55); border: 1px solid var(--stroke); }
.segmented .btn { min-height: 36px; border: 0; border-radius: 14px; color: var(--ink); background: transparent; box-shadow: none; }
.segmented .btn.active { background: #fff; color: var(--accent); box-shadow: 0 2px 8px rgba(40, 60, 120, 0.15); }

/* Modals, menus, toasts */
.modal-content { border-radius: var(--radius); }
.modal-header, .modal-footer { border-color: var(--hairline); }
.modal.fade .modal-dialog { transform: translateY(16px) scale(0.97); transition: transform 0.28s cubic-bezier(.2,.8,.2,1); }
.modal.show .modal-dialog { transform: none; }
.modal-backdrop.show { opacity: 0.28; }
.dropdown-menu { border-radius: 18px; padding: 8px; }
.dropdown-item { border-radius: 10px; min-height: 40px; display: flex; align-items: center; }
.toast { border-radius: 18px; border: 1px solid var(--stroke); background: var(--glass-strong); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%); box-shadow: var(--shadow); animation: toast-in 0.4s cubic-bezier(.2,.8,.2,1); }
.palette-list { max-height: 50vh; overflow-y: auto; }
.palette-list .list-group-item { background: transparent; min-height: 44px; display: flex; align-items: center; justify-content: space-between; border-color: var(--hairline); }
.palette-list .list-group-item.active { background: var(--accent); border-color: var(--accent); }

/* Page content */
#view { display: flex; flex-direction: column; gap: 16px; outline: 0; }
#view > * { animation: rise 0.45s cubic-bezier(.2,.8,.2,1) both; }
#view > *:nth-child(2) { animation-delay: 0.05s; }
#view > *:nth-child(3) { animation-delay: 0.1s; }
#view > *:nth-child(4) { animation-delay: 0.15s; }
.rise { animation: rise 0.5s cubic-bezier(.2,.8,.2,1) both; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 16px; }
.kpi-label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.kpi-value { font-size: clamp(2.6rem, 5vw, 4rem); font-weight: 700; line-height: 1; letter-spacing: -0.03em; }
.kpi-sub { font-size: 0.85rem; color: var(--muted); }
.kpi-accent { background: linear-gradient(140deg, rgba(10, 102, 232, 0.92), rgba(88, 160, 255, 0.85)); color: #fff; border-color: rgba(255, 255, 255, 0.45); }
.kpi-accent .kpi-label, .kpi-accent .kpi-sub { color: rgba(255, 255, 255, 0.92); }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 16px; }
.chart-box { position: relative; height: 260px; }
.card-title-x { font-size: 1.05rem; font-weight: 700; margin: 0 0 0.75rem; }
.tech-chip { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tech-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.82rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* Tables */
.table { --bs-table-bg: transparent; --bs-table-hover-bg: rgba(255, 255, 255, 0.6); margin-bottom: 0; font-size: 0.9rem; }
.table > :not(caption) > * > * { border-bottom-color: var(--hairline); padding: 0.6rem 0.65rem; vertical-align: middle; white-space: nowrap; }
.table thead th { font-size: 0.75rem; font-weight: 600; color: var(--muted); }
.table tbody td.wrap { white-space: normal; }
tr.row-danger > td { color: var(--row-danger); }
tr.row-success > td { color: var(--row-success); }
tr.row-info > td { color: var(--row-info); }
tr.row-muted > td { color: var(--row-muted); }
.table-wrap { overflow-x: auto; }
div.dt-container .dt-search input, div.dt-container .dt-length select { border-radius: 14px; min-height: 40px; background: rgba(255,255,255,.75); }
.page-link { border-radius: 10px !important; margin: 0 2px; border-color: var(--stroke); background: rgba(255,255,255,.6); color: var(--ink); }
.active > .page-link { background: var(--accent); border-color: var(--accent); }

/* Submissions board */
.board { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 4px; }
.lane { padding: 12px; min-height: 320px; display: flex; flex-direction: column; gap: 10px; transition: box-shadow 0.2s ease, background 0.2s ease; }
.lane.over { background: rgba(255, 255, 255, 0.85); box-shadow: 0 0 0 3px rgba(10, 102, 232, 0.35), var(--shadow); }
.lane-head { display: flex; align-items: baseline; justify-content: space-between; padding: 2px 4px; font-weight: 700; }
.lane-count { font-size: 1.4rem; }
.sub-card { text-align: left; padding: 12px; border-radius: 16px; border: 1px solid var(--stroke); background: rgba(255, 255, 255, 0.8); box-shadow: 0 2px 10px rgba(40, 60, 120, 0.08); display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--ink); cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease; }
.sub-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(40, 60, 120, 0.14); }
.sub-card.row-danger { color: var(--row-danger); }
.sub-card.row-success { color: var(--row-success); }
.sub-card .muted { color: var(--muted); font-size: 0.78rem; }

/* Permissions */
.perm-grid { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; }
.perm-people { flex: 1 1 240px; max-width: 320px; padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.perm-person { text-align: left; border: 0; border-radius: 14px; padding: 8px 12px; min-height: 52px; background: transparent; color: var(--ink); }
.perm-person small { display: block; color: var(--muted); }
.perm-person.active { background: var(--accent); color: #fff; }
.perm-person.active small { color: rgba(255, 255, 255, 0.9); }
.perm-matrix { flex: 3 1 480px; min-width: 0; }
.perm-matrix .form-check-input { width: 1.35rem; height: 1.35rem; margin: 0; }
.perm-cell { text-align: center; }
.perm-cell label { display: inline-flex; width: 44px; height: 44px; align-items: center; justify-content: center; cursor: pointer; }

/* FullCalendar on glass */
.fc { --fc-border-color: rgba(27, 29, 34, 0.1); --fc-today-bg-color: rgba(10, 102, 232, 0.06); --fc-now-indicator-color: var(--accent); --fc-page-bg-color: transparent; }
.fc .fc-toolbar-title { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; }
.fc .fc-button { border-radius: 12px !important; margin: 0 2px !important; background: rgba(255, 255, 255, 0.7); border: 1px solid var(--stroke); color: var(--ink); font-weight: 600; min-height: 40px; text-transform: capitalize; box-shadow: none !important; }
.fc .fc-button-primary:not(:disabled).fc-button-active, .fc .fc-button-primary:not(:disabled):active { background: var(--accent); border-color: var(--accent); color: #fff; }
.fc .fc-button-primary:hover { background: #fff; color: var(--ink); border-color: #fff; }
.fc .fc-event { border-radius: 10px; border: 0; padding: 3px 6px; font-size: 0.78rem; font-weight: 600; cursor: pointer; box-shadow: 0 2px 8px rgba(40, 60, 120, 0.18); }
.fc .fc-event-title { white-space: normal; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: rgba(255, 255, 255, 0.9); }
}
