:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #607080;
  --line: #d9e0e7;
  --accent: #06c755;
  --danger: #b42318;
  --blue: #2563eb;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: Arial, "Noto Sans Thai", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.panel, .content section.page {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}

.panel {
  width: min(420px, calc(100vw - 32px));
}

#app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

aside {
  background: #101820;
  color: #fff;
  padding: 20px;
}

aside h2 {
  font-size: 18px;
  margin: 0 0 24px;
}

nav {
  display: grid;
  gap: 6px;
}

nav button, .ghost {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: #d9e0e7;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
}

nav button.active, nav button:hover, .ghost:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
}

.content {
  padding: 24px;
  min-width: 0;
}

header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 18px;
}

h1, h3 { margin: 0 0 14px; }
#status { color: var(--muted); margin: 0; }
.page { display: none; }
.page.active { display: block; }

.help-card {
  border: 1px solid #cfe8dc;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #f4fbf7;
  padding: 14px 16px;
  margin-bottom: 18px;
}

.help-card h3 {
  margin-bottom: 8px;
}

.help-card p {
  color: #314151;
  margin: 0 0 8px;
  line-height: 1.5;
}

.help-card p:last-child {
  margin-bottom: 0;
}

.help-card ol {
  margin: 8px 0 0 20px;
  padding: 0;
  color: #314151;
  line-height: 1.55;
}

code {
  background: #e8eef5;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.field-help {
  color: #7a8896;
  font-size: 12px;
  line-height: 1.35;
}

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

input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  color: var(--ink);
  background: #fff;
  min-width: 0;
}

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
}

button.secondary { background: var(--blue); }
button.danger { background: var(--danger); }
.error { color: var(--danger); min-height: 20px; }
.hint { color: var(--muted); font-size: 13px; }

.grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 16px;
  align-items: start;
}

.compact-form {
  margin-bottom: 24px;
}

.grid-form .check {
  grid-template-columns: auto 1fr;
  align-items: center;
  color: var(--ink);
}

.grid-form .check input { width: 18px; height: 18px; }
fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 12px;
}

.flow label, fieldset, textarea, #requestPreview, #testOutput {
  grid-column: 1 / -1;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 16px;
}

.inline-form input, .inline-form select {
  min-width: 160px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.metric strong {
  display: block;
  font-size: 26px;
  margin-top: 8px;
}

.ops-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.ops-panel {
  min-width: 0;
}

.ops-panel h3 {
  margin: 0 0 10px;
}

.status-list {
  display: grid;
  gap: 8px;
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fff;
}

.status-row strong {
  font-size: 18px;
}

.compact-table {
  margin-bottom: 0;
}

.compact-table table {
  min-width: 620px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 24px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

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

th { background: #eef2f6; color: #344454; }
pre {
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101820;
  color: #e8eef5;
  padding: 16px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 40px));
  background: #101820;
  color: #fff;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 14px 16px;
  box-shadow: 0 12px 30px rgba(16, 24, 32, .22);
}

.toast.error-toast {
  border-left-color: var(--danger);
}

@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; }
  aside { position: static; }
  .grid-form { grid-template-columns: 1fr; }
  .ops-grid { grid-template-columns: 1fr; }
  header { display: block; }
}
