:root {
  --ink: #17211c;
  --muted: #69746d;
  --paper: #f5f1e8;
  --panel: #fffdf8;
  --panel-2: #f9fbf8;
  --line: #d9d3c7;
  --green: #28684f;
  --green-dark: #163f31;
  --gold: #b57826;
  --blue: #2f6172;
  --red: #a44338;
  --violet: #5b557c;
  --shadow: 0 18px 42px rgba(28, 33, 30, 0.09);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #f6f8f2 0%, #edf2ec 48%, #f7f2e8 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(250px, max-content) minmax(0, 1fr) max-content;
  align-items: center;
  gap: 20px;
  padding: 16px clamp(16px, 3vw, 34px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.95);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--green-dark);
  color: #fff;
  font-weight: 900;
}

.brand strong {
  display: block;
  font-family: Outfit, ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(1rem, 1.5vw, 1.2rem);
  line-height: 1.15;
}

.eyebrow {
  display: block;
  margin: 0 0 3px;
  color: var(--red);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topnav {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  min-width: 0;
}

.topnav a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 850;
  text-decoration: none;
  white-space: nowrap;
}

.topnav a:hover,
.topnav a:focus-visible,
.topnav a[aria-current="page"] {
  color: #fff;
  background: var(--green-dark);
  outline: none;
}

.data-stamp {
  display: grid;
  justify-items: end;
  gap: 1px;
  min-width: 128px;
  color: var(--muted);
  font-size: 0.76rem;
}

.data-stamp strong {
  color: var(--ink);
  font-size: 0.84rem;
}

.dashboard-shell {
  width: min(1780px, 100%);
  margin: 0 auto;
  padding: clamp(16px, 3vw, 28px);
}

.command-band {
  position: relative;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  min-height: 144px;
  margin-bottom: 16px;
  overflow: hidden;
}

.command-band > div:first-child {
  min-width: 0;
  max-width: 100%;
}

.command-band::after {
  content: "";
  position: absolute;
  inset: 0 0 auto auto;
  z-index: -1;
  width: min(560px, 46vw);
  height: 100%;
  background:
    linear-gradient(90deg, rgba(246, 248, 242, 1), rgba(246, 248, 242, 0.54), rgba(246, 248, 242, 0.16)),
    url("assets/rice.jpg") center / cover;
  opacity: 0.36;
  mask-image: linear-gradient(90deg, transparent 0%, #000 34%, #000 100%);
}

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

h1,
h2,
h3 {
  font-family: Outfit, ui-sans-serif, system-ui, sans-serif;
}

h1 {
  max-width: 880px;
  margin-bottom: 0;
  font-size: clamp(1.55rem, 3vw, 2.65rem);
  line-height: 1.02;
  overflow-wrap: break-word;
}

.mobile-title {
  display: none;
}

.command-actions,
.table-toolbar,
.panel-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tool-button,
.icon-button,
.quick-views button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--green-dark);
  font-weight: 850;
}

.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 12px;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(28, 33, 30, 0.05);
}

.tool-button:hover,
.tool-button:focus-visible,
.icon-button:hover,
.icon-button:focus-visible,
.quick-views button:hover,
.quick-views button:focus-visible {
  border-color: rgba(40, 104, 79, 0.45);
  background: #eef5ef;
  outline: none;
}

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

.metric {
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: 0 8px 18px rgba(28, 33, 30, 0.04);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 4px;
  color: var(--green-dark);
  font-family: Outfit, ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(1.55rem, 2.5vw, 2.1rem);
}

.workspace-grid {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 380px;
  gap: 14px;
  align-items: start;
}

.filter-panel,
.table-panel,
.detail-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.97);
  box-shadow: var(--shadow);
}

.filter-panel,
.detail-panel {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 108px);
  overflow: auto;
  padding: 14px;
}

.panel-heading {
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-heading h2,
.queue-box h2,
.detail-panel h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
}

.field,
.compact-field {
  display: grid;
  gap: 5px;
}

.field {
  margin-bottom: 11px;
}

.field span,
.compact-field span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 850;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 39px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus {
  border-color: rgba(40, 104, 79, 0.7);
  outline: 3px solid rgba(40, 104, 79, 0.16);
}

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

.quick-views button {
  min-height: 36px;
  padding: 7px 8px;
  font-size: 0.82rem;
}

.quick-views button.is-active {
  border-color: var(--green-dark);
  background: var(--green-dark);
  color: #fff;
}

