:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --line: #d7dde5;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --danger: #b42318;
  --code-bg: #111827;
  --code-text: #e5e7eb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  min-height: 40px;
}

button {
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  padding: 0 16px;
}

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

a {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  display: inline-flex;
  padding: 0 14px;
  text-decoration: none;
}

a:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.app-shell {
  margin: 0 auto;
  max-width: 1280px;
  padding: 32px 20px;
}

.hidden {
  display: none !important;
}

.login-panel,
.tool-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.07);
}

.login-panel {
  display: grid;
  gap: 28px;
  grid-template-columns: 1.2fr 0.8fr;
  margin: 10vh auto 0;
  max-width: 900px;
  padding: 40px;
}

.eyebrow {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 8px;
  text-transform: uppercase;
}

h1 {
  font-size: 34px;
  line-height: 1.15;
  margin: 0 0 12px;
}

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

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

.error-text {
  color: var(--danger);
  min-height: 22px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

label {
  font-weight: 700;
}

input[type="password"],
input[type="text"],
input[type="url"],
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  outline: none;
  width: 100%;
}

input[type="password"],
input[type="text"],
select {
  min-height: 44px;
  padding: 0 12px;
}

input[type="url"] {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  line-height: 1.55;
  min-height: 320px;
  padding: 14px;
  resize: vertical;
  white-space: pre;
}

textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.topbar {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
}

.topbar h1 {
  font-size: 26px;
  margin: 0;
}

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

.user-badge {
  color: var(--muted);
  font-size: 13px;
}

.workspace {
  padding: 24px;
}

.mode-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.mode-btn {
  background: #e7edf2;
  color: var(--text);
}

.mode-btn.active {
  background: var(--accent);
  color: #fff;
}

.input-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr 1fr;
}

.anthropic-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr 1fr;
}

.field-group {
  min-width: 0;
}

.field-head {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 10px;
}

input[type="file"] {
  color: var(--muted);
  max-width: 240px;
}

.check-row {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
}

.check-row input {
  flex: 0 0 auto;
}

.check-row span {
  color: var(--text);
  font-weight: 500;
  overflow-wrap: anywhere;
}

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

.action-row,
.script-actions,
.meta-strip,
.tabs {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.action-row {
  margin: 18px 0;
}

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

.meta-strip {
  background: #eef7f5;
  border: 1px solid #b9ddd6;
  border-radius: 6px;
  color: #164e46;
  margin-bottom: 14px;
  padding: 10px 12px;
}

.tabs {
  margin-bottom: 12px;
}

.tab {
  background: #e7edf2;
  color: var(--text);
}

.tab.active {
  background: var(--accent);
  color: #fff;
}

.script-actions {
  margin-bottom: 12px;
}

#scriptOutput,
#configEditor {
  background: var(--code-bg);
  color: var(--code-text);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  min-height: 430px;
}

.admin-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: 320px 1fr;
  padding: 24px;
}

.status-box,
.user-manager,
.config-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.user-manager,
.config-editor {
  grid-column: 2;
}

.user-table-wrap {
  overflow-x: auto;
}

.user-table {
  border-collapse: collapse;
  margin: 14px 0;
  min-width: 680px;
  width: 100%;
}

.user-table th,
.user-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: middle;
}

.user-table th {
  color: var(--muted);
  font-size: 13px;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inline-actions button,
.form-actions button {
  min-height: 34px;
  padding: 0 12px;
}

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

.user-form .check-row,
.user-form .form-actions {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

dl {
  display: grid;
  gap: 12px;
  margin: 18px 0 0;
}

dl div {
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

dt {
  color: var(--muted);
  font-size: 13px;
}

dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

@media (max-width: 820px) {
  .app-shell {
    padding: 16px;
  }

  .login-panel,
  .input-grid,
  .anthropic-grid,
  .user-form,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .user-manager,
  .config-editor {
    grid-column: auto;
  }

  .login-panel {
    margin-top: 4vh;
    padding: 24px;
  }

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

  h1 {
    font-size: 28px;
  }

  .workspace,
  .admin-grid {
    padding: 16px;
  }

  input[type="file"] {
    max-width: 100%;
  }
}
