:root {
  --bg: #f2efe6;
  --bg-2: #eae6da;
  --surface: #ffffff;
  --surface-2: #faf8f2;
  --ink: #14201b;
  --muted: #6b7a72;
  --line: #e3ddd0;
  --line-2: #d5cdbc;
  --brand: #0e5a46;
  --brand-2: #16866a;
  --brand-soft: #e4f0ea;
  --accent: #e0703a;
  --accent-soft: #f9e7dc;
  --danger: #bf4438;
  --danger-soft: #f7e2df;
  --ok: #1c8c6b;
  --warn: #c98a1e;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px -18px rgba(20, 32, 27, 0.45);
  --shadow-sm: 0 4px 14px -10px rgba(20, 32, 27, 0.5);
  --font: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(1200px 500px at 100% -10%, rgba(22, 134, 106, 0.10), transparent 60%),
    radial-gradient(900px 400px at -10% 0%, rgba(224, 112, 58, 0.08), transparent 55%),
    var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}

#app { max-width: 720px; margin: 0 auto; padding-bottom: 92px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px 12px;
  background: rgba(242, 239, 230, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.logo-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(140deg, var(--brand) 0%, var(--brand-2) 100%);
  display: grid; place-items: center; flex: none;
  box-shadow: var(--shadow-sm);
}
.logo-mark svg { width: 22px; height: 22px; }

.brand-name { font-weight: 800; font-size: 18px; letter-spacing: -0.02em; }
.brand-sub { font-size: 11.5px; color: var(--muted); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.topbar .spacer { flex: 1; }
.user-pill {
  font-size: 12.5px; font-weight: 700; color: var(--brand);
  background: var(--brand-soft); padding: 7px 12px; border-radius: 999px;
  max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

main { padding: 16px 16px 24px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  max-width: 720px; margin: 0 auto;
}
.tab {
  border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--muted); font-family: var(--font); font-size: 11px; font-weight: 700;
  padding: 6px 10px; border-radius: 12px; flex: 1;
  transition: color .18s ease, background .18s ease;
}
.tab svg { width: 22px; height: 22px; stroke-width: 1.9; }
.tab.active { color: var(--brand); background: var(--brand-soft); }

/* --- sections & cards --- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 10px; margin: 4px 2px 12px; }
.section-title { font-size: 13px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.link-btn { border: 0; background: none; color: var(--brand); font-weight: 700; font-family: var(--font); font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.link-btn svg { width: 14px; height: 14px; }
.row svg { width: 15px; height: 15px; vertical-align: -2px; }
.row > svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.check svg { width: 16px; height: 16px; flex: none; }
.back-btn svg { width: 16px; height: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  max-width: 100%;
}
.card.tight { padding: 12px 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.stat .num { font-family: var(--mono); font-size: 26px; font-weight: 600; letter-spacing: -0.03em; }
.stat .lab { font-size: 12px; color: var(--muted); font-weight: 700; margin-top: 2px; }
.stat.accent .num { color: var(--accent); }
.stat.brand .num { color: var(--brand); }

/* --- buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line-2); background: var(--surface);
  color: var(--ink); font-family: var(--font); font-weight: 700; font-size: 14px;
  padding: 10px 14px; border-radius: 12px; cursor: pointer;
  transition: transform .08s ease, background .18s ease, border-color .18s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-ghost { background: var(--surface-2); }
.btn-danger { color: var(--danger); border-color: var(--danger-soft); background: var(--danger-soft); }
.btn-sm { padding: 7px 11px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.chip {
  display: inline-block; font-family: var(--mono); font-size: 11.5px; font-weight: 500;
  background: var(--brand-soft); color: var(--brand); padding: 3px 9px;
  border-radius: 999px; margin: 0 5px 5px 0;
}
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 800;
  padding: 4px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em; }
.badge.ok { background: var(--brand-soft); color: var(--ok); }
.badge.err { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--accent-soft); color: var(--warn); }
.badge.mono { font-family: var(--mono); text-transform: none; letter-spacing: 0; }

.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- forms --- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.input, .select {
  width: 100%; border: 1px solid var(--line-2); background: var(--surface-2);
  border-radius: 12px; padding: 11px 13px; font-family: var(--font); font-size: 14.5px;
  color: var(--ink); outline: none; transition: border-color .16s ease, background .16s;
}
.input:focus, .select:focus { border-color: var(--brand-2); background: #fff; }
.input.mono { font-family: var(--mono); font-size: 13px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* --- progress --- */
.progress { height: 8px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-2), var(--accent)); transition: width .5s ease; }
.progress.indeterminate > i { width: 40% !important; animation: slide 1.2s infinite ease-in-out; }
@keyframes slide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }

