/* ── Reset ─────────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* ── Base ──────────────────────────────────────────────────── */
:root {
  --bg:       #0f1117;
  --surface:  #1a1d27;
  --surface2: #222635;
  --border:   #2e3347;
  --accent:   #3ecf8e;
  --blue:     #4f8ef7;
  --yellow:   #f5c542;
  --red:      #e05c5c;
  --text:     #dde1f0;
  --muted:    #7c839e;
  --heading:  #ffffff;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ────────────────────────────────────────────────── */
body > header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  width: 100%;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
body > header nav { display: flex; gap: 2rem; }
body > header a {
  color: var(--muted);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
  font-weight: 600;
  transition: color 0.15s;
}
body > header a:hover { color: var(--accent); }

/* ── Footer ────────────────────────────────────────────────── */
footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  width: 100%;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  color: var(--muted);
  flex-shrink: 0;
}

/* ── Main ──────────────────────────────────────────────────── */
main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── index.php ─────────────────────────────────────────────── */
.container {
  text-align: center;
  padding: 2rem;
}
.title {
  font-size: 3rem;
  font-weight: bold;
  letter-spacing: 0.2em;
  color: var(--heading);
  text-transform: uppercase;
}
.subtitle {
  font-size: 1rem;
  color: var(--muted);
  margin-top: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.divider {
  width: 60px;
  height: 2px;
  background: var(--border);
  margin: 2rem auto;
}
.welcome {
  font-size: 1rem;
  color: var(--muted);
  line-height: 1.8;
}

/* ── links.php ─────────────────────────────────────────────── */
.page-title {
  font-size: 1.1rem;
  letter-spacing: 0.2em;
  color: var(--heading);
  text-transform: uppercase;
  margin-bottom: 2rem;
}
.links-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.links-list a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  transition: color 0.15s;
}
.links-list a:hover { color: var(--accent); }

/* ── login.php ─────────────────────────────────────────────── */
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2.5rem 3rem;
  width: 100%;
  max-width: 360px;
  border-radius: 10px;
}
.login-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text);
  margin-bottom: 2rem;
  text-align: center;
}
label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
input[type="password"],
input[type="text"],
input[type="number"],
select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.6rem 0.75rem;
  outline: none;
  border-radius: 6px;
}
input[type="password"] { width: 100%; margin-bottom: 1.5rem; }
input[type="password"]:focus,
input[type="text"]:focus,
input[type="number"]:focus,
select:focus { border-color: var(--accent); }
button {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  padding: 0.65rem;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
}
button:hover { border-color: var(--accent); color: var(--accent); }
.error {
  font-size: 0.75rem;
  color: var(--red);
  text-align: center;
  margin-top: 1rem;
}

/* ── components.php / usbhub.php ────────────────────────────── */
.section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 2.5rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.section-nav a {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-decoration: none;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--border);
  background: var(--surface2);
  border-radius: 4px;
  transition: color 0.15s, border-color 0.15s;
}
.section-nav a:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.section-nav a.active {
  color: var(--accent);
  border-color: rgba(62,207,142,0.4);
  background: rgba(62,207,142,0.08);
}

.card-notes {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.7;
}
.card-notes p { margin-bottom: 0.5rem; }
.card-notes ul { padding-left: 1.1rem; margin-top: 0.25rem; }
.card-notes li { margin-bottom: 0.2rem; color: var(--muted); }
.card-notes .label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 0.35rem;
  margin-top: 0.75rem;
}
.card-notes .label:first-child { margin-top: 0; }

main.components-main {
  display: block;
  flex: 1;
  padding: 2.5rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.section-heading {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--accent);
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1.5rem;
  border-radius: 10px;
}
.card-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text);
  margin-bottom: 1.25rem;
  font-weight: 600;
}

.schematic-img {
  display: block;
  margin: 0 auto 1.25rem;
  max-width: 100%;
  border: 1px solid var(--border);
  background: #FEFEF9;
  border-radius: 6px;
}

.schematic {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 1rem;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--muted);
  margin-bottom: 1.25rem;
  overflow-x: auto;
  white-space: pre;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.field-row label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  width: 5rem;
  flex-shrink: 0;
  margin-bottom: 0;
}
.field-row input,
.field-row select {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
  margin-bottom: 0;
  border-radius: 4px;
}
.field-row .unit {
  font-size: 0.7rem;
  color: var(--muted);
  width: 2rem;
  text-align: left;
}

.mode-select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.35rem 0.5rem;
  margin-bottom: 1rem;
  outline: none;
  border-radius: 4px;
}

