/* AI7 Matrix Lab — control panel styles.
   Extracted from the prototype's design system. Preview-only devices (the demo role toggle,
   the "Viewing as" org switcher, the .view show/hide machinery) are deliberately absent —
   those exist so one static file could show every screen, and rules 37 and the login note in
   CLAUDE.md both say not to carry them into the real app.

   Mobile-first: every screen must work at 375px before it's done (rule 5). */

:root {
  --bg-base: #0B1220;
  --bg-panel: #101B2D;
  --bg-panel-raised: #152238;
  --line: #233250;
  --line-bright: #33496e;
  --amber: #E8A33D;
  --cyan: #4FD1C5;
  --red: #E8654F;
  --text: #E7EDF5;
  --text-muted: #8296B5;
  --text-dim: #546b8a;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
button:not(:disabled), select, [role="button"] { cursor: pointer; }
html, body { height: 100%; }

body {
  background:
    linear-gradient(var(--line) 1px, transparent 1px) 0 0/32px 32px,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0/32px 32px,
    var(--bg-base);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% -10%, rgba(79, 209, 197, .08), transparent 45%),
    radial-gradient(ellipse at 90% 110%, rgba(232, 163, 61, .06), transparent 50%);
  pointer-events: none;
}

/* ---------- brand mark ---------- */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: 13px;
  color: var(--text);
}
.brand .node {
  width: 9px;
  height: 9px;
  border: 1.5px solid var(--cyan);
  transform: rotate(45deg);
  box-shadow: 0 0 8px rgba(79, 209, 197, .6);
}
.brand b { font-weight: 700; }
.brand span { color: var(--text-dim); font-weight: 400; }

/* ---------- login ---------- */
.login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}
.login-wrap {
  width: 100%;
  max-width: 420px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
}
.login-schematic {
  padding: 30px 22px;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at 30% 20%, rgba(79, 209, 197, .08), transparent 60%),
    var(--bg-panel-raised);
}
.login-schematic h1 {
  font-family: var(--mono);
  font-size: 21px;
  line-height: 1.35;
  font-weight: 600;
  margin-top: 22px;
  letter-spacing: -.01em;
}
.login-schematic h1 em { font-style: normal; color: var(--cyan); }
.login-form { padding: 28px 22px; display: flex; flex-direction: column; }
.login-form .eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--amber);
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.login-form h2 { font-size: 21px; font-weight: 600; margin-bottom: 28px; }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-family: var(--mono);
}
.field input {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--text);
  font-size: 16px; /* 16px avoids iOS zoom-on-focus */
  font-family: var(--sans);
}
.field input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(79, 209, 197, .12);
}

.btn-primary {
  margin-top: 8px;
  background: var(--cyan);
  color: #062521;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .01em;
  width: 100%;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .55; cursor: default; }

.btn-ghost {
  background: var(--bg-panel-raised);
  border: 1px solid var(--line-bright);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
}

.form-error {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--red);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--red);
  background: rgba(232, 101, 79, .08);
}
.form-error:empty { display: none; }

