/* ═══════════════════════════════════════════════════════════════
   CM Cockpit — Redesign Layer (v23)
   Aesthetic: refined operational calm + StudySmarter energy.
   8px spacing grid · strong type hierarchy · soft elevation · sidebar shell.
   Loaded AFTER cockpit.css + brand.css.
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* spacing scale (8px grid) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
  /* elevation */
  --el-1: 0 1px 2px rgba(35,35,35,.04), 0 1px 3px rgba(35,35,35,.06);
  --el-2: 0 2px 4px rgba(35,35,35,.04), 0 4px 12px rgba(35,35,35,.07);
  --el-3: 0 8px 24px rgba(35,35,35,.10), 0 2px 6px rgba(35,35,35,.06);
  --radius: 14px; --radius-sm: 10px; --radius-xs: 7px;
  --sidebar-w: 248px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--sm-stone);
  color: var(--sm-charcoal);
  font-family: var(--sm-font-body);
  -webkit-font-smoothing: antialiased;
}

/* Sidebar = FIXED to viewport so it's always visible, scrolls its own overflow.
   Main content gets a left margin so nothing slides under it. */
.shell { position: relative; }
@media (max-width: 900px) {
  .sidebar { position: static; height: auto; width: 100%; }
  .shell { padding-left: 0 !important; }
}

/* Kill the old SalesOS flex-column body + topbar */
.topbar { display: none !important; }

/* ═══════════ SHELL ═══════════ */
.shell { display: block; padding-left: var(--sidebar-w); min-height: 100vh; }

/* ═══════════ SIDEBAR ═══════════ */
.sidebar {
  background: var(--sm-charcoal);
  color: #EDEBE7;
  display: flex; flex-direction: column;
  padding: var(--s5) var(--s4);
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w); height: 100vh;
  overflow-y: auto; overflow-x: hidden;
  z-index: 50;
  gap: var(--s5);
}
/* Custom scrollbar inside sidebar (subtle, on charcoal) */
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 3px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.22); }

