/* Dashboard shell and shared components. Tool-specific styles live in tools/<id>/static/style.css. */
:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --border: #2a2f3a;
  --text: #e6e8ee;
  --muted: #9aa3b2;
  --accent: #4f8cff;
  --accent-2: #7cc4ff;
  --danger: #ff6b6b;
  --ok: #4cd18a;
  --sidebar-w: 230px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { display: flex; min-height: 100vh; }
a { color: var(--accent-2); }
[hidden] { display: none !important; }

/* ---------- login ---------- */
.login-body { align-items: center; justify-content: center; }
.login-card {
  width: min(380px, 92vw); background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px;
}
.login-card h1 { margin: 4px 0 8px; font-size: 22px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 10px 12px; font-size: 15px;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.error { background: rgba(255,107,107,.12); color: var(--danger); border: 1px solid rgba(255,107,107,.35); padding: 8px 10px; border-radius: 8px; font-size: 13px; }

/* ---------- shell ---------- */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .2px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: var(--panel); border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh;
}
.tabs { display: flex; flex-direction: column; gap: 4px; }
.tab {
  text-align: left; background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 10px 12px; border-radius: 8px; font-size: 14px; cursor: pointer;
}
.tab:hover { background: var(--panel-2); color: var(--text); }
.tab.active { background: rgba(79,140,255,.14); border-color: rgba(79,140,255,.35); color: var(--text); }
.schedule { margin-top: auto; color: var(--muted); font-size: 12.5px; line-height: 1.5; padding: 10px 12px; border: 1px dashed var(--border); border-radius: 8px; }
.schedule b { color: var(--text); }
.sidebar-foot { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; }
.main { flex: 1; min-width: 0; padding: 28px 36px 60px; }

/* ---------- controls ---------- */
.btn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 14px; font-size: 14px; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.select, .input { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.select { max-width: 260px; }
.input { min-width: 240px; }
.input:focus { outline: none; border-color: var(--accent); }
.hint { color: var(--muted); font-size: 12.5px; margin: 0; }
.hint code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }

/* ---------- tool toolbar / run bar / status ---------- */
.toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar h1 { margin: 0 0 6px; font-size: 24px; }
.toolbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.meta { color: var(--muted); font-size: 13px; }
.meta b { color: var(--text); font-weight: 600; }
.runbar {
  display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 18px;
}
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.field.check .checkline { display: flex; align-items: center; gap: 6px; padding: 9px 0; font-size: 13px; color: var(--text); }
.estimate { flex: 1; min-width: 260px; font-size: 13px; color: var(--muted); line-height: 1.5; padding-bottom: 6px; }
.estimate b { color: var(--text); }
.estimate .sep { margin: 0 10px; color: var(--border); }
.estimate .basis { display: block; font-size: 11.5px; opacity: .75; }
.runbar-actions { display: flex; gap: 8px; margin-left: auto; }
.daily { flex-basis: 100%; display: flex; align-items: center; gap: 12px; font-size: 12.5px; color: var(--muted); border-top: 1px dashed var(--border); padding-top: 8px; margin-top: 2px; }
.daily b { color: var(--text); }
.status { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 18px; }
.status-head { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.status.done .spinner { display: none; }
.status.failed { border-color: rgba(255,107,107,.5); }
.spinner { width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.log { margin: 10px 0 0; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-size: 12px; max-height: 260px; overflow: auto; color: var(--muted); white-space: pre-wrap; }

/* ---------- tables in markdown-rendered content ---------- */
.report table { border-collapse: collapse; width: 100%; font-size: 13.5px; margin: 8px 0 12px; }
.report th, .report td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.report th { background: var(--panel-2); color: var(--muted); font-weight: 600; }
.report tr:nth-child(even) td { background: rgba(255,255,255,.015); }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal.wide { width: min(860px, 100%); }
.modal .contract { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; font-size: 12px; max-height: 160px; overflow: auto; }
.modal { width: min(520px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 22px 24px; display: flex; flex-direction: column; gap: 10px; }
.modal h2 { margin: 0; font-size: 18px; }
.modal textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; resize: vertical;
}
.modal textarea:focus { outline: none; border-color: var(--accent); }
.modal-foot { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.modal-foot .btn { margin-left: auto; }
.modal-foot .btn + .btn { margin-left: 0; }
.error-inline { color: var(--danger); font-size: 12.5px; }

@media (max-width: 760px) {
  body { flex-direction: column; }
  .sidebar { width: auto; flex: none; height: auto; position: static; flex-direction: row; align-items: center; }
  .tabs { flex-direction: row; }
  .sidebar-foot { margin-top: 0; margin-left: auto; }
  .main { padding: 18px; }
}