.queue-box {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.queue-box ol {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding-left: 22px;
}

.queue-box button {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 7px;
  background: #f7f5ee;
  color: var(--ink);
  text-align: left;
}

.queue-box strong,
.queue-box span {
  display: block;
}

.queue-box span {
  color: var(--muted);
  font-size: 0.76rem;
}

.table-panel {
  min-width: 0;
  overflow: hidden;
}

.table-toolbar {
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.table-toolbar p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.compact-field {
  grid-template-columns: auto minmax(160px, 220px);
  align-items: center;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 236px);
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  table-layout: fixed;
}

th:nth-child(1),
td:nth-child(1) {
  width: 23%;
}

th:nth-child(2),
td:nth-child(2) {
  width: 8%;
}

th:nth-child(3),
td:nth-child(3) {
  width: 17%;
}

th:nth-child(4),
td:nth-child(4) {
  width: 22%;
}

th:nth-child(5),
td:nth-child(5) {
  width: 30%;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid #e8e2d7;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #f3efe5;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

tbody tr {
  background: rgba(255, 253, 248, 0.98);
}

tbody tr:hover,
tbody tr.is-selected {
  background: #f0f6f0;
}

tbody tr:focus-within {
  outline: 3px solid rgba(47, 97, 114, 0.2);
  outline-offset: -3px;
}

.row-button {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.supplier-name {
  display: block;
  max-width: 280px;
  font-weight: 900;
  line-height: 1.2;
}

.muted-line {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.cell-note {
  max-width: none;
  color: var(--ink);
  font-size: 0.85rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1.1;
  white-space: nowrap;
}

.badge.priority-a1,
.badge.result-reply-received,
.badge.verified-official {
  background: #e6f3e9;
  color: #1f5b3f;
}

.badge.priority-a2 {
  background: #e8f0f3;
  color: #245a6a;
}

.badge.priority-b {
  background: #f6eddc;
  color: #875714;
}

.badge.priority-c1,
.badge.result-delivery-delayed,
.badge.repaired-contact-found {
  background: #fff3d8;
  color: #866114;
}

.badge.priority-c2,
.badge.needs-manual-review {
  background: #eee9f7;
  color: #51486e;
}

.badge.priority-c3,
.badge.result-delivery-failed,
.badge.bad-contact-suppressed,
.badge.unverified {
  background: #f9e5e2;
  color: #8c352e;
}

.badge.result-no-reply-yet,
.badge.pending-verification {
  background: #eef0ed;
  color: #59635c;
}

.contact-stack {
  display: grid;
  gap: 4px;
  max-width: 100%;
}

.contact-stack a {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.contact-stack a:hover,
.contact-stack a:focus-visible {
  text-decoration: underline;
}

.detail-panel {
  display: grid;
  gap: 14px;
}

.detail-empty p {
  margin: 8px 0 0;
  color: var(--muted);
}

.detail-card h2 {
  margin-bottom: 8px;
  font-size: 1.2rem;
  line-height: 1.1;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.detail-block {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.detail-block h3 {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.detail-block p {
  margin-bottom: 8px;
  font-size: 0.9rem;
}

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

.detail-actions a,
.detail-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  background: #fff;
  color: var(--green-dark);
  font-weight: 850;
  text-decoration: none;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: min(360px, calc(100vw - 36px));
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--green-dark);
  color: #fff;
  font-weight: 800;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1280px) {
  .workspace-grid {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .detail-panel {
    grid-column: 1 / -1;
    position: static;
    max-height: none;
  }
}

@media (max-width: 920px) {
  .topbar,
  .command-band {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .topbar {
    display: grid;
  }

  .topnav {
    justify-content: start;
    overflow-x: auto;
    width: 100%;
  }

  .data-stamp {
    justify-items: start;
  }

  .command-band {
    display: grid;
    min-height: auto;
    overflow: visible;
  }

  .command-band::after {
    display: none;
  }

  h1 {
    max-width: calc(100vw - 20px);
    font-size: clamp(1.34rem, 6vw, 1.75rem);
    line-height: 1.08;
  }

  .desktop-title {
    display: none;
  }

  .mobile-title {
    display: grid;
    gap: 2px;
  }

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

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

  .filter-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 620px) {
  .dashboard-shell {
    padding: 14px 10px 24px;
  }

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

  .command-actions,
  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .tool-button,
  .compact-field {
    width: 100%;
  }

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