:root {
  --border: #d6dbe1;
  --text: #1b1f24;
  --muted: #5b6470;
  --accent: #0a5cd6;
  --bg: #ffffff;
  --bg-alt: #f5f7fa;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg-alt);
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

header h1 { font-size: 18px; margin: 0; }

nav { display: flex; gap: 4px; }

nav button {
  padding: 8px 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 2px solid transparent;
}

nav button.active { border-bottom-color: var(--accent); font-weight: 600; }

main { padding: 20px; max-width: 1400px; margin: 0 auto; }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.status-text { color: var(--muted); font-size: 13px; }

.legend-swatch { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.legend-swatch .swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border); display: inline-block; }
.legend-swatch .swatch.source-customer-list { background: #e6f4ea; }

.source-filter-row { display: flex; align-items: center; gap: 20px; margin: 12px 0; font-size: 14px; }
.source-filter-row .source-filter-label { color: var(--muted); font-size: 13px; }
.source-filter-row label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg);
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: normal;
  /* Gentler than word-break: break-word — only forces a mid-word break
     when a single word genuinely doesn't fit even after normal
     space-wrapping, rather than fragmenting short words like "Importer"
     or "Flagged" just because a column happened to render narrow. */
  overflow-wrap: break-word;
  vertical-align: top;
}

/* Explicit column widths (set per-column via inline style from the
   PARTNER_COLUMNS definition) only take effect under fixed layout —
   without this, the browser's automatic width algorithm was giving
   Phone/Email disproportionate space and starving the other columns
   down to the point where ordinary words had to be force-broken. */
#partners-table {
  table-layout: fixed;
}

th.sortable { cursor: pointer; user-select: none; }
th.sorted-asc::after { content: " ▲"; }
th.sorted-desc::after { content: " ▼"; }

.table-wrap { overflow-x: auto; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }

button, input {
  font-family: inherit;
  font-size: 14px;
}

input[type="text"], input[type="password"], input[type="email"], input[type="search"] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 100%;
}

.btn {
  padding: 8px 16px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  border-radius: 4px;
  cursor: pointer;
}

.pill {
  padding: 5px 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}

.pill.pill-active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* Identifiers (part numbers, HTS codes) read worse broken across two
   lines than they do truncated/scrolled — kept on one line regardless of
   the general wrap-everything rule above. */
th.nowrap, td.nowrap {
  white-space: nowrap;
  word-break: normal;
  /* Without this, a value wider than its fixed column (e.g. a long email
     address) visually spills into the next cell instead of stopping at
     the column boundary — confirmed by screenshot, not assumed. */
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-danger {
  background: transparent;
  color: #c02020;
  border-color: #c02020;
}

#login-view, #new-password-form {
  max-width: 360px;
  margin: 80px auto;
  background: var(--bg);
  padding: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

#login-view h2, #new-password-form h2 { margin-top: 0; }

.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 4px; font-size: 13px; color: var(--muted); }

.error-text { color: #c02020; font-size: 13px; min-height: 18px; margin-top: 8px; }

#hts-search-form { display: flex; gap: 8px; margin-bottom: 16px; max-width: 500px; }

[hidden] { display: none !important; }

tr.clickable-row { cursor: pointer; }
tr.clickable-row:hover { background: var(--bg-alt); }
tr.expanded-row { background: var(--bg-alt); }
tr.expanded-row td { border-bottom: none; }

/* HTS/Part Search: distinguish a curated customer-catalog row (client_reference_data —
   a broker-maintained HTS list for that client) from a row learned by ingesting a
   filed 7501/entry (invoice_part_numbers) — per Kellie's request 2026-08-28. */
tr.source-customer-list { background: #e6f4ea; }

/* Click-to-copy HTS code cells (HTS/Part Search + filed-line-items tables). */
.hts-code-copy {
  cursor: pointer;
  border-bottom: 1px dashed var(--muted);
  padding-bottom: 1px;
}
.hts-code-copy:hover { background: var(--bg-alt); }
.hts-code-copy.copied {
  color: #1a7f37;
  border-bottom-style: solid;
  border-bottom-color: #1a7f37;
}

.dashboard-note-textarea {
  width: 100%;
  max-width: 500px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  resize: vertical;
  display: block;
}

.dashboard-note-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

tr.detail-row td {
  background: var(--bg-alt);
  border-bottom: 2px solid var(--border);
  padding: 0;
  cursor: default;
  white-space: normal;
}

.inline-detail {
  padding: 16px 24px;
}

.inline-detail h4 {
  margin: 20px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.inline-detail h4:first-child { margin-top: 0; }

table.detail-kv {
  width: 100%;
  font-size: 13px;
}
table.detail-kv td, table.detail-kv th {
  padding: 4px 8px 4px 0;
  border: none;
}
td.detail-label { color: var(--muted); width: 40%; }

.note-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.note-text {
  white-space: pre-wrap;
  font-size: 13px;
}
.note-updated {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}
