:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #eef3f6;
  --border: #d8dee5;
  --text: #1d252d;
  --muted: #64717f;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --danger: #b42318;
  --warning: #9a6700;
  --code-bg: #14213d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  min-height: 36px;
  padding: 0 14px;
  cursor: pointer;
}

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

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

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

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

button.link-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
  min-height: auto;
}

.icon-button {
  inline-size: 34px;
  block-size: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px clamp(18px, 4vw, 52px);
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.topbar h1,
.login-panel h1,
.dialog-title h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(24px, 3vw, 34px);
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 14px clamp(18px, 4vw, 52px);
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.tabs button {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
  white-space: nowrap;
}

.tabs button.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.workspace {
  padding: 22px clamp(18px, 4vw, 52px) 60px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.section-head h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

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

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
}

table {
  inline-size: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

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

th {
  background: var(--surface-soft);
  color: #34404b;
  font-weight: 650;
}

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

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

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: #384754;
  font-size: 12px;
  white-space: nowrap;
}

.badge.ok {
  background: #def7ec;
  color: #03543f;
}

.badge.err {
  background: #fde8e8;
  color: var(--danger);
}

.badge.warn {
  background: #fef3c7;
  color: var(--warning);
}

dialog {
  border: 0;
  border-radius: 8px;
  inline-size: min(920px, calc(100vw - 28px));
  max-height: calc(100vh - 48px);
  padding: 0;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.24);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.dialog-shell {
  margin: 0;
  background: #fff;
}

.dialog-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

#dialogBody {
  padding: 20px;
  overflow: auto;
  max-height: calc(100vh - 140px);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #34404b;
  font-size: 13px;
  font-weight: 600;
}

input,
textarea,
select {
  inline-size: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  min-height: 38px;
  padding: 8px 10px;
  font-weight: 400;
}

textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.45;
}

textarea.code {
  min-height: 360px;
  background: var(--code-bg);
  color: #f8fafc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.span-2 {
  grid-column: 1 / -1;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}

.checkbox-line input {
  inline-size: 18px;
  min-height: 18px;
}

.selection-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 2px;
}

.selection-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px;
  background: #fff;
}

.selection-check {
  display: flex;
  align-items: center;
  grid-template-columns: none;
  gap: 8px;
  min-width: 0;
  font-weight: 500;
}

.selection-check span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selection-check input {
  inline-size: 18px;
  min-height: 18px;
}

.order-input {
  inline-size: 72px;
  min-height: 32px;
  padding: 5px 8px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(135deg, #eef3f6 0%, #f7f7f2 45%, #edf7f4 100%);
}

.login-panel {
  inline-size: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px;
}

.login-panel h1 {
  margin-bottom: 22px;
  font-size: 30px;
}

.login-form {
  display: grid;
  gap: 16px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-inline-size: min(420px, calc(100vw - 44px));
  padding: 12px 14px;
  border-radius: 7px;
  background: #172033;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.24);
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}
