:root {
  color-scheme: light;
  --bg: #ffffff;
  --page: #f7f8fa;
  --surface: #ffffff;
  --surface-soft: #f7f7f8;
  --text: #09090b;
  --muted: #737373;
  --line: #e7e7e8;
  --line-strong: #d8d8db;
  --ink: #18181b;
  --ink-soft: #f4f4f5;
  --success: #059669;
  --success-soft: #ecfdf5;
  --success-line: #a7f3d0;
  --warning: #b7791f;
  --warning-soft: #fffbeb;
  --warning-line: #fde68a;
  --shadow: 0 10px 26px rgba(24, 24, 27, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--page);
  color: var(--text);
  font-family:
    Inter, "SF Pro Text", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.workspace {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  background: var(--page);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #fafafa;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 26px 18px;
}

.brand-mark,
.avatar {
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.brand-mark {
  width: 24px;
  height: 24px;
  font-style: italic;
}

.brand-name {
  font-size: 14px;
  font-weight: 600;
}

.brand-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 2px;
  padding: 0 10px;
}

.nav-list a,
.nav-list .nav-label {
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
}

.nav-list .nav-label {
  color: var(--ink);
  cursor: default;
}

.nav-list a.active,
.nav-list a.current {
  background: #f1f2f6;
}

.nav-list a.nested,
.nav-list .nav-label.nested {
  margin-left: 24px;
  color: #3f3f46;
  font-size: 13px;
}

.nav-group {
  display: grid;
  gap: 1px;
}

.sidebar-footer {
  display: grid;
  gap: 12px;
  margin-top: auto;
  padding: 18px;
}

.currency-row,
.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
}

.avatar {
  width: 28px;
  height: 28px;
}

.root-pill {
  padding: 2px 6px;
  border-radius: 6px;
  background: #fee2e2;
  color: #b91c1c;
  font-size: 10px;
  font-weight: 500;
}

.content {
  min-width: 0;
}

.topbar {
  min-height: 72px;
  display: grid;
  grid-template-columns: auto repeat(4, minmax(160px, 1fr));
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.topbar label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.topbar select,
.topbar input {
  width: 100%;
}

.sidebar-toggle {
  width: 34px;
  height: 34px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}

.app-shell {
  width: min(1320px, calc(100vw - 320px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.15;
  font-weight: 600;
}

h2,
h3 {
  font-weight: 600;
}

h2 {
  margin-bottom: 0;
  font-size: 16px;
  line-height: 1.25;
}

h3 {
  margin-bottom: 6px;
  font-size: 15px;
  line-height: 1.3;
}

.header-actions,
.filters,
.panel-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-actions,
.panel-heading {
  justify-content: space-between;
}

.primary-button,
.secondary-button,
.icon-button,
.drawer-close,
.delete-button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
}

.primary-button {
  min-height: 38px;
  padding: 0 14px;
  border-color: var(--ink);
  background: var(--ink);
  color: white;
  font-weight: 500;
}

.secondary-button {
  min-height: 38px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
}

.icon-button,
.drawer-close {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
}

.delete-button {
  min-height: 38px;
  padding: 0 14px;
  border-color: #dc2626;
  background: #dc2626;
  color: #ffffff;
  border-radius: 8px;
  font-weight: 500;
}

.summary-grid,
.dashboard-grid,
.monitor-grid {
  display: grid;
  gap: 12px;
}

.summary-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 12px;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.3fr) minmax(340px, 0.7fr);
  margin-bottom: 12px;
}

.panel,
.summary-card,
.monitor-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.panel {
  padding: 16px;
}

.summary-card {
  padding: 14px;
}

.summary-card .value {
  margin-bottom: 6px;
  font-size: 25px;
  font-weight: 600;
  line-height: 1;
}

.summary-card .label {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.data-source {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

select,
.topbar input,
.search-box {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
}

select {
  padding: 0 10px;
  color: var(--text);
}

.topbar input {
  padding: 0 10px;
  color: var(--text);
}

select:focus,
input:focus,
button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.search-box {
  min-width: 280px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  color: var(--muted);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.subtle-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.status-pill.outstanding {
  border-color: var(--success-line);
  background: var(--success-soft);
  color: var(--success);
}

.status-pill.early-called {
  border-color: var(--line-strong);
  background: var(--ink-soft);
  color: var(--ink);
}

.status-pill.matured {
  border-color: var(--warning-line);
  background: var(--warning-soft);
  color: var(--warning);
}

.status-pill.expired {
  border-color: var(--line-strong);
  background: #f4f4f5;
  color: #52525b;
}

.breakdown-list,
.event-list,
.product-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.breakdown-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(120px, 2fr) auto;
  align-items: center;
  gap: 12px;
}

.breakdown-label,
.event-date,
.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.bar-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #ededf0;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--ink);
}

.event-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  text-align: left;
}

