/* PQI portal — light/dark via data-theme on <html> */

:root,
[data-theme="light"] {
  --bg: #f6f4f0;
  --bg-elevated: #ffffff;
  --bg-sidebar: #1a1612;
  --text: #1a1612;
  --text-muted: #5c5348;
  --text-on-sidebar: #f6f4f0;
  --text-muted-sidebar: #a89f92;
  --border: #e2dcd2;
  --accent: #c43e2b;
  --accent-hover: #a33324;
  --accent-soft: #fde8e4;
  --shadow: 0 8px 30px rgba(26, 22, 18, 0.08);
  --input-bg: #ffffff;
  --success: #2d6a4f;
  --warning: #b45309;
}

[data-theme="dark"] {
  --bg: #12100e;
  --bg-elevated: #1e1b17;
  --bg-sidebar: #0a0908;
  --text: #f6f4f0;
  --text-muted: #a89f92;
  --text-on-sidebar: #f6f4f0;
  --text-muted-sidebar: #7a7268;
  --border: #2e2923;
  --accent: #e85d4a;
  --accent-hover: #f0705e;
  --accent-soft: #3d221c;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --input-bg: #1e1b17;
  --success: #52b788;
  --warning: #fbbf24;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.brand-mark {
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--accent);
  font-size: 1.25rem;
}

.brand-mark--center {
  display: block;
  text-align: center;
  margin-bottom: 1rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-muted-sidebar);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
}

.btn-text:hover {
  color: var(--text-on-sidebar);
  text-decoration: underline;
}

/* Landing */
.landing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2rem;
  max-width: 1100px;
  margin: 0 auto;
}

.landing-hero {
  max-width: 680px;
  margin: 0 auto;
  padding: 4rem 2rem 3rem;
  text-align: center;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 700;
  margin: 0 0 0.75rem;
}

.landing-hero h1 {
  font-size: clamp(2rem, 5vw, 2.75rem);
  line-height: 1.15;
  margin: 0 0 1rem;
}

.lead {
  font-size: 1.15rem;
  color: var(--text-muted);
  margin: 0 0 2rem;
}

.landing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.landing-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem;
}

.feature-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.feature-card h2 {
  font-size: 1.1rem;
  margin: 0 0 0.5rem;
}

.feature-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Auth */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  text-align: center;
}

.auth-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 1.5rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-footer {
  text-align: center;
  margin: 1.25rem 0 0;
  font-size: 0.9rem;
}

/* App shell */
.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  color: var(--text-on-sidebar);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0;
}

.sidebar-brand {
  padding: 0 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-link {
  text-decoration: none;
  display: block;
}

.brand-link .brand-mark {
  color: #f0705e;
  display: block;
}

.brand-sub {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted-sidebar);
  letter-spacing: 0.04em;
  margin-top: 0.15rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem;
  gap: 0.25rem;
}

.sidebar-nav--bottom {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 1rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  color: var(--text-muted-sidebar);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-on-sidebar);
  text-decoration: none;
}

.nav-link.is-active {
  background: rgba(228, 93, 74, 0.2);
  color: #fff;
}

.nav-icon {
  opacity: 0.85;
  width: 1.1rem;
  text-align: center;
}

.sidebar-user {
  padding: 1rem 1.25rem 0;
  font-size: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: 0.5rem;
}

.user-name {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.main {
  flex: 1;
  padding: 2rem 2.5rem;
  overflow-x: auto;
}

.page-header {
  margin-bottom: 1.75rem;
}

.page-header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.75rem;
}

.page-lead {
  margin: 0;
  color: var(--text-muted);
}

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.panel-title {
  margin: 0 0 1rem;
  font-size: 1.05rem;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.num {
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--text-muted);
}

.grade-badge {
  display: inline-block;
  min-width: 2rem;
  text-align: center;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.85rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.status-pill {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: capitalize;
}

.status-pill--success {
  background: rgba(45, 106, 79, 0.15);
  color: var(--success);
}

.status-pill--failed {
  background: rgba(196, 62, 43, 0.15);
  color: var(--accent);
}

.status-pill--running {
  background: rgba(180, 83, 9, 0.15);
  color: var(--warning);
}

.simple-list,
.version-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.simple-list li,
.version-item {
  display: flex;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.version-item.is-active .version-name {
  color: var(--accent);
  font-weight: 600;
}

.empty-state {
  color: var(--text-muted);
  margin: 0;
}

/* Forms */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.label {
  font-size: 0.85rem;
  font-weight: 600;
}

.input,
.select {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 1rem;
  width: 100%;
}

.field-error,
.form-errors {
  color: var(--accent);
  font-size: 0.85rem;
}

.messages {
  margin-bottom: 1rem;
}

.message {
  padding: 0.65rem 1rem;
  border-radius: 8px;
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}

.message--success {
  background: rgba(45, 106, 79, 0.12);
  color: var(--success);
}

.message--warning,
.message--error {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Settings */
.settings-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 2rem;
  align-items: start;
}

.settings-tabs {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.settings-tab {
  text-align: left;
  padding: 0.65rem 1rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
}

.settings-tab:hover {
  background: var(--bg-elevated);
  color: var(--text);
}

.settings-tab.is-active {
  background: var(--bg-elevated);
  color: var(--accent);
  font-weight: 600;
  border: 1px solid var(--border);
}

.settings-panels {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem;
  min-height: 320px;
}

.settings-panel h2 {
  margin: 0 0 0.35rem;
  font-size: 1.25rem;
}

.panel-desc {
  color: var(--text-muted);
  margin: 0 0 1.5rem;
  font-size: 0.95rem;
}

.settings-form {
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.settings-panel[hidden] {
  display: none;
}

.theme-toggle-row {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.theme-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.theme-option {
  padding: 0.55rem 1.25rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
}

.theme-option.is-selected {
  background: var(--accent);
  color: #fff;
}

.hint {
  font-size: 0.85rem;
  margin-top: 1rem;
}

@media (max-width: 768px) {
  .shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0.75rem;
  }

  .sidebar-brand {
    width: 100%;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0.5rem;
  }

  .sidebar-nav--bottom {
    margin-top: 0;
    border-top: none;
  }

  .sidebar-user {
    width: 100%;
  }

  .settings-layout {
    grid-template-columns: 1fr;
  }

  .settings-tabs {
    flex-direction: row;
    flex-wrap: wrap;
  }
}
