/* Property Research UI — white/charcoal, emerald + coral accents, IBM Plex Sans */

@font-face {
  font-family: "IBM Plex Sans";
  src: url("../fonts/ibm-plex-sans-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("../fonts/ibm-plex-sans-500.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("../fonts/ibm-plex-sans-600.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("../fonts/ibm-plex-sans-700.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --font: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
  --bg: #ffffff;
  --bg-subtle: #f6f7f7;
  --bg-sunken: #eef0f0;
  --ink: #1c2124;
  --ink-2: #454d52;
  --ink-3: #6b747a;
  --line: #e2e6e8;
  --line-strong: #cfd6d9;
  --emerald: #047857;
  --emerald-strong: #065f46;
  --emerald-tint: #ecf7f2;
  --coral: #e0452c;
  --coral-strong: #c2361f;
  --coral-tint: #fdf0ed;
  --amber: #b45309;
  --amber-tint: #fdf6ec;
  --blue: #1d4ed8;
  --blue-tint: #eef2fd;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 28, .06), 0 1px 3px rgba(16, 24, 28, .05);
  --shadow-pop: 0 8px 24px rgba(16, 24, 28, .12);
  --focus: 0 0 0 3px rgba(4, 120, 87, .25);
  --topbar-h: 52px;
  --sidenav-w: 232px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg-subtle);
  -webkit-font-smoothing: antialiased;
}

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--ink); color: #fff; padding: 8px 12px; z-index: 100;
}
.skip-link:focus { left: 8px; top: 8px; }

/* ---------- icons (lucide via CSS mask, inherits currentColor) ---------- */
.icon {
  display: inline-block; width: 16px; height: 16px; flex: none;
  background-color: currentColor;
  -webkit-mask: var(--icon-url) center / contain no-repeat;
  mask: var(--icon-url) center / contain no-repeat;
  vertical-align: -3px;
}
.icon-lg { width: 20px; height: 20px; }

