/* ==========================================================================
   Lilly's Anew — design tokens, reset and shared components
   ========================================================================== */

:root {
  --ink: #0a1a33;
  --ink-2: #243956;
  --muted: #586b85;
  --muted-2: #8a9ab0;

  --green: #0a6fca;
  --green-700: #055ba3;
  --green-900: #071426;
  --lime: #bfe4ff;
  --lime-soft: #eaf5ff;
  --green-soft: #e8f2fd;

  --cream: #f4f8fd;
  --paper: #ffffff;
  --line: #e1e9f3;
  --line-strong: #c6d5e6;

  --clay: #f0653a;
  --clay-soft: #fff0ea;
  --amber: #a9680a;
  --amber-soft: #fff5e0;
  --danger: #c0362c;
  --danger-soft: #fdecea;

  --radius: 18px;
  --radius-md: 13px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(10, 26, 51, 0.05);
  --shadow: 0 2px 4px rgba(10, 26, 51, 0.04), 0 20px 44px -30px rgba(10, 26, 51, 0.38);
  --shadow-lg: 0 32px 64px -32px rgba(7, 20, 38, 0.45);

  --maxw: 1180px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --tabbar-h: 64px;
}

*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--cream);
  background-image: radial-gradient(1100px 520px at 50% -12%, rgba(10, 132, 227, 0.08), transparent 65%);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
  border-radius: 6px;
}

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 32px);
}

.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;
}

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 200;
  background: var(--green); color: #fff; padding: 10px 16px; border-radius: 10px;
  transition: top 0.2s ease;
}
.skip-link:focus { top: 12px; }

/* ---------- type helpers ---------- */
.display {
  font-family: var(--font-display);
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.06;
}
.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--green);
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.strong { font-weight: 650; }
.price { font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 11px 20px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  transition: background 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--green-700); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled {
  background: var(--line-strong);
  color: #56657a;
  cursor: not-allowed;
  transform: none;
}
.btn svg { width: 18px; height: 18px; flex: none; }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: transparent;
}
.btn-ghost:hover { background: rgba(10, 26, 51, 0.06); }

.btn-outline {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-outline:hover { background: rgba(10, 26, 51, 0.04); border-color: var(--ink); }

.btn-lime { background: var(--lime); color: var(--green-900); }
.btn-lime:hover { background: #a6d9ff; }

.btn-clay { background: var(--clay); }
.btn-clay:hover { background: #b8522d; }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #962f29; }

.btn-sm { min-height: 36px; padding: 7px 14px; font-size: 13.5px; }
.btn-lg { min-height: 52px; padding: 14px 28px; font-size: 16px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover { background: var(--lime-soft); border-color: var(--green); }
.icon-btn svg { width: 19px; height: 19px; }

.link {
  color: var(--green);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.link:hover { color: var(--green-700); }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field > label,
.field-label {
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.input, .select, .textarea {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 11px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(10, 132, 227, 0.16);
}
.input::placeholder, .textarea::placeholder { color: #93a1b5; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23586b85' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
}
.field-hint { font-size: 12.5px; color: var(--muted); }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid > * { min-width: 0; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  cursor: pointer;
}
.check input { width: 18px; height: 18px; accent-color: var(--green); }

/* ---------- surfaces ---------- */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.panel { padding: clamp(18px, 3vw, 26px); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-700);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge--clay { background: var(--clay-soft); color: #9b3f1d; }
.badge--amber { background: var(--amber-soft); color: #7c580f; }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--gray { background: #edf1f7; color: #4f6079; }
.badge--lime { background: var(--lime); color: var(--green-900); }

/* ---------- modal / sheet ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(7, 20, 38, 0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fade-in 0.18s ease;
}
.sheet {
  width: min(640px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: var(--paper);
  border-radius: 24px 24px 0 0;
  box-shadow: var(--shadow-lg);
  animation: slide-up 0.22s ease;
}
@media (min-width: 720px) {
  .sheet-backdrop { align-items: center; padding: 24px; }
  .sheet { border-radius: 24px; }
}
.sheet-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.sheet-head h2 { font-size: 19px; }
.sheet-body { padding: 22px; }
.sheet-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 10px;
  padding: 14px 22px calc(14px + env(safe-area-inset-bottom));
  background: var(--paper);
  border-top: 1px solid var(--line);
}
.close-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 999px;
  border: 0; background: var(--cream); color: var(--ink);
  flex: none;
}
.close-x:hover { background: var(--line); }
.close-x svg { width: 18px; height: 18px; }

@keyframes fade-in { from { opacity: 0; } }
@keyframes slide-up { from { transform: translateY(18px); opacity: 0; } }

/* ---------- toasts ---------- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 18px);
  transform: translateX(-50%);
  z-index: 200;
  display: grid;
  gap: 8px;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--green-900);
  color: #f5f9ff;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease;
}
.toast--error { background: var(--danger); }
.toast svg { width: 17px; height: 17px; flex: none; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ---------- empty state ---------- */
.empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: clamp(32px, 6vw, 56px) 24px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
}
.empty-icon {
  display: grid; place-items: center;
  width: 54px; height: 54px; border-radius: 999px;
  background: var(--green-soft); color: var(--green);
}
.empty-icon svg { width: 24px; height: 24px; }
.empty h3 { font-size: 17px; }
.empty p { max-width: 40ch; color: var(--muted); font-size: 14px; }

/* ---------- divider ---------- */
.hr { height: 1px; background: var(--line); border: 0; margin: 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 560px;
}
table.data th {
  text-align: left;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #f7fafd; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- misc ---------- */
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  font-size: 13.5px;
  font-weight: 550;
  color: var(--ink-2);
  white-space: nowrap;
  transition: all 0.15s ease;
}
.chip:hover { border-color: var(--green); }
.chip.is-active { background: var(--green); border-color: var(--green); color: #fff; }

.stat-value { font-size: clamp(24px, 3vw, 30px); font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-label { font-size: 12px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

.notice {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--lime-soft);
  border: 1px solid #cde6fb;
  font-size: 13.5px;
  line-height: 1.5;
}
.notice svg { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--green-700); }
.notice--warn { background: var(--amber-soft); border-color: #ecd9a5; }
.notice--danger { background: var(--danger-soft); border-color: #f3c6c2; }
.notice strong { font-weight: 650; }

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