/* waterfall UI
   Dark by default with a light-scheme override: CFD fields are rendered on
   dark backgrounds and a bright chrome around them makes the colour maps hard
   to judge. */

:root {
  --bg: #0e1116;
  --bg-2: #161b23;
  --bg-3: #1d232d;
  --line: #2a323e;
  --text: #e6edf5;
  --muted: #8b98a9;
  --accent: #4aa8ff;
  --accent-dim: #1e4d7a;
  --ok: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f8fa; --bg-2: #ffffff; --bg-3: #eef2f6;
    --line: #d6dee7; --text: #12181f; --muted: #5c6b7a;
    --accent: #0969da; --accent-dim: #b6d8ff;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ---------- header ---------- */

header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; padding: 14px 24px;
  background: var(--bg-2); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 30px; height: 30px; border-radius: 8px; display: block;
  background: linear-gradient(150deg, var(--accent), #6ee7ff 55%, #2b5f8f);
}
h1 { font-size: 17px; margin: 0; letter-spacing: .2px; }
.sub { margin: 0; font-size: 11.5px; color: var(--muted); }

nav { display: flex; gap: 4px; }
.tab {
  background: none; border: 1px solid transparent; color: var(--muted);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
  display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--text); background: var(--bg-3); }
.tab.active { color: var(--text); background: var(--bg-3); border-color: var(--line); }
.badge {
  background: var(--accent); color: #04121f; border-radius: 20px;
  padding: 1px 7px; font-size: 11px; font-weight: 700;
}

main { max-width: 1180px; margin: 0 auto; padding: 24px; }
.view.hidden, .hidden { display: none !important; }

/* ---------- dropzone ---------- */

