/* Smoak Host — "boardroom" reskin per the Agenticity HQ style guide. v1
   Light canvas by default; .dark on <html> flips content tokens (navy chrome
   is identical in both modes). Self-contained: the panel loads ONLY this. */

/* ================= 1. Tokens ================= */
:root {
  color-scheme: light;
  --radius: 8px; --radius-sm: 4.8px; --radius-md: 6.4px; --radius-xl: 11.2px; --radius-2xl: 14.4px;

  --background: #f3f6fc;
  --foreground: #0c1a2e;
  --card: #ffffff;
  --card-foreground: #0c1a2e;
  --primary: #2f6ab0;
  --primary-foreground: #ffffff;
  --secondary: #e9f0fa;
  --secondary-foreground: #24405f;
  --muted: #e9f0fa;
  --muted-foreground: #5b6f8c;
  --accent: #eaf2fb;
  --accent-foreground: #215489;
  --border: #d7e0ee;
  --input: #d7e0ee;
  --ring: #2f6ab0;
  --destructive: #b42318;

  --sidebar: #0d1f39;
  --sidebar-border: #274a7d;
  --nav-2: #15305a;
  --nav-line: #274a7d;
  --nav-text: #c4d3e8;
  --nav-dim: #8ba0c0;
  --nav-bright: #9cc2ef;
  --accent-bright: #8fbdea;

  --status-idle: #a8aeb2;
  --status-queued: #f59e0b;
  --status-running: #2563eb;
  --status-review: #7c3aed;
  --status-done: #22c55e;
  --status-blocked: #dc2626;

  --font-heading: "Fraunces", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.dark {
  color-scheme: dark;
  --background: #0a1526;
  --foreground: #e6edf7;
  --card: #10233f;
  --card-foreground: #e6edf7;
  --primary: #9cc2ef;
  --primary-foreground: #0c1a2e;
  --secondary: #15305a;
  --secondary-foreground: #e6edf7;
  --muted: #14294a;
  --muted-foreground: #8ba0c0;
  --accent: #15305a;
  --accent-foreground: #c4d3e8;
  --border: rgba(143, 189, 234, 0.16);
  --input: rgba(143, 189, 234, 0.22);
  --ring: #5e93cd;
}

/* ================= 2. Base ================= */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; overflow: hidden;
  font-family: var(--font-sans); font-size: 14px; line-height: 1.55;
  background: var(--background); color: var(--foreground);
  -webkit-font-antialiasing: antialiased; -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--font-heading); font-weight: 640; letter-spacing: -0.02em; text-wrap: balance; }
code { font-family: var(--font-mono); font-size: 12.5px; background: var(--muted); padding: 2px 7px; border-radius: var(--radius-sm); }
.muted { color: var(--muted-foreground); }
.small { font-size: 12px; }

/* ================= 3. Shell ================= */
.hq { display: flex; flex-direction: column; height: 100vh; }

