:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #f1f5f9;
  --ink: #172033;
  --muted: #64748b;
  --line: #dbe3ee;
  --navy: #1e3a8a;
  --orange: #f97316;
  --green: #15803d;
  --red: #b91c1c;
  --yellow: #a16207;
  --shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 18px;
  background: #102a67;
  color: #ffffff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.brand img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  background: #ffffff;
  border-radius: 8px;
}

.brand strong {
  display: block;
  font-size: 17px;
}

.brand span {
  display: block;
  margin-top: 3px;
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 700;
}

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

.nav-btn {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 12px;
  background: transparent;
  color: #cbd5e1;
  font-weight: 800;
  text-align: left;
}

.nav-btn:hover,
.nav-btn.active {
  background: var(--orange);
  color: #ffffff;
}

/* ── Transfer Pill Buttons ── */
.transfer-pills {
  margin-top: auto;
  display: flex;
  gap: 8px;
}

.pill-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.pill-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.45);
  color: #ffffff;
}

.pill-btn svg {
  flex-shrink: 0;
  opacity: 0.85;
}

.stack {
  display: grid;
  gap: 8px;
}

.main {
  min-width: 0;
}

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

.eyebrow {
  margin: 0 0 2px;
  color: var(--orange);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

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

.top-actions,
.row-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.content {
  padding: 24px 28px 40px;
}

.btn {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 9px 13px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--orange);
  color: #ffffff;
}

.btn-navy {
  background: var(--navy);
  color: #ffffff;
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.btn-danger {
  background: #fee2e2;
  color: var(--red);
  border-color: #fecaca;
}

.file-btn {
  position: relative;
  overflow: hidden;
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

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

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

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

.kpi strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
  color: var(--navy);
}

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

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 17px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filters input,
.filters select {
  min-height: 40px;
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: var(--surface);
  color: var(--ink);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

tr:last-child td {
  border-bottom: 0;
}

.muted {
  color: var(--muted);
}

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

.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 900;
}

.badge.draft,
.badge.sent {
  background: #fef3c7;
  color: var(--yellow);
}

.badge.approved,
.badge.paid,
.badge.active {
  background: #dcfce7;
  color: var(--green);
}

.badge.cancelled,
.badge.expired {
  background: #fee2e2;
  color: var(--red);
}

.badge.converted {
  background: #dbeafe;
  color: var(--navy);
}

.editor {
  display: grid;
  gap: 16px;
}

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

.section h2,
.section h3 {
  margin-bottom: 12px;
  color: var(--navy);
  font-size: 18px;
}

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

.field {
  display: grid;
  gap: 7px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: var(--surface);
  color: var(--ink);
}

.field textarea {
  min-height: 84px;
  resize: vertical;
}

.field input[readonly] {
  background: var(--surface-soft);
}

.products {
  display: grid;
  gap: 12px;
}

.product-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-soft);
}

.product-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.product-head strong {
  color: var(--navy);
}

.summary-bar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -10px 28px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(8px);
}

.totals {
  display: grid;
  grid-template-columns: repeat(5, auto);
  gap: 10px 18px;
  align-items: end;
}

.total-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.total-item strong {
  display: block;
  margin-top: 3px;
}

.total-item.grand strong {
  color: var(--orange);
  font-size: 21px;
}

.toast-wrap {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  display: grid;
  gap: 8px;
}

.toast {
  max-width: 360px;
  border-radius: 8px;
  padding: 12px 14px;
  background: #0f172a;
  color: #ffffff;
  box-shadow: var(--shadow);
  font-weight: 700;
}

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

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

  .nav {
    grid-template-columns: repeat(3, 1fr);
  }

  .transfer-pills {
    margin-top: 0;
  }

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

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

@media (max-width: 680px) {
  .topbar,
  .panel-head,
  .summary-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .content {
    padding: 18px;
  }

  .nav,
  .form-grid,
  .kpis,
  .totals {
    grid-template-columns: 1fr;
  }

  .filters,
  .filters input,
  .filters select,
  .top-actions .btn,
  .form-actions .btn {
    width: 100%;
  }
}
