:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --text: #1f2937;
  --muted: #667085;
  --line: #d9e0ea;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #15803d;
  --amber: #b45309;
  --red: #b91c1c;
  --slate: #334155;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  background: #101828;
  color: #f8fafc;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: #22c55e;
  color: #052e16;
  border-radius: 8px;
  font-weight: 800;
}

.brand span {
  display: block;
  margin-top: 2px;
  color: #cbd5e1;
  font-size: 13px;
}

.field-label {
  color: #cbd5e1;
  font-size: 13px;
  margin-bottom: -8px;
}

#userSelect,
#clientTokenSelect,
label[for="userSelect"],
label[for="clientTokenSelect"] {
  display: none;
}

.app-profile {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  padding: 12px;
  display: grid;
  gap: 5px;
}

.app-profile strong,
.app-profile span {
  display: block;
}

.app-profile span {
  color: #cbd5e1;
  font-size: 13px;
}

.select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
}

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

.nav button,
.ghost-button {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
  border-radius: 7px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}

.nav button.active {
  background: #f8fafc;
  color: #101828;
}

.ghost-button {
  margin-top: auto;
  text-align: center;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 92px;
  padding: 22px 28px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 16px;
}

.top-actions,
.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  border: 0;
  border-radius: 7px;
  padding: 10px 13px;
  cursor: pointer;
  font-weight: 650;
}

.primary-button {
  background: var(--blue);
  color: #fff;
}

.primary-button:hover {
  background: var(--blue-dark);
}

.secondary-button {
  background: #e7edf5;
  color: var(--slate);
}

.danger-button {
  background: #fee2e2;
  color: var(--red);
}

.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
}

.content-grid {
  padding: 24px 28px 40px;
  display: grid;
  gap: 18px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
}

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

.metric strong {
  display: block;
  font-size: 28px;
}

.metric span,
.muted {
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(420px, 1.6fr);
  gap: 18px;
  align-items: start;
}

.role-cockpit {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  box-shadow: var(--shadow);
}

.role-cockpit h2 {
  margin-bottom: 6px;
  font-size: 18px;
}

.access-panel {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
  display: grid;
  gap: 12px;
  box-shadow: var(--shadow);
}

.access-panel h2,
.access-panel h3 {
  margin-bottom: 6px;
}

.access-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.access-grid .compact-list {
  display: flex;
  flex-wrap: wrap;
}

.access-grid .compact-list li {
  border: 0;
  background: transparent;
  padding: 0;
}

.cockpit-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 8px;
}

.cockpit-stats span {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
  padding: 8px 10px;
  color: var(--muted);
}

.cockpit-stats strong {
  display: block;
  color: var(--text);
}

.inbox-list,
.sla-list {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
}

.inbox-item,
.sla-item,
.sla-strip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 11px;
}

.inbox-item.needs-review,
.sla-item.late,
.sla-strip.late {
  border-color: #f59e0b;
  background: #fffbeb;
}

.inbox-item div,
.inbox-item footer,
.sla-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.inbox-item span,
.inbox-item footer,
.sla-item span,
.sla-item time,
.sla-strip span {
  color: var(--muted);
  font-size: 13px;
}

.inbox-item p {
  margin: 8px 0;
  color: var(--slate);
}

.sla-item strong,
.sla-item span {
  display: block;
}

.sla-strip {
  display: flex;
  align-items: center;
  gap: 10px;
}

.order-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 180px);
  overflow: auto;
}

.order-row {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  display: grid;
  gap: 8px;
}

.order-row-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.mini-next {
  max-width: 170px;
  border-radius: 999px;
  padding: 3px 8px;
  background: #eef2f7;
  color: #475467;
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-row.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.order-row header,
.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
  color: #0f172a;
  background: #e2e8f0;
  white-space: nowrap;
}

.badge.green {
  background: #dcfce7;
  color: #166534;
}

.badge.amber {
  background: #fef3c7;
  color: #92400e;
}

.badge.red {
  background: #fee2e2;
  color: #991b1b;
}

.badge.blue {
  background: #dbeafe;
  color: #1e40af;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.info-box {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px;
}

.info-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 3px;
}

.next-action {
  margin: 14px 0;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(210px, 0.42fr);
  gap: 14px;
  align-items: stretch;
}

.next-action h3 {
  margin-bottom: 6px;
  font-size: 18px;
}

.next-action p {
  margin-bottom: 0;
}

.next-action.green {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.next-action.amber {
  border-color: #fde68a;
  background: #fffbeb;
}

.why-box {
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.65);
  padding: 10px;
  display: grid;
  gap: 6px;
}

.why-box span,
.why-box small {
  color: var(--muted);
  font-size: 12px;
}

.why-box strong {
  line-height: 1.35;
}

.action-panel,
.embedded-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 14px 0;
  padding: 12px;
  background: var(--panel-soft);
}

.embedded-panel {
  margin-top: 14px;
}

.timeline,
.compact-list {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.timeline li,
.compact-list li {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: #fff;
}

.readiness {
  border: 1px solid var(--line);
  background: #f9fafb;
  border-radius: 8px;
  padding: 12px;
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.readiness > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.readiness > div:first-child span {
  color: var(--muted);
}

.readiness-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.check {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  background: #eef2f7;
  color: #475467;
  font-size: 12px;
  font-weight: 700;
}

.check.ok {
  background: #dcfce7;
  color: #166534;
}

.order-graph {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  margin: 14px 0;
}

.order-graph h3 {
  margin-bottom: 0;
}

.graph-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.graph-node {
  min-height: 66px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: #f8fafc;
  display: grid;
  align-content: space-between;
  gap: 6px;
}

.graph-node span {
  color: var(--muted);
  font-size: 12px;
}

.graph-node strong {
  line-height: 1.25;
}

.graph-node.ok {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.graph-node.blocked {
  border-color: #fed7aa;
  background: #fff7ed;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(460px, calc(100vw - 36px));
  background: #101828;
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: #991b1b;
}

.flow-map {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.flow-node {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.flow-node.has-orders {
  border-color: #93c5fd;
  background: #eff6ff;
}

.flow-node.problem {
  border-color: #f59e0b;
  background: #fffbeb;
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.dialog {
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
  width: min(720px, calc(100vw - 24px));
}

.dialog-header,
.dialog-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.dialog-actions {
  margin-top: 18px;
  justify-content: flex-end;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 20px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .workspace,
  .role-cockpit,
  .access-grid,
  .next-action,
  .two-col,
  .form-grid,
  .graph-grid {
    grid-template-columns: 1fr;
  }

  .cockpit-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .graph-grid,
  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .dashboard-grid,
  .cockpit-stats,
  .graph-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .order-row-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .mini-next {
    max-width: 100%;
    white-space: normal;
  }
}
