:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-strong: #eef2f5;
  --line: #d5dde5;
  --line-strong: #b8c3cf;
  --text: #16212d;
  --muted: #5b6876;
  --primary: #0f766e;
  --primary-strong: #115e59;
  --primary-soft: #dff4f1;
  --danger: #b42318;
  --warning: #926200;
  --shadow: 0 18px 50px rgba(22, 33, 45, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 720;
}

h2 {
  font-size: 16px;
  font-weight: 720;
}

h3 {
  font-size: 14px;
  font-weight: 720;
}

h4 {
  font-size: 14px;
  font-weight: 720;
}

a {
  color: var(--primary-strong);
  font-weight: 720;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.session-strip,
.action-row,
.field-row,
.section-heading,
.lens-actions,
.meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.session-strip {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.muted {
  color: var(--muted);
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 20px;
}

.auth-grid,
.app-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.75fr);
  gap: 18px;
}

.app-grid {
  align-items: start;
}

.wide {
  grid-column: 1 / -1;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field-row {
  align-items: flex-start;
}

.field-row > label {
  flex: 1 1 0;
}

.field-row.tight {
  align-items: center;
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: #2b3948;
  font-weight: 640;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.checkbox-field {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}

.checkbox-field input {
  width: 16px;
  height: 16px;
}

.button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 13px;
  font-weight: 720;
}

.button.primary {
  background: var(--primary);
  color: #ffffff;
}

.button.primary:hover {
  background: var(--primary-strong);
}

.button.secondary {
  border-color: var(--line-strong);
  background: #ffffff;
  color: var(--text);
}

.button.secondary:hover {
  background: var(--surface-strong);
}

.button.warning {
  border-color: #f5c362;
  background: #fff5dc;
  color: var(--warning);
}

.button.danger {
  border-color: #f4b0aa;
  background: #fff1f0;
  color: var(--danger);
}

.status-pill,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: #334155;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 720;
  white-space: nowrap;
}

.tag.public {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.tag.private {
  background: #e7ecf2;
  color: #465568;
}

.tag.custom {
  background: #f2e8ff;
  color: #6941a8;
}

.search-input {
  max-width: 260px;
}

.section-heading {
  justify-content: space-between;
}

.result-box {
  min-height: 112px;
  max-height: 300px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: #263241;
  padding: 12px;
  white-space: pre-wrap;
}

.workflow-panel {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.calibration-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 680px;
  overflow: auto;
}

.calibration-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
}

.calibration-item header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.calibration-summary {
  color: #263241;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f8fafc;
  color: #465568;
  font-size: 12px;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.lens-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 240px;
}

.lens-title strong {
  font-size: 14px;
}

.lens-actions {
  flex-wrap: wrap;
}

.button.small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

.list-view {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 520px;
  overflow: auto;
}

.list-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
}

.list-item header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.list-item h3 {
  margin: 0;
  font-size: 14px;
}

.meta-row {
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(420px, calc(100vw - 48px));
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #111827;
  color: #ffffff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

@media (max-width: 900px) {
  .shell {
    padding: 18px;
  }

  .topbar,
  .section-heading,
  .field-row,
  .auth-grid,
  .app-grid {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .session-strip,
  .action-row {
    justify-content: flex-start;
  }

  .search-input {
    max-width: none;
  }
}
