/* Nexora TradeFlow — Design System */

:root {
  /* Neutrals - warm cream backdrop */
  --bg: #F6F4EE;
  --bg-elev: #FBFAF6;
  --surface: #FFFFFF;
  --surface-alt: #F2EFE7;
  --border: #E5E0D3;
  --border-strong: #CFC8B6;
  --border-subtle: #ECE7D8;

  /* Text */
  --text: #0E1A2B;
  --text-2: #3A4A5F;
  --text-3: #6B7889;
  --text-4: #93A0B0;
  --text-inv: #F6F4EE;

  /* Brand — deep maritime navy */
  --brand: #0B2A47;
  --brand-2: #133E63;
  --brand-3: #1F567F;
  --brand-tint: #E8EEF4;

  /* Accent — atlantic teal */
  --accent: #1E7A6F;
  --accent-2: #166A60;
  --accent-tint: #DBEDE9;

  /* Semantic */
  --success: #2D7A4F;
  --success-tint: #E0EFE3;
  --warning: #B88515;
  --warning-tint: #F4E9C8;
  --danger: #B0322E;
  --danger-tint: #F4DCD9;
  --info: #2F6FB5;
  --info-tint: #DEEAF7;
  --neutral: #6B7889;
  --neutral-tint: #ECECEC;

  /* Status colors for workflow */
  --draft: #6B7889;
  --pending: #B88515;
  --inprogress: #2F6FB5;
  --approved: #2D7A4F;
  --rejected: #B0322E;
  --closed: #0E1A2B;

  /* Layout */
  --sidebar-w: 248px;
  --topbar-h: 56px;
  --radius: 6px;
  --radius-sm: 4px;
  --radius-lg: 10px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(14, 26, 43, 0.04);
  --shadow: 0 1px 3px rgba(14, 26, 43, 0.06), 0 1px 2px rgba(14, 26, 43, 0.04);
  --shadow-lg: 0 10px 32px rgba(14, 26, 43, 0.12), 0 2px 6px rgba(14, 26, 43, 0.04);

  /* Type */
  --font: "Manrope", -apple-system, "Helvetica Neue", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
}

#root {
  min-height: 100vh;
}

/* ===== Layout ===== */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  height: 100vh;
  overflow: hidden;
}

.topbar {
  grid-column: 1 / -1;
  background: var(--brand);
  color: var(--text-inv);
  display: flex;
  align-items: center;
  padding: 0 16px 0 0;
  border-bottom: 1px solid #051828;
  z-index: 10;
  position: relative;
}

.topbar-brand {
  width: var(--sidebar-w);
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 100%;
  border-right: 1px solid rgba(255,255,255,0.08);
}

.topbar-brand-mark {
  width: 26px;
  height: 26px;
  background: var(--accent);
  display: grid;
  place-items: center;
  border-radius: 4px;
  color: white;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: -0.02em;
}

.topbar-brand-text {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
}
.topbar-brand-text .sub {
  display: block;
  font-size: 10px;
  font-weight: 500;
  opacity: 0.6;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-center {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
}

.topbar-search {
  flex: 1;
  max-width: 420px;
  position: relative;
}

.topbar-search input {
  width: 100%;
  height: 32px;
  padding: 0 12px 0 32px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  color: white;
  font-family: inherit;
  font-size: 13px;
  outline: none;
}
.topbar-search input::placeholder { color: rgba(255,255,255,0.5); }
.topbar-search input:focus {
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.25);
}
.topbar-search .icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.6;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-btn {
  height: 32px;
  min-width: 32px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: white;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
}
.topbar-btn:hover { background: rgba(255,255,255,0.08); }

.topbar-env {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.topbar-env .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4CD0A8;
}

.topbar-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  cursor: pointer;
}
.topbar-user .avatar {
  width: 24px;
  height: 24px;
  background: var(--accent);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
}
.topbar-user .name {
  font-size: 12px;
  font-weight: 600;
}

.topbar-tenant {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
  background: rgba(255,255,255,0.04);
}
.topbar-tenant:hover { background: rgba(255,255,255,0.08); }
.topbar-tenant .label {
  font-size: 9.5px;
  opacity: 0.55;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: block;
  line-height: 1;
}
.topbar-tenant .value {
  font-weight: 600;
  line-height: 1.2;
}

/* ===== Sidebar ===== */

.sidebar {
  background: var(--brand-2);
  color: rgba(255,255,255,0.85);
  overflow-y: auto;
  padding: 12px 0;
  border-right: 1px solid #051828;
}

