/* ===========================================================================
   Design tokens + base layer
   A light, premium theme: a warm off-white canvas, crisp white cards with soft
   layered shadows, an emerald primary and a refined gold accent. Serif display
   face paired with a grotesque sans.
   =========================================================================== */

:root {
  /* Surfaces */
  --bg: #f4f3ee;
  --bg-grain: #faf9f5;
  --surface: #ffffff;
  --surface-2: #f4f2ec;
  --surface-3: #ebe9e1;
  --border: #e3e0d6;
  --border-soft: #ece9e1;

  /* Ink */
  --text: #191b20;
  --text-dim: #5c616b;
  --text-faint: #8b909a;

  /* Emerald (primary action) */
  --green: #1c8159;
  --green-bright: #239a6c;
  --green-deep: #15633f;
  --green-soft: rgba(28, 129, 89, 0.10);
  --green-line: rgba(28, 129, 89, 0.32);

  /* Gold (premium accent) */
  --gold: #9c7320;
  --gold-bright: #b88a36;
  --gold-soft: rgba(156, 115, 32, 0.12);
  --gold-line: rgba(156, 115, 32, 0.32);
  --pitch: #2f8e68;

  /* Category colors (mirror the price categories, vivid on light) */
  --cat-vip: #b88a36;
  --cat-1: #1f8a63;
  --cat-2: #3a6fb0;
  --cat-3: #7a59ad;

  /* Status */
  --ok: #1f9468;
  --warn: #b9821c;
  --danger: #cf4d47;
  --info: #3a6fb0;

  /* Radii */
  --r-xs: 6px;
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 22px;
  --r-pill: 999px;

  /* Shadow (soft, layered, for a premium light feel) */
  --shadow-sm: 0 1px 2px rgba(24, 27, 33, 0.05), 0 1px 1px rgba(24, 27, 33, 0.04);
  --shadow: 0 18px 40px -24px rgba(24, 27, 33, 0.22), 0 2px 8px -4px rgba(24, 27, 33, 0.08);
  --shadow-lg: 0 50px 90px -42px rgba(24, 27, 33, 0.30), 0 8px 24px -12px rgba(24, 27, 33, 0.12);

  /* Type */
  --font-display: 'Fraunces', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, monospace;

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 120ms;
  --t: 220ms;

  /* Layout */
  --maxw: 1200px;
  --nav-h: 72px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 560px at 84% -12%, rgba(28, 129, 89, 0.07), transparent 60%),
    radial-gradient(840px 480px at -5% 2%, rgba(184, 138, 54, 0.06), transparent 55%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.01em;
  margin: 0;
}

a { color: inherit; text-decoration: none; }

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

img { max-width: 100%; display: block; }

::selection { background: var(--green-soft); color: var(--green-deep); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: #d4d1c6 transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #d4d1c6; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: #c2bfb2; background-clip: padding-box; }

/* ---------------------------------------------------------------- layout */
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 650;
}

.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--font-mono); }

/* ---------------------------------------------------------------- buttons */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-bd: var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: 44px;
  padding: 0 20px;
  border-radius: var(--r-sm);
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 1px solid var(--btn-bd);
  font-weight: 560;
  font-size: 14px;
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-fast) var(--ease), background var(--t) var(--ease),
    border-color var(--t) var(--ease), box-shadow var(--t) var(--ease), opacity var(--t) var(--ease);
  user-select: none;
}
/* Hover adjusts the --btn-bg variable (not `background` directly) so each
   variant's own :hover can override it. Setting `background` here would win the
   cascade and turn every button grey on hover, including the primary one. */
