/* Caliper design system — 260912_caliper_ui-design-guideline.md */
:root {
  /* 1.1 palette */
  --page:#F5F5F7; --surface:#FFFFFF; --sunken:#F0F0F2; --elevated:#FFFFFF;
  --ink:#1D1D1F; --ink-2:#6E6E73; --ink-3:#86868B;
  --line:#D2D2D7; --line-2:#E8E8ED;
  --accent:#0071E3; --accent-hover:#0077ED; --accent-soft:#E8F0FE;
  /* status quintet */
  --pass:#1A7F4B; --pass-bg:#E3F5EC;
  --fail:#C4302B; --fail-bg:#FDE8E8;
  --block:#A05A00; --block-bg:#FDF0DD;
  --skip:#6E6E73; --skip-bg:#EDEDF0;
  --untested:#86868B;
  /* 1.3 spacing */
  --sp-xs:4px; --sp-sm:8px; --sp-md:12px; --sp-lg:16px; --sp-xl:24px; --sp-2xl:32px;
  /* 1.5 radius */
  --r-sm:4px; --r-md:8px; --r-full:9999px;
  /* 1.2 typography */
  --sans:-apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif;
  --mono:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,monospace;
  /* 1.4 elevation */
  --shadow-raised:0 1px 3px rgba(0,0,0,0.08);
  --shadow-overlay:0 8px 24px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--sans); font-size: 14px; line-height: 1.5; color: var(--ink); background: var(--page); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
a { color: var(--accent); }

/* 1.2 type scale */
.mono { font-family: var(--mono); font-size: 12px; }
.page-title { font-size: 20px; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; margin: 0; }
.section-title { font-size: 14px; font-weight: 600; line-height: 1.4; letter-spacing: -0.01em; margin: 0; }
.small { font-size: 12px; font-weight: 500; line-height: 1.4; }

/* 5.1 topbar */
.topbar { display: flex; align-items: center; gap: 0; padding: 0 var(--sp-xl); height: 48px; background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: var(--shadow-raised); flex: none; }
.topbar .brand { display: flex; align-items: baseline; gap: var(--sp-sm); font-weight: 600; letter-spacing: -0.01em; font-size: 14px; color: var(--ink); margin-right: var(--sp-xl); }
.topbar .brand small { font-size: 12px; font-weight: 500; color: var(--ink-3); letter-spacing: 0; }
.topbar .nav { display: flex; gap: 2px; align-items: center; }
.topbar .nav a { color: var(--ink-2); text-decoration: none; font-size: 13px; font-weight: 500; padding: 6px 12px; border-radius: var(--r-sm); }
.topbar .nav a:hover { background: var(--sunken); }
.topbar .nav a.active { background: var(--accent-soft); color: var(--accent); }
.topbar .spacer { margin-left: auto; }
.topbar .user { font-size: 12px; font-weight: 500; color: var(--ink-2); }
.topbar .signout-btn { padding: 6px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 13px; font-weight: 500; color: var(--ink); margin-left: var(--sp-md); }
.topbar .signout-btn:hover { background: var(--sunken); }

/* 4.1 screen content */
[data-testid="screen"] { padding: 0; max-width: none; margin: 0; display: block; }
.screen-content { max-width: 1200px; margin: 0 auto; padding: 20px 24px; }

/* headings */
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 20px; font-weight: 600; line-height: 1.3; }
h2 { font-size: 20px; font-weight: 600; line-height: 1.3; }
h3 { font-size: 14px; font-weight: 600; line-height: 1.4; }

/* 5.3 back link */
.back-link { display: inline-block; font-size: 12px; font-weight: 500; color: var(--accent); text-decoration: none; margin-bottom: var(--sp-lg); }
.back-link:hover { text-decoration: underline; }

