/* OpenCloudBox hosted console — documented UI system (visual-only).
 *
 * Tokens and components used by apps/web/src/views.ts:
 * - Spacing/type tokens: --space-*, --radius-*, --shadow, h1/h2 scale.
 * - Layout: .page-head, .breadcrumb, .subnav, .grid-2, .lifecycle-bar.
 * - Surfaces: .card (.card--hero), .table-wrap + table.table, .pill, .kv.
 * - States: .state (+ .state--error), .empty (+ .empty-icon), .skeleton.
 * - Utilities: .mono, .numeric, .truncate, .lede, .eyebrow, .footer-note.
 * - Legacy aliases kept for compatibility: .list, .meta, .badge, .notice,
 *   .actions, .button, .danger, .skip, .state.
 * Color values are unchanged from the AA-passing baseline; new accents reuse
 * the audited accent/badge/danger ramps only. See docs/t19-web-console-ui.md.
 */

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #1b1b1b;
  --muted: #595959;
  --border: #767676;
  --surface: #f2f2f2;
  --accent: #0b57d0;
  --danger: #b3261e;
  --focus: #1a73e8;
  --badge-bg: #e8f0fe;
  --badge-fg: #0b3d91;
  --notice-bg: #fff8e1;
  --notice-fg: #1b1b1b;
  --notice-border: #8a6d3b;
  --code-bg: #111111;
  --code-fg: #f0f0f0;
  /* Type + spacing tokens (visual only). */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.08);
  --max-width: 72rem;
  --measure: 44rem;
  /* Primary action reuses the audited accent ramp (AA on both themes). */
  --primary-bg: #0b57d0;
  --primary-fg: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --fg: #f5f5f5;
    --muted: #c9c9c9;
    --border: #8f8f8f;
    --surface: #1e1e1e;
    --accent: #8ab4f8;
    --danger: #f2b8b5;
    --focus: #8ab4f8;
    --badge-bg: #1f3a5f;
    --badge-fg: #d3e3fd;
    --notice-bg: #3a2f0b;
    --notice-fg: #f5f5f5;
    --notice-border: #c9a227;
    --code-bg: #0b0b0b;
    --code-fg: #f0f0f0;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
    --primary-bg: #8ab4f8;
    --primary-fg: #121212;
  }
}
* {
  box-sizing: border-box;
}
body {
  font-family: system-ui, sans-serif;
  margin: 0;
  line-height: 1.5;
  background: var(--bg);
  color: var(--fg);
}
a {
  color: var(--accent);
}
h1 {
  font-size: 1.75rem;
  line-height: 1.2;
  font-weight: 700;
  margin: 0 0 var(--space-2);
  letter-spacing: -0.01em;
}
h2 {
  font-size: 1.15rem;
  line-height: 1.35;
  font-weight: 650;
  margin: var(--space-5) 0 var(--space-2);
}
h3 {
  font-size: 1rem;
  font-weight: 650;
  margin: var(--space-4) 0 var(--space-2);
}
p {
  margin: 0 0 var(--space-3);
  max-width: var(--measure);
}
header nav {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  max-width: var(--max-width);
  margin: 0 auto;
}
header nav a[aria-current="page"] {
  font-weight: 700;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
main {
  padding: var(--space-4);
  max-width: var(--max-width);
  margin: 0 auto;
  min-width: 0;
}
section {
  min-width: 0;
}
pre {
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 1rem;
  overflow: auto;
  max-height: 24rem;
  border-radius: var(--radius-md);
  overflow-wrap: anywhere;
}

/* Page header: eyebrow + title + lede + optional actions. */
.page-head {
  margin: var(--space-2) 0 var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}
.page-head h1 {
  margin-bottom: var(--space-1);
}
.eyebrow {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 var(--space-1);
}
.lede {
  color: var(--muted);
  margin: 0 0 var(--space-2);
  max-width: var(--measure);
}
.page-head-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: var(--space-2);
}

/* Breadcrumbs: orientation cue for project/env/session depth. */
.breadcrumb {
  margin: 0 0 var(--space-2);
  padding: 0;
}
.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.9rem;
}
.breadcrumb li + li::before {
  content: "›";
  color: var(--muted);
  margin-right: var(--space-1);
}
.breadcrumb [aria-current="page"] {
  color: var(--fg);
  font-weight: 600;
  text-decoration: none;
}

/* In-page section nav (anchor links, no JS): separates session areas. */
.subnav {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin: 0 0 var(--space-4);
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
}
.subnav a {
  white-space: nowrap;
}

/* Cards: the primary content bound. */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: var(--space-4);
  margin: 0 0 var(--space-4);
  min-width: 0;
}
.card > h2:first-child,
.card > h3:first-child {
  margin-top: 0;
}
.card--hero {
  background: var(--surface);
}
.card-title {
  margin: 0 0 var(--space-1);
  font-size: 1.15rem;
  font-weight: 650;
}
.card-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 var(--space-3);
}

/* Definition rows: human-readable summary with technical IDs collapsed. */
.kv {
  display: grid;
  grid-template-columns: minmax(8rem, 12rem) 1fr;
  gap: var(--space-1) var(--space-3);
  margin: 0 0 var(--space-3);
  padding: 0;
}
.kv dt {
  color: var(--muted);
  font-size: 0.9rem;
}
.kv dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}
details.tech {
  margin: var(--space-2) 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  background: var(--bg);
}
details.tech summary {
  cursor: pointer;
  font-weight: 600;
}
details.tech pre {
  margin-bottom: 0;
}

