:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: #1c2533;
  background: #eef3f8;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(120deg, rgba(34, 117, 255, 0.08), transparent 38%),
    linear-gradient(155deg, #eef3f8 0%, #f8fafc 52%, #edf7f2 100%);
}

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

button {
  border: 0;
  cursor: pointer;
}

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

.sidebar {
  padding: 24px 18px;
  background: #172033;
  color: #eef5ff;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #36c38f;
  color: #082116;
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 3px;
  color: #9db0ca;
}

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

nav a {
  padding: 11px 12px;
  border-radius: 8px;
  color: #c9d6e8;
  text-decoration: none;
}

nav a.active,
nav a:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.workspace {
  padding: 24px;
  overflow: auto;
}

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

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

.topbar h1 {
  margin-bottom: 6px;
  font-size: 30px;
  letter-spacing: 0;
}

.topbar p {
  max-width: 820px;
  margin-bottom: 0;
  color: #647286;
  line-height: 1.7;
}

.status-pill {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 999px;
  background: #dbf7ec;
  color: #087246;
  font-weight: 800;
}

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

.panel {
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid #dce4ee;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 16px 40px rgba(36, 51, 77, 0.08);
}

.panel-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-title h1,
.panel-title h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.panel-title span {
  color: #768497;
  font-size: 13px;
  text-align: right;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  color: #405066;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #ccd8e5;
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
  color: #172033;
  outline: none;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #2275ff;
  box-shadow: 0 0 0 3px rgba(34, 117, 255, 0.12);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.primary {
  width: 100%;
  min-height: 46px;
  border-radius: 8px;
  background: #2275ff;
  color: #fff;
  font-weight: 900;
}

.hint {
  min-height: 20px;
  margin: 10px 0 0;
  color: #087246;
  font-weight: 700;
}

.parse-tools {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: -4px 0 12px;
}

.parse-hint {
  margin: 0;
  color: #647286;
  font-size: 13px;
  line-height: 1.5;
}

.parse-hint.ok {
  color: #087246;
  font-weight: 800;
}

.parse-hint.warn {
  color: #a15c00;
  font-weight: 800;
}

.reuse-panel {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid #d5e0ee;
  border-radius: 8px;
  background: #f8fbff;
}

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

.reuse-head strong,
.reuse-head span {
  display: block;
}

.reuse-head span {
  margin-top: 4px;
  color: #647286;
  font-size: 13px;
  line-height: 1.5;
}

.history-results {
  display: grid;
  gap: 8px;
}

.history-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid #dce4ee;
  border-radius: 8px;
  background: #fff;
}

.history-card strong,
.history-card span,
.history-card small {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.history-card strong {
  color: #172033;
}

.history-card span {
  margin-top: 4px;
  color: #526176;
  font-size: 13px;
}

.history-card small {
  margin-top: 3px;
  color: #768497;
  font-size: 12px;
}

.order-list,
.supplier-list,
.log-list,
.finance-packet-list {
  display: grid;
  gap: 12px;
}

.empty {
  padding: 26px;
  border: 1px dashed #cbd8e7;
  border-radius: 8px;
  color: #7b8899;
  text-align: center;
}

.empty.compact {
  padding: 14px;
  font-size: 13px;
}

.order-card,
.supplier-card,
.log-card,
.finance-packet {
  border: 1px solid #dce4ee;
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

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

.packet-grid section {
  display: grid;
  gap: 7px;
  padding: 12px;
  border-radius: 8px;
  background: #f8fbff;
  color: #526176;
  font-size: 14px;
}

.packet-grid h3 {
  margin: 0 0 4px;
  color: #1c2533;
  font-size: 15px;
}

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

.summary-cards article {
  padding: 14px;
  border: 1px solid #dce4ee;
  border-radius: 8px;
  background: #f8fbff;
}

.summary-cards span {
  display: block;
  color: #647286;
  font-size: 13px;
}

.summary-cards strong {
  display: block;
  margin-top: 8px;
  color: #172033;
  font-size: 22px;
  line-height: 1;
  overflow-wrap: anywhere;
}

.dashboard-table {
  border: 1px solid #dce4ee;
  border-radius: 8px;
  overflow: hidden;
}

.dashboard-row {
  display: grid;
  grid-template-columns: 1fr 1.2fr 0.6fr 0.9fr 0.9fr 0.9fr 0.7fr;
  gap: 10px;
  padding: 11px 12px;
  border-top: 1px solid #e7edf5;
  color: #526176;
  font-size: 14px;
}

.dashboard-row:first-child {
  border-top: 0;
}

.dashboard-head {
  background: #edf3fb;
  color: #253348;
  font-weight: 900;
}

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

.card-head strong {
  font-size: 16px;
}

.tag {
  padding: 5px 9px;
  border-radius: 999px;
  background: #eef4ff;
  color: #205fca;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.tag.done {
  background: #dbf7ec;
  color: #087246;
}

.tag.warn {
  background: #fff2cf;
  color: #8a6100;
}

.auto-capture-note {
  margin: 0 0 10px;
  padding: 9px 10px;
  border-radius: 8px;
  background: #eef7ff;
  color: #245b92;
  font-size: 13px;
  font-weight: 800;
}

.meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  color: #5f6f83;
  font-size: 14px;
}

.meta span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.order-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.finance-form,
.review-box {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #dce4ee;
  border-radius: 8px;
  background: #f8fbff;
}

.finance-form textarea {
  min-height: 70px;
}

.review-box strong {
  display: block;
  margin-bottom: 8px;
}

.private-rebate-fields[hidden] {
  display: none;
}

.private-rebate-fields.is-visible {
  display: grid;
}

.ocr-fallback {
  margin: 8px 0 12px;
  padding: 12px;
  border: 1px solid #dce4ee;
  border-radius: 8px;
  background: #f8fbff;
}

.ocr-fallback[hidden] {
  display: none;
}

.ocr-fallback textarea {
  min-height: 86px;
}

.small-button,
.link-button {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 8px;
  background: #edf3fb;
  color: #1f4f95;
  font-weight: 800;
  text-decoration: none;
}

.receipt-preview {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #dce4ee;
  border-radius: 8px;
  background: #f8fbff;
}

.receipt-image {
  width: 180px;
  height: 120px;
  border: 1px solid #dce4ee;
  border-radius: 8px;
  object-fit: cover;
  background: #fff;
}

.log-card pre {
  margin: 8px 0 0;
  padding: 10px;
  max-height: 160px;
  overflow: auto;
  border-radius: 8px;
  background: #111827;
  color: #dbeafe;
  white-space: pre-wrap;
}

.supplier-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.supplier-shell {
  width: min(100%, 720px);
}

.receipt-card {
  margin: 0;
}

.summary {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  padding: 14px;
  border-radius: 8px;
  background: #f3f7fb;
  color: #3e4e62;
}

.simple-upload {
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 1px dashed #9db1c9;
  border-radius: 8px;
  background: #f8fbff;
  cursor: pointer;
}

.simple-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.simple-upload strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border-radius: 8px;
  background: #1f6feb;
  color: #fff;
}

.simple-upload em {
  color: #64748b;
  font-style: normal;
}

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

  .sidebar {
    position: static;
  }

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

  nav a {
    text-align: center;
  }

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

@media (max-width: 640px) {
  .workspace {
    padding: 14px;
  }

  .topbar {
    display: grid;
  }

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

  .form-row,
  .meta,
  .packet-grid,
  .summary-cards,
  .dashboard-row,
  .history-card {
    grid-template-columns: 1fr;
  }
}