.sidebar-section {
  padding: 10px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 16px 7px 14px;
  margin: 0 8px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  color: rgba(255,255,255,0.78);
  border-left: 2px solid transparent;
  position: relative;
  transition: background 0.1s;
  white-space: nowrap;
}
.sidebar-item span:not(.badge) { overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.sidebar-item:hover {
  background: rgba(255,255,255,0.06);
  color: white;
}
.sidebar-item.active {
  background: rgba(255,255,255,0.1);
  color: white;
  font-weight: 600;
}
.sidebar-item .badge {
  margin-left: auto;
  background: rgba(255,255,255,0.12);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}
.sidebar-item .accent {
  background: var(--accent);
}
.sidebar-item .icon {
  opacity: 0.7;
  flex-shrink: 0;
}
.sidebar-item.active .icon { opacity: 1; }

.pipeline-strip {
  margin: 8px 16px 16px;
  padding: 10px;
  background: rgba(0,0,0,0.18);
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.06);
}
.pipeline-strip h5 {
  margin: 0 0 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.4);
  font-weight: 700;
}
.pipeline-strip .pipe {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  color: rgba(255,255,255,0.6);
  flex-wrap: wrap;
}
.pipeline-strip .pipe span {
  white-space: nowrap;
}
.pipeline-strip .pipe .arrow {
  opacity: 0.4;
}

/* ===== Main content ===== */

.main {
  overflow-y: auto;
  background: var(--bg);
}

.page {
  padding: 24px 28px 64px;
  max-width: 1600px;
}

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

.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 4px;
}

.page-sub {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 4px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.crumbs {
  display: flex;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 8px;
}
.crumbs a {
  color: var(--text-3);
  text-decoration: none;
  cursor: pointer;
}
.crumbs a:hover { color: var(--brand); }
.crumbs .sep { opacity: 0.5; }

/* ===== Buttons ===== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  transition: all 0.1s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-alt); }
.btn:active { transform: translateY(0.5px); }

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}
.btn-primary:hover { background: var(--brand-2); }

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.btn-accent:hover { background: var(--accent-2); }

.btn-danger {
  background: var(--surface);
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger-tint); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--surface-alt);
  border-color: var(--border);
}

.btn-icon {
  padding: 0;
  width: 32px;
}

.btn-sm {
  height: 26px;
  padding: 0 10px;
  font-size: 11.5px;
}

.btn-lg {
  height: 38px;
  padding: 0 16px;
  font-size: 13.5px;
}

/* ===== Cards ===== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.card-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}
.card-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}
.card-body {
  padding: 18px;
}
.card-body.no-pad { padding: 0; }

/* ===== KPI cards ===== */

.kpi-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}
.kpi-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.kpi-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.kpi-grid.cols-5 { grid-template-columns: repeat(5, 1fr); }

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}
.kpi.kpi-brand { background: var(--brand); color: white; border-color: var(--brand); }
.kpi.kpi-brand .kpi-label { color: rgba(255,255,255,0.7); }
.kpi.kpi-brand .kpi-delta-up { color: #6FE5B8; }
.kpi.kpi-brand .kpi-foot { color: rgba(255,255,255,0.6); }
.kpi-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.kpi-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-family: var(--font);
  line-height: 1.1;
}
.kpi-value .unit {
  font-size: 13px;
  opacity: 0.5;
  font-weight: 500;
  margin-left: 4px;
}
.kpi-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--text-3);
}
.kpi-delta-up { color: var(--success); font-weight: 600; }
.kpi-delta-down { color: var(--danger); font-weight: 600; }
.kpi-spark {
  position: absolute;
  right: 14px;
  bottom: 12px;
  width: 80px;
  height: 30px;
  opacity: 0.65;
}

/* ===== Tables ===== */

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th, .table td {
  text-align: left;
  padding: 10px 12px;
  vertical-align: middle;
}
.table th {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text); }
.table td {
  border-bottom: 1px solid var(--border-subtle);
}
.table tbody tr {
  cursor: pointer;
  transition: background 0.06s;
}
.table tbody tr:hover {
  background: var(--surface-alt);
}
.table tbody tr.selected {
  background: var(--brand-tint);
}
.table-id {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
  font-weight: 500;
}
.table-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.table-strong { font-weight: 600; }
.table-muted { color: var(--text-3); }
.table .row-action {
  opacity: 0;
  display: inline-flex;
  gap: 4px;
}
.table tbody tr:hover .row-action { opacity: 1; }

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.table-toolbar .grow { flex: 1; }