.sb-brand { display: flex; align-items: center; gap: var(--s3); }
.sb-logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--sm-lime); color: var(--sm-charcoal);
  font-family: var(--sm-font-heading); font-weight: 800; font-size: 22px;
  display: grid; place-items: center; flex-shrink: 0;
}
.sb-brand-name { font-family: var(--sm-font-heading); font-weight: 800; font-size: 16px; letter-spacing: -.02em; color: #fff; }
.sb-brand-sub { font-family: var(--sm-font-mono); font-size: 9.5px; color: rgba(237,235,231,.45); letter-spacing: .02em; margin-top: 2px; }

.sb-cm { display: flex; flex-direction: column; gap: var(--s2); }
.sb-cm-label { font-family: var(--sm-font-mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: .08em; color: rgba(237,235,231,.4); }
.sb-cm-select {
  background: rgba(255,255,255,.06); color: #fff;
  border: 1px solid rgba(255,255,255,.12); border-radius: var(--radius-xs);
  padding: 9px 11px; font-family: var(--sm-font-body); font-size: 13px; font-weight: 500;
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23EDEBE7' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
.sb-cm-select:focus { outline: none; border-color: var(--sm-lime); }

/* Sidebar nav — override SalesOS .tabs segmented-control look */
.sidebar .tabs.sb-nav,
.sb-nav {
  display: flex; flex-direction: column; gap: 2px;
  background: transparent !important; padding: 0 !important;
  border-radius: 0 !important; box-shadow: none !important; border: none !important;
}
.sb-nav .tab {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; text-align: left;
  background: transparent; border: none; color: rgba(237,235,231,.72);
  padding: 10px var(--s3); border-radius: var(--radius-xs);
  font-family: var(--sm-font-heading); font-weight: 600; font-size: 13.5px; letter-spacing: -.01em;
  cursor: pointer; transition: background .14s, color .14s; position: relative;
}
.sb-nav .tab .sb-ico { font-size: 13px; width: 18px; opacity: .65; text-align: center; }
.sb-nav .tab .sb-label { flex: 1; }
.sb-nav .tab:hover { background: rgba(255,255,255,.06); color: #fff; }
.sb-nav .tab.active { background: var(--sm-blue); color: #fff; }
.sb-nav .tab.active .sb-ico { opacity: 1; }
.sb-nav .tab.active::after { display: none; }
.sb-nav .badge-count {
  font-family: var(--sm-font-mono); font-size: 10px; font-weight: 500;
  background: rgba(255,255,255,.12); color: #fff;
  padding: 1px 7px; border-radius: 9px; min-width: 18px; text-align: center;
}
.sb-nav .tab.active .badge-count { background: rgba(255,255,255,.22); }
.sb-nav .badge-count.rail-hot { background: var(--sm-hotrod); color: #fff; }

/* Sidebar footer */
.sb-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--s4); }
.sb-gauge { background: rgba(255,255,255,.05); border-radius: var(--radius-sm); padding: var(--s3) var(--s4); }
.sb-gauge-row { display: flex; justify-content: space-between; font-size: 11.5px; color: rgba(237,235,231,.6); margin-bottom: var(--s2); }
.sb-gauge-row b { font-family: var(--sm-font-mono); color: var(--sm-lime); font-weight: 500; }
.sb-gauge-row.sub { margin-bottom: 0; margin-top: var(--s2); font-size: 10.5px; }
.sb-gauge-row.sub b { color: #fff; }
.sb-gauge-bar { height: 6px; background: rgba(255,255,255,.1); border-radius: 3px; overflow: hidden; }
.sb-gauge-bar > div { height: 100%; background: linear-gradient(90deg, var(--sm-blue-60), var(--sm-lime)); border-radius: 3px; }
.sb-live { display: flex; align-items: center; gap: var(--s3); }
#live-label { font-family: var(--sm-font-mono); font-size: 11px; font-weight: 500; color: rgba(237,235,231,.6); }
#live-mode:checked ~ #live-label { color: var(--sm-lime); }
.sb-ext { font-size: 12px; color: rgba(237,235,231,.55); font-weight: 500; }
.sb-ext:hover { color: var(--sm-lime); text-decoration: none; }

/* ═══════════ MAIN ═══════════ */
/* Use most of the screen: fluid up to a generous cap, comfortable side padding. */
.main { padding: var(--s6) var(--s7); max-width: 1760px; width: 100%; margin: 0 auto; }
@media (max-width: 1400px) { .main { padding: var(--s5) var(--s5); } }

/* Full width on all pages */
#tab-heute .heute-section { max-width: none; }
#tab-touchpoints .tp-grid { max-width: none; }
/* On very wide screens, queue cards read better at 2-up than one giant row */
@media (min-width: 1500px) {
  #queue-review, #queue-ready, #queue-auto { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
  #queue-bootstrap { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
}

/* Tab panels */
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeUp .35s cubic-bezier(.2,.7,.3,1); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ═══════════ ALERT BANNER ═══════════ */
.timing-banner {
  display: flex; align-items: center; gap: var(--s4);
  background: var(--sm-charcoal); color: #fff;
  border-radius: var(--radius); padding: var(--s4) var(--s5);
  margin-bottom: var(--s6); box-shadow: var(--el-2); border: none;
  position: relative; overflow: hidden;
}
.timing-banner::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--sm-hotrod);
}
.timing-banner .bell { font-size: 18px; }
.timing-banner .banner-text { flex: 1; font-size: 13.5px; line-height: 1.5; }
.timing-banner .banner-text b { font-family: var(--sm-font-heading); font-weight: 700; }
.timing-banner .banner-meta { color: rgba(255,255,255,.55); }
.timing-banner .banner-actions { display: flex; gap: var(--s2); }

/* ═══════════ HEUTE / QUEUE ═══════════ */
.heute-section { padding: 0; max-width: none; }

/* Bulk bar → hero strip */
.bulk-bar {
  display: flex; justify-content: space-between; align-items: center; gap: var(--s4);
  background: linear-gradient(110deg, var(--sm-blue) 0%, var(--sm-blue-60) 100%);
  color: #fff; border-radius: var(--radius); padding: var(--s5) var(--s5);
  margin-bottom: var(--s6); box-shadow: var(--el-2); border: none;
  font-size: 14px;
}
.bulk-bar b { font-family: var(--sm-font-heading); font-weight: 700; }
.bulk-bar .btn-bulk {
  background: var(--sm-lime); color: var(--sm-charcoal); border: none;
  font-family: var(--sm-font-heading); font-weight: 700; font-size: 13px;
  padding: 12px 20px; border-radius: var(--radius-xs); cursor: pointer; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(198,250,2,.4); transition: transform .12s;
}
.bulk-bar .btn-bulk:hover { transform: translateY(-1px); background: #d4ff3a; }

/* Section headers */
.queue-group-h {
  display: flex; align-items: center; gap: var(--s2);
  font-family: var(--sm-font-heading); font-weight: 700; font-size: 13px;
  letter-spacing: -.01em; text-transform: none; color: var(--sm-charcoal);
  padding: 0; border: none; margin: var(--s6) 0 var(--s3);
}
.queue-group-h .count {
  font-family: var(--sm-font-mono); font-size: 11px; font-weight: 500;
  background: var(--sm-stone-200); color: var(--sm-grey-600);
  padding: 2px 9px; border-radius: 9px; margin-left: var(--s1);
}
.queue-group-h .count.urgent { background: rgba(255,92,65,.14); color: #a02d18; }
.queue-group-h .count.ready { background: rgba(198,250,2,.25); color: #3d5800; }

/* Cards */
.q-card {
  display: grid; grid-template-columns: 44px 1fr auto; gap: var(--s4); align-items: start;
  background: #fff; border: 1px solid var(--sm-stone-200); border-left: 3px solid var(--sm-stone-400);
  border-radius: var(--radius); padding: var(--s4) var(--s5);
  margin-bottom: var(--s3); box-shadow: var(--el-1);
  transition: box-shadow .16s, transform .1s, border-color .16s;
}
.q-card:hover { box-shadow: var(--el-2); transform: translateY(-1px); }
.q-card.ready { border-left-color: var(--sm-lime); }
.q-card.urgent { border-left-color: var(--sm-hotrod); }
.q-card.auto { opacity: .58; box-shadow: none; }
.q-card.auto:hover { opacity: .85; }

.q-icon {
  width: 44px; height: 44px; border-radius: 12px; background: var(--sm-stone);
  display: grid; place-items: center; font-size: 19px;
}
.q-icon.ready { background: rgba(198,250,2,.16); }
.q-icon.urgent { background: rgba(255,92,65,.12); }
.q-icon.auto { background: rgba(198,250,2,.12); }

.q-body { min-width: 0; }
.q-body .q-title {
  font-family: var(--sm-font-heading); font-weight: 700; font-size: 14.5px;
  letter-spacing: -.015em; line-height: 1.35; color: var(--sm-charcoal); margin-bottom: var(--s2);
}
.q-body .q-meta {
  display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center;
  font-family: var(--sm-font-mono); font-size: 11px; color: var(--sm-grey-500); margin-bottom: var(--s2);
}
.q-body .q-meta > span:not(:last-child)::after { content: ""; }
.q-body .q-prop { font-size: 12.5px; line-height: 1.55; color: var(--sm-grey-600); margin-bottom: var(--s2); }

.q-body .q-pipe {
  margin-top: var(--s3); font-family: var(--sm-font-mono); font-size: 10.5px;
  background: var(--sm-stone); border-radius: var(--radius-xs); padding: var(--s2) var(--s3);
  display: flex; flex-wrap: wrap; gap: var(--s1) var(--s2); align-items: center; color: var(--sm-grey-600);
}
.q-body .q-pipe b { font-family: var(--sm-font-heading); color: var(--sm-grey-500); font-size: 9.5px; text-transform: uppercase; letter-spacing: .06em; }
.q-body .q-pipe .pipe-step { background: #fff; border: 1px solid var(--sm-stone-200); padding: 2px 8px; border-radius: 5px; }
.q-body .q-pipe .pipe-step.tool { background: rgba(19,0,255,.06); color: var(--sm-blue); border-color: rgba(19,0,255,.16); }
.q-body .q-pipe .pipe-step.out { background: rgba(198,250,2,.18); color: #3d5800; border-color: rgba(198,250,2,.4); }
.q-body .q-pipe .pipe-arrow { color: var(--sm-stone-dark); }

.q-actions { display: flex; flex-direction: column; gap: var(--s2); align-items: flex-end; }
.q-conf {
  font-family: var(--sm-font-mono); font-size: 12px; font-weight: 500;
  padding: 3px 9px; border-radius: 8px; background: var(--sm-stone-200); color: var(--sm-grey-600);
}
.q-conf.high { background: rgba(198,250,2,.22); color: #3d5800; }
.q-conf.low { background: rgba(255,92,65,.16); color: #a02d18; }

/* Buttons */
.btn-primary, .btn-secondary {
  font-family: var(--sm-font-heading); font-weight: 600; font-size: 13px; letter-spacing: -.01em;
  border-radius: var(--radius-xs); padding: 9px 16px; cursor: pointer; transition: all .14s; white-space: nowrap;
}
.btn-primary { background: var(--sm-blue); color: #fff; border: 1px solid var(--sm-blue); }
.btn-primary:hover { background: var(--sm-blue-80); border-color: var(--sm-blue-80); box-shadow: 0 2px 8px rgba(19,0,255,.25); }
.btn-secondary { background: #fff; color: var(--sm-charcoal); border: 1px solid var(--sm-stone-400); }
.btn-secondary:hover { background: var(--sm-stone); border-color: var(--sm-stone-dark); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* Inline draft preview on cards */
.q-body [style*="border-left:3px solid #1300FF"],
.q-body [style*="border-left:3px solid var(--sm-blue)"] { border-radius: var(--radius-xs) !important; }

/* ═══════════ POSTEINGANG ═══════════ */
.dial-toolbar {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  background: #fff; border: 1px solid var(--sm-stone-200); border-radius: var(--radius);
  padding: var(--s3) var(--s4); margin-bottom: var(--s4); box-shadow: var(--el-1);
}
.filter-sel {
  border: 1px solid var(--sm-stone-300, var(--sm-stone-400)); border-radius: var(--radius-xs);
  padding: 7px 12px; font-family: var(--sm-font-body); font-size: 12.5px; background: #fff; cursor: pointer;
}
.dial-view-table { gap: var(--s4) !important; }
.inbox-rail { background: #fff; border: 1px solid var(--sm-stone-200); border-radius: var(--radius); padding: var(--s3); box-shadow: var(--el-1); height: fit-content; }
.inbox-rail-h { font-family: var(--sm-font-heading); font-weight: 700; font-size: 12px; color: var(--sm-charcoal); padding: var(--s2) var(--s2) var(--s3); }
.center-table#mail-reader { background: #fff; border: 1px solid var(--sm-stone-200); border-radius: var(--radius); box-shadow: var(--el-1); }
.detail-pane { background: #fff; border: 1px solid var(--sm-stone-200); border-radius: var(--radius); box-shadow: var(--el-1); }
.rail-cat { border-radius: var(--radius-xs) !important; }
.rail-cat.active { background: var(--primary-50) !important; box-shadow: inset 3px 0 0 var(--sm-blue); }

/* ═══════════ KANBAN ═══════════ */
.kanban-grid { gap: var(--s4); }
.kanban-col { background: var(--sm-stone); border-radius: var(--radius); padding: var(--s3); border: none; }
.kanban-col-h { font-family: var(--sm-font-heading); font-weight: 700; font-size: 13px; padding: var(--s2) var(--s2) var(--s3); }
.kanban-card { background: #fff; border: 1px solid var(--sm-stone-200); border-radius: var(--radius-sm); padding: var(--s3); margin-bottom: var(--s2); box-shadow: var(--el-1); transition: box-shadow .14s; }
.kanban-card:hover { box-shadow: var(--el-2); }

/* ═══════════ TOUCHPOINTS ═══════════ */
.tp-grid { gap: var(--s4); padding: 0; }
.tp-card { background: #fff; border: 1px solid var(--sm-stone-200); border-radius: var(--radius); padding: var(--s5); box-shadow: var(--el-1); gap: var(--s3); }
.tp-card:hover { box-shadow: var(--el-3); transform: translateY(-2px); }
.tp-card .tp-icon { font-size: 26px; }
.tp-card .tp-title { font-family: var(--sm-font-heading); font-weight: 700; font-size: 15px; letter-spacing: -.015em; }

/* ═══════════ MANAGER / TEAM ═══════════ */
.mgr-grid { gap: var(--s4); }
.mgr-card { background: #fff; border: 1px solid var(--sm-stone-200); border-radius: var(--radius); padding: var(--s5); box-shadow: var(--el-1); }
.mgr-card-h { font-family: var(--sm-font-heading); font-weight: 700; font-size: 15px; letter-spacing: -.015em; margin-bottom: var(--s4); }
.mgr-table { font-size: 12.5px; }
.mgr-table th { font-family: var(--sm-font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--sm-grey-500); font-weight: 500; padding-bottom: var(--s2); }
.mgr-table td { padding: var(--s2) 0; }
.pill { font-family: var(--sm-font-mono); font-size: 10.5px; font-weight: 500; padding: 2px 8px; border-radius: 8px; }
.pill.ok { background: rgba(198,250,2,.22); color: #3d5800; }
.pill.warn { background: rgba(255,92,65,.16); color: #a02d18; }

/* ═══════════ AUDIT TABLE ═══════════ */
#audit-table { background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--el-1); border: 1px solid var(--sm-stone-200); }
#audit-table th { font-family: var(--sm-font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; background: var(--sm-stone); padding: var(--s3); }
.vt-btn { font-family: var(--sm-font-heading); font-weight: 600; font-size: 12px; border-radius: var(--radius-xs); border: 1px solid var(--sm-stone-400); background: #fff; padding: 7px 13px; cursor: pointer; }
.vt-btn.active { background: var(--sm-charcoal); color: #fff; border-color: var(--sm-charcoal); }

/* Muted helper used widely */
.muted, .ml-auto { color: var(--sm-grey-500); }
.ml-auto { margin-left: auto; font-family: var(--sm-font-mono); font-size: 11.5px; }

/* Floating help button */
.kbd-fab { background: var(--sm-charcoal); color: #fff; box-shadow: var(--el-3); }

/* ═══════════ MOBILE ═══════════ */
@media (max-width: 900px) {
  .shell { padding-left: 0; }
  .sidebar { position: static; height: auto; width: 100%; flex-direction: column; overflow-y: visible; }
  .sb-nav { flex-direction: row; overflow-x: auto; }
  .sb-nav .tab { white-space: nowrap; }
  .sb-foot { margin-top: var(--s4); }
  .main { padding: var(--s4); }
}