.btn:hover { --btn-bg: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn svg { width: 17px; height: 17px; }

.btn-primary {
  --btn-bg: linear-gradient(180deg, var(--green-bright), var(--green));
  --btn-fg: #ffffff;
  --btn-bd: transparent;
  font-weight: 640;
  box-shadow: 0 12px 26px -12px rgba(28, 129, 89, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.btn-primary:hover { --btn-bg: linear-gradient(180deg, var(--green), var(--green-deep)); }

.btn-ghost { --btn-bg: transparent; --btn-bd: var(--border); box-shadow: none; }
.btn-ghost:hover { --btn-bg: var(--surface); box-shadow: var(--shadow-sm); }

.btn-quiet { --btn-bg: transparent; --btn-bd: transparent; color: var(--text-dim); height: 38px; padding: 0 12px; box-shadow: none; }
.btn-quiet:hover { --btn-bg: var(--surface-2); color: var(--text); box-shadow: none; }

.btn-sm { height: 36px; padding: 0 14px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-danger { --btn-bg: var(--surface); --btn-bd: rgba(207, 77, 71, 0.4); color: var(--danger); box-shadow: none; }
.btn-danger:hover { --btn-bg: rgba(207, 77, 71, 0.08); }

/* ---------------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.label { font-size: 12.5px; font-weight: 600; color: var(--text-dim); letter-spacing: 0.02em; }
.input, .select, .textarea {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
  outline: none;
}
.textarea { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); opacity: 1; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--green-line);
  box-shadow: 0 0 0 3px var(--green-soft);
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235c616b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
  cursor: pointer;
}
.select option { background: var(--surface); }

/* password field with show/hide toggle */
.pw-wrap { position: relative; }
.pw-wrap .input-pw { padding-right: 44px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; display: grid; place-items: center;
  background: transparent; border: none; color: var(--text-faint); cursor: pointer;
  border-radius: 7px; transition: color var(--t), background var(--t);
}
.pw-toggle:hover { color: var(--text); background: var(--surface-2); }
.pw-toggle svg { width: 18px; height: 18px; }

/* brand logo mark */
.brand-logo { display: inline-grid; place-items: center; line-height: 0; flex: none; filter: drop-shadow(0 6px 14px rgba(156, 115, 32, 0.28)); }
.brand-logo svg { display: block; }

/* ---------------------------------------------------------------- chips, badges */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 560;
  color: var(--text-dim);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--t) var(--ease);
  white-space: nowrap;
}
.chip:hover { color: var(--text); border-color: var(--border); background: var(--surface-2); }
.chip.is-active { background: var(--green); border-color: var(--green); color: #fff; box-shadow: 0 8px 18px -10px rgba(28, 129, 89, 0.6); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 23px;
  padding: 0 9px;
  border-radius: var(--r-xs);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--surface-3);
  color: var(--text-dim);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { background: rgba(31, 148, 104, 0.14); color: var(--ok); }
.badge-warn { background: rgba(185, 130, 28, 0.16); color: var(--warn); }
.badge-danger { background: rgba(207, 77, 71, 0.14); color: var(--danger); }
.badge-gold { background: var(--gold-soft); color: var(--gold); }

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}

/* ---------------------------------------------------------------- toast */
#toast-host {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 500;
  animation: toast-in 0.32s var(--ease-out);
  max-width: 90vw;
}
.toast .accent { width: 4px; align-self: stretch; border-radius: 4px; background: var(--green); }
.toast.is-out { animation: toast-out 0.25s var(--ease) forwards; }
.toast-ok .accent { background: var(--ok); }
.toast-err .accent { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ---------------------------------------------------------------- modal */
.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(28, 30, 36, 0.42);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t) var(--ease);
}
.modal-scrim.is-open { opacity: 1; pointer-events: auto; }
.modal {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  transform: translateY(12px) scale(0.99);
  transition: transform var(--t) var(--ease-out);
  max-height: calc(100vh - 48px);
  overflow: auto;
}
.modal-scrim.is-open .modal { transform: none; }
.modal-head { padding: 24px 26px 6px; }
.modal-body { padding: 14px 26px 26px; }

.spinner {
  width: 17px; height: 17px;
  border: 2px solid rgba(24, 27, 33, 0.16);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

[hidden] { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}
