/**
 * Moot Business Portal — Customs module
 * Matches enterprise teal mockup (not lime/purple shipments chrome).
 */

/* Customs module surfaces — chrome comes from sender-portal-theme.css */
#moot-business-customs .dash-topbar {
  background: transparent !important;
  border-bottom: 0 !important;
  box-shadow: none !important;
  padding-bottom: 0;
}

#moot-business-customs .dash-topbar__greeting h1,
#moot-business-customs .dash-topbar__greeting p {
  display: none;
}

.customs-portal {
  --cp-ink: #1e293b;
  --cp-muted: #475569;
  --cp-line: #e2e8f0;
  --cp-surface: #ffffff;
  --cp-canvas: #f4f6f8;
  --cp-soft: #eef2f5;
  --cp-accent: #0f766e;
  --cp-accent-deep: #0b5f59;
  --cp-accent-soft: #e6f4f3;
  --cp-warn: #b45309;
  --cp-danger: #b91c1c;
  --cp-ok: #047857;
  --cp-info: #1d4ed8;
  --cp-await: #6b21a8;
  --cp-radius: 12px;
  color: var(--cp-ink);
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 4px 0 40px;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  box-sizing: border-box;
}

#moot-business-customs,
#moot-business-customs .dash-shell,
#moot-business-customs .dash-main,
#moot-business-customs .dash-content,
#moot-business-customs .customs-portal {
  max-width: none !important;
  width: 100% !important;
  box-sizing: border-box;
}

#moot-business-customs .dash-main {
  flex: 1 1 auto;
  min-width: 0;
  margin-right: 0 !important;
}

#moot-business-customs .dash-content {
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

#moot-business-customs .cp-grid--main {
  grid-template-columns: minmax(0, 2fr) minmax(280px, 0.9fr);
}

#moot-business-customs .cp-table--activity th:first-child,
#moot-business-customs .cp-table--activity td:first-child {
  min-width: 160px;
  width: 32%;
}

.customs-portal__header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.customs-portal__eyebrow {
  display: none;
}

.customs-portal__title {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: #0f172a;
}

.customs-portal__lead {
  margin: 8px 0 0;
  color: var(--cp-muted);
  font-size: 14px;
  max-width: 56ch;
  line-height: 1.45;
}

.customs-portal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

/* Pill subnav — mockup style */
.customs-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin-bottom: 22px;
  background: transparent;
  border: 0;
}

.customs-subnav__link {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--cp-line);
  background: #fff;
  color: #475569;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.customs-subnav__link svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.customs-subnav__link:hover {
  color: var(--cp-accent);
  border-color: #99d5cf;
  background: #f8fffe;
}

.customs-subnav__link.is-active {
  color: #fff;
  background: var(--cp-accent);
  border-color: var(--cp-accent);
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.25);
}

.customs-subnav__link.is-active:hover {
  color: #fff;
  background: var(--cp-accent-deep);
  border-color: var(--cp-accent-deep);
}

.cp-grid {
  display: grid;
  gap: 16px;
}

.cp-grid--stats {
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 12px;
}

.cp-grid--main {
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr);
  gap: 16px;
  margin-top: 4px;
}

.cp-grid--2 {
  grid-template-columns: 1.4fr 1fr;
}

.cp-grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 1280px) {
  .cp-grid--stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
  .cp-grid--stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cp-grid--main,
  .cp-grid--2,
  .cp-grid--3 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .cp-grid--stats { grid-template-columns: 1fr; }
  .customs-portal__title { font-size: 26px; }
}

.cp-card {
  background: var(--cp-surface);
  border: 1px solid #e8edf2;
  border-radius: var(--cp-radius);
  padding: 18px 18px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.cp-card--soft {
  background: #fff;
  padding: 14px 14px 12px;
  min-height: 112px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cp-card--glass {
  background: #fff;
}

.cp-stat__icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--cp-accent-soft);
  color: var(--cp-accent);
  margin-bottom: 2px;
}

.cp-stat__icon svg {
  width: 15px;
  height: 15px;
}

.cp-stat__icon--danger {
  background: #fee2e2;
  color: var(--cp-danger);
}

.cp-stat__icon--ok {
  background: #d1fae5;
  color: var(--cp-ok);
}

.cp-card__label {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--cp-muted);
  line-height: 1.25;
}

.cp-card__value {
  margin: 2px 0 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--cp-accent);
}

.cp-card__value.is-danger { color: var(--cp-danger); }
.cp-card__value.is-ok { color: var(--cp-ok); }
.cp-card__value.is-warn { color: var(--cp-warn); }
.cp-card__value.is-info { color: var(--cp-info); }

.cp-card__hint {
  margin: auto 0 0;
  padding-top: 4px;
  font-size: 11px;
  color: #475569;
}

