:root {
  color-scheme: light dark;
  --canvas: #f1f4f8;
  --shell: #e8edf4;
  --surface: #fff;
  --raised: #f8fafc;
  --field: #fff;
  --text: #0f172a;
  --muted: #475569;
  --line: #e2e8f0;
  --strong: #cbd5e1;
  --input-line: #71839a;
  --accent: #214fc2;
  --accent-fill: #2563eb;
  --accent-hover: #1d4ed8;
  --focus: #2563eb;
  --on: #fff;
  --selected: #e7efff;
  --hover: #edf3fc;
  --bad: #a92c29;
  --bad-bg: #fff0ed;
  --danger-fill: #a92c29;
  --good: #087854;
  --mid: #995b08;
  --radius: 12px;
  --mono: "Cascadia Code",Consolas,monospace;
  font-family: "OpenAI Sans","Segoe UI Variable Text","Segoe UI","Microsoft YaHei UI",sans-serif;
  line-height: 1.55;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #0d1117;
    --shell: #111622;
    --surface: #161c28;
    --raised: #1d2535;
    --field: #1e2738;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --line: #232d3f;
    --strong: #2e3b52;
    --input-line: #7489a6;
    --accent: #92c0ff;
    --focus: #64a2ff;
    --selected: #1f3254;
    --hover: #202c43;
    --bad: #ffb4ac;
    --bad-bg: #472a31;
    --good: #58d5ac;
    --mid: #f6c16a;
  }
}

