/* =========================================================================
   Enosea Logistics - design tokens & shared primitives
   Base tones: royal blue + cream, with the logo's wine and sea accents.
   ========================================================================= */

:root {
  /* --- royal blue ramp --- */
  --royal-950: #0A142F;
  --royal-900: #0F1D4D;
  --royal-800: #16255C;
  --royal-700: #1B2F73;
  --royal-600: #24409A;
  --royal-500: #3355C4;
  --royal-400: #5B79DA;
  --royal-300: #8FA3E8;
  --royal-200: #C0CBF3;
  --royal-100: #E3E8FB;

  /* --- cream ramp --- */
  --cream-50:  #FDFBF6;
  --cream-100: #FAF5E9;
  --cream-200: #F4ECDA;
  --cream-300: #E9DCC2;
  --cream-400: #D8C7A4;

  /* --- brand accents (from the enosea mark) --- */
  --wine: #8E2A5F;
  --wine-soft: #F7EAF1;
  --sea: #4B9CD3;
  --sea-deep: #2E6E96;
  --gold: #B8862B;

  /* --- semantic --- */
  --ok: #12694A;
  --ok-soft: #E6F4EE;
  --warn: #9A6B00;
  --warn-soft: #FDF3DE;
  --danger: #B3261E;
  --danger-soft: #FDECEA;

  --ink: #16203C;
  --ink-soft: #4A5670;
  --ink-faint: #7C879F;
  --hairline: #E2DCCC;
  --hairline-strong: #D2C9B2;

  --surface: #FFFFFF;
  --surface-sunk: var(--cream-100);
  --page: var(--cream-100);

  /* --- shape & motion --- */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 26px;
  --r-pill: 999px;

  --sh-1: 0 1px 2px rgba(15, 29, 77, .06), 0 1px 3px rgba(15, 29, 77, .05);
  --sh-2: 0 2px 6px rgba(15, 29, 77, .07), 0 6px 18px rgba(15, 29, 77, .07);
  --sh-3: 0 10px 30px rgba(15, 29, 77, .13), 0 2px 8px rgba(15, 29, 77, .08);
  --sh-4: 0 24px 70px rgba(10, 20, 47, .28);

  --ease: cubic-bezier(.22, .61, .36, 1);

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
             Arial, "Noto Sans", sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua",
                  Georgia, "Times New Roman", serif;
  --font-num: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;

  /* safe areas for iPhone notch / home indicator */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
img { max-width: 100%; display: block; }

[hidden] { display: none !important; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }
button:disabled { cursor: not-allowed; }

a { color: var(--royal-600); }

:focus-visible {
  outline: 3px solid var(--royal-400);
  outline-offset: 2px;
  border-radius: 4px;
}

.tnum { font-variant-numeric: tabular-nums; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------- buttons -- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  background: var(--royal-600);
  color: #fff;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  transition: background .18s var(--ease), transform .12s var(--ease),
              box-shadow .18s var(--ease), border-color .18s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover:not(:disabled) { background: var(--royal-700); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; }

.btn--ghost {
  background: transparent;
  color: var(--royal-700);
  border-color: var(--hairline-strong);
}
.btn--ghost:hover:not(:disabled) { background: var(--cream-200); border-color: var(--royal-300); }

.btn--quiet {
  background: var(--cream-200);
  color: var(--royal-800);
}
.btn--quiet:hover:not(:disabled) { background: var(--cream-300); }

.btn--ok { background: var(--ok); }
.btn--ok:hover:not(:disabled) { background: #0D5239; }

.btn--wine { background: var(--wine); }
.btn--wine:hover:not(:disabled) { background: #74234E; }

.btn--danger { background: transparent; color: var(--danger); border-color: #EFC9C5; }
.btn--danger:hover:not(:disabled) { background: var(--danger-soft); }

.btn--sm { min-height: 36px; padding: 0 13px; font-size: 13px; gap: 6px; }
.btn--block { width: 100%; }

.btn .ic { width: 17px; height: 17px; flex: none; }
.btn--sm .ic { width: 15px; height: 15px; }

/* -------------------------------------------------------------- fields -- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.field > label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.input, .select, .textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: 16px; /* 16px stops iOS Safari zooming on focus */
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--royal-500);
  box-shadow: 0 0 0 3px rgba(51, 85, 196, .16);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-faint); }
.textarea { min-height: 84px; resize: vertical; line-height: 1.45; }

.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234A5670' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  background-size: 16px;
}

/* --------------------------------------------------------------- pills -- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .04em;
  white-space: nowrap;
}
.pill--pending  { background: var(--warn-soft); color: var(--warn); }
.pill--saved    { background: var(--ok-soft);   color: var(--ok); }
.pill--added    { background: var(--wine-soft); color: var(--wine); }
.pill--variance { background: var(--danger-soft); color: var(--danger); }
.pill--neutral  { background: var(--cream-200); color: var(--ink-soft); }

/* --------------------------------------------------------------- toast -- */
#toasts {
  position: fixed;
  left: 50%;
  bottom: calc(20px + var(--sab));
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  width: min(440px, calc(100vw - 24px));
  pointer-events: none;
}
.toast {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  background: var(--royal-900);
  color: var(--cream-100);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--sh-3);
  animation: toast-in .28s var(--ease);
}
.toast--ok    { background: #12694A; }
.toast--error { background: #96201A; }
.toast.is-out { animation: toast-out .22s var(--ease) forwards; }
.toast .ic { width: 18px; height: 18px; flex: none; }

@keyframes toast-in  { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(8px) scale(.98); } }

/* --------------------------------------------------------------- modal -- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 20, 47, .55);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: fade-in .2s var(--ease);
}
.modal {
  width: min(720px, 100%);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--cream-50);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-4);
  overflow: hidden;
  animation: modal-in .3s var(--ease);
}
.modal__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface);
}
.modal__head h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--royal-800);
  flex: 1;
  min-width: 0;
}
.modal__head p { font-size: 12.5px; color: var(--ink-faint); margin-top: 2px; }
.modal__body { padding: 20px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal__foot {
  display: flex;
  gap: 10px;
  padding: 14px 20px calc(14px + var(--sab));
  border-top: 1px solid var(--hairline);
  background: var(--surface);
}
.modal__foot .btn { flex: 1; }

.icon-btn {
  width: 40px; height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--cream-200);
  color: var(--ink-soft);
  transition: background .16s var(--ease), color .16s var(--ease);
}
.icon-btn:hover { background: var(--cream-300); color: var(--ink); }
.icon-btn .ic { width: 19px; height: 19px; }

@keyframes fade-in  { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(18px) scale(.98); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