/* Data tables: structured rows replace raw JSON/ID lists. */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin: 0 0 var(--space-4);
  background: var(--bg);
}
table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  min-width: 34rem;
}
table.table caption {
  text-align: left;
  font-weight: 650;
  padding: var(--space-2) var(--space-3);
}
table.table th,
table.table td {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--border);
  vertical-align: top;
  overflow-wrap: anywhere;
}
table.table thead th {
  border-top: 0;
  background: var(--surface);
  color: var(--fg);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
table.table tbody tr:hover {
  background: var(--surface);
}
.mono,
code {
  overflow-wrap: anywhere;
}
.mono {
  font-family: ui-monospace, monospace;
  font-size: 0.88em;
}
.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.truncate {
  display: inline-block;
  max-width: 22rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

/* Status pills: human-readable state with technical value retained. */
.pill {
  display: inline-block;
  background: var(--badge-bg);
  color: var(--badge-fg);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  font-size: 0.82rem;
  font-weight: 650;
  white-space: nowrap;
}
.pill--danger {
  background: var(--notice-bg);
  color: var(--notice-fg);
  border: 1px solid var(--notice-border);
}

/* Sticky lifecycle bar: session controls stay visible above details. */
.lifecycle-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  margin: 0 0 var(--space-4);
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}
.lifecycle-bar .pill {
  margin-right: auto;
}

/* Two-column grid for overview/operations splits on wide screens. */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}
@media (min-width: 48rem) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.list {
  padding-left: 1.25rem;
}
.meta {
  color: var(--muted);
  font-size: 0.9rem;
}
.badge {
  background: var(--badge-bg);
  color: var(--badge-fg);
  border-radius: 0.25rem;
  padding: 0 0.375rem;
}
.test-badge {
  background: var(--notice-bg);
  color: var(--notice-fg);
  border: 1px solid var(--notice-border);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--radius-sm);
  background: var(--primary-bg);
  color: var(--primary-fg);
  font-weight: 800;
  font-size: 0.9rem;
  margin-right: 0.25rem;
}
.button,
button {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
}
.button {
  text-decoration: none;
  display: inline-block;
}
.button--primary,
button.button--primary {
  background: var(--primary-bg);
  border-color: var(--primary-bg);
  color: var(--primary-fg);
  font-weight: 650;
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}
.danger {
  border-color: var(--danger);
  color: var(--danger);
}
.state {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin: 1rem 0;
  background: var(--bg);
}
.state--error {
  border-color: var(--danger);
  border-left-width: 4px;
}
.state--notice {
  background: var(--surface);
}
/* Empty state: distinct from loading/error, carries the primary CTA. */
.empty {
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-4);
  margin: var(--space-3) 0;
  text-align: left;
  background: var(--bg);
}
.empty h2 {
  margin-top: 0;
}
.empty-icon {
  font-size: 1.5rem;
  line-height: 1;
  margin-bottom: var(--space-2);
}
/* Skeleton shimmer for loading (static when reduced-motion is preferred). */
.skeleton {
  display: block;
  height: 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  margin: var(--space-2) 0;
}
.skeleton--title {
  height: 1.4rem;
  width: 55%;
}
.skeleton--line {
  width: 90%;
}
.skeleton--short {
  width: 40%;
}
.notice {
  background: var(--notice-bg);
  color: var(--notice-fg);
  border: 1px solid var(--notice-border);
  padding: 0.5rem 1rem;
}
.notice:empty {
  display: none;
}
.confirm-inline {
  margin: 0;
  max-width: none;
}
.actions .confirm-inline {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.footer-note {
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  margin-top: var(--space-6);
  padding-top: var(--space-3);
}
.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 0.5rem;
  top: 0.5rem;
  background: var(--bg);
  color: var(--fg);
  padding: 0.5rem;
  z-index: 10;
}
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible,
pre:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
form {
  display: grid;
  gap: 0.5rem;
  max-width: 32rem;
  margin: 1rem 0;
}
label {
  font-weight: 600;
}
input,
textarea,
select {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--bg);
  color: var(--fg);
  min-width: 0;
  max-width: 100%;
}
.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.steps {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  list-style: none;
  margin: var(--space-4) 0;
  padding: 0;
}
.steps li {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  background: var(--bg);
}
.steps strong {
  display: block;
  margin-bottom: var(--space-1);
}
@media (min-width: 48rem) {
  .steps {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 640px) {
  header nav {
    gap: 0.5rem;
  }
  main {
    padding: 0.75rem;
  }
  .actions {
    flex-direction: column;
  }
  .actions button {
    width: 100%;
  }
  .kv {
    grid-template-columns: 1fr;
  }
  .lifecycle-bar .pill {
    margin-right: 0;
    width: 100%;
  }
  table.table {
    min-width: 0;
  }
  .truncate {
    max-width: 12rem;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms;
    animation-iteration-count: 1;
    transition-duration: 0.01ms;
    scroll-behavior: auto;
  }
}