/* ---------- app shell ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}
.sidebar {
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  background: rgba(11, 18, 32, .92);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.sidebar nav {
  display: flex;
  flex-direction: row;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.sidebar nav::-webkit-scrollbar { display: none; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: 7px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 11.5px;
  white-space: nowrap;
}
.sidebar nav a.active {
  background: var(--bg-panel-raised);
  color: var(--text);
  border: 1px solid var(--line);
}
.sidebar nav a[hidden] { display: none; }
.sidebar .foot { display: none; font-family: var(--mono); font-size: 11px; color: var(--text-dim); }
.logout-link { color: var(--red) !important; }

.main { padding: 18px 16px 60px; overflow-x: hidden; }
.main header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 26px;
}
.main h1 { font-size: 22px; font-weight: 700; }
.main .sub { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
}
.panel h3 { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.panel .desc { font-size: 12.5px; color: var(--text-muted); margin-bottom: 18px; }
.panel[hidden] { display: none; }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 0 10px 10px;
  font-weight: 500;
  white-space: nowrap;
}
td { padding: 12px 10px; border-top: 1px solid var(--line); color: var(--text); }
td.muted { color: var(--text-muted); font-size: 12.5px; }
tr:hover td { background: rgba(255, 255, 255, .015); }

.avatar {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--bg-panel-raised);
  border: 1px solid var(--line-bright);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--amber);
  margin-right: 9px;
}
.name-cell { display: flex; align-items: center; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 3px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge.ok {
  background: rgba(79, 209, 197, .12);
  color: var(--cyan);
  border: 1px solid rgba(79, 209, 197, .3);
}
.badge.ok::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--cyan); }
.badge.idle {
  background: rgba(130, 150, 181, .1);
  color: var(--text-muted);
  border: 1px solid var(--line-bright);
}
.badge.idle::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--text-dim); }
.badge.warn { background: rgba(232, 163, 61, .12); color: var(--amber); border: 1px solid rgba(232, 163, 61, .3); }
.badge.bad { background: rgba(232, 101, 79, .12); color: var(--red); border: 1px solid rgba(232, 101, 79, .3); }

/* ---------- forms in panels ---------- */
.inline-form { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.inline-form input,
.inline-form select {
  background: var(--bg-base);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-size: 16px;
  width: 100%;
}

/* ---------- AI progress (never rendered in a client's view — rule 20) ---------- */
.progress-cell { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.progress-track {
  flex: 1;
  height: 6px;
  background: var(--bg-base);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.progress-fill { height: 100%; background: var(--cyan); border-radius: 4px; }
.progress-pct { font-family: var(--mono); font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }
.progress-summary { font-size: 11px; color: var(--text-dim); margin-top: 2px; line-height: 1.4; }

/* ---------- client view ---------- */
.client-shell { max-width: 640px; margin: 0 auto; padding: 32px 20px; min-height: 100vh; position: relative; z-index: 1; }
.client-shell .brand { margin-bottom: 36px; }
.client-project-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 20px;
  margin-bottom: 20px;
}
.client-project-card h2 { font-size: 18px; margin-bottom: 6px; }
.approval-card {
  background: var(--bg-panel);
  border: 1px solid var(--line-bright);
  border-radius: 14px;
  padding: 22px 20px;
  margin-bottom: 16px;
}
.approval-card .milestone { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.approval-artifact-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 20px;
  border: 1px solid var(--line-bright);
  color: var(--text-muted);
  margin: 8px 0 14px;
}
.approval-view-link {
  display: inline-block;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 13px;
  text-decoration: none;
  margin-bottom: 16px;
}
.approval-actions { display: flex; gap: 10px; }
.approval-actions button {
  flex: 1;
  padding: 11px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  border: none;
}
.btn-approve { background: var(--cyan); color: #062521; }
.btn-reject { background: transparent; border: 1px solid var(--red) !important; color: var(--red); }
.empty-note { color: var(--text-muted); font-size: 13px; text-align: center; padding: 24px 0; }

/* ---------- workspace / project picker (rule 27: a list, never one hardcoded workspace) --- */
.project-list { display: flex; flex-direction: column; gap: 10px; }
.project-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
  color: inherit;
}
.project-card:hover { border-color: var(--line-bright); }
.project-card .name { font-size: 14px; font-weight: 700; }
.project-card .meta { font-size: 12px; color: var(--text-muted); font-family: var(--mono); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--bg-panel-raised);
  border: 1px solid var(--line-bright);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 12.5px;
  z-index: 999;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  max-width: 90vw;
  text-align: center;
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--line-bright); border-radius: 10px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- wider screens ---------- */
@media (min-width: 861px) {
  body { background-size: 48px 48px; }

  .login-wrap {
    max-width: 920px;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
  }
  .login-schematic { border-bottom: none; border-right: 1px solid var(--line); padding: 44px 36px; }
  .login-schematic h1 { font-size: 26px; margin-top: 28px; }
  .login-form { padding: 44px 40px; }

  .app-shell { grid-template-columns: 220px 1fr; }
  .sidebar {
    border-bottom: none;
    border-right: 1px solid var(--line);
    padding: 22px 16px;
    background: rgba(16, 27, 45, .6);
    backdrop-filter: blur(6px);
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    position: static;
  }
  .sidebar .brand { margin-bottom: 32px; padding-left: 2px; }
  .sidebar nav { flex-direction: column; overflow-x: visible; }
  .sidebar nav a { padding: 9px 10px; font-size: 13.5px; }
  .sidebar .foot { display: block; margin-top: auto; }

  .main { padding: 30px 36px; }
  .main header { flex-direction: row; justify-content: space-between; align-items: flex-end; }
  .panel { padding: 22px; }
  .inline-form { flex-direction: row; align-items: center; }
  .inline-form input, .inline-form select { font-size: 13px; width: auto; flex: 1; }
  .client-shell { padding: 48px 24px; }
}
