/* SelfParcel "Waybill" design system.
   Neutral paper/ink chrome; saturated color is reserved for data (carrier brand).
   Monospace reads as data. The waybill card is the signature element. */

:root {
  /* chrome: paper and ink (light) */
  --paper: #f6f4ef;
  --paper-grid: rgba(27, 30, 37, 0.035);
  --surface: #ffffff;
  --surface-2: #f3f1ea;
  --ink: #1b1e25;
  --ink-soft: #646b79;
  --ink-faint: #9aa0ab;
  --line: #e5e1d8;
  --line-strong: #d6d1c4;

  /* single interactive accent: ink blue */
  --accent: #24348c;
  --accent-press: #1a276e;
  --accent-tint: rgba(36, 52, 140, 0.08);

  /* carrier brand rails (the data color) */
  --c-ups: #6b4a2b;
  --c-usps: #1c4e9c;
  --c-fedex: #6a1b9a;
  --c-speedpak: #e8590c;

  /* status colors */
  --st-delivered: #1e8e5a;
  --st-transit: #2563c9;
  --st-ofd: #c77700;
  --st-exception: #c7382b;
  --st-neutral: #6c727e;

  --shadow-sm: 0 1px 2px rgba(27, 30, 37, 0.06);
  --shadow-md: 0 6px 22px -8px rgba(27, 30, 37, 0.22);
  --shadow-lg: 0 24px 60px -20px rgba(27, 30, 37, 0.38);

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;

  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Cascadia Mono", "Consolas",
    "Roboto Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14161b;
    --paper-grid: rgba(255, 255, 255, 0.025);
    --surface: #1b1e25;
    --surface-2: #20242d;
    --ink: #ecedf0;
    --ink-soft: #a4abb8;
    --ink-faint: #6c727e;
    --line: #2a2f39;
    --line-strong: #353c48;

    --accent: #93a4ff;
    --accent-press: #aab8ff;
    --accent-tint: rgba(147, 164, 255, 0.12);

    --c-ups: #c79a6a;
    --c-usps: #6fa0e8;
    --c-fedex: #c084e8;
    --c-speedpak: #ff8a4c;

    --st-delivered: #4fc78a;
    --st-transit: #6fa0e8;
    --st-ofd: #e8a23c;
    --st-exception: #f0766a;
    --st-neutral: #9aa0ab;

    --shadow-md: 0 6px 22px -8px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, 0.7);
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background-color: var(--paper);
  /* faint manifest grid, like logistics paper. kept very subtle */
  background-image: linear-gradient(var(--paper-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--paper-grid) 1px, transparent 1px);
  background-size: 26px 26px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: var(--mono);
}

/* manifest bar */
.manifest-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 9px;
}
.logo {
  font-size: 20px;
  transform: translateY(2px);
}
.wordmark {
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.02em;
}
.tagline {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-left: 9px;
  border-left: 1px solid var(--line-strong);
}
.bar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* buttons */
.btn {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 9px 15px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.06s,
    box-shadow 0.15s;
}
.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn:active {
  transform: translateY(1px);
}
.btn .ico {
  display: inline-block;
}
.btn.ghost {
  background: transparent;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn.primary:hover {
  background: var(--accent-press);
  border-color: var(--accent-press);
  color: #fff;
}
.btn.small {
  padding: 6px 10px;
  font-size: 13px;
}
.btn.danger:hover {
  border-color: var(--st-exception);
  color: var(--st-exception);
}
.btn:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

/* layout */
main {
  max-width: 880px;
  margin: 0 auto;
  padding: 28px 18px 80px;
}

/* intake (waybill form) */
.intake {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  margin-bottom: 20px;
}
.intake-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: end;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 150px;
}
.field-grow {
  flex: 1;
}
.field-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.field-label .opt {
  color: var(--ink-faint);
  letter-spacing: 0.08em;
}
input,
select {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input.mono {
  font-family: var(--mono);
  letter-spacing: 0.02em;
}
input::placeholder {
  color: var(--ink-faint);
}
input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.intake-grid .btn.primary {
  padding: 10px 22px;
  height: 40px;
}
.hint {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
  margin: 12px 2px 0;
  min-height: 15px;
}

/* status line (carrier chips) */
.statusline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  padding: 0 4px;
}
.carrier-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-soft);
}
.chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-faint);
}
.chip.ok .dot {
  background: var(--st-delivered);
}
.chip.warn {
  color: var(--st-ofd);
}
.chip.warn .dot {
  background: var(--st-ofd);
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
}
.toggle input {
  width: auto;
  accent-color: var(--accent);
}

/* waybill card, the signature element */
.package-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.package {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 15px 18px 15px 20px;
  cursor: pointer;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.14s ease, box-shadow 0.18s ease, border-color 0.15s;
  animation: rise 0.32s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
/* carrier color rail */
.package::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--rail, var(--ink-faint));
  transition: width 0.16s ease;
}
.package:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--line-strong);
}
.package:hover::before {
  width: 6px;
}
.package.carrier-ups {
  --rail: var(--c-ups);
}
.package.carrier-usps {
  --rail: var(--c-usps);
}
.package.carrier-fedex {
  --rail: var(--c-fedex);
}
.package.carrier-speedpak {
  --rail: var(--c-speedpak);
}

