/* Meridian UI — "Warm Atelier" system ported from PinForge:
   deep sage primary (#3d6b50) on warm cream, white cards rounded 20px,
   warm-tinted shadows, Inter-like system stack + serif display. */

:root {
  --brand-50: #f0f5f1; --brand-100: #dce8df; --brand-200: #bcd3c3;
  --brand-300: #92b49d; --brand-400: #628f72; --brand-500: #3d6b50;
  --brand-600: #2f5540; --brand-700: #264536;
  --copper-500: #c47a5a;
  --neutral-50: #faf7f2; --neutral-100: #f3eee6; --neutral-200: #e7dfd2;
  --neutral-300: #d5cabb;
  --ink-900: #1c1917; --ink-700: #44403c; --ink-500: #78716c; --ink-400: #a8a29e;
  --red-50: #fef2f2; --red-200: #fecaca; --red-600: #dc2626;
  --green-50: #f0fdf4; --green-200: #bbf7d0; --green-700: #15803d;
  --amber-50: #fffbeb; --amber-200: #fde68a; --amber-700: #b45309;
  --shadow-card: 0 1px 2px rgba(38,32,26,.05), 0 1px 3px rgba(38,32,26,.07);
  --shadow-soft: 0 8px 30px rgba(38,32,26,.08);
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Helvetica, Arial, sans-serif;
  --display: "Playfair Display", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--sans); font-size: 14px; line-height: 1.5;
  background: var(--neutral-100); color: var(--ink-900);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- app shell ---------- */
