:root {
  --theme-primary: #7c818a;
  --color-navy: #7c818a;
  --color-accent: #d81818;
  --color-corner: #d81818;
  --color-corner-neutral: #1f2937;
  --color-bg: #f3f4f6;
  --color-surface: #ffffff;
  --color-border: #e5e7eb;
  --color-text: #1f2937;
  --color-text-muted: #6b7280;
  --color-sidebar-active: #db4040;
  --color-sidebar-hover: rgba(255, 255, 255, 0.08);
  --ui-primary-bg: #10b981;
  --ui-primary-bg-hover: #059669;
  --ui-create-project-bg: #2563eb;
  --ui-create-project-bg-hover: #1d4ed8;
  --ui-input-height: 44px;
  --ui-border-radius: 12px;
  --font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sidebar-width: 272px;
  --sidebar-width-collapsed: 76px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-family);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }

.auth {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #f8fafc;
}
.auth-card { width: min(420px, 100%); }
.corner-frame {
  position: relative;
  background: #fff;
  border: 1px solid #f1f5f9;
  border-radius: 16px;
  padding: 32px;
}
.corner { position: absolute; width: 20px; height: 20px; pointer-events: none; }
.corner-tl { top: 10px; left: 10px; border-top: 3px solid var(--color-corner-neutral); border-left: 3px solid var(--color-corner-neutral); }
.corner-br { right: 10px; bottom: 10px; border-right: 3px solid var(--color-corner-neutral); border-bottom: 3px solid var(--color-corner-neutral); }
.corner-tr { top: 10px; right: 10px; border-top: 3px solid var(--color-corner); border-right: 3px solid var(--color-corner); }
.corner-bl { left: 10px; bottom: 10px; border-bottom: 3px solid var(--color-corner); border-left: 3px solid var(--color-corner); }
.auth-mark {
  position: relative;
  width: 72px; height: 72px;
  margin: 0 auto 12px;
  display: grid; place-items: center;
}
.lk-mark__tl, .lk-mark__br { position: absolute; width: 14px; height: 14px; }
.lk-mark__tl { top: 2px; left: 2px; border-top: 1.5px solid #0f172a; border-left: 1.5px solid #0f172a; }
.lk-mark__br { right: 2px; bottom: 2px; border-right: 1.5px solid var(--color-accent); border-bottom: 1.5px solid var(--color-accent); }
.auth-logo {
  width: 56px; height: 56px; border-radius: 50%;
  background: #0f172a; color: #fff;
  display: grid; place-items: center;
  font-weight: 800; letter-spacing: -0.04em;
}
.auth-brand {
  margin: 0 0 16px;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #94a3b8;
}
.auth-card h1 { margin: 0; font-size: 28px; font-weight: 900; letter-spacing: -0.03em; text-align: center; }
.auth-lead { margin: 8px 0 24px; text-align: center; color: #64748b; }
.auth-card label { display: block; margin: 0 0 14px; font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: #64748b; }
.auth-card input, .field input, .field select {
  width: 100%;
  height: var(--ui-input-height);
  margin-top: 6px;
  padding: 0 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--ui-border-radius);
  background: #f8fafc;
}
.auth-card input:focus, .field input:focus, .field select:focus {
  outline: none;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(124, 129, 138, 0.12);
}
.auth-error { min-height: 18px; margin: 0 0 12px; color: var(--color-accent); font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 40px; padding: 0 16px; border-radius: var(--ui-border-radius);
  border: 1px solid transparent; cursor: pointer; font-weight: 600; background: #fff;
}
.btn:disabled { opacity: 0.45; cursor: default; }
.btn--primary { background: var(--ui-primary-bg); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--ui-primary-bg-hover); }
.btn--create { background: var(--ui-create-project-bg); color: #fff; }
.btn--create:hover:not(:disabled) { background: var(--ui-create-project-bg-hover); }
.btn--outline { border-color: var(--color-border); color: var(--color-text); }
.btn--outline:hover { background: #f9fafb; }
.btn--danger { background: #fff; color: var(--color-accent); border-color: #fecaca; }
.auth-card .btn--primary { width: 100%; height: 48px; }

.wrapper { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar.is-collapsed { width: var(--sidebar-width-collapsed); }
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 14px; flex-shrink: 0;
}
.sidebar-toggle {
  width: 36px; height: 36px; border: 0; border-radius: 8px;
  background: var(--color-sidebar-hover); color: #fff; cursor: pointer;
}
.sidebar-title {
  font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase;
  white-space: nowrap;
}
.sidebar.is-collapsed .sidebar-title,
.sidebar.is-collapsed .nav-group,
.sidebar.is-collapsed .sidebar-foot,
.sidebar.is-collapsed .sidebar-nav a { display: none; }
.sidebar-nav { flex: 1; overflow: auto; padding: 8px 10px 16px; }
.nav-group {
  margin: 16px 10px 6px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: rgba(255,255,255,0.55);
}
.sidebar-nav a {
  display: block; padding: 9px 12px; border-radius: 8px;
  color: #fff; text-decoration: none;
}
.sidebar-nav a:hover { background: var(--color-sidebar-hover); }
.sidebar-nav a.is-active { background: var(--color-sidebar-active); }
.sidebar-foot { padding: 12px 16px 16px; font-size: 11px; color: rgba(255,255,255,0.65); }

.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--color-bg); }
.topbar {
  height: 56px; background: #fff; border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; position: sticky; top: 0; z-index: 2;
}
.topbar-title { display: flex; align-items: center; gap: 8px; }
.topbar h1 {
  margin: 0; font-size: 18px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
}
.hint {
  border: 0; background: none; color: var(--color-text-muted); cursor: help; font-weight: 700;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.who { color: var(--color-text-muted); font-size: 13px; }
.view { flex: 1; overflow: auto; padding: 20px; }
.view.view--hall { padding: 0; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-head .meta-row { flex: 1 1 100%; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.search { position: relative; flex: 1; max-width: 360px; }
.search input { width: 100%; height: 40px; padding: 0 32px 0 12px; border: 1px solid var(--color-border); border-radius: 12px; background: #fff; }
.search .clear {
  position: absolute; right: 6px; top: 6px; width: 28px; height: 28px;
  border: 0; background: none; color: #94a3b8; cursor: pointer;
}
.summary { color: var(--color-text-muted); font-size: 13px; }

.card {
  background: #fff; border: 1px solid var(--color-border); border-radius: var(--ui-border-radius);
}
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--color-text-muted); font-weight: 700; padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--color-border); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: #f9fafb; }
.table a { color: inherit; }

.meta-row { display: flex; align-items: center; gap: 6px; color: #64748b; font-size: 12px; }
.dot-status { display: inline-flex; align-items: center; gap: 4px; font-weight: 500; font-size: 11px; }
.dot-status svg { width: 6px; height: 6px; fill: currentColor; }
.dot-status--ok { color: #059669; }
.dot-status--idle { color: #64748b; }
.dot-status--wait { color: #d97706; }
.dot-status--err { color: #e11d48; }
.meta-sep { color: #cbd5e1; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; height: 32px; padding: 0 12px;
  border: 1px solid var(--color-border); border-radius: 999px;
  background: #fff; color: var(--color-text); text-decoration: none; font-size: 13px;
}
.chip.is-on { border-color: #fecaca; color: var(--color-accent); background: #fef2f2; }
.sparks { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 8px 0; }
.spark-cell { background: #f9fafb; border-radius: 8px; padding: 8px 10px; }
.spark-label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-text-muted); margin-bottom: 4px; }
.spark { width: 100%; height: 32px; display: block; }
.spark-empty { font-size: 12px; color: #94a3b8; }
.table tr.expand { cursor: default; }
.table tr.expand:hover { background: #fff; }

.later {
  background: #fff; border: 1px solid var(--color-border); border-radius: 12px;
  padding: 28px; color: var(--color-text-muted);
}

.card-head { padding: 20px 20px 0; }
.card-head h2 { margin: 0 0 8px; font-size: 22px; font-weight: 800; }
.tabs { display: flex; gap: 18px; padding: 0 20px; border-bottom: 1px solid var(--color-border); }
.tabs button {
  border: 0; background: none; padding: 12px 0; cursor: pointer; color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
}
.tabs button.is-on { color: var(--color-accent); border-bottom-color: var(--color-accent); font-weight: 700; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; color: var(--color-text-muted); font-size: 12px; }
.field--wide { grid-column: 1 / -1; }
.readonly { font-size: 22px; font-weight: 800; color: var(--color-text); }
.form-actions { grid-column: 1 / -1; display: flex; gap: 10px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.35);
  display: grid; place-items: center; padding: 20px; z-index: 20;
}
.modal {
  width: min(560px, 100%);
  background: #fff; border-radius: 12px; border: 1px solid var(--color-border);
}
.modal__header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--color-border); }
.modal__header h3 { margin: 0; font-size: 16px; font-weight: 800; }
.modal__body { padding: 20px; display: grid; gap: 12px; }
.modal textarea {
  width: 100%; min-height: 180px; padding: 12px;
  border: 1px solid var(--color-border); border-radius: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
}
.secret-warn { color: #b45309; font-size: 13px; }
.field-hint { margin: 0; color: var(--color-text-muted); font-size: 13px; line-height: 1.45; }
.field--check {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--color-text);
}
.secret-box {
  margin: 0 20px 16px;
  padding: 14px 16px;
  border: 1px solid #fde68a;
  background: #fffbeb;
  border-radius: 12px;
}
.secret-box b { display: block; margin-bottom: 8px; }
.secret-box code {
  display: block;
  margin: 8px 0;
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.secret-box__acts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.ini-pre {
  margin: 8px 0 0;
  padding: 12px;
  overflow: auto;
  max-height: 240px;
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  white-space: pre-wrap;
}
.ini-row td { padding-top: 0; border-top: 0; }
.table .acts { display: flex; flex-wrap: wrap; gap: 6px; }
.key-issue-place { margin: 0; font-weight: 700; }
.keys-how { padding: 0 20px 20px; display: grid; gap: 10px; color: var(--color-text); }
.keys-how p { margin: 0; line-height: 1.45; }
.keys-how code { font-size: 12px; }

.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.health-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--ui-border-radius);
  padding: 16px 20px;
}
.health-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.health-card h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  color: #1f2937;
}
.health-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
}
.health-row:last-child { border-bottom: 0; }
.health-val { display: inline-flex; align-items: center; gap: 8px; color: #334155; }
.health-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.health-chart {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--ui-border-radius);
  padding: 12px 14px;
}
.health-svg { width: 100%; height: 72px; display: block; }
a.health-card { text-decoration: none; color: inherit; display: block; }
.inbox-unread { background: #eff6ff; }
.inbox-unread td:first-child .dot-status { color: #2563eb; }
#inbox-link { text-decoration: none; }