/* --- topbar (52px navy) --- */
.hq-topbar {
  height: 52px; flex: 0 0 52px; display: flex; align-items: center; gap: 14px;
  background: var(--sidebar); border-bottom: 1px solid var(--nav-line);
  padding: 0 16px; color: var(--nav-text);
}
.hq-brand { display: flex; align-items: center; gap: 10px; text-decoration: none !important; }
.hq-brand-tile {
  width: 26px; height: 26px; border-radius: 7px; flex: 0 0 26px;
  background: linear-gradient(140deg, #2f6ab0, #215489);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 13px; font-family: var(--font-sans);
}
.hq-wordmark { font-family: var(--font-heading); font-weight: 800; font-size: 15px; color: #fff; letter-spacing: -0.01em; }
.hq-wordmark b { color: var(--accent-bright); font-weight: 800; }
.hq-env {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--nav-2); border: 1px solid var(--nav-line); border-radius: var(--radius-md);
  padding: 4px 10px; font-size: 12px; color: var(--nav-dim); white-space: nowrap;
}
.hq-env .dot { width: 7px; height: 7px; border-radius: 50%; background: #12b76a; box-shadow: 0 0 0 3px rgba(18,183,106,.18); }
.hq-env b { color: var(--nav-bright); font-weight: 600; }
.hq-search {
  flex: 1; max-width: 520px; margin: 0 auto;
  display: flex; align-items: center; gap: 9px;
  height: 32px; padding: 0 10px; border-radius: 7px;
  border: 1px solid var(--nav-line); background: var(--nav-2);
  color: var(--nav-dim); font-size: 13px; font-family: inherit; cursor: pointer; text-align: left;
}
.hq-search .kbd {
  margin-left: auto; font-size: 11px; border: 1px solid var(--nav-line);
  border-radius: 4px; padding: 1px 5px; color: var(--nav-dim);
}
.hq-search:hover { color: var(--nav-text); }
.hq-iconbtn {
  width: 34px; height: 34px; border-radius: 7px; border: 0; background: transparent;
  color: var(--nav-dim); display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .13s, color .13s; flex: 0 0 34px;
}
.hq-iconbtn:hover { background: var(--nav-2); color: #fff; }
.hq-iconbtn svg { width: 17px; height: 17px; }
.hq-user { display: flex; align-items: center; gap: 9px; margin-left: 2px; }
.hq-ava {
  width: 28px; height: 28px; border-radius: 50%; background: var(--primary, #2f6ab0);
  background: #2f6ab0; color: #fff; font-size: 11.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; text-transform: uppercase;
}
.hq-user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.hq-user-meta strong { font-size: 13px; color: #fff; font-weight: 600; max-width: 170px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hq-user-meta span { font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--nav-dim); }

/* --- body row: rail + sidebar + main --- */
.hq-body { flex: 1; display: flex; min-height: 0; }

.hq-rail {
  width: 60px; flex: 0 0 60px; background: var(--sidebar); border-right: 1px solid var(--sidebar-border);
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 0 14px;
}
.hq-rail .spacer { flex: 1; }
.hq-rail-item {
  width: 40px; height: 40px; border-radius: var(--radius-xl); position: relative;
  display: flex; align-items: center; justify-content: center;
  color: var(--nav-dim); transition: background .13s, color .13s; text-decoration: none !important;
}
.hq-rail-item svg { width: 21px; height: 21px; }
.hq-rail-item:hover { background: var(--nav-2); color: #fff; }
.hq-rail-item.active { background: var(--nav-2); color: #fff; }
.hq-rail-item.active::before {
  content: ""; position: absolute; left: -10px; top: 10px; bottom: 10px; width: 3px;
  background: #2f6ab0; border-radius: 0 3px 3px 0;
}

.hq-side {
  width: 244px; flex: 0 0 244px; background: var(--sidebar); border-right: 1px solid var(--sidebar-border);
  display: flex; flex-direction: column; padding: 12px 10px 14px; gap: 4px;
}
.hq-ws { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; }
.hq-ws-tile {
  width: 40px; height: 40px; border-radius: var(--radius-xl); flex: 0 0 40px;
  background: linear-gradient(140deg, #2f6ab0, #15305a);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
  color: #fff; font-weight: 800; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.hq-ws-meta { line-height: 1.3; min-width: 0; }
.hq-ws-meta strong { display: block; font-size: 16px; font-weight: 700; color: #fff; }
.hq-ws-meta span { font-size: 11px; color: var(--nav-dim); }
.hq-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em;
  color: var(--nav-dim); padding: 8px 12px 6px;
}
.hq-nav-item {
  height: 40px; display: flex; align-items: center; gap: 12px; padding: 0 12px;
  border-radius: 10px; color: var(--nav-text); font-size: 14.5px; font-weight: 500;
  text-decoration: none !important; transition: background .13s, color .13s;
}
.hq-nav-item svg { width: 17px; height: 17px; flex: 0 0 17px; opacity: .9; }
.hq-nav-item:hover { background: var(--nav-2); color: #fff; }
.hq-nav-item.active { background: var(--nav-2); color: #fff; }
.hq-nav-item .count { margin-left: auto; font-size: 11px; color: var(--nav-dim); }
.hq-side .spacer { flex: 1; }
.hq-side-widget {
  background: rgba(0,0,0,.22); border: 1px solid var(--nav-line); border-radius: 10px;
  padding: 10px 12px; margin: 0 2px;
}
.hq-side-widget .wl { font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--nav-dim); display: flex; justify-content: space-between; }
.hq-side-widget .wl b { color: var(--nav-bright); letter-spacing: 0; }
.hq-side-widget .bar { height: 3px; background: var(--nav-line); border-radius: 2px; margin: 8px 0 6px; overflow: hidden; }
.hq-side-widget .bar i { display: block; height: 100%; background: var(--accent-bright); border-radius: 2px; }
.hq-side-widget .wm { font-size: 11px; color: var(--nav-dim); }
.hq-side-widget a { color: var(--nav-bright); font-size: 11px; }

/* --- breadcrumb + main --- */
.hq-main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.hq-crumbs {
  padding: 10px 24px; border-bottom: 1px solid var(--border); font-size: 13px;
  color: var(--muted-foreground); display: flex; align-items: center; gap: 8px;
  background: var(--background); flex: 0 0 auto;
}
.hq-crumbs b { color: var(--foreground); font-weight: 600; }
.hq-crumbs .sep { color: var(--border); }
.hq-main { flex: 1; overflow-y: auto; padding: 24px; }
.hq-main-inner { max-width: 1080px; }

/* ================= 4. Content components ================= */
.app-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 0 0 20px; }
.app-head h1 { margin: 0; font-size: 29px; }
.app-head .btn { margin-top: 4px; }

.section-title {
  font-family: var(--font-sans); font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .12em; color: var(--muted-foreground); margin: 30px 0 10px; text-wrap: initial;
}
.section-title:first-of-type { margin-top: 6px; }

.card {
  background: var(--card); color: var(--card-foreground);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; margin: 0 0 16px;
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card p { line-height: 1.55; }
.card .muted.small { margin-top: 12px; }
.card.empty { text-align: center; color: var(--muted-foreground); padding: 40px 22px; }

/* alerts / notices */
.alert { border: 1px solid var(--border); background: var(--accent); color: var(--accent-foreground); padding: 11px 14px; border-radius: var(--radius); margin: 0 0 14px; font-size: 13px; }
.alert-ok { border-color: color-mix(in srgb, var(--status-done) 40%, transparent); background: color-mix(in srgb, var(--status-done) 12%, var(--card)); color: color-mix(in srgb, var(--status-done) 70%, var(--foreground)); }
.alert-error { border-color: color-mix(in srgb, var(--status-blocked) 40%, transparent); background: color-mix(in srgb, var(--status-blocked) 10%, var(--card)); color: color-mix(in srgb, var(--status-blocked) 72%, var(--foreground)); }
.alert ul { margin: 8px 0 0 18px; padding: 0; }

/* KPI stats */
.stat-row { display: flex; gap: 14px; flex-wrap: wrap; margin: 0 0 8px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 22px 14px; min-width: 128px; }
.stat-num { display: block; font-family: var(--font-heading); font-weight: 640; font-size: 26px; letter-spacing: -0.02em; color: var(--foreground); line-height: 1.15; }
.stat .muted { font-size: 12px; }

/* health strip */
.host-health { display: flex; gap: 34px; row-gap: 18px; flex-wrap: wrap; align-items: flex-start; }
.host-health .hh { display: flex; flex-direction: column; gap: 4px; min-width: 96px; }
.host-health .hh .muted.small, .host-health .hh span.muted { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; margin: 0; }
.host-health .hh strong { font-size: 14.5px; font-weight: 600; }
.hh-ok { color: var(--status-done); }
.hh-bad { color: var(--status-blocked); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--radius-md);
  font: 500 14px var(--font-sans); cursor: pointer; text-decoration: none !important;
  border: 1px solid transparent; transition: background .13s, color .13s, border-color .13s;
  white-space: nowrap;
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 50%, transparent); }
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { background: color-mix(in srgb, var(--primary) 90%, black); }
.dark .btn-primary:hover { background: color-mix(in srgb, var(--primary) 90%, white); }
.btn-ghost { background: var(--card); color: var(--foreground); border-color: var(--input); box-shadow: 0 1px 2px rgba(12,26,46,.04); }
.btn-ghost:hover { background: var(--accent); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-link { background: none; border: 0; padding: 0 4px; height: auto; color: var(--primary); font: 500 13px var(--font-sans); cursor: pointer; }
.btn-link:hover { text-decoration: underline; }

/* forms */
.field-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.field-row label {
  display: flex; flex-direction: column; gap: 7px; flex: 1; min-width: 220px;
  font-size: 12px; font-weight: 600; color: var(--muted-foreground); letter-spacing: .01em;
}
.field-row input[type=text], .field-row input[type=url], .field-row input[type=email],
.field-row input[type=password], .field-row select, .stack-form input {
  height: 38px; padding: 0 12px; border: 1px solid var(--input); border-radius: var(--radius-md);
  font: 400 14px var(--font-sans); color: var(--foreground); background: var(--card); width: 100%;
  transition: border-color .13s, box-shadow .13s;
}
.field-row input:focus, .field-row select:focus, .stack-form input:focus {
  border-color: var(--ring); outline: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--ring) 35%, transparent);
}
.field-row ::placeholder, .stack-form ::placeholder { color: var(--muted-foreground); font-weight: 400; }
.field-row select {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 32px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235b6f8c' stroke-width='2.5'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 11px center;
}
.field-row input[type=file] {
  padding: 7px 10px; border: 1px dashed var(--input); border-radius: var(--radius-md);
  font-size: 13px; color: var(--muted-foreground); background: var(--muted); width: 100%; cursor: pointer;
}
.field-row input[type=file]:hover { border-color: var(--ring); }
.field-row input[type=file]::file-selector-button {
  height: 26px; padding: 0 11px; margin-right: 10px; border: 1px solid var(--input);
  border-radius: var(--radius-sm); background: var(--card); font: 600 12px var(--font-sans);
  color: var(--foreground); cursor: pointer;
}
.field-row .btn { flex: 0 0 auto; }
.field-row + .muted.small { margin-top: 12px; }

/* tables */
.vis-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.vis-table th {
  text-align: left; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted-foreground); padding: 12px 12px 9px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.vis-table td { padding: 14px 12px; border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent); vertical-align: middle; }
.vis-table tr:last-child td { border-bottom: 0; }
.vis-table tbody tr { transition: background .12s; }
.vis-table tbody tr:hover { background: color-mix(in srgb, var(--muted) 30%, transparent); }
.table-card { padding: 2px 18px 6px; }
td.small, .admin-table td.muted { white-space: nowrap; font-size: 12px; color: var(--muted-foreground); }
.th-right { text-align: right !important; }

.td-biz strong { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.td-biz strong a { color: var(--foreground); }
.td-biz strong a:hover { color: var(--primary); text-decoration: none; }
.td-biz strong .ext { font-size: 12px; color: var(--muted-foreground); }
.td-biz .host { display: block; margin-top: 3px; color: var(--muted-foreground); font-size: 12px; }

/* status chips */
.st {
  --sc: var(--status-idle);
  display: inline-flex; align-items: center; gap: 6px; padding: 2.5px 8px;
  border: 1px solid var(--sc); border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--sc) 15%, var(--card));
  color: color-mix(in srgb, var(--sc) 82%, black);
  font: 600 10.5px var(--font-sans); white-space: nowrap; text-transform: none;
}
.dark .st {
  background: color-mix(in srgb, var(--sc) 22%, transparent);
  color: color-mix(in srgb, var(--sc) 80%, white);
  border-color: color-mix(in srgb, var(--sc) 48%, transparent);
}
.st::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--sc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sc) 18%, transparent); }
.st-live { --sc: var(--status-done); }
.st-pending_dns { --sc: var(--status-queued); }
.st-ssl_failed { --sc: var(--status-blocked); }
.st-offline { --sc: var(--status-idle); }
.st-generated_full { --sc: var(--status-running); }
.admin-table .st { margin: 2px 6px 2px 0; }

.tag-bespoke {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: color-mix(in srgb, var(--status-review) 80%, black);
  background: color-mix(in srgb, var(--status-review) 12%, var(--card));
  border: 1px solid color-mix(in srgb, var(--status-review) 40%, transparent);
  border-radius: var(--radius-sm); padding: 2px 7px; line-height: 1.5;
}
.dark .tag-bespoke { color: color-mix(in srgb, var(--status-review) 65%, white); }

/* dns helpers */
.dns-line, .dns-tip {
  display: inline-block; font-family: var(--font-mono); font-size: 11.5px;
  background: var(--secondary); border: 1px solid var(--border); color: var(--secondary-foreground);
  padding: 5px 10px; border-radius: var(--radius-md); user-select: all; white-space: nowrap; cursor: copy;
  margin-top: 9px; line-height: 1.5;
}
.dns-tip { white-space: normal; max-width: 300px; }
.dns-line:hover, .dns-tip:hover { border-color: var(--ring); }
.card .vis-table td code { font-size: 12.5px; }

/* actions */
.host-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.host-actions form { display: inline-flex; margin: 0; }
.sites-table .host-actions { justify-content: flex-end; }
.sites-table td.host-actions { white-space: nowrap; }

/* delete confirm */
.confirm-inline { position: relative; }
.confirm-inline summary {
  list-style: none; cursor: pointer; font: 600 12.5px var(--font-sans); color: var(--destructive);
  padding: 6px 10px; border-radius: var(--radius-md); border: 1px solid transparent; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.confirm-inline summary::-webkit-details-marker { display: none; }
.confirm-inline summary:hover, .confirm-inline[open] summary {
  background: color-mix(in srgb, var(--destructive) 8%, var(--card));
  border-color: color-mix(in srgb, var(--destructive) 30%, transparent);
}
.confirm-inline form {
  display: flex; gap: 8px; align-items: center; margin-top: 8px; padding: 10px;
  background: color-mix(in srgb, var(--destructive) 5%, var(--card));
  border: 1px solid color-mix(in srgb, var(--destructive) 25%, transparent); border-radius: var(--radius);
}
.confirm-inline input[type=text] {
  width: 170px; height: 32px; padding: 0 10px; font-family: var(--font-mono); font-size: 12.5px;
  border: 1px solid color-mix(in srgb, var(--destructive) 30%, transparent); border-radius: var(--radius-sm);
  background: var(--card); color: var(--foreground);
}
.confirm-inline .btn { height: 32px; padding: 0 12px; font-size: 12.5px; background: var(--card); color: var(--destructive); border-color: color-mix(in srgb, var(--destructive) 30%, transparent); }
.confirm-inline .btn:hover { background: color-mix(in srgb, var(--destructive) 10%, var(--card)); }

/* login */
.auth-wrap { min-height: calc(100vh - 52px); display: flex; align-items: center; justify-content: center; padding: 24px; overflow-y: auto; }
.auth-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 34px 36px; width: 100%; max-width: 400px; }
.auth-card h1 { margin: 0 0 4px; font-size: 26px; }
.stack-form { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.stack-form label { font-size: 12px; font-weight: 600; color: var(--muted-foreground); display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.stack-form .btn { margin-top: 18px; }

/* certs */
.cert-soon { color: var(--status-queued) !important; font-weight: 600; }
.cert-expired { color: var(--status-blocked) !important; font-weight: 700; }

/* ================= 5. Mobile ================= */
@media (max-width: 900px) {
  .hq-side { display: none; }
  .hq-search { display: none; }
  .hq-env { display: none; }
  .hq-main { padding: 16px; }
  .hq-crumbs { padding: 10px 16px; }
  .field-row label { min-width: 100%; }
  .field-row .btn { width: 100%; }
  .table-card { overflow-x: auto; }
  .vis-table { min-width: 640px; }
  .hq-user-meta { display: none; }
}