.shell { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 256px; flex-shrink: 0; display: flex; flex-direction: column;
  background: #fff; border-right: 1px solid var(--neutral-200); padding: 20px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; padding: 0 4px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, #4a7a5c, #264536);
  box-shadow: var(--shadow-soft); display: grid; place-items: center;
  color: #faf7f2; font-weight: 800; font-size: 15px;
}
.brand-name { font-family: var(--display); font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.brand-name span { color: var(--brand-600); }
.nav-kicker {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--ink-400); margin: 18px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 12px; border-radius: 14px; font-size: 14px; font-weight: 500;
  color: var(--ink-500); background: none; border: 0; cursor: pointer;
  transition: all .15s; text-decoration: none;
}
.nav-item:hover { background: var(--neutral-100); color: var(--ink-900); text-decoration: none; }
.nav-item.active { background: var(--brand-50); color: var(--brand-700); }
.nav-item svg { width: 18px; height: 18px; stroke-width: 2; flex-shrink: 0; }
.nav-item.active svg { color: var(--brand-600); }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--neutral-100); padding-top: 16px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: #fff; border-bottom: 1px solid var(--neutral-200); padding: 16px 24px;
}
.user-chip {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--neutral-200);
  border-radius: 14px; padding: 4px 10px 4px 4px; font-size: 13px; color: var(--ink-700);
}
.user-chip .avatar {
  width: 28px; height: 28px; border-radius: 8px; background: var(--brand-500);
  color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center;
}
.content { flex: 1; overflow-y: auto; padding: 24px; }
.page-head { margin-bottom: 24px; }
.page-head h1 { font-family: var(--display); font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.page-head p { margin-top: 2px; font-size: 14px; color: var(--ink-500); }

/* ---------- cards & controls ---------- */
.card {
  background: #fff; border: 1px solid var(--neutral-200); border-radius: 20px;
  padding: 20px; box-shadow: var(--shadow-card);
}
.card + .card { margin-top: 20px; }
.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.card .sub { font-size: 12px; color: var(--ink-400); margin-bottom: 14px; }

.field-label { display: block; font-size: 12px; font-weight: 500; color: var(--ink-500); margin-bottom: 4px; }
.input {
  width: 100%; border: 1px solid var(--neutral-200); background: var(--neutral-50);
  border-radius: 14px; padding: 9px 12px; font-size: 14px; font-family: var(--sans);
  outline: none; transition: all .15s; color: var(--ink-900);
}
.input::placeholder { color: var(--ink-400); }
.input:focus { border-color: var(--brand-300); background: #fff; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 14px; padding: 9px 16px; font-size: 14px; font-weight: 600;
  font-family: var(--sans); cursor: pointer; transition: all .15s;
  border: 0; text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand-500); color: #fff; box-shadow: var(--shadow-soft); }
.btn-primary:hover { background: var(--brand-600); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary { background: #fff; color: var(--ink-700); border: 1px solid var(--neutral-200); font-weight: 500; }
.btn-secondary:hover { background: var(--neutral-50); }
.btn-danger-ghost { background: #fff; color: var(--red-600); border: 1px solid var(--neutral-200); }
.btn-danger-ghost:hover { background: var(--red-50); }
.btn-block { width: 100%; padding: 11px 16px; }

/* ---------- auth screens ---------- */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(135deg, var(--brand-50), var(--neutral-50) 45%, #fff);
}
.auth-box { width: 100%; max-width: 420px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 24px; }
.auth-brand .brand-mark { width: 44px; height: 44px; border-radius: 12px; font-size: 18px; }
.auth-brand .brand-name { font-size: 30px; }
.auth-card {
  background: #fff; border: 1px solid var(--neutral-200); border-radius: 20px;
  padding: 24px; box-shadow: var(--shadow-soft);
}
.auth-card h1 { font-size: 18px; font-weight: 600; }
.auth-card .lede { margin-top: 4px; font-size: 14px; color: var(--ink-500); }
.auth-card form { margin-top: 20px; display: flex; flex-direction: column; gap: 12px; }
.auth-foot {
  margin-top: 20px; border-top: 1px solid var(--neutral-100); padding-top: 16px;
  text-align: center; font-size: 13px; color: var(--ink-500);
}
.auth-under { margin-top: 16px; text-align: center; font-size: 11px; color: var(--ink-400); }

/* ---------- alerts & toast ---------- */
.alert {
  display: flex; gap: 8px; border-radius: 10px; padding: 10px 12px;
  font-size: 12.5px; margin-bottom: 4px;
}
.alert-error { background: var(--red-50); color: var(--red-600); }
.alert-success { background: var(--green-50); color: var(--green-700); }
.toast {
  position: fixed; top: 20px; right: 20px; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  background: #fff; border: 1px solid var(--brand-200); border-radius: 14px;
  padding: 12px 16px; box-shadow: var(--shadow-soft); font-size: 14px; font-weight: 500;
}
.toast.error { border-color: var(--red-200); }

/* ---------- template picker ---------- */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.tpl-card { position: relative; }
.tpl-card input { position: absolute; opacity: 0; }
.tpl-card label {
  display: block; height: 100%; border: 1px solid var(--neutral-200); border-radius: 14px;
  padding: 14px; cursor: pointer; transition: all .15s; background: var(--neutral-50);
}
.tpl-card label:hover { border-color: var(--brand-300); background: #fff; }
.tpl-card input:checked + label { border-color: var(--brand-400); background: var(--brand-50); box-shadow: 0 0 0 1px var(--brand-400); }
.tpl-card .tpl-name { font-weight: 600; font-size: 14px; }
.tpl-card .tpl-desc { margin-top: 4px; font-size: 12px; color: var(--ink-500); }
.tpl-badge {
  display: inline-block; margin-bottom: 8px; border-radius: 6px; padding: 2px 6px;
  font-size: 9px; font-weight: 700; letter-spacing: .04em;
  background: var(--brand-100); color: var(--brand-700);
}
.tpl-locked a {
  display: block; height: 100%; border: 1px dashed var(--neutral-300); border-radius: 14px;
  padding: 14px; background: var(--neutral-50); text-decoration: none; color: var(--ink-400);
  transition: all .15s;
}
.tpl-locked a:hover { border-color: var(--brand-300); background: var(--brand-50); color: var(--ink-700); text-decoration: none; }
.tpl-locked .tpl-name { color: var(--ink-500); }
.tpl-badge-lock { background: var(--neutral-100); color: var(--ink-400); }
.tpl-locked a:hover .tpl-badge-lock { background: var(--brand-100); color: var(--brand-700); }
.tpl-unlock { margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--brand-600); }

/* ---------- station picker ---------- */
.station-picker { position: relative; }
.station-results {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 20; margin-top: 4px;
  background: #fff; border: 1px solid var(--neutral-200); border-radius: 14px;
  box-shadow: var(--shadow-soft); max-height: 280px; overflow-y: auto; display: none;
}
.station-results.open { display: block; }
.station-results button {
  display: flex; justify-content: space-between; gap: 8px; width: 100%;
  padding: 10px 14px; background: none; border: 0; border-bottom: 1px solid var(--neutral-100);
  font-size: 13px; font-family: var(--sans); text-align: left; cursor: pointer; color: var(--ink-700);
}
.station-results button:hover { background: var(--brand-50); }
.station-results .sid { color: var(--ink-400); font-size: 11px; display: flex; align-items: center; gap: 6px; }
.station-results button.is-taken { opacity: .55; cursor: not-allowed; }
.avail-tag { border-radius: 6px; padding: 1px 6px; font-size: 9px; font-weight: 700; letter-spacing: .04em; }
.avail-tag.free { background: var(--green-50); color: var(--green-700); }
.avail-tag.taken { background: var(--red-50); color: var(--red-600); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand-50); color: var(--brand-700); border: 1px solid var(--brand-200);
  border-radius: 10px; padding: 5px 8px 5px 10px; font-size: 12.5px; font-weight: 500;
}
.chip button {
  background: none; border: 0; cursor: pointer; color: var(--brand-600);
  font-size: 14px; line-height: 1; padding: 0 2px; font-weight: 700;
}
.chip button:hover { color: var(--red-600); }
.picker-hint { margin-top: 8px; font-size: 11px; color: var(--ink-400); }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--ink-400); padding: 8px 10px;
  border-bottom: 1px solid var(--neutral-200);
}
.table td { padding: 10px; border-bottom: 1px solid var(--neutral-100); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }

.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 11.5px; font-weight: 600; }
.pill-pending { background: var(--neutral-100); color: var(--ink-500); }
.pill-processing { background: var(--amber-50); color: var(--amber-700); }
.pill-done, .pill-completed { background: var(--green-50); color: var(--green-700); }
.pill-completed_with_errors { background: var(--amber-50); color: var(--amber-700); }
.pill-failed { background: var(--red-50); color: var(--red-600); }

/* ---------- progress ---------- */
.progress-track {
  height: 10px; border-radius: 999px; background: var(--neutral-100);
  overflow: hidden; border: 1px solid var(--neutral-200);
}
.progress-fill {
  height: 100%; border-radius: 999px; width: 0;
  background: linear-gradient(90deg, var(--brand-400), var(--brand-500));
  transition: width .6s ease;
}
.progress-meta { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; color: var(--ink-500); }

.empty {
  display: grid; place-items: center; border: 1px dashed var(--neutral-200);
  border-radius: 14px; padding: 40px 20px; text-align: center;
  font-size: 14px; color: var(--ink-500);
}

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.muted { color: var(--ink-500); }
.small { font-size: 12px; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mb-4 { margin-bottom: 16px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .shell { flex-direction: column; height: auto; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; overflow-x: auto; padding: 12px 16px; }
  .sidebar .nav-kicker, .sidebar-footer { display: none; }
  .brand { margin-bottom: 0; margin-right: 12px; }
  .content { padding: 16px; }
}
