:root {
  --ink: #0b132b;
  --paper: #f6fff8;
  --teal: #5bc0be;
  --sun: #ffd166;
  --line: #d7e6df;
  --muted: #64736d;
  --danger: #dc5a4b;
  --ok: #2f9d70;
  --panel: #ffffff;
  --shadow: 0 18px 50px rgba(11, 19, 43, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(91, 192, 190, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(11, 19, 43, 0.06) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.left-rail,
.inspection {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(18px);
}

.left-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 22px;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-size: 20px;
  font-weight: 800;
}

.brand img {
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(11, 19, 43, 0.16);
}

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

.nav-item {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #41504b;
  text-align: left;
  padding: 10px 12px;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

.nav-item:hover {
  transform: translateX(3px);
  background: rgba(91, 192, 190, 0.12);
}

.nav-item.is-active {
  background: var(--ink);
  color: var(--paper);
}

.rail-footer {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.rail-footer strong {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  line-height: 1.35;
}

.rail-kicker,
.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.workspace {
  min-width: 0;
  padding: 26px clamp(18px, 3vw, 38px) 38px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 4px 0 0;
  font-size: clamp(32px, 4.5vw, 58px);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  margin: 3px 0 0;
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.05;
  letter-spacing: 0;
}

h3 {
  margin: 0 0 10px;
  font-size: 13px;
  color: #33433d;
}

.topbar-actions {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.search {
  display: grid;
  gap: 6px;
  min-width: min(270px, 42vw);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.search input,
.note-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  outline: 0;
}

.search input {
  height: 42px;
  padding: 0 12px;
}

.search input:focus,
.note-form textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(91, 192, 190, 0.18);
}

.primary-action,
.ghost-action {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-action {
  background: var(--teal);
  color: #07171c;
  box-shadow: 0 10px 24px rgba(91, 192, 190, 0.24);
}

.ghost-action {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.primary-action:hover,
.ghost-action:hover {
  transform: translateY(-1px);
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin: 24px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  box-shadow: var(--shadow);
}

.metric {
  min-width: 0;
  padding: 18px;
  background: rgba(255, 255, 255, 0.94);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(30px, 5vw, 52px);
  line-height: 0.92;
  letter-spacing: 0;
}

.canvas {
  position: relative;
}

.screen {
  display: none;
  animation: riseIn 260ms ease both;
}

.screen.is-active {
  display: block;
}

.progress-map {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.track-step {
  position: relative;
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.track-step::before {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 18px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--teal), var(--sun));
}

.track-step b {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-top: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 209, 102, 0.35);
  color: #58420f;
  font-size: 11px;
  font-weight: 850;
}

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

.case-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
  text-align: left;
  box-shadow: 0 10px 28px rgba(11, 19, 43, 0.08);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.case-card:hover {
  transform: translateY(-2px);
  border-color: rgba(91, 192, 190, 0.75);
  box-shadow: var(--shadow);
}

.case-card.is-selected {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(91, 192, 190, 0.22);
}

.case-topline,
.item-topline,
.calendar-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.case-card h3 {
  margin: 12px 0 10px;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.08;
}

.case-meta,
.item-meta,
.calendar-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.risk-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.risk-pill {
  background: rgba(220, 90, 75, 0.12);
  color: #a43125;
}

.risk-pill.low {
  background: rgba(47, 157, 112, 0.12);
  color: #176448;
}

.status-pill {
  background: rgba(91, 192, 190, 0.16);
  color: #0b5e5c;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.detail-list,
.calendar-lane,
.report-table,
.stock-board,
.action-log,
.flow-links {
  display: grid;
  gap: 10px;
}

.detail-item,
.calendar-item,
.report-row,
.stock-row,
.log-entry,
.flow-link {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  padding: 14px;
}

.detail-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.detail-item h3,
.calendar-item h3 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 17px;
}

.item-action {
  min-width: 92px;
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 800;
}

.calendar-lane {
  grid-template-columns: repeat(4, minmax(190px, 1fr));
  overflow-x: auto;
  padding-bottom: 6px;
}

.calendar-item {
  min-height: 178px;
  background:
    linear-gradient(180deg, rgba(91, 192, 190, 0.16), rgba(255, 255, 255, 0.95) 52%),
    #fff;
}

.calendar-day {
  display: block;
  color: var(--ink);
  font-size: 36px;
  font-weight: 900;
  line-height: 1;
}

.report-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, 0.85fr);
  gap: 14px;
}

.report-row,
.stock-row,
.flow-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.bar {
  height: 8px;
  margin-top: 8px;
  border-radius: 999px;
  background: #e7eee9;
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--sun), var(--danger));
}

.inspection {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  border-left: 1px solid var(--line);
  overflow-y: auto;
}

.drawer-head {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.drawer-head h2 {
  margin-bottom: 10px;
  font-size: 28px;
}

.drawer-block {
  min-width: 0;
}

.log-entry {
  font-size: 13px;
}

.log-entry time {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.note-form {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

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

.note-form textarea {
  min-height: 86px;
  resize: vertical;
  padding: 10px;
}

.empty-state,
.loading-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 190px minmax(0, 1fr);
  }

  .inspection {
    grid-column: 1 / -1;
    position: static;
    height: auto;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .left-rail {
    position: static;
    height: auto;
    padding: 14px;
  }

  .rail-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav-item {
    text-align: center;
    padding: 9px 6px;
  }

  .rail-footer {
    display: none;
  }

  .topbar,
  .section-head {
    display: grid;
  }

  .topbar-actions {
    display: grid;
    align-items: stretch;
  }

  .search {
    min-width: 0;
  }

  .metric-strip,
  .progress-map,
  .session-grid,
  .report-grid {
    grid-template-columns: 1fr;
  }

  .detail-item,
  .report-row,
  .stock-row,
  .flow-link {
    grid-template-columns: 1fr;
  }
}