/* ---------- layout ---------- */
.app { display: flex; flex-direction: column; height: 100dvh; }
.app[hidden] { display: none; }
.topbar {
  height: var(--topbar-h); flex: none;
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: var(--ink); color: #f3f5f6;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 6px;
  background: var(--emerald); color: #fff;
  font-weight: 700; font-size: 12px; letter-spacing: .02em;
}
.brand-name { font-weight: 600; font-size: 14px; white-space: nowrap; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.session-user { font-size: 13px; color: #b9c2c7; }
.topbar .btn-ghost { color: #e7ebec; }
.topbar .btn-ghost:hover { background: rgba(255, 255, 255, .1); }

.shell { flex: 1; display: flex; min-height: 0; }
.sidenav {
  width: var(--sidenav-w); flex: none;
  background: var(--bg); border-right: 1px solid var(--line);
  overflow-y: auto; padding: 10px 8px 24px;
}
.main { flex: 1; min-width: 0; overflow-y: auto; }
.main:focus { outline: none; }
.view { max-width: 1120px; margin: 0 auto; padding: 20px 24px 64px; }

.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.nav-section {
  margin: 14px 8px 4px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3);
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); text-decoration: none; font-weight: 500;
}
.nav-link:hover { background: var(--bg-sunken); color: var(--ink); }
.nav-link.active { background: var(--emerald-tint); color: var(--emerald-strong); }
.nav-link.active .icon { color: var(--emerald); }
.nav-link:focus-visible { outline: none; box-shadow: var(--focus); }
.nav-count {
  margin-left: auto; font-size: 11px; font-weight: 600;
  background: var(--bg-sunken); color: var(--ink-3);
  border-radius: 999px; padding: 1px 7px;
}
.nav-link.active .nav-count { background: #fff; color: var(--emerald-strong); }

.nav-scrim {
  position: fixed; inset: var(--topbar-h) 0 0 0;
  background: rgba(16, 24, 28, .4); z-index: 30;
}

/* ---------- page headers ---------- */
.page-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-title { font-size: 19px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.page-sub { color: var(--ink-3); font-size: 13px; margin: 2px 0 0; }
.page-head .spacer { flex: 1; }

/* ---------- panels (flat, single level — no nested cards) ---------- */
.panel {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 16px; }
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.panel-title { font-size: 13px; font-weight: 600; margin: 0; color: var(--ink); }
.panel-title .icon { color: var(--emerald); margin-right: 6px; }
.panel-body { padding: 14px 16px; }
.panel-body.flush { padding: 0; }

/* ---------- stat tiles ---------- */
.stat-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  margin-bottom: 16px;
}
.stat {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; color: var(--ink-3); font-weight: 500; }
.stat-value { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-hint { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-weight: 600; font-size: 13px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 7px 13px; cursor: pointer; text-decoration: none;
  background: var(--emerald); color: #fff;
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover { background: var(--emerald-strong); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-secondary { background: var(--bg); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--bg-sunken); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg-sunken); color: var(--ink); }
.btn-danger { background: var(--coral); color: #fff; }
.btn-danger:hover { background: var(--coral-strong); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; border: none; border-radius: var(--radius-sm);
  background: transparent; color: inherit; cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 255, 255, .12); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--focus); }

/* ---------- pills & status ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; letter-spacing: .01em;
  border-radius: 999px; padding: 2px 9px; white-space: nowrap;
}
.pill-running { background: var(--blue-tint); color: var(--blue); }
.pill-pending { background: var(--amber-tint); color: var(--amber); }
.pill-succeeded { background: var(--emerald-tint); color: var(--emerald-strong); }
.pill-failed { background: var(--coral-tint); color: var(--coral-strong); }
.pill-neutral { background: var(--bg-sunken); color: var(--ink-3); }
.pill .icon { width: 12px; height: 12px; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td {
  text-align: left; padding: 8px 16px;
  border-bottom: 1px solid var(--line); vertical-align: top;
}
table.data th {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--ink-3);
  background: var(--bg-subtle); position: sticky; top: 0;
}
table.data tbody tr:hover { background: var(--bg-subtle); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.rowlink { cursor: pointer; }

/* ---------- forms ---------- */
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field-label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field-hint { font-size: 12px; color: var(--ink-3); }
.input, select.input, textarea.input {
  font: inherit; color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 7px 10px; background: var(--bg); width: 100%;
}
.input:focus { outline: none; border-color: var(--emerald); box-shadow: var(--focus); }
.input[aria-invalid="true"] { border-color: var(--coral); }
.checkbox-field { flex-direction: row; align-items: center; gap: 8px; padding-top: 20px; }
.checkbox-field input { width: 16px; height: 16px; accent-color: var(--emerald); }

.price-rows { display: flex; flex-direction: column; gap: 6px; }
.price-row { display: grid; grid-template-columns: 1fr 140px 32px; gap: 8px; align-items: center; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; }
.form-error {
  margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--coral-tint); color: var(--coral-strong);
  font-size: 13px; display: flex; gap: 8px; align-items: flex-start;
}

/* ---------- workflow list ---------- */
.wf-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.wf-search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.wf-search .icon { position: absolute; left: 10px; top: 9px; color: var(--ink-3); }
.wf-search .input { padding-left: 32px; }
.wf-list { display: flex; flex-direction: column; gap: 10px; }
.wf-item {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.wf-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; flex-wrap: wrap;
}
.wf-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.wf-cat { color: var(--ink-3); font-size: 12px; }
.wf-row .spacer { flex: 1; }
.wf-form-wrap { border-top: 1px solid var(--line); padding: 14px; background: var(--bg-subtle); border-radius: 0 0 var(--radius) var(--radius); }
.wf-unavailable { color: var(--amber); font-size: 12px; display: inline-flex; gap: 6px; align-items: center; }

/* ---------- jobs ---------- */
.job-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font: inherit; font-size: 12px; font-weight: 600;
  border: 1px solid var(--line-strong); background: var(--bg); color: var(--ink-2);
  border-radius: 999px; padding: 4px 12px; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip:focus-visible { outline: none; box-shadow: var(--focus); }

.artifact-list { display: flex; flex-direction: column; gap: 8px; }
.artifact {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg);
}
.artifact .icon { color: var(--emerald); }
.artifact-name { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.artifact-kind { color: var(--ink-3); font-size: 12px; }
.artifact-actions { margin-left: auto; display: flex; gap: 6px; }
.artifact-preview { margin-top: 10px; }
.artifact-preview img {
  max-width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff;
}
.artifact-preview iframe {
  width: 100%; height: 480px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff;
}

.kv { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; row-gap: 6px; column-gap: 16px; font-size: 13px; }
.kv dt { color: var(--ink-3); font-weight: 500; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.mono { font-family: var(--mono); font-size: 12.5px; }

.progress-track { height: 6px; background: var(--bg-sunken); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--emerald); border-radius: 999px; transition: width .3s ease; }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: var(--bg-subtle);
}
.login-panel {
  width: 100%; max-width: 360px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-pop);
  padding: 28px 26px 26px;
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.login-title { font-size: 17px; font-weight: 700; margin: 0 0 18px; }
.login-panel .field { margin-bottom: 12px; }

/* ---------- misc ---------- */
.empty {
  padding: 32px 16px; text-align: center; color: var(--ink-3);
  display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px;
}
.empty .icon { width: 24px; height: 24px; color: var(--line-strong); }
.loading-block { display: flex; align-items: center; gap: 10px; color: var(--ink-3); padding: 24px 0; font-size: 13px; }
.error-block {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--coral-tint); border: 1px solid #f3c5bd;
  color: var(--coral-strong); border-radius: var(--radius);
  padding: 12px 14px; font-size: 13px; margin-bottom: 16px;
}
.error-block .icon { flex: none; margin-top: 1px; }
.muted { color: var(--ink-3); }
.nowrap { white-space: nowrap; }

.toast-root { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast {
  display: flex; gap: 8px; align-items: center;
  background: var(--ink); color: #f3f5f6;
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px;
  box-shadow: var(--shadow-pop);
}
.toast-error { background: var(--coral-strong); color: #fff; }

#nav-toggle { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  #nav-toggle { display: inline-grid; }
  .sidenav {
    position: fixed; top: var(--topbar-h); bottom: 0; left: 0; z-index: 40;
    transform: translateX(-100%); transition: transform .18s ease;
    box-shadow: var(--shadow-pop);
  }
  .sidenav.open { transform: none; }
  .view { padding: 16px 14px 56px; }
  .session-user { display: none; }
  .btn-label { display: none; }
  .kv { grid-template-columns: 1fr; row-gap: 2px; }
  .kv dd { margin-bottom: 6px; }
  .price-row { grid-template-columns: 1fr 110px 32px; }
}
@media (prefers-reduced-motion: reduce) {
  .spin { animation: none; }
  .sidenav { transition: none; }
}