* {box-sizing:border-box}
[hidden] {display:none !important}
body {margin:0; min-width:300px; background:var(--canvas); color:var(--text); font-size:15px}
img {object-fit:contain; border-radius:8px; vertical-align:middle}
h1,h2,h3,p,dl {margin:0}
h1 {font-size:clamp(25px,3.5vw,36px); letter-spacing:.01em; line-height:1.25}
h2 {font-size:20px; line-height:1.35}
h3 {font-size:16px}
strong, b {font-weight:650}
a {color:var(--accent)}
button,input,select {font:inherit}
button,input,select {border:1px solid var(--line); border-radius:8px; min-height:42px; color:var(--text)}
button {padding:7px 14px; background:var(--surface); cursor:pointer}
button:hover:not(:disabled) {background:var(--hover)}
button:disabled,
button.primary:disabled {
  color: var(--muted);
  background: var(--raised);
  border-color: var(--line);
  box-shadow: none;
  cursor: default;
}
button.primary {color:var(--on); background:var(--accent-fill); border-color:transparent; font-weight:650}
button.primary:hover:not(:disabled) {background:var(--accent-hover)}
button.link {color:var(--accent); border-color:transparent; background:transparent}
button.danger {color:var(--bad)}
button.primary.danger:not(:disabled) {background:var(--danger-fill); color:var(--on)}
button.primary.danger:hover:not(:disabled) {background:#8c241e}
input,select {width:100%; min-width:0; padding:9px 11px; background:var(--field); border-color:var(--input-line)}
input::placeholder {color:var(--muted); opacity:1}
input[type="checkbox"] {width:17px; height:17px; min-height:0; accent-color:var(--accent-fill)}
*:focus-visible {outline:2px solid var(--focus); outline-offset:3px}
label {display:block; font-weight:600; font-size:14px}
label + :is(input,select) {margin-top:6px}
.secondary,.fine {color:var(--muted)}
.fine {font-size:13px}
.notice {padding:10px 13px; border-radius:8px; background:var(--selected); overflow-wrap:anywhere}
.notice.error {color:var(--bad); background:var(--bad-bg)}
.gate {
  position:relative; isolation:isolate; overflow:hidden; overflow:clip;
  min-height:100vh; min-height:100svh; min-height:100dvh;
  display:grid; align-items:center; justify-items:end;
  padding:clamp(28px,5vh,70px) clamp(32px,7vw,144px);
  background:#213a55;
}
.gate-art {
  position:absolute; z-index:-2; inset:0; width:100%; height:110%;
  object-fit:cover; object-position:center top; border-radius:0;
}
.gate::before {
  content:""; position:absolute; z-index:-1; inset:0;
  background:
    linear-gradient(0deg,#17314819 0%,transparent 32%),
    linear-gradient(100deg,transparent 45%,#18355136 100%);
}
.gate-form {
  --card-fill:#f8fbff;
  --card-glass:#f8fbfff2;
  --card-line:#ffffffa6;
  width:min(100%,440px); display:grid; gap:23px;
  padding:clamp(23px,2.7vw,36px);
  border:1px solid var(--card-line); border-radius:20px;
  background:var(--card-fill); box-shadow:0 24px 70px -16px #030a16c2,0 4px 20px #030a1640;
}
@supports (backdrop-filter:blur(18px)) {
  .gate-form {background:var(--card-glass); backdrop-filter:blur(18px)}
}
@media (prefers-color-scheme: dark) {
  .gate-form {
    --card-fill:#161c28;
    --card-glass:#161c28ed;
    --card-line:#9bb6d250;
    --field:#243044;
  }
}
@media (prefers-reduced-transparency: reduce) {
  .gate-form {background:var(--card-fill); backdrop-filter:none}
}
.gate-heading {
  display:grid;
  grid-template-columns:auto minmax(0,1fr);
  align-items:center; gap:12px 13px;
}
.gate-mark {width:44px; height:44px; border-radius:11px}
.gate-form h1 {font-size:clamp(22px,2vw,26px); font-weight:700; letter-spacing:normal}
.gate-form h1 span {white-space:nowrap}
.gate-heading .secondary {grid-column:1 / -1}
.gate-fields,.gate-field {display:grid; gap:16px; min-width:0}
.gate-field {gap:6px}
.gate-field label {color:var(--text)}
.gate-field input {margin:0; min-height:50px; border-radius:10px; padding:10px 13px; font-size:1rem}
.password-control {position:relative; min-width:0}
.password-control input {padding-inline-end:53px}
button.password-visibility {
  position:absolute; inset-block-start:4px; inset-inline-end:4px;
  min-width:42px; width:42px; min-height:42px; height:42px; padding:0; border:0;
  display:grid; place-items:center; color:var(--muted); background:transparent;
}
button.password-visibility:hover:not(:disabled) {background:var(--hover); color:var(--text)}
.password-visibility:focus-visible {outline-offset:0}
.gate-form > .primary {
  min-height:50px; border-radius:10px; font-size:1rem;
  box-shadow:0 8px 19px -10px var(--accent-fill);
}
.gate-form > .notice {font-size:14px}
@media (max-width:760px) {
  .gate {
    justify-items:center;
    padding:max(24px,env(safe-area-inset-top)) max(18px,env(safe-area-inset-right)) max(24px,env(safe-area-inset-bottom)) max(18px,env(safe-area-inset-left));
  }
  .gate-art {object-position:32% top}
  .gate::before {background:#17314812}
  .gate-form {gap:20px; border-radius:18px}
  .gate-form h1 {font-size:clamp(20px,5.15vw,24px)}
  .gate-mark {width:40px; height:40px}
}

.masthead {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  min-height: 60px;
  padding: 9px clamp(16px,2.25vw,36px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.identity,
.toolbar,
.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
}

.identity {min-width:0}
.identity img {flex:none}
.identity strong {font-size:16px}
.toolbar {justify-content:flex-end}
.active-account {
  overflow: hidden;
  max-width: 26vw;
  color: var(--muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.toolbar button {min-height:36px}

.shell {
  display: grid;
  grid-template-columns: 192px minmax(0,1fr);
  min-height: calc(100vh - 60px);
}

.rail {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 19px 12px;
  background: var(--shell);
  border-right: 1px solid var(--line);
}

.rail button {
  min-height: 44px;
  padding-inline: 12px;
  background: transparent;
  border-color: transparent;
  font-weight: 600;
  text-align: left;
}

.rail button[aria-current="page"] {
  color: var(--accent);
  background: var(--selected);
}

.workspace {
  width: 100%;
  max-width: 1440px;
  min-width: 0;
  padding: clamp(18px,2.6vw,36px) clamp(14px,3vw,44px) 42px;
}

.page-heading,
.section-head,
.row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.page-heading {
  min-height: 52px;
  margin-bottom: 18px;
}

.page-heading h1 {font-size:clamp(22px,2.5vw,26px); letter-spacing:0}
.page-heading .secondary {margin-top:4px; font-size:14px}
.workspace > .notice {margin-bottom:14px}
#page-body,
.project-detail {
  display: grid;
  gap: 16px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(min(100%,190px),1fr));
  gap: 14px;
}

.tile,
.panel {
  min-width: 0;
  padding: clamp(14px,1.7vw,22px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.tile {display:grid; gap:6px; align-content:start}
.metric {font-size:28px; line-height:1.2; font-variant-numeric:tabular-nums}
.metric-label {color:var(--muted); font-size:13px}
.tile .metric-label {font-weight:600}
.tile .health-value {display:grid; align-content:center; min-height:34px; font-weight:650}
.section-head {margin-bottom:14px}
.section-head h2 {font-size:17px}

.stack {display:grid; gap:10px}
.item {
  min-width: 0;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-wrap: anywhere;
}
.item .fine {margin-top:2px}
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-inline-end: 7px;
  background: var(--muted);
  border-radius: 50%;
}
.dot.good {background:var(--good)}
.dot.bad {background:var(--bad)}
.dot.wait {background:var(--mid)}
.status-label {display:inline-flex; align-items:center; white-space:nowrap; font-size:13px}
.badge {
  display: inline-block;
  padding: 2px 7px;
  color: var(--accent);
  background: var(--selected);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.project-view {
  display: grid;
  align-items: start;
  gap: 16px;
}

@media (min-width:1120px) {
  .project-view.has-project {grid-template-columns:minmax(230px, .85fr) minmax(0,2.2fr)}
}

.project-list {display:grid; gap:6px}
.project-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
}
.project-entry strong {min-width:0; overflow-wrap:anywhere}
.project-entry:hover {background:var(--hover)}
.project-entry.selected {color:var(--accent); background:var(--selected)}
.project-entry button {min-height:36px}

.version-states,
.operations-grid,
.two-cols {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 12px;
}

.version-state,
.operations-group {
  min-width: 0;
  padding: 12px 14px;
  background: var(--raised);
  border-radius: 9px;
}

.version-state {display:grid; gap:4px}
.version-state strong {font-variant-numeric:tabular-nums}
.version-state.draft {border-inline-start:2px solid var(--mid)}
.version-state.published {border-inline-start:2px solid var(--accent-fill)}
.project-actions {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.record-controls {
  display: flex;
  align-items: end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 12px;
}

.record-entry {
  display: grid;
  grid-template-columns: minmax(0,1fr) max-content;
  align-items: center;
  gap: 8px 14px;
}
.record-entry strong {overflow-wrap:anywhere}
.record-type {color:var(--muted); font-size:13px}

.account-list {display:grid; gap:0}
.account-columns,
.account-entry {
  display: grid;
  grid-template-columns: minmax(145px,1.1fr) minmax(170px,2fr) 80px 62px;
  align-items: center;
  gap: 10px 14px;
  padding: 10px 12px;
}
.account-columns {
  color: var(--muted);
  background: var(--raised);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}
.account-entry {
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  min-height: 58px;
}
.account-entry:last-child {border-bottom:0}
.account-identity {display:flex; align-items:center; flex-wrap:wrap; gap:5px 8px}
.account-identity strong {min-width:0; overflow-wrap:anywhere}
.account-projects {margin:0}
.account-status {grid-column:3}
.account-actions {grid-column:4}
.account-actions button {min-height:34px; padding:4px 9px; white-space:nowrap}

.kv {
  display: grid;
  grid-template-columns: minmax(90px,1fr) minmax(0,1.7fr);
  align-items: baseline;
  gap: 8px 12px;
}
.kv dt {color:var(--muted); font-size:13px}
.kv dd {margin:0; overflow-wrap:anywhere}
.technical-values dd {font-family:var(--mono); font-size:13px}
.operations-group h3 {margin-bottom:10px; font-size:14px}
.plan-result {margin-top:12px}
.field-group {align-self:start; min-width:0}
.plan-form {
  display: grid;
  align-items: end;
  grid-template-columns: minmax(100px,1fr) max-content;
  gap: 10px;
  max-width: 450px;
  margin: 12px 0 0;
}
.indented-message {max-width:72ch}
.inline-note {margin-top:10px}
.log {padding-left:22px; margin:8px 0 0; color:var(--muted)}

dialog {
  width: min(580px,calc(100% - 28px));
  max-height: calc(100vh - 28px);
  max-height: calc(100dvh - 28px);
  padding: 0;
  overflow: auto;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--strong);
  border-radius: 16px;
  box-shadow: 0 22px 70px #06162d65;
}
dialog::backdrop {background:#07152890}
.dialog-head {
  position: sticky;
  z-index: 1;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.dialog-head h2 {min-width:0; overflow-wrap:anywhere; font-size:18px}
.dialog-head button {flex:none; min-height:36px}
#dialog-content {padding:16px 18px 18px}
#dialog-note {margin:12px 18px 0}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.grants {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.grants legend {padding:0 4px; color:var(--muted)}
.grant {display:grid; grid-template-columns:minmax(0,1fr) minmax(110px,155px); align-items:center; gap:8px}
.grant label {display:flex; align-items:center; gap:6px; overflow-wrap:anywhere}
.grant input {flex:none}

.import-summary {display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px}
.import-summary .version-state {padding:8px 10px}
.search {width:min(100%,360px)}
.empty {padding:12px 0; color:var(--muted)}

@media (max-width:900px) {
  .account-columns,
  .account-entry {grid-template-columns:minmax(116px,1fr) minmax(120px,1.65fr) 70px 54px; gap:8px}
  .operations-grid {grid-template-columns:1fr}
}

@media (max-width:760px) {
  .masthead {
    position: static;
    flex-wrap: wrap;
    gap: 8px 12px;
    min-height: 54px;
    padding: 8px 12px;
  }
  .identity {gap:6px}
  .identity img {width:28px; height:28px}
  .identity strong {font-size:14px}
  .toolbar {margin-inline-start:auto; gap:6px}
  .active-account {max-width:24vw; font-size:12px}
  .shell {grid-template-columns:minmax(0,1fr)}
  .rail {
    display: grid;
    grid-template-columns: repeat(4,minmax(0,1fr));
    padding: 6px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .rail button {text-align:center; min-height:42px; padding:4px}
  .workspace {padding:16px 12px 26px}
  .cards {grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px}
  .tile:last-child {grid-column:1 / -1}
  .tile .health-value {min-height:0}
  .account-columns {display:none}
  .account-list {gap:8px}
  .account-entry {
    grid-template-columns: minmax(0,1fr) max-content;
    grid-template-areas: "identity status" "projects projects" "actions actions";
    gap: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
  }
  .account-entry:last-child {border-bottom:1px solid var(--line)}
  .account-identity {grid-area:identity}
  .account-status {grid-area:status; justify-self:end}
  .account-projects {grid-area:projects}
  .account-actions {grid-area:actions; justify-self:end}
  .account-actions:empty {display:none}
}

@media (max-width:430px) {
  .two-cols {grid-template-columns:1fr}
  .version-states {gap:8px}
  .version-state {padding:8px 9px}
  .plan-form {grid-template-columns:1fr}
  .plan-form button {justify-self:start}
  .kv {grid-template-columns:minmax(75px,.9fr) minmax(0,1.8fr); gap:7px 8px}
  .technical-values dd {font-size:12px}
  .import-summary .metric-label {font-size:12px}
  .record-entry {grid-template-columns:minmax(0,1fr)}
}