/* 4.2 rail layout (cases) */
.rail-layout { display: flex; flex: 1; min-width: 0; min-height: 60vh; }
.rail { width: 240px; flex: none; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.rail-head { padding: var(--sp-md) var(--sp-lg); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.rail-head h2 { font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 0; }
.rail-body { overflow: auto; padding: 6px; flex: 1; }
.tree-row { display: flex; align-items: center; gap: 6px; width: 100%; padding: 4px 8px; border-radius: var(--r-sm); color: var(--ink); text-align: left; font-size: 13px; }
.tree-row:hover { background: var(--sunken); }
.tree-row.sel { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tree-row .count { margin-left: auto; font-size: 11px; color: var(--ink-3); font-family: var(--mono); }
.main { flex: 1; min-width: 0; padding: 20px 24px; max-width: 1200px; }

/* list header bar */
.list-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-lg); gap: var(--sp-md); }
.list-header h2 { margin: 0; }

/* 2.3 tables */
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--ink-2); padding: var(--sp-sm) var(--sp-md); border-bottom: 1px solid var(--line); background: var(--sunken); }
td { padding: var(--sp-sm) var(--sp-md); border-bottom: 1px solid var(--line-2); font-size: 14px; vertical-align: top; }
tbody tr:hover { background: var(--sunken); }
tr[data-testid] { cursor: pointer; }
.title-cell { font-weight: 500; }
td.col-key { width: 100px; }
td.col-status { width: 100px; }
td.col-narrow { width: 120px; }
table.no-border { border: none; }

/* 2.1 buttons */
button.btn, .btn { padding: 6px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); font-size: 13px; font-weight: 500; color: var(--ink); line-height: 1; }
button.btn:hover, .btn:hover { background: var(--sunken); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover, .btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.ghost, .btn.ghost { background: transparent; border: none; color: var(--accent); padding: 6px 8px; }
button.ghost:hover, .btn.ghost:hover { text-decoration: underline; background: transparent; }
button.destructive, .btn.destructive { background: var(--surface); border-color: var(--fail); color: var(--fail); }
button.destructive:hover, .btn.destructive:hover { background: var(--fail-bg); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

/* 2.2 inputs & selects */
input, select, textarea { padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); width: 100%; font-size: 14px; }
input[type="checkbox"], input[type="radio"] { width: auto; padding: 0; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
textarea { resize: none; overflow: hidden; line-height: 1.45; min-height: 68px; }
.field-label { display: block; font-size: 12px; color: var(--ink-2); font-weight: 500; margin-bottom: var(--sp-xs); }
.field-wrap { margin: var(--sp-sm) 0; max-width: 640px; }
label.check { display: flex; gap: 6px; align-items: center; font-weight: 400; }
.checks { display: flex; flex-direction: column; gap: 2px; margin: var(--sp-sm) 0; }

/* steps repeater */
.step { display: flex; flex-direction: column; gap: var(--sp-xs); margin: 6px 0; padding: var(--sp-md); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.step-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.step-head { display: flex; align-items: center; margin-bottom: 2px; }
.step-head button { margin-left: auto; color: var(--ink-3); padding: 2px 6px; }

/* 2.6 token multi-select */
.token-select { position: relative; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); padding: 6px 8px 4px; min-height: 36px; max-width: 640px; cursor: text; }
.token-select:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }
.token-chips { display: flex; flex-wrap: wrap; gap: var(--sp-xs); }
.token-chip { display: inline-flex; align-items: center; gap: 5px; background: var(--accent-soft); color: var(--accent); border-radius: var(--r-full); padding: 1px 4px 1px 9px; font-size: 12px; font-weight: 500; font-family: var(--mono); }
.token-chip-x { width: 16px; height: 16px; border-radius: 50%; color: var(--accent); font-size: 12px; line-height: 1; }
.token-chip-x:hover { background: rgba(0,113,227,.15); }
.token-search { border: none; outline: none; background: transparent; padding: 3px 0; min-width: 120px; font-size: 14px; }
.token-panel { display: none; position: absolute; top: calc(100% + 4px); left: -1px; right: -1px; max-height: 240px; overflow: auto; background: var(--elevated); border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: var(--shadow-overlay); z-index: 30; padding: var(--sp-xs); }
.token-panel.open { display: block; }
.token-option { display: flex; align-items: flex-start; gap: var(--sp-sm); padding: 5px 8px; border-radius: var(--r-sm); cursor: pointer; }
.token-option:hover { background: var(--sunken); }
.token-option .mono { color: var(--accent); }
.token-option-title { color: var(--ink-2); font-size: 12px; white-space: normal; overflow: visible; }
.token-empty { padding: 10px; color: var(--ink-3); font-size: 12px; }

/* 2.4 cards & details */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); margin: var(--sp-md) 0; }
.card-head { padding: var(--sp-md) var(--sp-lg); border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: var(--sp-md); }
.card-head h3 { font-size: 14px; margin: 0; font-weight: 600; }
.card-head .head-actions { margin-left: auto; display: flex; gap: var(--sp-xs); }
.card-body { padding: var(--sp-lg); }
.meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-md) var(--sp-xl); }
.meta-grid label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 2px; font-weight: 500; }
.meta-value { font-size: 14px; }