.table-search {
  position: relative;
  width: 260px;
}
.table-search input {
  width: 100%;
  height: 30px;
  padding: 0 12px 0 30px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 12.5px;
  background: var(--surface);
  outline: none;
}
.table-search input:focus { border-color: var(--brand); }
.table-search .icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  height: 30px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
}
.filter-chip:hover { border-style: solid; border-color: var(--brand); color: var(--brand); }
.filter-chip.active {
  border-style: solid;
  border-color: var(--brand);
  background: var(--brand-tint);
  color: var(--brand);
}
.filter-chip .pill {
  background: var(--brand);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  font-family: var(--font-mono);
}

.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
  background: var(--surface-alt);
}

.pager {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pager button {
  height: 26px;
  min-width: 26px;
  padding: 0 8px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-2);
}
.pager button.active { background: var(--brand); color: white; border-color: var(--brand); }
.pager button:hover:not(.active) { background: var(--surface-alt); }

/* ===== Badges / Status pills ===== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.4;
  border: 1px solid transparent;
}
.badge .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.badge-draft { background: #ECEEF1; color: #4A5563; border-color: #DDE1E6; }
.badge-pending { background: var(--warning-tint); color: var(--warning); border-color: #E5D29A; }
.badge-progress { background: var(--info-tint); color: var(--info); border-color: #BAD2EE; }
.badge-approved { background: var(--success-tint); color: var(--success); border-color: #B7D9C0; }
.badge-rejected { background: var(--danger-tint); color: var(--danger); border-color: #E8B9B6; }
.badge-closed { background: #2A3849; color: white; border-color: #2A3849; }
.badge-accent { background: var(--accent-tint); color: var(--accent); border-color: #BBD9D3; }

.badge-soft {
  padding: 2px 7px;
  font-size: 10.5px;
  font-weight: 600;
  background: var(--surface-alt);
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ===== Tabs ===== */

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}
.tab .count {
  background: var(--surface-alt);
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-3);
}
.tab.active .count { background: var(--brand-tint); color: var(--brand); }

/* ===== Forms ===== */

.form-grid {
  display: grid;
  gap: 14px 18px;
  grid-template-columns: repeat(4, 1fr);
}
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field.span-2 { grid-column: span 2; }
.form-field.span-3 { grid-column: span 3; }
.form-field.span-4 { grid-column: span 4; }
.form-field.span-full { grid-column: 1 / -1; }
.form-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 4px;
}
.form-label .req { color: var(--danger); }
.form-label .info { color: var(--text-4); font-weight: 500; }
.form-input,
.form-select,
.form-textarea {
  height: 34px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  outline: none;
  width: 100%;
  font-feature-settings: "tnum";
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.form-input:disabled,
.form-select:disabled { background: var(--surface-alt); color: var(--text-3); cursor: not-allowed; }
.form-input.with-prefix { padding-left: 32px; }

.form-textarea {
  min-height: 76px;
  padding: 8px 10px;
  height: auto;
  resize: vertical;
  line-height: 1.4;
}

.form-help {
  font-size: 11px;
  color: var(--text-3);
}

.input-prefix {
  position: relative;
}
.input-prefix .px {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-3);
}

.form-section {
  border-top: 1px solid var(--border);
  padding-top: 18px;
  margin-top: 22px;
}
.form-section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.form-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-section-title .num {
  background: var(--brand);
  color: white;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
}

/* ===== Sticky form bar ===== */

.form-actions-bar {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 20px -18px -18px;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ===== Status workflow display ===== */

.workflow-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 16px;
}

.workflow-states {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
  overflow-x: auto;
}
.wf-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 20px;
  background: var(--surface-alt);
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
  position: relative;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%, 10px 50%);
  margin-right: -1px;
  white-space: nowrap;
}
.wf-state:first-child {
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%);
  padding-left: 12px;
}
.wf-state:last-child {
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 10px 50%);
}
.wf-state.done { background: var(--accent-tint); color: var(--accent); }
.wf-state.current { background: var(--brand); color: white; }
.wf-state .ix { font-family: var(--font-mono); opacity: 0.55; font-size: 10.5px; }

/* ===== Sub-grid editable table ===== */

.subgrid {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.subgrid-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.subgrid-toolbar .title {
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.subgrid table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.subgrid th {
  background: var(--surface);
  font-weight: 600;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.subgrid td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.subgrid .input-cell {
  width: 100%;
  height: 26px;
  padding: 0 8px;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 12.5px;
  border-radius: 4px;
  outline: none;
}
.subgrid .input-cell:hover { background: var(--surface-alt); }
.subgrid .input-cell:focus { background: var(--surface); border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-tint); }
.subgrid .input-cell.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: 12px; }
.subgrid .calc-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
  background: var(--surface-alt);
  padding: 6px 10px;
  border-radius: 3px;
}
.subgrid tfoot td {
  background: var(--surface-alt);
  font-weight: 600;
  font-size: 12px;
  border-top: 2px solid var(--border-strong);
  border-bottom: 0;
  padding: 10px;
}
.subgrid .row-del {
  color: var(--text-4);
  cursor: pointer;
  padding: 4px;
  border-radius: 3px;
}
.subgrid .row-del:hover { color: var(--danger); background: var(--danger-tint); }

