/* Youlify brand: primary blue #2D40CB, dark blue #242992, light blue #E2EBFF, greens #15803D / #EAF7EB, ELZA type. */
@font-face { font-family: "Elza"; src: url("fonts/Elza-Regular.woff") format("woff"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Elza"; src: url("fonts/Elza-Medium.woff") format("woff"); font-weight: 500; font-display: swap; }
/* Semibold is the heaviest cut we have, so it also serves 700/800. */
@font-face { font-family: "Elza"; src: url("fonts/Elza-Semibold.woff") format("woff"); font-weight: 600 800; font-display: swap; }

:root {
  --blue-900: #242992;
  --blue-800: #1f2a9e;
  --blue-700: #2d40cb;
  --blue-600: #3a4fd9;
  --blue-300: #a9b8f5;
  --blue-100: #e2ebff;
  --blue-50: #f3f6ff;
  --green-700: #15803d;
  --green-50: #eaf7eb;
  --orange-500: #f87a3a;
  --orange-100: #fff2e5;
  --purple-500: #8c3efa;
  --red-600: #c8371e;
  --red-50: #fdecea;
  --ink-900: #0b0d1f;
  --ink-700: #3f4358;
  --ink-500: #6b7084;
  --line: #d9dce8;
  --line-soft: #eceef5;
  --surface: #ffffff;
  --page: #f6f8fd;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(36, 41, 146, .05), 0 6px 20px rgba(36, 41, 146, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Elza", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink-900);
  background: var(--page);
  display: flex;
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--blue-700); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Sidebar ---------- */
/* White sidebar: the logo file is blue on a white background, so it sits cleanly here. */
.sidebar {
  width: 248px;
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--line-soft);
  color: var(--ink-900);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; flex-direction: column; gap: 6px; padding: 4px 8px 22px; }
.brand:hover { text-decoration: none; }
.brand-logo { width: 132px; height: auto; display: block; }
.brand-sub { display: block; font-size: 12px; color: var(--ink-500); letter-spacing: .01em; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  color: var(--ink-700); padding: 10px 12px; border-radius: 10px; font-weight: 600;
}
.nav a:hover { background: var(--blue-50); color: var(--blue-900); text-decoration: none; }
.nav a.active { background: var(--blue-100); color: var(--blue-900); }
.sidebar-foot { margin-top: auto; font-size: 12.5px; }
.engine {
  background: var(--blue-50); border: 1px solid var(--blue-100);
  border-radius: 10px; padding: 10px 12px; color: var(--ink-700);
}
.engine b { color: var(--green-700); }
.engine.off b { color: #b24c12; }
.sidebar-note { color: var(--ink-500); padding: 10px 4px 0; }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  padding: 26px 36px 18px; background: var(--surface); border-bottom: 1px solid var(--line-soft);
}
.crumbs { color: var(--ink-500); font-size: 13px; font-weight: 600; }
.crumbs a { color: var(--ink-500); }
h1 { margin: 2px 0 0; font-size: 26px; letter-spacing: -.02em; font-weight: 600; color: var(--blue-900); }
.view { padding: 28px 36px 60px; max-width: 1360px; width: 100%; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; border-radius: 999px;
  padding: 9px 18px; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  border: 1.5px solid transparent; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--blue-700); color: #fff; }
.btn-primary:hover { background: var(--blue-800); }
.btn-dark { background: var(--blue-900); color: #fff; }
.btn-dark:hover { background: var(--blue-800); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--blue-900); }
.btn-ghost:hover { border-color: var(--blue-700); background: var(--blue-50); }
.btn-danger { background: transparent; border-color: #f2c4bb; color: var(--red-600); }
.btn-danger:hover { background: var(--red-50); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-icon { padding: 6px 8px; gap: 6px; white-space: nowrap; }
.btn-icon span:empty { display: none; }
.row-actions { width: 104px; text-align: right; vertical-align: middle; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Cards / tiles ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line-soft); }
.card-pad { padding: 22px 24px; }
.card h2 { font-size: 17px; margin: 0 0 4px; color: var(--blue-900); font-weight: 600; }
.card .sub { color: var(--ink-500); font-size: 13.5px; margin: 0 0 16px; }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.tile { padding: 18px 20px; position: relative; overflow: hidden; }
.tile::after {
  content: ""; position: absolute; right: -28px; top: -28px; width: 90px; height: 90px; border-radius: 50%;
  border: 14px solid var(--blue-50);
}
.tile-label { font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-500); font-weight: 600; }
.tile-value { font-size: 32px; font-weight: 600; color: var(--blue-700); letter-spacing: -.02em; line-height: 1.15; margin-top: 4px; }
.tile-foot { font-size: 13px; color: var(--ink-500); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--blue-900);
  font-weight: 600; padding: 12px 14px; background: var(--blue-100); border-bottom: 1px solid var(--line-soft);
}
td { padding: 13px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: var(--blue-50); }
.cell-strong { font-weight: 600; color: var(--blue-900); }
.cell-muted { color: var(--ink-500); font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Badges / chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; background: var(--line-soft); color: var(--ink-700); white-space: nowrap;
}
.badge-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.b-green { background: var(--green-50); color: var(--green-700); }
/* .b-teal is kept as a class name (app.js uses it) but now renders in brand blue. */
.b-teal { background: var(--blue-700); color: #fff; }
.b-blue { background: var(--blue-100); color: var(--blue-900); }
.b-orange { background: var(--orange-100); color: #b24c12; }
.b-red { background: var(--red-50); color: var(--red-600); }
.b-purple { background: #efe4ff; color: #5d1fbf; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.page-link {
  display: inline-block; font-size: 12px; font-weight: 600; color: var(--blue-700); background: var(--blue-50);
  padding: 1px 8px; border-radius: 6px; cursor: pointer; border: none; font-family: inherit;
}
.page-link:hover { background: var(--blue-100); }

/* ---------- Empty state / upload ---------- */
.empty { text-align: center; padding: 56px 24px; }
.empty svg { width: 48px; height: 48px; color: var(--blue-700); }
.empty h2 { margin: 12px 0 6px; }
.empty p { color: var(--ink-500); margin: 0 auto 18px; max-width: 460px; }

.upload-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 22px; }
.dropzone {
  display: block; /* it's a <label>, which is inline by default and breaks the box */
  border: 2px dashed var(--blue-300); border-radius: var(--radius); background: var(--blue-50);
  padding: 54px 24px; text-align: center; cursor: pointer; transition: background .15s, border-color .15s;
}
.dropzone.drag { background: var(--blue-100); border-color: var(--blue-700); }
.dropzone svg { width: 46px; height: 46px; color: var(--blue-700); }
.dropzone h3 { margin: 12px 0 4px; color: var(--blue-900); font-size: 19px; font-weight: 600; }
.dropzone p { margin: 0 0 16px; color: var(--ink-500); }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.checklist li:last-child { border-bottom: none; }
.checklist svg { color: var(--green-700); margin-top: 2px; }

.stepper { list-style: none; margin: 18px 0 0; padding: 0; }
.stepper li { display: flex; gap: 12px; align-items: center; padding: 10px 0; color: var(--ink-500); font-weight: 600; }
.stepper .dot {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; flex: none;
}
.stepper li.done { color: var(--blue-900); }
.stepper li.done .dot { background: var(--blue-700); border-color: var(--blue-700); color: #fff; }
.stepper li.active { color: var(--blue-900); }
.stepper li.active .dot { border-color: var(--blue-700); border-top-color: transparent; animation: spin 1s linear infinite; }
.stepper li.failed { color: var(--red-600); }
.stepper li.failed .dot { border-color: var(--red-600); }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-detail { margin-top: 6px; color: var(--ink-500); font-size: 13.5px; }

/* ---------- Contract detail ---------- */
.hero {
  background: var(--blue-900);
  background-image: radial-gradient(circle at 100% 0, rgba(45, 64, 203, .9), transparent 45%);
  color: #fff; border-radius: var(--radius); padding: 24px 28px; margin-bottom: 20px;
  display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap;
}
.hero-parties { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.hero-party .lbl { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--blue-300); font-weight: 600; }
.hero-party .val { font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.hero-arrow { color: var(--blue-300); }
.hero-arrow svg { width: 26px; height: 26px; }
.hero-meta { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 16px; font-size: 13.5px; color: var(--blue-100); }
.hero-meta b { color: #fff; display: block; font-size: 15px; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.hero .btn-primary { background: #fff; color: var(--blue-900); }
.hero .btn-primary:hover { background: var(--blue-100); }
.hero .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, .35); }
.hero .btn-ghost:hover { background: rgba(255, 255, 255, .1); border-color: #fff; }
.hero .badge { margin-top: 10px; }

.summary-box {
  border-left: 4px solid var(--blue-700); background: var(--surface); padding: 16px 20px; border-radius: 10px;
  box-shadow: var(--shadow); margin-bottom: 20px; font-size: 15px; color: var(--ink-700);
}
.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 10px;
  background: var(--orange-100); color: #8a3a0c; font-size: 14px; margin-bottom: 18px;
}
.notice.error { background: var(--red-50); color: var(--red-600); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tab {
  background: none; border: none; font: inherit; font-weight: 600; color: var(--ink-500); padding: 11px 14px;
  cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; display: flex; gap: 7px; align-items: center;
}
.tab:hover { color: var(--blue-700); }
.tab.active { color: var(--blue-900); border-bottom-color: var(--blue-700); }
.tab .count { font-size: 11.5px; background: var(--line-soft); color: var(--ink-700); border-radius: 999px; padding: 0 7px; }
.tab.active .count { background: var(--blue-100); color: var(--blue-900); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
/* minmax(0, 1fr) + wrapping badges keep long values (e.g. payer entity names) inside the card. */
.kv { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 0; font-size: 14px; }
.kv dt { color: var(--ink-500); font-weight: 600; padding: 9px 12px 9px 0; border-bottom: 1px solid var(--line-soft); }
.kv dd { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--line-soft); min-width: 0; overflow-wrap: anywhere; }
.kv .badge { white-space: normal; border-radius: 8px; }
.kv dt:last-of-type, .kv dd:last-of-type { border-bottom: none; }

.rate-big { font-size: 22px; font-weight: 600; color: var(--blue-700); }
.quote { font-size: 13px; color: var(--ink-500); font-style: italic; margin-top: 6px; }

.timeline-group h3 { font-size: 14px; color: var(--blue-900); margin: 0 0 10px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.days { font-size: 24px; font-weight: 600; color: var(--blue-700); line-height: 1; }
.days small { display: block; font-size: 11.5px; color: var(--ink-500); font-weight: 600; margin-top: 3px; }

.source { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 18px; }
.page-nav { position: sticky; top: 16px; align-self: start; max-height: 80vh; overflow: auto; }
.page-nav button {
  display: block; width: 100%; text-align: left; border: none; background: none; font: inherit; font-size: 13.5px;
  padding: 6px 10px; border-radius: 8px; cursor: pointer; color: var(--ink-700);
}
.page-nav button:hover { background: var(--blue-50); }
.page-nav button.active { background: var(--blue-100); color: var(--blue-900); font-weight: 600; }
.page-text {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; white-space: pre; overflow-x: auto;
  padding: 20px 22px; margin: 0; line-height: 1.55; color: var(--ink-900);
}
mark { background: #fff1a8; padding: 0 1px; border-radius: 2px; }

.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; }
.search {
  border: 1.5px solid var(--line); border-radius: 999px; padding: 8px 16px; font: inherit; font-size: 14px; min-width: 260px;
}
.search:focus { outline: none; border-color: var(--blue-700); box-shadow: 0 0 0 3px rgba(45, 64, 203, .18); }

.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--blue-900); color: #fff; padding: 12px 18px;
  border-radius: 10px; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }

@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .upload-grid { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  body { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--line-soft); }
  .sidebar-foot { display: none; }
  .topbar, .view { padding-left: 16px; padding-right: 16px; }
  .source { grid-template-columns: 1fr; }
  .page-nav { position: static; display: flex; overflow-x: auto; }
}

/* ---------- edit mode ---------- */
.edit-card { margin-bottom: 18px; }
.edit-card h2 { margin-bottom: 14px; }
.edit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field > span { font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-500); }
.field input, .field select, .field textarea {
  width: 100%; font: inherit; font-size: 14px; color: var(--ink-900); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: 8px; padding: 7px 10px;
}
.field textarea { resize: vertical; min-height: 38px; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--blue-700); box-shadow: 0 0 0 3px var(--blue-100); }
.summary-edit { margin: 18px 0; }
.edit-items { display: grid; gap: 12px; justify-items: start; }
.edit-item { width: 100%; border: 1px solid var(--line-soft); border-radius: 12px; padding: 14px 16px; background: var(--page); }
.edit-item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; color: var(--blue-900); }
.edit-bar {
  position: sticky; bottom: 16px; z-index: 5; margin-top: 18px; display: flex; gap: 16px; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1.5px solid var(--blue-300); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px; font-size: 14px;
}
.edit-bar-actions { display: flex; gap: 10px; flex: none; }
@media (max-width: 640px) { .edit-bar { flex-direction: column; align-items: stretch; } }
