:root {
  --sidebar: #2f5f90;
  --sidebar-strong: #234b72;
  --sidebar-soft: #3d6f9f;
  --text-on-dark: #f6fbff;
  --bg: #eaf2f9;
  --panel: #ffffff;
  --panel-soft: #f4f8fc;
  --line: #cddaea;
  --line-strong: #9fb5cf;
  --text: #16324a;
  --muted: #67809a;
  --accent: #2f5f90;
  --accent-soft: #dceaf7;
  --ok: #2d7a55;
  --warn: #9a6a22;
  --danger: #a33e3e;
  --shadow: 0 12px 28px rgba(23, 60, 94, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 13px/1.35 "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-strong));
  color: var(--text-on-dark);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px;
  gap: 10px;
}

.sidebar--collapsed {
  width: 64px;
}

.sidebar-top {
  display: grid;
  gap: 8px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 4px;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  display: grid;
  place-items: center;
  font-weight: 700;
}

.brand-copy {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.sidebar-toggle {
  width: 100%;
  min-height: 28px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: var(--text-on-dark);
  border-radius: 8px;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-item {
  min-height: 30px;
  border: 0;
  border-radius: 8px;
  text-align: left;
  padding: 0 10px;
  background: transparent;
  color: rgba(246, 251, 255, 0.88);
}

.nav-item.is-active,
.nav-item:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

.sidebar-user {
  position: relative;
}

.avatar-button {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.16);
  color: var(--text-on-dark);
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: 40px minmax(0, 1fr);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--sidebar);
  color: var(--text-on-dark);
  border-bottom: 1px solid rgba(255,255,255,0.12);
  padding: 6px 10px;
}

.filter-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.chip, .button {
  min-height: 26px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--text);
}

.chip--title {
  background: transparent;
  border-color: transparent;
  color: var(--text-on-dark);
  padding-left: 0;
  font-size: 12px;
  text-transform: lowercase;
}

.chip--ghost,
.button--ghost {
  background: rgba(255,255,255,0.08);
  color: var(--text-on-dark);
  border-color: rgba(255,255,255,0.18);
}

.view {
  display: none;
  padding: 10px;
  min-height: 0;
}

.view.is-active {
  display: grid;
  align-content: start;
  gap: 10px;
}

.table-frame,
.summary-panel,
.modal-card,
.info-banner,
.list-box,
.timeline-box,
.access-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.table-frame {
  overflow: hidden;
}

.table-frame--simple {
  padding: 8px;
}

.table-top-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  border-bottom: 1px solid var(--line);
}

.table-top-scroll > div {
  height: 1px;
}

.table-scroll {
  overflow: auto;
  max-height: calc(100vh - 180px);
  cursor: grab;
}

.table-scroll.is-dragging {
  cursor: grabbing;
}

.streams-table,
.simple-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
}

.streams-table th,
.streams-table td,
.simple-table th,
.simple-table td {
  padding: 5px 8px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  text-align: right;
  font-size: 12px;
}

.streams-table thead th,
.simple-table thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: #f7fbff;
  text-align: center;
}

.sticky-left {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #fcfeff;
}

.sticky-left-2 { left: 38px; }
.sticky-left-3 { left: 106px; }
.sticky-left-4 { left: 178px; }
.sticky-left-5 { left: 252px; }

.left-col {
  text-align: left !important;
}

.select-col { width: 38px; min-width: 38px; max-width: 38px; text-align: center !important; }
.flow-col { width: 68px; min-width: 68px; max-width: 68px; }
.date-col { width: 72px; min-width: 72px; max-width: 72px; }
.weekday-col { width: 74px; min-width: 74px; max-width: 74px; }
.time-col { width: 74px; min-width: 74px; max-width: 74px; border-right: 2px solid var(--line-strong) !important; }

.metric-divider {
  border-left: 2px solid var(--line-strong) !important;
}

.summary-panel {
  padding: 8px 10px;
}

.summary-title,
.section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 6px;
}

.summary-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 8px;
  background: var(--panel-soft);
}

.summary-card strong,
.summary-card span {
  display: block;
}

.summary-card span {
  color: var(--muted);
  font-size: 11px;
}

.compare-head {
  display: flex;
  justify-content: flex-end;
}

.comparison-blocks {
  display: grid;
  gap: 10px;
}

.comparison-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 8px;
}

.menu {
  position: absolute;
  left: 0;
  bottom: 44px;
  width: 190px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: grid;
  gap: 4px;
  z-index: 60;
}

.menu-item {
  min-height: 30px;
  border: 0;
  background: transparent;
  text-align: left;
  border-radius: 8px;
  color: var(--text);
}

.menu-item:hover {
  background: var(--panel-soft);
}

.menu-item.danger {
  color: var(--danger);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 41, 62, 0.36);
  z-index: 80;
}

.modal-card {
  position: fixed;
  z-index: 90;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(960px, calc(100vw - 24px));
  padding: 10px;
}

.modal-card--center,
.modal-card--small {
  width: min(420px, calc(100vw - 24px));
}

.modal-card--wide {
  width: min(1160px, calc(100vw - 24px));
}

.hidden {
  display: none !important;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.modal-title {
  font-size: 14px;
  font-weight: 700;
}

.modal-actions {
  display: flex;
  gap: 6px;
}

.icon-button {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.form-stack {
  display: grid;
  gap: 8px;
}

.field {
  display: grid;
  gap: 4px;
}

.field span {
  font-size: 11px;
  color: var(--muted);
}

.field input,
.field textarea {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
}

.form-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.form-error {
  color: var(--danger);
}

.form-note {
  color: var(--muted);
  font-size: 12px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.list-box,
.timeline-box,
.log-list {
  max-height: 60vh;
  overflow: auto;
  padding: 6px;
}

.list-item,
.timeline-item,
.log-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
  padding: 7px 8px;
  margin-bottom: 6px;
}

.list-item button {
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
}

.client-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.client-summary-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 8px;
  background: var(--panel-soft);
}

.client-summary-card strong,
.client-summary-card span {
  display: block;
}

.client-summary-card span {
  color: var(--muted);
  font-size: 11px;
}

.popover {
  position: fixed;
  z-index: 70;
  min-width: 220px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 8px;
}

.popover-list {
  display: grid;
  gap: 6px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.checkbox-row input {
  margin: 0;
}

.popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 8px;
}

.info-banner {
  padding: 8px 10px;
  margin-bottom: 8px;
  background: var(--accent-soft);
}

.metric-cell-button {
  border: 0;
  background: transparent;
  padding: 0;
  color: inherit;
  min-width: 100%;
  text-align: inherit;
}

.metric-cell-button:hover {
  color: var(--accent);
}

.access-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #dfeaf6, #edf4fb);
}

.access-card {
  width: min(480px, calc(100vw - 24px));
  padding: 10px;
}

@media (max-width: 960px) {
  .shell {
    grid-template-columns: 64px minmax(0, 1fr);
  }
  .sidebar {
    padding: 8px 6px;
  }
  .brand-copy,
  .nav-item {
    display: none;
  }
  .sidebar--expanded .brand-copy,
  .sidebar--expanded .nav-item {
    display: block;
  }
  .sidebar--expanded {
    width: 180px;
  }
  .two-col {
    grid-template-columns: 1fr;
  }
}
