/* ==========================================================
   QUALITY OS
   Global stylesheet
   ========================================================== */

:root {
  --primary: #2563eb;
  --success: #16a34a;
  --warning: #ea580c;
  --review: #7c3aed;
  --danger: #dc2626;
  --background: #f5f7fb;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #d1d5db;
}

/* Status badges */
.status-badge {
  display: inline-block;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.status-current { background: #dcfce7; color: #166534; }
.status-draft { background: #ffedd5; color: #9a3412; }
.status-review { background: #ede9fe; color: #5b21b6; }
.status-superseded { background: #e5e7eb; color: #374151; }
.status-retired { background: #fee2e2; color: #991b1b; }
.status-default { background: #f3f4f6; color: #374151; }

/* ---------- Dashboard ---------- */

body {
  font-family: Arial, sans-serif;
  margin: 2rem;
  background: var(--background);
  color: var(--text);
}

h1 {
  margin-bottom: 0.2rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.brand img {
  max-height: 64px;
  max-width: 220px;
  object-fit: contain;
}

.subtitle {
  color: var(--muted);
  margin-bottom: 2rem;
}

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

.card {
  border-radius: 12px;
  padding: 1rem;
  color: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.card strong {
  display: block;
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.card:link,
.card:visited {
  color: white;
  text-decoration: none;
}

.blue { background: #2563eb; }
.green { background: #16a34a; }
.orange { background: #f97316; }
.purple { background: #7c3aed; }
.red { background: #dc2626; }

/* ---------- Tables ---------- */

table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 1rem;
  background: var(--surface);
}

th,
td {
  border: 1px solid var(--border);
  padding: 0.45rem;
  text-align: left;
  vertical-align: top;
}

th {
  background: #eeeeee;
}

/* ---------- Forms ---------- */

input,
select {
  padding: 0.4rem;
  margin-right: 0.35rem;
  margin-bottom: 0.35rem;
}

input {
  width: 20rem;
}

button {
  padding: 0.4rem 0.8rem;
}

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

/* ---------- Document Page ---------- */

.pill {
  display: inline-block;
  background: #eef2ff;
  padding: 0.25rem 0.5rem;
  margin: 0.15rem;
  border-radius: 999px;
  text-decoration: none;
  color: #1e3a8a;
}

.pill:hover {
  background: #dbeafe;
}

.actions a {
  margin-right: 1rem;
}

.document-details th {
  width: 14rem;
}

/* ---------- Panels and Health ---------- */

.panel {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.ok {
  background: #16a34a;
  color: white;
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
}

.warn {
  background: #f97316;
  color: white;
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
}

li {
  margin: 0.3rem 0;
}

/* ---------- Maintenance Operations Console ---------- */

.maintenance-card {
  max-width: 980px;
}

pre {
  background: #111827;
  color: white;
  padding: 1rem;
  border-radius: 10px;
  white-space: pre-wrap;
  overflow-x: auto;
}

/* ---------- Sticky top navigation polish ---------- */

.qos-nav-wrap {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: #f5f7fb;
  padding: 0.75rem 0 0.5rem 0;
  margin: -2rem -2rem 1.5rem -2rem;
  padding-left: 2rem;
  padding-right: 2rem;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.qos-nav {
  margin-bottom: 0 !important;
}

body {
  scroll-padding-top: 5rem;
}

.ai-advisory {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-left: 5px solid #f97316;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  margin: 1rem 0;
}

.ai-advisory strong {
  color: #9a3412;
}

.page-subtitle {
  color: #64748b;
  margin-top: -0.4rem;
  margin-bottom: 1.25rem;
}

/* ---------- Final UI polish ---------- */

.qos-brand {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 0.45rem;
}

.qos-brand small {
  color: #64748b;
  font-weight: 500;
}

.review-progress {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 1.25rem 0;
}

.review-step {
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.9rem;
}

.review-step.done {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
  font-weight: 600;
}

.review-step.todo {
  background: #f8fafc;
  color: #64748b;
}

.qos-footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid #d1d5db;
  color: #64748b;
  font-size: 0.9rem;
}

.help-tip {
  color: #64748b;
  cursor: help;
  font-size: 0.9rem;
}

.empty-state {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  padding: 1rem;
  color: #475569;
}

.coming-soon {
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin: 1rem 0;
  color: #3730a3;
}

/* ---------- Branded two-row header ---------- */

.qos-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.7rem;
}

.qos-brand-main a {
  display: flex;
  align-items: center;
  gap: 14px;
  color: inherit;
  text-decoration: none;
}

.qos-brand-main img {
  height: 58px;
  width: auto;
}

.qos-brand-title {
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.1;
}

.qos-brand-subtitle {
  font-size: 0.92rem;
  color: #64748b;
}

.qos-brand-tagline {
  color: #64748b;
  font-size: 0.92rem;
  white-space: nowrap;
}

/* ---------- Core navigation ---------- */

.qos-nav {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  background: #111827;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.qos-nav a {
  color: white;
  text-decoration: none;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  font-size: 0.95rem;
}

.qos-nav a:hover {
  background: #374151;
}

.qos-nav .spacer {
  flex: 1;
}

.qos-nav .version {
  color: #d1d5db;
  font-size: 0.85rem;
}

/* ---------- Persistent document search ---------- */

.qos-nav-search {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
}

.qos-nav-search input {
  width: 15rem;
  min-width: 10rem;
  margin: 0;
  padding: 0.4rem 0.55rem;
}

.qos-nav-search button {
  margin: 0;
  padding: 0.4rem 0.65rem;
  white-space: nowrap;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1100px) {
  .qos-nav-search {
    order: 20;
    width: 100%;
  }

  .qos-nav-search input {
    flex: 1;
    width: auto;
  }
}

/* ---------- Administration reporting ---------- */

.qos-page {
  margin: 2rem;
}

.cards {
  display: grid;
  grid-template-columns:
    repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.admin-card {
  display: block;
  padding: 1rem;
  background: #fff;
  border-radius: 12px;
  text-decoration: none;
  color: #222;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.admin-card:hover {
  background: #eef2ff;
}

.admin-card strong {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 2rem;
}

.admin-issue-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.admin-issue-table th,
.admin-issue-table td {
  padding: 0.45rem;
  border: 1px solid #ccc;
  text-align: left;
  vertical-align: top;
}

.admin-issue-table th {
  background: #eee;
}

/* ---------- Document viewer ---------- */

.document-viewer-page {
  margin: 0;
}

.document-viewer-toolbar {
  padding: 0.75rem;
  background: #222;
  color: #fff;
}

.document-viewer-toolbar a {
  margin-left: 1rem;
  color: #fff;
}

.document-viewer-frame {
  width: 100%;
  height: calc(100vh - 50px);
  border: 0;
}

/* ---------- New document creation ---------- */

.new-document-form {
  display: grid;
  gap: 0.6rem;
  max-width: 700px;
  margin-bottom: 1rem;
}

.new-document-form label {
  margin-top: 0.5rem;
  font-weight: 700;
}

.new-document-form input,
.new-document-form select {
  width: 100%;
  padding: 0.45rem;
}

.new-document-form button {
  justify-self: start;
  margin-top: 0.5rem;
}

.suggested-number,
.preview-number {
  margin: 1rem 0;
  font-size: 1.4rem;
  font-weight: 700;
}

.new-document-card {
  max-width: 900px;
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
}

.document-preview-table {
  width: 100%;
  margin-top: 0.5rem;
  border-collapse: collapse;
}

.document-preview-table th,
.document-preview-table td {
  padding: 0.45rem 0.6rem;
  border: 1px solid #ddd;
  text-align: left;
  vertical-align: top;
}

.document-preview-table th {
  width: 260px;
  background: #f3f3f3;
}

.new-document-page .warning {
  margin: 1rem 0;
  padding: 0.75rem;
  border: 1px solid #e3ca7a;
  border-radius: 6px;
  background: #fff8e5;
}

/* ---------- RFC review views ---------- */

.rfc-document-title {
  margin-top: 0.25rem;
  margin-bottom: 1rem;
}

.rfc-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
}

.rfc-action-row form {
  display: inline-block;
}

/* Quality OS persistent operating-mode banner */
.qos-operating-mode-banner {
  position: sticky;
  top: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  box-sizing: border-box;
  width: 100%;
  padding: 0.55rem 1rem;
  border-top: 1px solid;
  border-bottom: 1px solid;
  font-size: 0.9rem;
  line-height: 1.35;
  text-align: center;
}

.qos-operating-mode-banner strong {
  white-space: nowrap;
  letter-spacing: 0.04em;
}

.qos-operating-mode-development {
  color: #2d2100;
  background: #ffd86b;
  border-color: #a87500;
  box-shadow: 0 2px 7px rgb(78 55 0 / 25%);
}

.qos-operating-mode-commissioned {
  color: #083f23;
  background: #d8f4e4;
  border-color: #3a9465;
}

.qos-operating-mode-unavailable {
  color: #5b0b0b;
  background: #ffdede;
  border-color: #b3261e;
  box-shadow: 0 2px 7px rgb(91 11 11 / 25%);
}

@media (max-width: 760px) {
  .qos-operating-mode-banner {
    position: static;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.6rem 0.75rem;
  }
}

/* Quality OS isolated unauthenticated boundary */
html,
body.qos-public-auth { min-height: 100%; }
body.qos-public-auth {
  margin: 0;
  background: radial-gradient(circle at top, rgb(255 255 255 / 8%), transparent 42%), #111827;
  color: #111827;
}
.qos-auth-viewport {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  box-sizing: border-box;
  padding: clamp(1rem, 4vw, 3rem);
}
.qos-auth-card {
  width: min(100%, 27rem);
  box-sizing: border-box;
  padding: clamp(1.5rem, 5vw, 2.5rem);
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 1rem;
  background: rgb(255 255 255 / 97%);
  box-shadow: 0 1.5rem 4rem rgb(0 0 0 / 32%);
}
.qos-auth-brand { margin-bottom: 1.5rem; text-align: center; }
.qos-auth-logo { display: block; width: min(12rem, 72%); height: auto; margin: 0 auto 1rem; }
.qos-auth-brand h1 { margin: 0; font-size: clamp(1.8rem, 7vw, 2.45rem); }
.qos-auth-tagline { margin: 0.45rem 0 0; color: #4b5563; font-size: 0.95rem; }
.qos-auth-operating-state { margin-top: 1rem; }
.qos-auth-operating-state .qos-operating-mode-banner {
  position: static; display: inline-flex; width: auto; max-width: 100%;
  padding: 0.35rem 0.65rem; border-radius: 999px; box-shadow: none; font-size: 0.75rem;
}
.qos-auth-operating-state .qos-operating-mode-banner span { display: none; }
.qos-auth-form-shell form { display: grid; gap: 0.8rem; }
.qos-auth-form-shell label { font-weight: 650; }
.qos-auth-form-shell input[type="text"],
.qos-auth-form-shell input[type="password"] {
  box-sizing: border-box; width: 100%; min-height: 2.75rem; padding: 0.65rem 0.75rem;
  border: 1px solid #9ca3af; border-radius: 0.45rem; font: inherit;
}
.qos-auth-form-shell button[type="submit"] {
  min-height: 2.8rem; margin-top: 0.35rem; border: 0; border-radius: 0.45rem;
  background: #1f4f78; color: white; font: inherit; font-weight: 700; cursor: pointer;
}
.qos-auth-form-shell [role="alert"] {
  padding: 0.75rem; border: 1px solid #b3261e; border-radius: 0.45rem;
  background: #fff0f0; color: #70130d;
}
.qos-nav-logout { display: inline-flex; margin: 0; }
.qos-nav-logout button {
  min-height: 2.25rem; padding: 0.4rem 0.75rem; border: 1px solid currentColor;
  border-radius: 0.4rem; background: transparent; color: inherit;
  font: inherit; font-weight: 700; cursor: pointer;
}

.qos-session-warning {
  display: inline-block;
  margin-right: 0.75rem;
  padding: 0.3rem 0.55rem;
  border: 1px solid currentColor;
  border-radius: 0.25rem;
  font-weight: 700;
}

.qos-admin-panel {
  width: min(42rem, calc(100% - 2rem));
  margin: 2rem auto;
}

.qos-admin-panel form {
  display: grid;
  gap: 1rem;
}

.qos-admin-panel label {
  display: grid;
  gap: 0.35rem;
}

/* DASH02 - dashboard module-status map */
.qos-dashboard-modules {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid #d5dce5;
}
.qos-dashboard-section-heading {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.qos-dashboard-section-heading h2 { margin: .15rem 0 0; }
.qos-eyebrow {
  margin: 0;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  opacity: .68;
}
.qos-module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
  gap: .85rem;
}
.qos-module-card {
  display: block;
  box-sizing: border-box;
  min-height: 165px;
  padding: 1rem;
  border: 1px solid #d5dce5;
  border-radius: 9px;
  background: var(--panel, #fff);
  color: inherit;
  text-decoration: none;
}
a.qos-module-card:hover,
a.qos-module-card:focus-visible {
  border-color: #74869a;
  transform: translateY(-1px);
}
.qos-module-card-heading {
  display: flex;
  gap: .6rem;
  justify-content: space-between;
  align-items: flex-start;
}
.qos-module-card h3 { margin: 0; font-size: 1rem; }
.qos-module-card p { margin: .85rem 0 0; line-height: 1.45; }
.qos-module-status {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: .25rem .5rem;
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
  background: #eef1f5;
  border: 1px solid #cbd3dc;
}
.qos-module-status-implemented { background: #e8f3eb; border-color: #a7c9af; }
.qos-module-status-active { background: #e8eff8; border-color: #a8bdd8; }
.qos-module-status-commissioning { background: #f7f0df; border-color: #d9c28d; }
.qos-dashboard-status-note {
  margin-top: 1rem;
  font-size: .85rem;
  opacity: .72;
}
@media (max-width: 720px) {
  .qos-module-card-heading { display: block; }
  .qos-module-status { display: inline-block; margin-top: .5rem; }
}
