:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --line: #d9e0e3;
  --text: #152026;
  --muted: #64727a;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  --ok: #16794c;
  --warn: #a15c07;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  padding: 9px 12px;
  cursor: pointer;
}

button:disabled {
  opacity: 0.68;
  cursor: wait;
}

a.download-link {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  padding: 9px 12px;
  text-decoration: none;
}

button.secondary {
  background: #fff;
  color: var(--accent-dark);
}

button.secondary-action {
  background: #fff;
  color: var(--accent-dark);
}

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

button.action-button {
  min-width: 96px;
  min-height: 42px;
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 700;
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(180, 35, 24, 0.18);
}

button.big-danger {
  width: min(360px, 100%);
  min-height: 52px;
  padding: 12px 18px;
  font-size: 16px;
  font-weight: 700;
  border-radius: 8px;
}

button.small-action {
  min-width: 72px;
  min-height: 38px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 8px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
}

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

.hidden {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.12) 1px, transparent 1px),
    linear-gradient(rgba(15, 118, 110, 0.08) 1px, transparent 1px),
    var(--bg);
  background-size: 42px 42px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(21, 32, 38, 0.12);
}

.login-panel h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.sidebar {
  background: #102025;
  color: #e7eff1;
  padding: 18px;
}

.brand-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-row span {
  display: block;
  color: #9fb0b6;
  font-size: 12px;
  margin-top: 2px;
}

nav {
  display: grid;
  gap: 6px;
  margin-top: 18px;
}

nav button {
  text-align: left;
  background: transparent;
  border-color: transparent;
  color: #dbe6e9;
}

nav button.active,
nav button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.14);
}

.workspace {
  min-width: 0;
  padding: 22px;
}

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

.topbar h2 {
  margin: 0;
  font-size: 24px;
}

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
}

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

.view {
  display: none;
}

.active-view {
  display: grid;
  gap: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.panel h3 {
  margin: 0 0 14px;
  font-size: 17px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
}

.metric strong {
  display: block;
  font-size: 28px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.65fr);
  gap: 16px;
}

.grid-form,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 10px;
  align-items: end;
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) 120px 100px;
  gap: 10px;
  align-items: end;
}

.stack-form {
  display: grid;
  gap: 10px;
}

.inline-fields {
  display: grid;
  grid-template-columns: 180px 140px;
  gap: 10px;
}

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

.checkbox input {
  width: auto;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

th {
  color: var(--muted);
  font-weight: 600;
  background: #f9fbfb;
}

.actions-head,
.actions-cell {
  width: 260px;
  min-width: 260px;
}

.actions-cell {
  background: #fffafa;
}

.action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 240px;
}

.table-input {
  min-width: 180px;
  padding: 7px 8px;
  font-size: 13px;
}

.key-code {
  display: inline-block;
  min-width: 88px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f9fbfb;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
}

.danger-zone {
  border-color: rgba(180, 35, 24, 0.32);
  background: #fffafa;
}

.status {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 999px;
  background: #e8eef0;
  color: var(--text);
  font-size: 12px;
}

.status.done,
.status.answered,
.status.ok {
  background: #dff4e9;
  color: var(--ok);
}

.status.failed,
.status.error {
  background: #fde5e1;
  color: var(--danger);
}

.status.pending,
.status.assigned {
  background: #fff2d7;
  color: var(--warn);
}

.message {
  color: var(--muted);
  word-break: break-all;
}

.action-message {
  min-height: 24px;
  margin: 10px 0;
  color: var(--ok);
  font-weight: 700;
}

.action-message.error {
  color: var(--danger);
}

.settings-preview {
  display: grid;
  grid-template-columns: repeat(3, minmax(90px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.settings-preview div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfc;
}

.settings-preview strong {
  display: block;
  font-size: 24px;
}

.settings-preview span {
  color: var(--muted);
  font-size: 13px;
}

pre {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f9fbfb;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  nav {
    grid-template-columns: repeat(2, 1fr);
  }

  .topbar,
  .split {
    grid-template-columns: 1fr;
    display: grid;
  }

  .metrics,
  .grid-form,
  .settings-grid,
  .settings-row,
  .inline-fields {
    grid-template-columns: 1fr;
  }
}