/* --- tables --- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-top: 10px; }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th, table.data td { padding: 9px 12px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); }
table.data th { position: sticky; top: 0; background: var(--surface-2); font-weight: 800; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); cursor: pointer; user-select: none; }
table.data th:hover { color: var(--brand); }
table.data td { font-family: var(--mono); font-size: 12.5px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: var(--surface-2); }

/* --- results as record cards --- */
.res-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.res-bar .input { flex: 1; min-width: 150px; }
.rec-list { display: flex; flex-direction: column; gap: 10px; }
.rec { border: 1px solid var(--line); border-radius: 12px; padding: 12px 13px; background: var(--surface); }
.rec-title { font-weight: 800; font-size: 14.5px; line-height: 1.35; word-break: break-word; margin-bottom: 8px; }
.rec-field { display: grid; grid-template-columns: minmax(70px, 36%) 1fr; gap: 3px 10px; padding: 5px 0; border-top: 1px dashed var(--line); }
.rec-field:first-of-type { border-top: 0; padding-top: 0; }
.rec-k { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; word-break: break-word; }
.rec-v { font-family: var(--mono); font-size: 12.5px; word-break: break-word; overflow-wrap: anywhere; }

/* --- task list --- */
.task-card { cursor: pointer; padding: 14px 15px; transition: border-color .16s ease, transform .08s ease; }
.task-card:active { transform: scale(0.995); }
.task-card:hover { border-color: var(--brand-2); }
.task-head { display: flex; align-items: flex-start; gap: 10px; }
.task-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 7px; flex: none; }
.dot-ok { background: var(--ok); }
.dot-err { background: var(--danger); }
.dot-run { background: var(--warn); }
.dot-idle { background: var(--line-2); }
.task-name-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.task-name-row .task-title { min-width: 0; }
.task-name-row .badge { flex: none; }
.task-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }
.task-meta svg { width: 13px; height: 13px; }
.dot-sep { opacity: .45; }
.task-actions { display: flex; align-items: center; gap: 7px; margin-top: 12px; }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: 11px; }
.btn-icon svg { width: 18px; height: 18px; }
.task-chev { margin-left: auto; align-self: center; color: var(--muted); display: inline-flex; }
.task-chev svg { width: 20px; height: 20px; }
.task-title { font-weight: 800; font-size: 15.5px; letter-spacing: -0.01em; }
.task-url { font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-top: 2px; word-break: break-all; }

/* --- misc --- */
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty > svg { width: 46px; height: 46px; opacity: .5; margin-bottom: 10px; }
.empty .btn svg { width: 16px; height: 16px; }
.spinner { width: 20px; height: 20px; border: 2.5px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%) translateY(10px);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px;
  font-size: 13.5px; font-weight: 600; z-index: 60; opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; max-width: 88vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

.chart { width: 100%; }
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--muted); font-weight: 600; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }

.candidate { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 10px; background: var(--surface-2); }
.candidate.selected { border-color: var(--brand-2); box-shadow: 0 0 0 2px var(--brand-soft); }

.back-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none;
  color: var(--brand); font-weight: 700; font-family: var(--font); font-size: 14px; cursor: pointer; padding: 4px 0; margin-bottom: 8px; }

.hidden { display: none !important; }
.stack > * + * { margin-top: 10px; }
.thumbmini { border-radius: 8px; border: 1px solid var(--line); width: 100%; height: auto; }

@media (max-width: 380px) {
  .stat .num { font-size: 22px; }
  .form-row { grid-template-columns: 1fr; }
}