.calc-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  padding: 0.5rem 1.2rem;
  cursor: pointer;
  margin-top: 0.5rem;
  border-radius: 4px;
  transition: all 0.15s;
}
.calc-btn:hover { border-color: var(--accent); color: var(--accent); }

.result {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface2);
  border-left: 2px solid var(--border);
  font-size: 0.85rem;
  color: var(--text);
  min-height: 2.5rem;
  border-radius: 0 4px 4px 0;
}
.result .result-val { color: var(--accent); font-size: 1rem; }
.result .result-err { color: var(--red); }

/* usbhub.php specific */
.bom-table { width: 100%; border-collapse: collapse; font-size: 0.75rem; margin-top: 0.75rem; }
.bom-table th {
  text-align: left; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.65rem;
  padding: 0 0.5rem 0.4rem 0; border-bottom: 1px solid var(--border);
}
.bom-table td { padding: 0.35rem 0.5rem 0.35rem 0; color: var(--muted); border-bottom: 1px solid var(--border); }
.bom-table td:first-child { color: var(--text); white-space: nowrap; }
.bom-table td:nth-child(2) { color: var(--text); }
.bom-table td:last-child { color: var(--muted); font-size: 0.7rem; }
.warn { color: var(--yellow); font-size: 0.75rem; }
.full-card { grid-column: 1 / -1; }

/* AI section */
.ai-section { margin-top: 3rem; }

.ai-locked {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2rem;
  text-align: center;
  border-radius: 10px;
}
.ai-locked p {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
  letter-spacing: 0.05em;
}
.ai-locked a {
  display: inline-block;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  padding: 0.5rem 1.5rem;
  border-radius: 4px;
  transition: all 0.15s;
}
.ai-locked a:hover { border-color: var(--accent); color: var(--accent); }

.ai-toolbar {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  align-items: flex-end;
}
.ai-toolbar input[type="text"] {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.6rem 0.75rem;
  outline: none;
  margin-bottom: 0;
  border-radius: 6px;
}
.ai-toolbar input[type="text"]:focus { border-color: var(--accent); }
.ai-toolbar input[type="text"]::placeholder { color: var(--muted); }
.ai-toolbar button {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  padding: 0.6rem 1.5rem;
  cursor: pointer;
  white-space: nowrap;
  border-radius: 6px;
  transition: all 0.15s;
}
.ai-toolbar button:hover { border-color: var(--accent); color: var(--accent); }
.ai-toolbar button:disabled { opacity: 0.4; cursor: default; }

.ai-topbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.5rem;
}
.logout-link {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-decoration: none;
}
.logout-link:hover { color: var(--accent); }

#ai-status {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 1rem;
  min-height: 1.2rem;
}

/* AI result cards */
.ai-result-header { margin-bottom: 1.5rem; }
.ai-result-header h2 {
  font-size: 1rem;
  color: var(--text);
  letter-spacing: 0.1em;
  margin-bottom: 0.25rem;
}
.ai-desc {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.ai-meta-tags {
  display: flex;
  gap: 1.5rem;
  font-size: 0.7rem;
  color: var(--muted);
}
.ai-meta-tags span b { color: var(--text); }

.ai-circuit-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border-radius: 10px;
}
.ai-circuit-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text);
  margin-bottom: 1rem;
  font-weight: 600;
}
.ai-schematic {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 1rem;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--muted);
  margin-bottom: 1.25rem;
  overflow-x: auto;
  white-space: pre;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.ai-bom table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  margin-bottom: 1.25rem;
}
.ai-bom th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.65rem;
  padding: 0 0.5rem 0.4rem 0;
  border-bottom: 1px solid var(--border);
}
.ai-bom td {
  padding: 0.35rem 0.5rem 0.35rem 0;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.ai-bom td:first-child { color: var(--text); }

.ai-steps ol { padding-left: 1.25rem; }
.ai-steps li {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 0.3rem;
}

.ai-notes {
  margin-top: 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--surface2);
  border-left: 2px solid var(--border);
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.6;
  border-radius: 0 4px 4px 0;
}

.ai-pin-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  margin-bottom: 1.5rem;
}
.ai-pin-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.65rem;
  padding: 0 0.75rem 0.4rem 0;
  border-bottom: 1px solid var(--border);
}
.ai-pin-table td {
  padding: 0.3rem 0.75rem 0.3rem 0;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.ai-pin-table td:first-child { color: var(--muted); width: 3rem; }
.ai-pin-table td:nth-child(2) { color: var(--text); width: 8rem; }