.dropzone {
  border: 2px dashed var(--line); border-radius: 14px;
  padding: 46px 20px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
  background: var(--bg-2);
}
.dropzone:hover { border-color: var(--accent-dim); }
.dropzone.over {
  border-color: var(--accent); background: var(--bg-3);
  transform: scale(1.006);
}
.dropzone.busy { opacity: .6; pointer-events: none; }
.drop-icon { width: 40px; height: 40px; color: var(--accent); margin-bottom: 8px; }
.drop-title { margin: 0; font-size: 17px; font-weight: 600; }
.drop-hint { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.link {
  background: none; border: none; color: var(--accent);
  cursor: pointer; font: inherit; padding: 0; text-decoration: underline;
}

.recent { margin-top: 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.recent-label { color: var(--muted); font-size: 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: var(--bg-3); border: 1px solid var(--line); color: var(--text);
  padding: 4px 11px; border-radius: 20px; cursor: pointer; font-size: 12.5px;
}
.chip:hover { border-color: var(--accent); }

/* ---------- panels ---------- */

.panel {
  margin-top: 20px; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
}
.panel-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: 16px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .5px;
     color: var(--muted); margin: 20px 0 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

.pill {
  font-size: 11px; padding: 3px 9px; border-radius: 20px;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--muted);
  white-space: nowrap;
}
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.pill.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.pill.run { color: var(--accent); border-color: var(--accent-dim); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 5px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }

.note { color: var(--muted); font-size: 12.5px; margin: 0 0 10px; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; min-height: 1em; }

/* ---------- form ---------- */

label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
label.check { display: flex; align-items: center; gap: 7px; color: var(--text);
              font-size: 13px; margin-top: 20px; }
input[type=number], input[type=search], select {
  width: 100%; margin-top: 4px; padding: 7px 9px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px; font: inherit;
  font-variant-numeric: tabular-nums;
}
input:focus, select:focus { outline: 2px solid var(--accent-dim); border-color: var(--accent); }
input[type=checkbox] { width: auto; margin: 0; accent-color: var(--accent); }
.field-row { display: flex; gap: 12px; }
.field-row > label { flex: 1; }

.estimate {
  margin-top: 16px; padding: 12px 14px; border-radius: 8px;
  background: var(--bg-3); border: 1px solid var(--line);
  font-size: 12.5px; font-variant-numeric: tabular-nums;
}
.estimate.over { border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.estimate b { font-size: 15px; }

.actions {
  display: flex; align-items: center; gap: 10px;
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line);
}
.btn {
  padding: 9px 18px; border-radius: 8px; cursor: pointer;
  font: inherit; font-weight: 500; border: 1px solid var(--line);
  background: var(--bg-3); color: var(--text);
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #04121f; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.small { padding: 6px 12px; font-size: 12.5px; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.msg { font-size: 12.5px; color: var(--muted); }
.msg.err { color: var(--bad); }

/* ---------- run cards ---------- */

.stack { display: flex; flex-direction: column; gap: 14px; }
.runcard {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
.runcard-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.runcard-head h3 { margin: 0; font-size: 15px; text-transform: none;
                   letter-spacing: 0; color: var(--text); flex: 1; }
.bar { height: 7px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.bar > i {
  display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #6ee7ff);
  transition: width .4s ease;
}
.bar.indet > i { width: 35% !important; animation: slide 1.3s ease-in-out infinite; }
@keyframes slide { 0%{margin-left:-35%} 100%{margin-left:100%} }
.metrics {
  display: flex; gap: 20px; flex-wrap: wrap; margin-top: 10px;
  font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.metrics b { color: var(--text); font-weight: 600; }

pre.log {
  margin: 12px 0 0; padding: 10px 12px; max-height: 220px; overflow: auto;
  background: var(--bg); border: 1px solid var(--line); border-radius: 7px;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.45;
  white-space: pre; color: var(--muted);
}

/* ---------- project cards ---------- */

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; }
.toolbar input { flex: 1; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.card {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; cursor: pointer;
  transition: border-color .15s, transform .1s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card-thumb {
  aspect-ratio: 16/7; background: var(--bg-3) center/cover no-repeat;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--line);
}
.card-body { padding: 12px 14px; }
.card-body h4 { margin: 0 0 4px; font-size: 14px; word-break: break-word; }
.card-meta { display: flex; justify-content: space-between; align-items: center;
             gap: 8px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.cd { font-size: 19px; font-weight: 700; color: var(--text);
      font-variant-numeric: tabular-nums; }
.cd small { font-size: 11px; font-weight: 400; color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 50px 20px; }

/* ---------- drawer ---------- */

.drawer { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55); }
.drawer-panel {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: min(760px, 100%); background: var(--bg-2);
  border-left: 1px solid var(--line); display: flex; flex-direction: column;
  animation: slidein .18s ease;
}
@keyframes slidein { from { transform: translateX(24px); opacity: .4 } }
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line);
}
.drawer-head h2 { margin: 0 0 6px; font-size: 17px; word-break: break-word; }
.drawer-body { padding: 20px; overflow: auto; }
.icon-btn {
  background: none; border: none; color: var(--muted);
  font-size: 26px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.icon-btn:hover { color: var(--text); }

.drawer-body video, .drawer-body img { width: 100%; border-radius: 8px;
  border: 1px solid var(--line); background: #000; display: block; }

.filelist { list-style: none; padding: 0; margin: 8px 0 0; }
.filelist li {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 7px; margin-bottom: 5px;
  font-size: 12.5px; background: var(--bg);
}
.filelist a { color: var(--accent); text-decoration: none; flex: 1;
              word-break: break-all; }
.filelist a:hover { text-decoration: underline; }
.filelist .sz { color: var(--muted); font-variant-numeric: tabular-nums; }
.ext {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--muted);
  padding: 2px 6px; border-radius: 4px; min-width: 42px; text-align: center;
}

.resultgrid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px; margin-bottom: 18px;
}
.stat {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 11px 13px;
}
.stat .l { font-size: 11px; color: var(--muted); text-transform: uppercase;
           letter-spacing: .4px; }
.stat .v { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums;
           margin-top: 2px; }

.warnbox {
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  background: color-mix(in srgb, var(--warn) 9%, transparent);
  border-radius: 8px; padding: 11px 13px; font-size: 12.5px; margin-bottom: 16px;
}
.warnbox b { color: var(--warn); }

.preview {
  width: 100%; border-radius: 8px; border: 1px solid var(--line);
  margin-bottom: 12px; background: var(--bg-3); display: block; min-height: 60px;
}
.preview.loading { opacity: .45; }
