/* =========================================================================
   INTERLINK components: page heads, panels, tables, forms, buttons,
   status labels, alerts, tabs, KPI tiles, sign-in, installer, error page.
   ========================================================================= */

/* ---- Page head -------------------------------------------------------- */
.page-head { display: flex; flex-direction: column; gap: var(--sp-1); }
.page-head--row { flex-direction: row; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; }
.page-head__lead { color: var(--text-2); max-width: 80ch; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }

.breadcrumbs ol { display: flex; flex-wrap: wrap; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--text-2); }
.breadcrumbs li + li::before { content: "/"; margin-right: var(--sp-2); color: var(--line-strong); }
.content > .breadcrumbs + * { margin-top: var(--sp-3); }

/* ---- Layout helpers ----------------------------------------------------- */
.grid { display: grid; gap: var(--sp-5); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 960px) { .grid--2 { grid-template-columns: 1fr; } }
.btn-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.plain-list li + li { margin-top: var(--sp-2); }

/* ---- Panels ------------------------------------------------------------- */
.panel {
  background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r-panel);
  padding: var(--sp-5); box-shadow: var(--shadow-1);
}
.panel > * + * { margin-top: var(--sp-3); }
.panel--flush { padding: 0; overflow-x: auto; }
.panel--flush > .table { min-width: 640px; }
.panel--flush > * + * { margin-top: 0; }
.panel__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap;
}
.panel--flush > .panel__head { padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--line); }
.panel__title { font-size: var(--fs-md); font-weight: 650; }
.link-more { display: inline-flex; align-items: center; gap: var(--sp-1); font-size: var(--fs-sm); }
.link-more .icon { width: 15px; height: 15px; }

.kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: var(--sp-2) var(--sp-5); }
.kv dt { color: var(--text-2); }
.kv dd { min-width: 0; overflow-wrap: anywhere; }

.empty { padding: var(--sp-8) var(--sp-5); text-align: center; color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); }
.empty .icon { width: 28px; height: 28px; color: var(--line-strong); }
p.empty { display: block; padding: var(--sp-5); }

.chip {
  display: inline-block; font-family: var(--font-mono); font-size: var(--fs-xs);
  padding: 1px 6px; border: 1px solid var(--line); border-radius: 3px; background: var(--surface-2); margin: 0 2px 4px 0;
}