.pkg-main {
  flex: 1;
  min-width: 0;
}
.pkg-eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.pkg-carrier {
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--rail, var(--ink-soft));
}
.pkg-tn {
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pkg-sep {
  color: var(--line-strong);
}
.pkg-title {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pkg-title.is-tn {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
}
.pkg-meta {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-soft);
  margin-top: 5px;
}
.pkg-meta .err {
  color: var(--st-exception);
}
.pkg-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* status stamp */
.stamp {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.stamp .sdot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.stamp.delivered {
  color: var(--st-delivered);
  background: color-mix(in srgb, var(--st-delivered) 12%, transparent);
}
.stamp.in_transit {
  color: var(--st-transit);
  background: color-mix(in srgb, var(--st-transit) 12%, transparent);
}
.stamp.out_for_delivery {
  color: var(--st-ofd);
  background: color-mix(in srgb, var(--st-ofd) 14%, transparent);
}
.stamp.exception {
  color: var(--st-exception);
  background: color-mix(in srgb, var(--st-exception) 12%, transparent);
}
.stamp.pre_transit,
.stamp.unknown {
  color: var(--st-neutral);
  background: color-mix(in srgb, var(--st-neutral) 10%, transparent);
}

/* account area */
.account {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
}
.account .who {
  color: var(--ink);
}
.account a {
  color: var(--accent);
  text-decoration: none;
}
.account a:hover {
  text-decoration: underline;
}

/* empty state */
.empty {
  color: var(--ink-soft);
  text-align: center;
  padding: 56px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--surface) 50%, transparent);
}

.hidden {
  display: none !important;
}

/* modal: scan log */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 17, 22, 0.55);
  backdrop-filter: blur(3px);
  animation: fade 0.18s ease both;
}
.modal-content {
  position: relative;
  width: 100%;
  max-width: 580px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 26px 26px 28px;
  animation: rise 0.24s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: var(--ink-faint);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover {
  color: var(--ink);
}
.modal h2 {
  margin: 0 0 6px;
  font-size: 20px;
  letter-spacing: -0.01em;
}
.modal-sub {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.03em;
}
.modal-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 4px;
}

.log-head {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 22px 0 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}
.timeline li {
  position: relative;
  padding: 0 0 18px 24px;
  border-left: 2px solid var(--line);
}
.timeline li:last-child {
  border-left-color: transparent;
  padding-bottom: 0;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 3px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--ink-faint);
}
.timeline li:first-child::before {
  border-color: var(--accent);
  background: var(--accent);
}
.timeline .t-desc {
  font-weight: 600;
  font-size: 14px;
}
.timeline .t-when {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-soft);
  margin-top: 2px;
}
.timeline .t-loc {
  font-size: 12.5px;
  color: var(--ink-soft);
}
.error-line {
  color: var(--st-exception);
  font-size: 13px;
  margin-top: 10px;
}

/* settings: channels */
.channel-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.channel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.channel-row .c-name {
  font-weight: 600;
  font-size: 14px;
}
.channel-state {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-faint);
}
.channel-state .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-faint);
}
.channel-state.on {
  color: var(--st-delivered);
}
.channel-state.on .dot {
  background: var(--st-delivered);
}
#trigger-mode {
  width: 100%;
}
.creds-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
}
@media (max-width: 540px) {
  .creds-grid {
    grid-template-columns: 1fr;
  }
}
.btn.muted-on {
  color: var(--st-ofd);
  border-color: var(--st-ofd);
}

/* login card */
.modal-content.login-card {
  max-width: 380px;
}
.login-brand {
  justify-content: center;
  margin-bottom: 8px;
}
#login-switch a,
#register-switch a {
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
}
#login-switch a:hover,
#register-switch a:hover {
  text-decoration: underline;
}

/* admin: users and providers */
.modal-content.wide {
  max-width: 720px;
}
.user-list,
.provider-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0 6px;
}
.admin-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  flex-wrap: wrap;
}
.admin-row .grow {
  flex: 1;
  min-width: 140px;
}
.admin-row .a-name {
  font-weight: 600;
}
.admin-row .a-tag {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  padding: 2px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
}
.admin-row .a-tag.admin {
  color: var(--accent);
  border-color: var(--accent);
}
.admin-row .a-tag.off {
  color: var(--st-exception);
  border-color: var(--st-exception);
}
.admin-row .a-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.code-area {
  width: 100%;
  min-height: 130px;
  margin: 8px 0;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  resize: vertical;
}
.code-area.tall {
  min-height: 280px;
}
#module-test-out {
  margin-top: 12px;
}

/* ── Sharing ────────────────────────────────────────────────────────────── */
.pkg-shared {
  color: var(--accent);
  font-style: italic;
}
.share-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0 4px;
}
.share-chips:empty::after {
  content: "Not shared with anyone yet.";
  color: var(--ink-faint);
  font-size: 13px;
}
.share-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 11px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  font-size: 13px;
}
.share-chip button {
  border: none;
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
}
.share-chip button:hover {
  color: var(--st-exception);
}
.share-suggest {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  max-height: 220px;
  overflow-y: auto;
}
.suggest-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
}
.suggest-row:hover {
  border-color: var(--accent);
}
.suggest-row .recent {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

/* motion */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* responsive */
@media (max-width: 620px) {
  .intake-grid {
    flex-direction: column;
    align-items: stretch;
  }
  .intake-grid .btn.primary {
    width: 100%;
  }
  .package {
    flex-wrap: wrap;
  }
  .pkg-main {
    flex-basis: 100%;
  }
  .tagline {
    display: none;
  }
}