/* 2.5 chips */
.chip { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: var(--r-full); font-size: 12px; font-weight: 500; background: var(--sunken); color: var(--ink-2); }
.chip.mono { font-family: var(--mono); font-size: 11px; }
.chip.low { background: var(--skip-bg); color: var(--skip); }
.chip.role-admin { background: var(--accent-soft); color: var(--accent); }

/* 3.1 status chips */
.status-chip { display: inline-flex; align-items: center; gap: 3px; padding: 2px 10px; border-radius: var(--r-full); font-size: 12px; font-weight: 600; white-space: nowrap; }
.status-passed { color: var(--pass); background: var(--pass-bg); }
.status-failed { color: var(--fail); background: var(--fail-bg); }
.status-blocked { color: var(--block); background: var(--block-bg); }
.status-skipped { color: var(--skip); background: var(--skip-bg); }
.status-untested { color: var(--untested); background: transparent; border: 1px dashed var(--line); }

/* run state badges */
.state-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: var(--r-full); font-size: 12px; font-weight: 600; }
.state-in_progress { color: var(--accent); background: var(--accent-soft); }
.state-locked { color: var(--ink-2); background: var(--sunken); }

/* summary bar */
.summary-bar { display: flex; gap: var(--sp-lg); align-items: center; margin: var(--sp-md) 0; flex-wrap: wrap; }
.summary-item { display: flex; align-items: center; gap: var(--sp-xs); font-size: 12px; font-weight: 500; }

/* detail header */
.detail-header { display: flex; align-items: baseline; gap: var(--sp-md); flex-wrap: wrap; }
.detail-header .large { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.id-link { color: var(--accent); text-decoration: none; }
a.id-link:hover { text-decoration: underline; }

/* detail controls — moved into header card head-actions */
.detail-controls { margin: var(--sp-md) 0; display: flex; gap: var(--sp-sm); }

.list-row { padding: var(--sp-sm) var(--sp-md); border-bottom: 1px solid var(--line-2); cursor: pointer; display: flex; gap: var(--sp-md); align-items: baseline; background: var(--surface); }
.list-row:first-child { border-top: 1px solid var(--line); }
.list-row:hover { background: var(--sunken); }
.muted { color: var(--ink-3); font-size: 12px; }

/* steps read table */
.steps-read { width: 100%; border-collapse: collapse; }
.steps-read th { text-align: left; font-size: 12px; color: var(--ink-2); padding: 4px 8px; border-bottom: 1px solid var(--line); background: transparent; }
.steps-read td { padding: 6px 8px; border-bottom: 1px solid var(--line-2); font-size: 14px; vertical-align: top; }
.steps-read td:first-child { width: 26px; color: var(--ink-3); font-family: var(--mono); font-size: 12px; }
.ref-row { padding: 3px 0; }

/* 2.7 dialog */
.dialog { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,0.3); z-index: 40; }
.dialog > * { background: var(--elevated); border-radius: var(--r-md); padding: var(--sp-xl); max-width: 480px; margin: 0 20px; box-shadow: var(--shadow-overlay); }