/* ===== Side panel ===== */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.panel-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  margin-bottom: 12px;
}

.kv {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  font-size: 12.5px;
}
.kv dt { color: var(--text-3); font-weight: 500; }
.kv dd { margin: 0; font-weight: 600; color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }

.kv.stacked {
  grid-template-columns: 1fr;
  gap: 12px;
}
.kv.stacked dt { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.kv.stacked dd { text-align: left; font-size: 13px; }

/* ===== Timeline ===== */

.timeline {
  position: relative;
  padding-left: 22px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: var(--border-strong);
}
.timeline-item {
  position: relative;
  padding-bottom: 14px;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: -22px;
  top: 4px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--brand);
}
.timeline-item.muted::before { border-color: var(--border-strong); }
.timeline-item.success::before { border-color: var(--success); background: var(--success); }
.timeline-item.danger::before { border-color: var(--danger); background: var(--danger); }
.timeline-item .head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12.5px;
}
.timeline-item .when {
  font-size: 11.5px;
  color: var(--text-3);
  font-family: var(--font-mono);
}
.timeline-item .who {
  font-weight: 600;
}
.timeline-item .comment {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 3px;
  padding: 6px 10px;
  background: var(--surface-alt);
  border-radius: 4px;
  border-left: 2px solid var(--border-strong);
}

/* ===== Permissions matrix ===== */

.perm-matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.perm-matrix th, .perm-matrix td {
  padding: 8px;
  text-align: center;
  border-bottom: 1px solid var(--border-subtle);
}
.perm-matrix th {
  background: var(--surface-alt);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
}
.perm-matrix th:first-child, .perm-matrix td:first-child {
  text-align: left;
  font-weight: 600;
}
.perm-matrix .perm-cell {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 4px;
  background: var(--surface-alt);
  cursor: pointer;
  color: var(--text-4);
  transition: all 0.1s;
}
.perm-matrix .perm-cell.on { background: var(--accent); color: white; }
.perm-matrix .perm-cell.na { opacity: 0.25; cursor: not-allowed; }

/* ===== Modal/dialog ===== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14,26,43,0.4);
  display: grid;
  place-items: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 560px;
  overflow: hidden;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { margin: 0; font-size: 15px; font-weight: 700; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-alt); }

/* ===== Utility ===== */

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-4 { gap: 4px; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }
.gap-24 { gap: 24px; }
.grow { flex: 1; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.text-3 { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-strong { font-weight: 700; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fullw { width: 100%; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-cols-side { display: grid; grid-template-columns: 1fr 320px; gap: 16px; }

/* ===== Map mockup ===== */

.map-wrap {
  background: linear-gradient(135deg, #DDE9F1 0%, #C9DDEC 100%);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
}

.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-3);
}
.empty-state .icon-circle {
  width: 48px;
  height: 48px;
  background: var(--surface-alt);
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  margin-bottom: 14px;
}
.empty-state h4 { margin: 0 0 6px; color: var(--text-2); font-size: 14px; }
.empty-state p { margin: 0 0 16px; font-size: 13px; }

/* ===== Tags inline ===== */

.tag-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  font-size: 10.5px;
  font-weight: 600;
  background: var(--brand-tint);
  color: var(--brand);
  border-radius: 3px;
  border: 1px solid #C7D6E5;
}
.tag.tag-accent { background: var(--accent-tint); color: var(--accent); border-color: #BAD7D2; }
.tag.tag-warn { background: var(--warning-tint); color: var(--warning); border-color: #E5D29A; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(14,26,43,0.18); border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: rgba(14,26,43,0.35); }
::-webkit-scrollbar-track { background: transparent; }

/* Sidebar scrollbar */
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-color: var(--brand-2); }

/* ===== Auth/login screen ===== */
.auth-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
}
.auth-left {
  background: var(--brand);
  color: white;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-left::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at top right, rgba(30,122,111,0.3), transparent 60%);
}
.auth-left > * { position: relative; z-index: 1; }
.auth-right {
  display: grid;
  place-items: center;
  padding: 48px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
}

.azure-btn {
  width: 100%;
  height: 44px;
  background: white;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}
.azure-btn:hover { background: var(--surface-alt); }