/* ---- Tables ------------------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
.table th, .table td { padding: var(--sp-3) var(--sp-4); text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.table thead th {
  font-size: var(--fs-xs); font-weight: 650; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-2); background: var(--surface-2); white-space: nowrap; padding-top: var(--sp-2); padding-bottom: var(--sp-2);
}
.table tbody tr:hover { background: #F7F9FC; }
.table tbody tr:last-child > * { border-bottom: 0; }
.table th.num, .table td.num { text-align: left; }
.table--compact th, .table--compact td { padding: var(--sp-2) var(--sp-4); }
.table__primary { font-weight: 600; }
.table__actions { text-align: right; white-space: nowrap; width: 1%; }
.table tbody th { font-weight: 500; }
.table-scroll { overflow-x: auto; }
.table-scroll:focus-visible { box-shadow: inset var(--focus-ring); }
.panel--flush > .table + .pagination, .panel--flush > .table-scroll + .pagination { border-top: 1px solid var(--line); }

.matrix th.matrix__role { vertical-align: bottom; text-transform: none; letter-spacing: 0; font-size: var(--fs-xs); min-width: 92px; white-space: normal; }
.matrix td.matrix__cell { text-align: center; vertical-align: middle; }
.matrix__yes { color: var(--ok); margin: 0 auto; }
.matrix__no { color: var(--line-strong); }
.matrix tbody th { min-width: 260px; }

.diff { font-family: var(--font-mono); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.diff--old { color: var(--text-2); }
.diff--new { color: var(--text-1); background: var(--ok-soft); }

/* ---- Pagination --------------------------------------------------------- */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; padding: var(--sp-3) var(--sp-5); font-size: var(--fs-sm); }
.pagination__summary { color: var(--text-2); }
.pagination ul { display: flex; gap: var(--sp-1); flex-wrap: wrap; }
.pagination a, .pagination span { display: inline-flex; min-width: 32px; height: 32px; align-items: center; justify-content: center; padding: 0 var(--sp-2); border-radius: var(--r-control); }
.pagination a:hover { background: var(--surface-2); text-decoration: none; }
.pagination .is-current { background: var(--accent); color: #fff; font-weight: 600; }
.pagination .is-disabled { color: var(--line-strong); }

/* ---- Status labels (icon + text + colour) ------------------------------ */
.status {
  display: inline-flex; align-items: center; gap: 4px; vertical-align: middle;
  font-size: var(--fs-xs); font-weight: 600; line-height: 1; white-space: nowrap;
  padding: 4px 8px 4px 6px; border-radius: 3px; border: 1px solid transparent;
}
.status .icon { width: 14px; height: 14px; }
.status--ok      { color: var(--ok);      background: var(--ok-soft);      border-color: #BFE3CD; }
.status--warn    { color: var(--warn);    background: var(--warn-soft);    border-color: #F1D49A; }
.status--crit    { color: var(--crit);    background: var(--crit-soft);    border-color: #F1BDBA; }
.status--unknown { color: var(--unknown); background: var(--unknown-soft); border-color: var(--line); }
.status--info    { color: var(--info);    background: var(--info-soft);    border-color: #B5E0E5; }
.status--sim     { color: var(--sim);     background: var(--sim-soft);     border-color: #D9C3F5; }
.status--neutral { color: var(--text-2);  background: var(--surface-2);    border-color: var(--line); }

/* ---- Alerts ------------------------------------------------------------- */
.alert {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-panel); border: 1px solid; border-left-width: 4px;
}
.alert .icon { margin-top: 1px; }
.alert p { margin: 0; overflow-wrap: anywhere; }
.alert--ok   { background: var(--ok-soft);   border-color: #BFE3CD; border-left-color: var(--ok);   color: #0F5132; }
.alert--info { background: var(--info-soft); border-color: #B5E0E5; border-left-color: var(--info); color: #0B5560; }
.alert--warn { background: var(--warn-soft); border-color: #F1D49A; border-left-color: var(--warn); color: #6B4500; }
.alert--crit { background: var(--crit-soft); border-color: #F1BDBA; border-left-color: var(--crit); color: #8A1F1C; }
.content > .alert + .alert { margin-top: var(--sp-2); }

/* ---- Tabs --------------------------------------------------------------- */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs__tab {
  padding: var(--sp-2) var(--sp-4); color: var(--text-2); font-weight: 550; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs__tab:hover { color: var(--text-1); text-decoration: none; background: var(--surface-2); }
.tabs__tab.is-active { color: var(--text-1); border-bottom-color: var(--accent); }

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: var(--control-h); padding: 0 var(--sp-4); border-radius: var(--r-control);
  border: 1px solid transparent; font-weight: 600; font-size: var(--fs-base); cursor: pointer; white-space: nowrap;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn .icon { width: 16px; height: 16px; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); color: #fff; }
.btn--secondary { background: var(--surface-1); color: var(--text-1); border-color: var(--line-strong); }
.btn--secondary:hover { background: var(--surface-2); color: var(--text-1); }
.btn--danger { background: var(--surface-1); color: var(--crit); border-color: #E7A9A6; }
.btn--danger:hover { background: var(--crit-soft); color: var(--crit); }
.btn--ghost { background: transparent; color: var(--accent); }
.btn--ghost:hover { background: var(--accent-soft); }
.btn--ghost-dark { background: transparent; color: var(--ops-text-2); border-color: var(--ops-line); }
.btn--ghost-dark:hover { color: var(--ops-text-1); background: var(--ops-3); }
.btn--ghost-dark:focus-visible { box-shadow: 0 0 0 2px var(--ops-accent); }
.btn--sm { height: 30px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.btn--xs { height: 24px; padding: 0 var(--sp-2); font-size: var(--fs-xs); }
.btn--block { width: 100%; }

/* ---- Forms -------------------------------------------------------------- */
.form > * + * { margin-top: var(--sp-4); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4) var(--sp-5); }
.form-grid > .field--wide { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .field .label { font-weight: 600; font-size: var(--fs-sm); }
.field input, .field select, .field textarea {
  width: 100%; height: var(--control-h); padding: 0 var(--sp-3);
  border: 1px solid var(--line-strong); border-radius: var(--r-control); background: var(--surface-1);
}
.field textarea { height: auto; min-height: 96px; padding: var(--sp-2) var(--sp-3); }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input[readonly] { background: var(--surface-2); color: var(--text-2); }
.field [aria-invalid="true"] { border-color: var(--crit); }
.help { font-size: var(--fs-xs); color: var(--text-2); }
.field-error { display: flex; align-items: center; gap: 4px; font-size: var(--fs-sm); color: var(--crit); font-weight: 550; }
.field-error .icon { width: 14px; height: 14px; }
.form-actions { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; }

.toolbar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-3);
  background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r-panel); padding: var(--sp-3) var(--sp-4);
}
.field--inline { flex: 0 1 200px; }
.field--inline:first-of-type { flex-basis: 260px; }
.field--inline label { font-size: var(--fs-xs); color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; }

.checklist { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--sp-2) var(--sp-5); }
.checklist legend { font-weight: 650; display: flex; align-items: center; gap: var(--sp-3); padding: 0; margin-bottom: var(--sp-2); }
.checklist--group + .checklist--group { margin-top: var(--sp-5); padding-top: var(--sp-4); border-top: 1px solid var(--line); }
.checklist__item { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-2); border-radius: var(--r-control); cursor: pointer; }
.checklist__item:hover { background: var(--surface-2); }
.checklist__item input { width: 16px; height: 16px; margin-top: 2px; flex: none; accent-color: var(--accent); }
.checklist__item > span { display: flex; flex-direction: column; gap: 2px; }
.checklist__help { font-size: var(--fs-xs); color: var(--text-2); }
.confirm-box { padding-top: var(--sp-4); border-top: 1px solid var(--line); }

.sql-preview summary { cursor: pointer; font-weight: 600; padding: var(--sp-1) 0; }
.sql-preview__title { margin-top: var(--sp-4); font-family: var(--font-mono); font-size: var(--fs-sm); }
.code {
  background: var(--ops-1); color: #D6E2F3; border-radius: var(--r-control); padding: var(--sp-3) var(--sp-4);
  overflow-x: auto; font-size: 12px; line-height: 1.55; margin: var(--sp-2) 0 0;
}
.steps-list { list-style: decimal; padding-left: var(--sp-5); }
.steps-list li + li { margin-top: var(--sp-2); }

/* ---- KPI tiles ---------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--sp-4); }
.kpi {
  background: var(--surface-1); border: 1px solid var(--line); border-top: 3px solid var(--accent);
  border-radius: var(--r-panel); padding: var(--sp-4);
}
.kpi--warn { border-top-color: var(--warn); }
.kpi__label { font-size: var(--fs-xs); font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); }
.kpi__value { font-family: var(--font-mono); font-size: 30px; font-weight: 650; margin: var(--sp-1) 0; }
.kpi__def { font-size: var(--fs-xs); color: var(--text-2); }
.kpis__source { grid-column: 1 / -1; font-size: var(--fs-xs); color: var(--text-3); }

/* ---- Roadmap ------------------------------------------------------------ */
.roadmap__list { display: grid; gap: 0; }
.roadmap__item {
  display: grid; grid-template-columns: 90px 240px 1fr; gap: var(--sp-4); align-items: baseline;
  padding: var(--sp-3) 0; border-top: 1px dashed var(--line);
}
.roadmap__item:first-child { border-top: 0; }
.roadmap__phase { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-3); text-transform: uppercase; }
.roadmap__name { font-weight: 600; color: var(--text-2); }
.roadmap__text { color: var(--text-2); font-size: var(--fs-sm); }
@media (max-width: 760px) { .roadmap__item { grid-template-columns: 1fr; gap: 2px; } }

/* ---- Sign-in ------------------------------------------------------------ */
.page-auth { background: var(--ops-1); }
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr minmax(360px, 480px); }
.auth__board {
  display: flex; flex-direction: column; justify-content: space-between; padding: var(--sp-10);
  color: var(--ops-text-1);
  background:
    repeating-linear-gradient(0deg, transparent 0 47px, rgba(59, 167, 245, .07) 47px 48px),
    var(--ops-1);
  border-right: 1px solid var(--ops-line);
}
.auth__clock { display: flex; flex-direction: column; gap: var(--sp-2); }
.auth__time { font-family: var(--font-mono); font-size: clamp(48px, 7vw, 88px); font-weight: 600; letter-spacing: .04em; line-height: 1; }
.auth__date { font-size: var(--fs-sm); color: var(--ops-text-2); text-transform: uppercase; letter-spacing: .12em; }
.auth__tagline { color: var(--ops-text-2); font-size: var(--fs-sm); }
.auth__panel { background: var(--surface-1); padding: var(--sp-10); display: flex; flex-direction: column; justify-content: center; gap: var(--sp-4); }
.auth__title { font-size: var(--fs-xl); }
.auth__lead { color: var(--text-2); }
.auth__note { font-size: var(--fs-sm); color: var(--text-2); }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth__board { padding: var(--sp-6); gap: var(--sp-6); }
  .auth__time { font-size: 48px; }
  .auth__panel { padding: var(--sp-6); justify-content: flex-start; }
}

/* ---- Installer ---------------------------------------------------------- */
.page-install { background: var(--surface-0); }
.install { min-height: 100vh; display: grid; grid-template-columns: 280px 1fr; }
.install__rail { background: var(--ops-1); color: var(--ops-text-2); padding: var(--sp-8) var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-6); }
.install__lead { text-transform: uppercase; letter-spacing: .12em; font-size: var(--fs-xs); color: #6F84A5; }
.install__steps { display: flex; flex-direction: column; gap: var(--sp-1); }
.install__step { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) 0; }
.install__dot {
  width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--ops-line);
  display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: var(--fs-xs);
}
.install__dot .icon { width: 14px; height: 14px; }
.install__step--current { color: #fff; font-weight: 600; }
.install__step--current .install__dot { border-color: var(--ops-accent); color: var(--ops-accent); }
.install__step--done .install__dot { background: var(--ops-3); color: var(--ops-info); border-color: var(--ops-3); }
.install__version { margin-top: auto; font-size: var(--fs-xs); color: #5A6E8E; }
.install__main { padding: var(--sp-10); max-width: 980px; display: flex; flex-direction: column; gap: var(--sp-5); }
@media (max-width: 820px) {
  .install { grid-template-columns: 1fr; }
  .install__steps { flex-direction: row; flex-wrap: wrap; gap: var(--sp-3); }
  .install__step span:not(.install__dot) { display: none; }
  .install__step--current span { display: inline !important; }
  .install__main { padding: var(--sp-5); }
}

/* ---- Error page --------------------------------------------------------- */
.page-error { min-height: 100vh; display: grid; place-items: center; background: var(--ops-1); padding: var(--sp-5); }
.error-card { background: var(--surface-1); border-radius: var(--r-panel); padding: var(--sp-8); max-width: 560px; width: 100%; display: flex; flex-direction: column; gap: var(--sp-3); }
.error-card__code { font-family: var(--font-mono); font-size: 40px; font-weight: 650; color: var(--accent); line-height: 1; }
.error-card__detail { font-family: var(--font-mono); font-size: var(--fs-sm); background: var(--warn-soft); padding: var(--sp-3); border-radius: var(--r-control); overflow-wrap: anywhere; }
.error-card__ref { font-size: var(--fs-sm); color: var(--text-2); }
.error-card__actions { margin-top: var(--sp-2); }