/* errors */
input.field-error, textarea.field-error, select.field-error { border-color: var(--fail); }
input.field-error:focus, textarea.field-error:focus, select.field-error:focus { outline-color: var(--fail); border-color: var(--fail); }
.err-slot { color: var(--fail); font-size: 12px; min-height: 0; margin-top: 2px; }
.err-item, .errors { color: var(--fail); font-size: 13px; }
.errors { margin: 6px 0; }

/* 2.9 empty state */
.empty-state { text-align: center; color: var(--ink-2); font-size: 14px; padding: var(--sp-2xl) var(--sp-lg); }

/* filters */
.filters { margin-bottom: var(--sp-lg); display: flex; gap: var(--sp-sm); align-items: center; flex-wrap: wrap; }
.filters input, .filters select { width: auto; }

/* hints */
.hint { font-size: 12px; color: var(--ink-3); }
.hint-warn { background: var(--block-bg); border: 1px solid #e8c268; color: var(--block); padding: var(--sp-sm) var(--sp-md); border-radius: var(--r-sm); margin: var(--sp-sm) 0; font-size: 13px; }

/* (i) help icon */
.info { display: inline-flex; align-items: center; justify-content: center; margin-left: var(--sp-xs); width: 16px; height: 16px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 10px; font-style: italic; cursor: help; position: relative; }
.info:hover { background: var(--accent); color: #fff; }
.info:hover::after { content: attr(data-tip); position: absolute; left: 0; top: 22px; z-index: 10; width: 280px; background: var(--ink); color: #fff; padding: var(--sp-sm) var(--sp-md); border-radius: var(--r-md); font-style: normal; font-size: 12px; line-height: 1.45; white-space: normal; box-shadow: var(--shadow-overlay); }

/* integrity badge */
.badge { display: inline-flex; align-items: center; gap: var(--sp-xs); padding: 4px 12px; border-radius: var(--r-full); font-size: 12px; font-weight: 600; }
.badge.ok { background: var(--pass-bg); color: var(--pass); }
.badge.bad { background: var(--fail-bg); color: var(--fail); }

/* activity entries (now table-based, keeping .entry for compat) */
.entry { padding: 4px 0; border-bottom: 1px solid var(--line-2); font-family: var(--mono); font-size: 12px; }

/* run-row (kept for testid compat, restyled) */
.run-row { display: flex; gap: var(--sp-sm); align-items: center; padding: var(--sp-sm) var(--sp-md); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); margin: 6px 0; flex-wrap: wrap; }
.run-row .status { margin-left: auto; }

/* sign-in (not polished per guideline §8, minimal alignment) */
.signin { max-width: 420px; margin: 80px auto; background: var(--surface); padding: var(--sp-xl); border-radius: var(--r-md); border: 1px solid var(--line); }
.signin-users { display: flex; flex-direction: column; gap: 6px; margin-top: var(--sp-md); }
.signin-row { padding: var(--sp-sm) var(--sp-md); border: 1px solid var(--line); border-radius: var(--r-sm); cursor: pointer; background: var(--sunken); }
.signin-row:hover { background: var(--accent-soft); }

/* folder controls */
.folder-line { display: flex; gap: 6px; align-items: center; }
.folder-line select { flex: 1; }

/* 2.8 toast */
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--r-md); font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .18s; max-width: 480px; box-shadow: var(--shadow-overlay); }
#toast.visible { opacity: 1; }

/* form layout for editors */
.form-body { max-width: 640px; }
.form-actions { display: flex; gap: var(--sp-sm); margin-top: var(--sp-lg); }

/* 7 responsive */
@media (max-width: 1024px) {
  .meta-grid { grid-template-columns: repeat(2, 1fr); }
  .rail { display: none; }
  .rail-layout { display: block; }
  .main { padding: 20px 24px; }
}
@media (max-width: 768px) {
  .meta-grid { grid-template-columns: 1fr; }
  .screen-content { padding: 16px; }
  .main { padding: 16px; }
  .list-header { flex-direction: column; align-items: stretch; gap: var(--sp-sm); }
  .filters { flex-direction: column; align-items: stretch; }
  table { display: block; overflow-x: auto; }
}