.event-main {
  min-width: 0;
}

.event-title,
.product-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.event-meta,
.product-meta,
.drawer-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.monitor-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 14px;
}

.hidden {
  display: none !important;
}

.product-tabs {
  width: min(860px, 100%);
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0;
  padding: 4px;
  border-radius: 10px;
  background: #f1f2f7;
}

.tab {
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
}

.tab.active {
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(24, 24, 27, 0.12);
}

.quote-form,
.upload-form {
  width: min(820px, 100%);
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  row-gap: 18px;
  column-gap: 28px;
  margin-top: 22px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.quote-form label,
.upload-form label {
  display: contents;
  color: var(--ink);
  font-size: 13px;
  font-weight: 400;
}

.quote-form input,
.quote-form select,
.upload-form input {
  min-height: 38px;
  width: 100%;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.quote-preview {
  width: min(1120px, 100%);
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.quote-preview-empty {
  color: var(--muted);
  font-size: 13px;
}

.quote-preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.quote-preview-header h3 {
  margin-top: 2px;
  font-size: 18px;
  font-weight: 600;
}

.quote-preview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.quote-preview-grid article {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.quote-preview-grid span,
.quote-preview-status,
.quote-preview-body p {
  color: var(--muted);
  font-size: 12px;
}

.quote-preview-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
  font-weight: 600;
}

.quote-preview-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.quote-preview-body h4 {
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 600;
}

.quote-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.quote-preview-table th,
.quote-preview-table td {
  padding: 10px 8px;
  border-top: 1px solid var(--line);
  text-align: left;
}

.quote-preview-table th {
  color: var(--muted);
  font-weight: 500;
}

.quote-preview-status {
  margin-top: 10px;
}

.upload-actions {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.upload-status {
  color: var(--muted);
  font-size: 12px;
}

.rfq-table {
  display: grid;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.rfq-row {
  display: grid;
  grid-template-columns: 110px 1.2fr 120px 120px 120px 120px;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 0 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  font-size: 13px;
}

.rfq-row:last-child {
  border-bottom: 0;
}

.rfq-row.header {
  min-height: 42px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
}

.rfq-empty {
  padding: 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.monitor-card {
  padding: 12px;
}

.monitor-card .monitor-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.level-meter {
  margin-top: 12px;
}

.level-meter .bar-track {
  height: 10px;
}

.monitor-values {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.metric-box {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.metric-value {
  margin-top: 2px;
  font-size: 13px;
  font-weight: 600;
}

.list-heading {
  align-items: flex-start;
}

.product-table-wrap {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
  background: var(--surface);
}

.product-table {
  width: 100%;
  min-width: 1160px;
  border-collapse: collapse;
  font-size: 13px;
}

.product-table th,
.product-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.product-table th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.product-table th button {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.product-table tbody tr:last-child td {
  border-bottom: 0;
}

.product-table tbody tr:hover {
  background: var(--surface-soft);
}

.product-table td:first-child {
  min-width: 240px;
}

.product-table td:first-child strong {
  display: block;
  margin-bottom: 3px;
  color: var(--text);
  font-weight: 600;
}

.product-table td:first-child span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.open-button {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
}

.open-button:hover,
.icon-button:hover,
.primary-button:hover,
.secondary-button:hover,
.nav-list a:hover {
  filter: brightness(0.97);
}

.empty-state {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.detail-page {
  display: grid;
  gap: 16px;
}

.detail-topbar {
  min-height: 52px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.detail-topbar h1 {
  text-align: center;
  font-size: 18px;
}

.detail-hero {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
}

.general-card {
  display: grid;
  align-content: start;
  gap: 12px;
}

.detail-kv {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) minmax(0, 1.2fr);
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.detail-kv strong {
  min-width: 0;
  color: var(--text);
  font-weight: 600;
  text-align: right;
}

.upload-inline {
  justify-self: start;
  margin-top: 6px;
}

.event-summary-rail {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
  padding: 32px 18px 8px;
}

.event-summary-rail::before {
  content: "";
  position: absolute;
  top: 42px;
  left: 28px;
  right: 28px;
  height: 1px;
  background: var(--line-strong);
}

.event-summary-card {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 4px;
  min-height: 150px;
  padding-top: 28px;
  text-align: center;
}

.event-dot {
  position: absolute;
  top: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #020617;
}

.event-summary-card h3 {
  margin: 0;
  font-size: 18px;
}

.event-summary-card p,
.event-summary-status,
.event-summary-note {
  margin: 0;
  font-size: 12px;
}

.event-summary-status {
  color: var(--muted);
}

.event-summary-note {
  max-width: 440px;
  color: var(--text);
  text-align: left;
  line-height: 1.4;
}

.detail-main-grid {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.terms-column {
  display: grid;
  gap: 16px;
}

.term-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.term-card h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  font-size: 18px;
}

.term-icon {
  color: #0f766e;
  font-weight: 600;
}

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

.term-item {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.term-item span {
  color: var(--muted);
  font-size: 13px;
}

.term-item strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.performance-detail-panel h2,
.detail-wide-panel h2 {
  margin-bottom: 18px;
  font-size: 18px;
}

.cashflow-table-wrap {
  overflow-x: auto;
  margin: 14px -16px -16px;
}

.cashflow-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  font-size: 14px;
}

.cashflow-table th,
.cashflow-table td {
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.cashflow-table th {
  color: var(--text);
  font-weight: 600;
}

.cashflow-table td {
  color: var(--text);
  line-height: 1.4;
}

.detail-drawer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
}

.detail-drawer.open {
  display: block;
}

.drawer-scrim {
  position: absolute;
  inset: 0;
  background: rgba(24, 24, 27, 0.32);
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(880px, 100vw);
  height: 100%;
  overflow: auto;
  padding: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.drawer-close {
  position: sticky;
  top: 0;
  float: right;
  border-radius: 8px;
  font-size: 24px;
}

.drawer-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.performance-card {
  margin: 12px 0 14px;
  overflow-x: auto;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.chart-legend-item i {
  width: 18px;
  height: 2px;
  display: inline-block;
}

.performance-chart {
  display: block;
  min-width: 720px;
  width: 100%;
  height: auto;
}

.grid-line {
  stroke: #e8ebef;
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.grid-line.vertical {
  stroke: #eef0f3;
}

.reference-line {
  stroke: #c9cdd3;
  stroke-width: 1.2;
}

.strike-line {
  stroke: #d7dbe0;
  stroke-width: 1.2;
}

.performance-line {
  fill: none;
  stroke: var(--line-color);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.performance-end-label {
  font-size: 13px;
  font-weight: 600;
  dominant-baseline: middle;
}

.axis-label,
.reference-label {
  fill: var(--muted);
  font-size: 11px;
}

.performance-table {
  width: 100%;
  min-width: 720px;
  margin-top: 12px;
  border-collapse: collapse;
  font-size: 13px;
}

.performance-table th,
.performance-table td {
  padding: 11px 10px;
  border-top: 1px solid var(--line);
  text-align: left;
}

.performance-table th {
  color: var(--muted);
  font-weight: 500;
}

.performance-table td {
  color: var(--text);
  font-weight: 500;
}

.performance-table td span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-weight: 400;
}

.performance-table .positive {
  color: #139b6b;
}

.performance-table .negative {
  color: #c24141;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .topbar {
    grid-template-columns: 1fr 1fr;
  }

  .app-shell {
    width: min(100vw - 32px, 1320px);
  }

  .summary-grid,
  .monitor-grid,
  .product-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .detail-hero,
  .detail-main-grid {
    grid-template-columns: 1fr;
  }

  .event-summary-rail {
    grid-template-columns: 1fr;
  }

  .event-summary-rail::before {
    display: none;
  }

  .quote-form,
  .upload-form,
  .rfq-row {
    grid-template-columns: 1fr;
  }

  .upload-actions {
    grid-column: 1;
  }

  .open-button {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 24px, 1440px);
    padding-top: 16px;
  }

  .page-header,
  .panel-heading,
  .filters,
  .topbar {
    align-items: stretch;
    flex-direction: column;
    display: flex;
  }

  .summary-grid,
  .monitor-grid {
    grid-template-columns: 1fr;
  }

  .search-box {
    min-width: 0;
  }

  .breakdown-row,
  .event-row {
    grid-template-columns: 1fr;
  }
}