.cp-card__title {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.cp-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.cp-card__head .cp-card__title { margin: 0; }

.cp-card__link {
  color: var(--cp-accent);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.cp-card__link:hover { text-decoration: underline; }

.cp-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  border: 0;
  white-space: nowrap;
}

.cp-badge--ok { background: #def7ec; color: #03543f; }
.cp-badge--warn { background: #fef3c7; color: #92400e; }
.cp-badge--danger { background: #fde2e2; color: #9b1c1c; }
.cp-badge--info { background: #e1effe; color: #1e429f; }
.cp-badge--muted { background: #f1f5f9; color: #475569; }
.cp-badge--accent { background: var(--cp-accent-soft); color: var(--cp-accent); }
.cp-badge--await { background: #f3e8ff; color: #6b21a8; }

.cp-table-wrap { overflow: auto; }
.cp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.cp-table th {
  text-align: left;
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  color: #475569;
  padding: 8px 10px;
  border-bottom: 1px solid var(--cp-line);
}
.cp-table td {
  padding: 13px 10px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  color: #334155;
}
.cp-table tr:last-child td { border-bottom: 0; }
.cp-table tr:hover td { background: #fafbfc; }
.cp-table a {
  color: var(--cp-accent);
  font-weight: 600;
  text-decoration: none;
}
.cp-table a:hover { text-decoration: underline; }

.cp-ship-link {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  max-width: 100%;
  color: var(--cp-accent);
  font-weight: 600;
  text-decoration: none;
  line-height: 1.25;
}
.cp-ship-link:hover { text-decoration: none; }
.cp-ship-link:hover .cp-ship-name { text-decoration: underline; }
.cp-ship-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 280px;
}
.cp-ship-ref {
  font-size: 11px;
  font-weight: 500;
  color: var(--cp-muted);
}
.cp-timeline__ship {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--cp-ink);
}

.cp-table__foot {
  margin: 12px 0 0;
  font-size: 12px;
  color: #475569;
}

.cp-empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--cp-muted);
  font-size: 14px;
}

.cp-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}
.cp-timeline__item {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 12px;
  position: relative;
  padding-bottom: 18px;
  align-items: start;
}
.cp-timeline__item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 18px;
  bottom: 0;
  width: 2px;
  background: #99d5cf;
}
.cp-timeline__dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  background: #fff;
  margin-top: 1px;
  z-index: 1;
}
.cp-timeline__item.is-done .cp-timeline__dot {
  border-color: var(--cp-accent);
  background: var(--cp-accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}
.cp-timeline__item.is-current .cp-timeline__dot {
  border-color: var(--cp-accent);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.16);
}
.cp-timeline__item.is-blocked .cp-timeline__dot {
  border-color: var(--cp-danger);
  background: #fee2e2;
}
.cp-timeline__title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
}
.cp-timeline__meta {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--cp-muted);
}
.cp-timeline__time {
  font-size: 11px;
  color: #475569;
  white-space: nowrap;
  padding-top: 2px;
}

.cp-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid var(--cp-line);
  margin-bottom: 16px;
}
.cp-tabs__btn {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 10px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--cp-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.cp-tabs__btn.is-active {
  color: var(--cp-accent);
  border-bottom-color: var(--cp-accent);
}

.cp-panel[hidden] { display: none !important; }

.cp-kv {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px 16px;
  font-size: 13px;
}
.cp-kv dt { color: var(--cp-muted); margin: 0; }
.cp-kv dd { margin: 0; font-weight: 600; }

.cp-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
@media (max-width: 800px) {
  .cp-form-grid { grid-template-columns: 1fr; }
  .cp-kv { grid-template-columns: 1fr; }
}

.cp-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--cp-muted);
  margin-bottom: 6px;
}
.cp-field input,
.cp-field select,
.cp-field textarea {
  width: 100%;
  border: 1px solid var(--cp-line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--cp-ink);
}
.cp-field input:focus,
.cp-field select:focus,
.cp-field textarea:focus {
  outline: none;
  border-color: var(--cp-accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}
.cp-field textarea { min-height: 88px; resize: vertical; }

.cp-health {
  display: grid;
  gap: 10px;
}
.cp-health__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--cp-line);
  border-radius: 12px;
  background: #fff;
}
.cp-health__name { font-weight: 700; font-size: 13px; }
.cp-health__desc { font-size: 12px; color: var(--cp-muted); margin-top: 2px; }

.cp-notice {
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.45;
  border: 1px solid var(--cp-line);
  background: #f8fafc;
  color: #334155;
}
.cp-notice--warn {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #9a3412;
}
.cp-notice--ok {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}

.cp-btn {
  appearance: none;
  border: 1px solid var(--cp-line);
  background: #fff;
  color: var(--cp-ink);
  border-radius: 999px;
  padding: 9px 16px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.cp-btn:hover { background: #f8fafc; }
.cp-btn--primary {
  background: var(--cp-accent);
  border-color: var(--cp-accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.22);
}
.cp-btn--primary:hover { filter: brightness(1.05); background: var(--cp-accent-deep); border-color: var(--cp-accent-deep); }
.cp-btn--danger {
  background: #fff;
  border-color: #fecaca;
  color: var(--cp-danger);
}
.cp-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.cp-section[hidden] { display: none !important; }

.cp-loading {
  padding: 48px;
  text-align: center;
  color: var(--cp-muted);
}

.cp-workspace-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.cp-doc-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 900px) {
  .cp-doc-grid { grid-template-columns: 1fr; }
}
.cp-doc-card h4 { margin: 0 0 6px; font-size: 14px; }
.cp-doc-card p { margin: 0; font-size: 12px; color: var(--cp-muted); }

.cp-side-stack {
  display: grid;
  gap: 16px;
  align-content: start;
}

.cp-mandate-dialog {
  position: fixed;
  inset: 0;
  z-index: 80;
}
.cp-mandate-dialog__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}
.cp-mandate-dialog__panel {
  position: relative;
  z-index: 1;
  max-width: 28rem;
  margin: 12vh auto 0;
  padding: 1.25rem 1.4rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}
.cp-mandate-dialog__panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}
.cp-mandate-dialog__panel input {
  width: 100%;
  margin: 0.35rem 0 0.75rem;
  padding: 0.55rem 0.7rem;
}
.cp-mandate-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

@media (prefers-color-scheme: dark) {
  .dash-app[data-theme='dark'] .customs-portal,
  html[data-theme='dark'] .customs-portal {
    --cp-ink: #e2e8f0;
    --cp-muted: #94a3b8;
    --cp-line: #334155;
    --cp-surface: #0f172a;
    --cp-soft: #111827;
  }
}
