:root {
  color-scheme: light;
  --sidebar: #111827;
  --sidebar-muted: #8f9bad;
  --sidebar-hover: #1b2536;
  --blue: #4b70e2;
  --blue-dark: #3658c5;
  --blue-soft: #eef3ff;
  --page: #f3f6fa;
  --surface: #ffffff;
  --ink: #172033;
  --muted: #718096;
  --line: #e3e8ef;
  --field-line: #ccd4df;
  --success: #18794e;
  --success-bg: #eaf7f0;
  --danger: #b42318;
  --danger-bg: #fff0ee;
  --shadow: 0 3px 14px rgba(23, 32, 51, 0.05);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: 0; }
a { color: inherit; }
button, input, select { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

.admin-body { min-height: 100vh; background: var(--page); }
.sidebar-toggle { position: fixed; opacity: 0; pointer-events: none; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: 252px;
  overflow-y: auto;
  background: var(--sidebar);
  color: #fff;
  border-right: 1px solid rgba(255,255,255,.06);
}
.platform-brand {
  height: 86px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  text-decoration: none;
}
.brand-mark {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: #dce6ff;
  background: #1d2a4a;
  border: 1px solid #2f4275;
  font-size: 13px;
  font-weight: 800;
}
.platform-brand strong { display: block; font-size: 16px; }
.platform-brand small { display: block; margin-top: 2px; color: var(--sidebar-muted); font-size: 12px; }
.sidebar-nav { padding: 18px 12px 30px; }
.nav-item, .nav-child {
  display: flex;
  align-items: center;
  min-width: 0;
  text-decoration: none;
}
.nav-item {
  width: 100%;
  min-height: 46px;
  gap: 11px;
  padding: 0 14px;
  margin-bottom: 6px;
  border-radius: 6px;
  color: #c8d0dc;
  font-weight: 650;
}
.nav-section-toggle { position: absolute; opacity: 0; pointer-events: none; }
.nav-group-toggle { border: 0; text-align: left; background: transparent; cursor: pointer; }
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--blue); color: #fff; }
.nav-icon { width: 18px; text-align: center; font-size: 16px; }
.nav-count { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; display: inline-flex; align-items: center; justify-content: center; border-radius: 11px; background: rgba(255,255,255,.12); font-size: 12px; }
.nav-chevron { margin-left: 2px; color: #8995a7; font-size: 20px; line-height: 1; transition: transform .18s ease; }
.nav-section-toggle:checked + .nav-group-toggle .nav-chevron { transform: rotate(90deg); }
.nav-children { display: none; padding: 2px 0 10px 20px; }
.nav-section-toggle:checked ~ .nav-children { display: block; }
.nav-child {
  min-height: 38px;
  gap: 10px;
  padding: 0 12px;
  border-radius: 5px;
  color: var(--sidebar-muted);
}
.nav-child:hover, .nav-child.active { color: #fff; background: rgba(255,255,255,.06); }
.nav-child span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-child-dot { width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; background: #667085; }
.nav-child.active .nav-child-dot { background: #8facff; }
.nav-add { color: #aebfff; }

.admin-shell { min-height: 100vh; margin-left: 252px; }
.admin-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 68px;
  display: flex;
  align-items: center;
  padding: 0 30px;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.header-title { min-width: 0; }
.header-title strong { display: block; font-size: 18px; line-height: 1.25; }
.header-title span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 22px; color: #5e6b7d; }
.header-actions a { text-decoration: none; }
.header-actions a:hover { color: var(--blue-dark); }
.header-actions form { margin: 0; }
.account-name { padding: 7px 12px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: #fff; }
.text-button { padding: 0; border: 0; background: transparent; color: #5e6b7d; cursor: pointer; }
.text-button:hover { color: var(--danger); }
.mobile-menu-button { display: none; margin-right: 14px; font-size: 21px; cursor: pointer; }
.sidebar-backdrop { display: none; }
.content-area { padding: 26px 30px 50px; }

.button {
  min-height: 38px;
  padding: 8px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 5px;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}
.button:disabled { opacity: .55; cursor: not-allowed; }
.button-primary { background: var(--blue); color: #fff; }
.button-primary:hover { background: var(--blue-dark); }
.button-secondary { background: #fff; color: #42526a; border-color: #cfd7e3; }
.button-secondary:hover { color: var(--blue-dark); border-color: #9eb2e8; background: var(--blue-soft); }
.button-quiet { background: #fff; color: #42526a; border-color: var(--line); }
.button-block { width: 100%; }

.content-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
}
.panel-heading {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.panel-heading h2, .section-heading h2, .form-intro h2 { margin: 0; font-size: 16px; }
.panel-heading p, .section-heading p, .form-intro p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.dashboard-metric { min-height: 118px; padding: 22px; background: #fff; border: 1px solid var(--line); border-radius: 7px; box-shadow: var(--shadow); }
.dashboard-metric span { display: block; color: var(--muted); font-weight: 600; }
.dashboard-metric strong { display: block; margin-top: 12px; font-size: 30px; line-height: 1; }
.dashboard-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.compact-list { min-height: 240px; }
.compact-row { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 20px; border-bottom: 1px solid #edf0f4; text-decoration: none; }
.compact-row:last-child { border-bottom: 0; }
.compact-row:hover { background: #f8faff; }
.compact-row strong, .compact-row span { display: block; }
.compact-row div > span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.row-meta { flex: 0 0 auto; text-align: right; }

.data-table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 980px; }
.data-table th { height: 48px; padding: 0 16px; text-align: left; color: #667085; background: #f8fafc; border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 700; white-space: nowrap; }
.data-table td { height: 62px; padding: 10px 16px; border-bottom: 1px solid #edf0f4; color: #42526a; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fafbfe; }
.data-table code { color: #44516a; font-size: 12px; }
.table-link { color: var(--blue-dark); font-weight: 650; text-decoration: none; }

.notice { margin: 0 0 16px; padding: 12px 15px; border: 1px solid; border-radius: 5px; }
.notice-success { color: var(--success); background: var(--success-bg); border-color: #b7dfc9; }
.notice-error { color: var(--danger); background: var(--danger-bg); border-color: #f0b8b2; }
.hidden { display: none !important; }
.empty-state { min-height: 140px; display: flex; align-items: center; justify-content: center; padding: 30px; color: #98a2b3; }

.stack-form { display: grid; gap: 18px; padding: 24px; }
.narrow-form { max-width: 720px; }
.stack-form label, .field, .app-name-form label { display: grid; gap: 7px; color: #344054; font-weight: 650; }
.stack-form label small { color: var(--muted); font-weight: 400; }
.stack-form input, .field input, .field select, .app-name-form input {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border: 1px solid var(--field-line);
  border-radius: 4px;
  color: var(--ink);
  background: #fff;
}
.stack-form input:focus, .field input:focus, .field select:focus, .app-name-form input:focus { outline: 3px solid rgba(75,112,226,.12); border-color: var(--blue); }
input[readonly] { color: #667085; background: #f6f8fa; }
.form-intro { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }

.app-profile-panel { margin-bottom: 16px; }
.app-name-form { display: grid; grid-template-columns: minmax(180px, 1.1fr) minmax(160px, .8fr) minmax(220px, 1fr) auto; align-items: end; gap: 14px; padding: 18px 20px 22px; }
.app-name-form .button { height: 40px; }
.summary-strip { display: grid; grid-template-columns: 140px 140px 140px minmax(300px, 1fr); gap: 1px; margin-bottom: 16px; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: var(--line); box-shadow: var(--shadow); }
.summary-strip > div { min-width: 0; padding: 16px 18px; background: #fff; }
.summary-strip span { display: block; color: var(--muted); font-size: 12px; }
.summary-strip strong { display: block; margin-top: 6px; font-size: 22px; }
.summary-code code { display: block; margin-top: 7px; overflow-wrap: anywhere; font-size: 12px; }

.editor-workspace { overflow: hidden; }
.workspace-toolbar { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 0 20px; border-bottom: 1px solid var(--line); }
.workspace-actions { display: flex; gap: 9px; }
.workspace-actions form, .release-row form { margin: 0; }
.tabs { display: flex; align-self: stretch; gap: 24px; }
.tab { position: relative; padding: 0 3px; border: 0; background: transparent; color: #667085; font-weight: 700; cursor: pointer; }
.tab::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: transparent; }
.tab.active { color: var(--blue-dark); }
.tab.active::after { background: var(--blue); }
.tab-panel { display: none; padding: 20px; }
.tab-panel.active { display: block; }
.section-heading { min-height: 52px; display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.section-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.editor-list { display: grid; gap: 14px; }
.editor-card { padding: 18px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.editor-card-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 15px; padding-bottom: 13px; border-bottom: 1px solid #edf0f4; }
.editor-card-header strong { font-size: 15px; }
.card-actions { display: flex; gap: 8px; }
.icon-action { min-width: 58px; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 4px; background: #fff; cursor: pointer; }
.icon-action.danger { color: var(--danger); }
.field-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field.wide { grid-column: 1 / -1; }
.field.checkbox { min-height: 40px; display: flex; align-items: center; gap: 9px; }
.field.checkbox input { width: 18px; height: 18px; }
.release-list { display: grid; gap: 10px; }
.release-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 5px; }
.release-row > div { min-width: 0; display: grid; gap: 3px; }
.release-row span { color: var(--muted); }
.release-row code { overflow-wrap: anywhere; font-size: 12px; }
.error-panel { max-width: 620px; padding: 26px; }
.error-panel h2 { margin-top: 0; }

.modal-open { overflow: hidden; }
.modal-layer { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(15,23,42,.48); }
.modal-panel { width: min(760px, 100%); max-height: calc(100vh - 48px); overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 22px 70px rgba(15,23,42,.22); }
.modal-heading { min-height: 78px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 20px 22px 16px; border-bottom: 1px solid var(--line); }
.modal-heading h2 { margin: 0; font-size: 17px; }
.modal-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.modal-close { flex: 0 0 34px; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: #667085; font-size: 23px; line-height: 1; cursor: pointer; }
.json-import-field { display: grid; gap: 8px; padding: 20px 22px 0; color: #344054; font-weight: 650; }
.json-import-field textarea { width: 100%; min-height: 330px; resize: vertical; padding: 13px; border: 1px solid var(--field-line); border-radius: 4px; color: var(--ink); background: #fff; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; letter-spacing: 0; }
.json-import-field textarea:focus { outline: 3px solid rgba(75,112,226,.12); border-color: var(--blue); }
.modal-panel > .notice { margin: 14px 22px 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 22px 22px; }

.login-body { min-height: 100vh; background: #edf1f7; }
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 30px 18px; }
.login-panel { width: min(420px, 100%); padding: 30px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 18px 55px rgba(23,32,51,.12); }
.login-brand { display: flex; align-items: center; gap: 12px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.login-brand strong, .login-brand small { display: block; }
.login-brand strong { font-size: 16px; }
.login-brand small { margin-top: 2px; color: var(--muted); }
.login-panel h1 { margin: 24px 0 5px; }
.login-panel > p { margin: 0; color: var(--muted); }
.login-panel .stack-form { padding: 0; margin-top: 22px; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-columns { grid-template-columns: 1fr; }
  .app-name-form { grid-template-columns: 1fr 1fr; }
  .summary-strip { grid-template-columns: repeat(3, 1fr); }
  .summary-code { grid-column: 1 / -1; }
  .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .admin-shell { margin-left: 0; }
  .sidebar-toggle:checked ~ .sidebar { transform: translateX(0); }
  .sidebar-toggle:checked ~ .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(15,23,42,.42); }
  .mobile-menu-button { display: block; }
  .admin-header { padding: 0 16px; }
  .header-actions { gap: 12px; }
  .account-name { display: none; }
  .content-area { padding: 18px 14px 36px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .app-name-form, .field-grid, .field-grid.two { grid-template-columns: 1fr; }
  .summary-strip { grid-template-columns: 1fr 1fr; }
  .summary-code { grid-column: 1 / -1; }
  .workspace-toolbar { align-items: stretch; flex-direction: column; padding: 0 16px 15px; }
  .tabs { min-height: 54px; width: 100%; justify-content: space-between; gap: 8px; overflow-x: auto; }
  .workspace-actions { justify-content: flex-end; flex-wrap: wrap; }
  .tab-panel { padding: 16px; }
  .section-heading { flex-direction: column; }
  .section-actions { width: 100%; }
  .release-row { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 520px) {
  .header-title span { max-width: 190px; }
  .header-actions a { display: none; }
  .metric-grid { grid-template-columns: 1fr; }
  .dashboard-metric { min-height: 96px; }
  .compact-row { align-items: flex-start; flex-direction: column; }
  .row-meta { text-align: left; }
  .summary-strip { grid-template-columns: 1fr; }
  .summary-code { grid-column: auto; }
  .workspace-actions .button { flex: 1; }
  .section-actions .button { flex: 1; }
  .modal-layer { padding: 12px; }
  .modal-panel { max-height: calc(100vh - 24px); }
  .json-import-field textarea { min-height: 280px; }
}
