/* Marlin Support: layout and pieces the app's stylesheet (app.css) doesn't have. Colors, type, buttons, inputs,
   segmented controls, badges and banners all come from app.css, so light and dark follow the same tokens. */

body.sup { min-height: 100vh; display: flex; flex-direction: column; background: var(--page); }
.sup-top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 20px; height: 52px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.sup-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.sup-brand .badge { border-style: solid; }
.sup-tabs { display: flex; gap: 4px; }
.sup-tabs [role='tab'] {
  height: 32px; padding: 0 12px; border: 0; border-radius: var(--r-control); background: transparent; color: var(--ink-2);
  font: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer;
}
.sup-tabs [role='tab']:hover { background: var(--surface-2); color: var(--ink); }
.sup-tabs [role='tab'][aria-selected='true'] { background: var(--accent-wash); color: var(--accent-text); }
.sup-tabs [role='tab']:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 1px; }
.sup-user { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-3); }

.sup-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.sup-query { flex: 1; min-height: 0; display: grid; grid-template-columns: 290px minmax(0, 1fr); }
.sup-query[hidden], .sup-logs[hidden] { display: none; }

/* Tables */
.sup-side { border-right: 1px solid var(--line); background: var(--surface); padding: 14px 12px; display: flex; flex-direction: column; gap: 10px; min-height: 0; max-height: calc(100vh - 52px); position: sticky; top: 52px; }
.sup-db .segmented { display: flex; }
.sup-db .segmented > button { flex: 1; justify-content: center; }
.sup-dbfile { font-size: 12px; color: var(--ink-3); margin-top: 6px; }
.sup-tables { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; min-height: 0; }
.sup-table-row { display: flex; align-items: center; gap: 2px; }
.sup-table {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 6px; border: 0; border-radius: var(--r-small);
  background: transparent; color: var(--ink); font: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.sup-table:hover { background: var(--surface-2); }
.sup-table .icon { width: 12px; height: 12px; color: var(--ink-3); flex: none; }
.sup-table .name { font-family: var(--mono); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sup-table .count { margin-left: auto; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.sup-table-row .btn-icon { opacity: 0.6; }
.sup-table-row:hover .btn-icon, .sup-table-row .btn-icon:focus-visible { opacity: 1; }
.sup-cols { list-style: none; margin: 0 0 6px 18px; padding: 0 0 0 8px; border-left: 1px solid var(--line); }
.sup-cols button {
  width: 100%; display: flex; gap: 8px; align-items: baseline; padding: 3px 6px; border: 0; border-radius: var(--r-small); background: transparent;
  color: var(--ink-2); font: inherit; font-size: 12px; text-align: left; cursor: pointer;
}
.sup-cols button:hover { background: var(--surface-2); color: var(--ink); }
.sup-cols .col { font-family: var(--mono); }
.sup-cols .type { margin-left: auto; color: var(--ink-3); font-size: 11.5px; white-space: nowrap; }
.sup-muted { color: var(--ink-3); font-size: 13px; }

/* Editor and results */
.sup-main { min-width: 0; display: flex; flex-direction: column; gap: 10px; padding: 14px 20px 20px; }
.sup-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sup-toolbar .grow, .sup-status .grow { flex: 1; }
.sup-hint { font-size: 12px; color: var(--ink-3); }
.input-sm, .select-sm { height: 30px; font-size: 13px; padding-top: 0; padding-bottom: 0; }
.sup-toolbar .select-sm { width: auto; max-width: 320px; appearance: auto; padding-right: 6px; }
.sup-toolbar .input-sm { width: 280px; max-width: 100%; }
.sup-editor {
  width: 100%; min-height: 150px; resize: vertical; padding: 12px 14px; border: 1px solid var(--control); border-radius: var(--r-control);
  background: var(--surface); color: var(--ink); font-family: var(--mono); font-size: 13px; line-height: 1.55; tab-size: 2;
}
.sup-editor:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 1px; border-color: var(--accent-text); }
.sup-status { display: flex; align-items: center; gap: 8px; min-height: 30px; font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }
.sup-status strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.sup-results { min-height: 0; transition: opacity var(--fast) var(--ease); }
.sup-results.is-refreshing { opacity: 0.55; }
.sup-empty { padding: 20px 0; }
.sup-error { margin: 0; }
.sup-grid-wrap { overflow: auto; max-height: calc(100vh - 340px); min-height: 120px; border: 1px solid var(--line); border-radius: var(--r-control); background: var(--surface); }
.sup-grid { border-collapse: separate; border-spacing: 0; font-size: 12.5px; min-width: 100%; }
.sup-grid th, .sup-grid td { padding: 6px 10px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); white-space: nowrap; text-align: left; vertical-align: top; }
.sup-grid td { font-family: var(--mono); font-size: 12px; max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
.sup-grid th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); font-weight: 500; color: var(--ink-2); }
.sup-grid th button { border: 0; background: none; padding: 0; font: inherit; color: inherit; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.sup-grid th button:hover { color: var(--ink); }
.sup-grid th .icon { width: 11px; height: 11px; }
.sup-grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.sup-grid th.num button { flex-direction: row-reverse; }
.sup-grid .rownum { color: var(--ink-3); text-align: right; font-family: var(--mono); background: var(--surface-2); position: sticky; left: 0; }
.sup-grid thead .rownum { z-index: 2; }
.sup-grid tbody tr:hover td:not(.rownum) { background: color-mix(in srgb, var(--accent-wash) 60%, transparent); }
.sup-grid .null { color: var(--ink-3); font-style: italic; }
.sup-grid .special { color: var(--ink-3); }
.cell-more { border: 0; background: none; padding: 0; font: inherit; color: var(--accent-text); cursor: pointer; text-align: left; }
.cell-more:hover { text-decoration: underline; }

/* Full value of a cell */
.sup-drawer {
  position: fixed; top: 52px; right: 0; bottom: 0; z-index: 30; width: min(560px, 100vw); display: flex; flex-direction: column; gap: 12px;
  padding: 16px 20px; background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow-float);
}
.sup-drawer[hidden] { display: none; }
.sup-drawer-head { display: flex; align-items: center; justify-content: space-between; }
.sup-drawer-head h2 { font-size: 15px; font-weight: 600; font-family: var(--mono); }
.sup-cell { flex: 1; overflow: auto; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-control); background: var(--surface-2); font-family: var(--mono); font-size: 12px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.sup-drawer .btn { align-self: flex-start; }

