/* ─── Design system ─────────────────────────────────────────────────────────── */
:root {
  --bg:          #0a0a0a;
  --surface:     #141414;
  --surface-hi:  #1e1e1e;
  --surface-top: #252525;
  --border:      #2a2a2a;
  --border-hi:   #383838;
  --text:        #e8e8e8;
  --muted:       #888;
  --dim:         #555;
  --accent:      #c8ff00;
  --accent-dim:  #8aad00;
  --danger:      #ff5555;
  --good:        #50fa7b;
  --warn:        #f1fa8c;
  --info:        #8be9fd;
  --star-on:     #f0b429;
  --star-off:    #333;
  --radius:      6px;
  --mono:        'SF Mono', 'Fira Code', 'Consolas', monospace;
}

/* ─── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; font-size: 14px; }
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; font-family: var(--mono); }

/* ─── Splash ─────────────────────────────────────────────────────────────────── */
.splash {
  display: flex; align-items: center; justify-content: center;
  height: 100vh;
  font-size: 1.4rem; letter-spacing: 0.2em; color: var(--dim);
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: .3; } 50% { opacity: 1; } }

/* ─── Layout ─────────────────────────────────────────────────────────────────── */
#app { min-height: 100vh; display: flex; flex-direction: column; }

.header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.25rem;
  height: 44px;
  background: rgba(10,10,10,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand {
  font-size: .95rem; font-weight: 700; letter-spacing: 0.1em;
  color: var(--accent); flex-shrink: 0;
}
.live-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--good); flex-shrink: 0;
  box-shadow: 0 0 6px var(--good);
  animation: blink 2s ease-in-out infinite;
}
.live-dot.off { background: var(--dim); box-shadow: none; animation: none; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

.nav { display: flex; gap: 0; margin-left: 0.5rem; }
.nav-btn {
  background: none; border: none; color: var(--dim);
  font-size: .8rem; letter-spacing: 0.08em; padding: 0.25rem 0.75rem;
  border-bottom: 2px solid transparent; transition: color .15s;
}
.nav-btn:hover { color: var(--text); }
.nav-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.header-right { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.user-email { font-size: .72rem; color: var(--dim); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-ghost {
  background: none; border: 1px solid var(--border); color: var(--muted);
  font-size: .72rem; padding: 0.2rem 0.6rem; border-radius: var(--radius);
  transition: border-color .15s, color .15s;
}
.btn-ghost:hover { border-color: var(--border-hi); color: var(--text); }

.main { flex: 1; max-width: 860px; width: 100%; margin: 0 auto; padding: 1.5rem 1.25rem; }

/* ─── Section headers ────────────────────────────────────────────────────────── */
.section-head {
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: 1rem;
}
.section-title { font-size: .78rem; letter-spacing: 0.12em; color: var(--muted); text-transform: uppercase; }
.section-meta { font-size: .72rem; color: var(--dim); margin-left: auto; }
.btn-icon {
  background: none; border: none; color: var(--dim); font-size: .8rem;
  padding: 0.15rem 0.35rem; transition: color .15s;
}
.btn-icon:hover { color: var(--text); }

/* ─── Cards ──────────────────────────────────────────────────────────────────── */
.card-list { display: flex; flex-direction: column; gap: .6rem; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  transition: border-color .15s;
}
.card:hover { border-color: var(--border-hi); }
.card.rated { border-left: 3px solid var(--accent-dim); }
.card.rated-bad { border-left: 3px solid var(--danger); }

.card-top { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.badge {
  font-size: .65rem; letter-spacing: .08em; text-transform: uppercase;
  padding: .15rem .4rem; border-radius: 3px;
}
.badge-analysis { background: #1a1a1a; color: var(--dim); border: 1px solid var(--border); }
.badge-draft    { background: rgba(80,250,123,.08); color: var(--good); border: 1px solid rgba(80,250,123,.2); }
.badge-attention { background: rgba(255,85,85,.08); color: var(--danger); border: 1px solid rgba(255,85,85,.2); }
.badge-attention2 { background: rgba(241,250,140,.08); color: var(--warn); border: 1px solid rgba(241,250,140,.2); }

.card-time { font-size: .72rem; color: var(--dim); margin-left: auto; }
.card-goal { font-size: .88rem; color: var(--text); line-height: 1.4; margin-bottom: .5rem; }
.card-path { font-size: .68rem; color: var(--dim); margin-bottom: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.stars { display: flex; gap: .15rem; align-items: center; }
.star {
  background: none; border: none; font-size: 1rem;
  color: var(--star-off); transition: color .1s, transform .1s;
  padding: 0; line-height: 1;
}
.star.on { color: var(--star-on); }
.star:hover { transform: scale(1.2); }
.stars-label { font-size: .68rem; color: var(--dim); margin-left: .4rem; }
.no-rate { font-size: .68rem; color: var(--dim); font-style: italic; }

/* ─── Trust view ─────────────────────────────────────────────────────────────── */
.trust-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
@media (max-width: 600px) { .trust-grid { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
}
.stat-label { font-size: .68rem; color: var(--dim); letter-spacing: .1em; text-transform: uppercase; margin-bottom: .5rem; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--accent); line-height: 1; }
.stat-sub { font-size: .75rem; color: var(--muted); margin-top: .3rem; }

.progress-bar {
  width: 100%; height: 4px; background: var(--surface-hi);
  border-radius: 2px; overflow: hidden; margin: .75rem 0;
}
.progress-fill {
  height: 100%; background: var(--accent); border-radius: 2px;
  transition: width .4s ease;
}

.btn-primary {
  background: var(--accent); color: #000; border: none;
  font-family: var(--mono); font-size: .8rem; font-weight: 700;
  padding: .5rem 1.2rem; border-radius: var(--radius);
  transition: background .15s, transform .1s;
}
.btn-primary:hover { background: var(--accent-dim); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { background: var(--border); color: var(--dim); cursor: not-allowed; }

/* ─── Tools table ────────────────────────────────────────────────────────────── */
.tools-table { width: 100%; border-collapse: collapse; font-size: .78rem; }
.tools-table th { text-align: left; color: var(--dim); font-weight: 400; padding: .4rem .6rem; border-bottom: 1px solid var(--border); }
.tools-table td { padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.tools-table tr:last-child td { border-bottom: none; }
.tool-name { color: var(--info); }
.tool-lvl { text-align: center; color: var(--muted); }
.tool-status-ok  { color: var(--good); }
.tool-status-off { color: var(--dim); }
.tool-desc { color: var(--muted); font-size: .72rem; }

/* ─── Log view ───────────────────────────────────────────────────────────────── */
.tab-row { display: flex; gap: 0; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.tab-btn {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--dim); font-size: .78rem; letter-spacing: .08em;
  padding: .4rem .9rem; margin-bottom: -1px; transition: color .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.log-list { display: flex; flex-direction: column; gap: .4rem; }
.log-row {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .55rem .75rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: .75rem;
}
.log-time { color: var(--dim); white-space: nowrap; flex-shrink: 0; width: 80px; }
.log-icon { flex-shrink: 0; width: 14px; text-align: center; }
.log-name { color: var(--info); width: 100px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-input { color: var(--muted); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-meta { color: var(--dim); flex-shrink: 0; text-align: right; white-space: nowrap; }
.log-ok  { color: var(--good); }
.log-err { color: var(--danger); }

.commit-row {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .65rem .75rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: .75rem;
}
.commit-hash { color: var(--warn); font-family: var(--mono); flex-shrink: 0; width: 60px; }
.commit-branch { color: var(--accent-dim); flex-shrink: 0; max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.commit-msg { color: var(--text); flex: 1; }
.commit-time { color: var(--dim); flex-shrink: 0; }

/* ─── Login ──────────────────────────────────────────────────────────────────── */
.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 1rem;
}
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2rem; width: 100%; max-width: 340px;
}
.login-title { font-size: 1.1rem; color: var(--accent); letter-spacing: .12em; margin-bottom: .25rem; }
.login-sub { font-size: .72rem; color: var(--dim); margin-bottom: 1.5rem; }
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; }
.field label { font-size: .72rem; color: var(--muted); letter-spacing: .08em; }
.field input {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  font-family: var(--mono); font-size: .85rem;
  padding: .5rem .7rem; border-radius: var(--radius);
  transition: border-color .15s;
}
.field input:focus { outline: none; border-color: var(--accent); }

/* ─── Toast ──────────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: var(--surface-top); border: 1px solid var(--border-hi);
  color: var(--text); font-size: .78rem; padding: .5rem 1rem;
  border-radius: var(--radius); z-index: 999;
  opacity: 0; transition: opacity .2s;
  pointer-events: none; white-space: nowrap;
}
#toast.show { opacity: 1; }
#toast.err { border-color: var(--danger); color: var(--danger); }

/* ─── Misc ───────────────────────────────────────────────────────────────────── */
.spinner { color: var(--dim); font-size: .8rem; padding: 2rem; text-align: center; }
.empty { color: var(--dim); font-size: .8rem; padding: 2rem; text-align: center; }
.load-more {
  display: block; width: 100%; margin-top: .75rem;
  background: none; border: 1px solid var(--border); color: var(--muted);
  font-family: var(--mono); font-size: .75rem; padding: .45rem;
  border-radius: var(--radius); transition: border-color .15s, color .15s;
}
.load-more:hover { border-color: var(--border-hi); color: var(--text); }