/* Logs */
.sup-logs { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; padding: 16px 20px 20px; }
.sup-services { display: flex; gap: 8px; flex-wrap: wrap; }
.sup-svc { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r-small); background: var(--surface); font-size: 12.5px; }
.sup-svc .icon { width: 14px; height: 14px; }
.sup-svc.ok .icon { color: var(--pos); }
.sup-svc.bad .icon { color: var(--crit); }
.sup-svc span:not(.state) { font-family: var(--mono); }
.sup-svc .state { color: var(--ink-3); }
.sup-log {
  flex: 1; min-height: 300px; max-height: calc(100vh - 220px); overflow: auto; margin: 0; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: var(--r-control); background: var(--surface); font-family: var(--mono); font-size: 12px; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}
.sup-log .bad { color: var(--crit); }
.sup-log .warn { color: var(--warn); }

/* Sign-in */
body.sup-login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--page); }
.sup-login-card { width: min(380px, 100%); display: grid; justify-items: center; gap: 12px; text-align: center; padding: 32px 28px; }
.sup-login-card h1 { font-size: 20px; font-weight: 600; }
.sup-login-card .sub { color: var(--ink-3); font-size: 13.5px; }
.sup-login-card .banner { margin: 0; text-align: left; font-size: 13px; }

@media (max-width: 900px) {
  .sup-top { gap: 12px; padding: 0 12px; }
  .sup-hint, .sup-user span { display: none; }
  .sup-query { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sup-side { position: static; max-height: 260px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sup-main, .sup-logs { padding: 12px; }
  .sup-toolbar .select-sm, .sup-toolbar .input-sm { flex: 1 1 140px; width: auto; }
  .sup-grid-wrap { max-height: 70vh; }
}
@media (max-width: 520px) {
  .sup-brand span:not(.badge) { display: none; }
}
