:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-soft: #edf3f5;
  --line: #d8e2e5;
  --line-strong: #b4c6cc;
  --text: #16252b;
  --muted: #65777f;
  --accent: #195b64;
  --accent-strong: #0f3f47;
  --danger: #a33b3b;
  --success: #216b4f;
  --shadow: 0 18px 48px rgba(22, 37, 43, 0.08);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: Inter, "Avenir Next", "Helvetica Neue", "PingFang SC", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  font-family: var(--sans);
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(25, 91, 100, 0.08), transparent 240px),
    var(--bg);
}

button,
input,
textarea,
a.button {
  font: inherit;
}

button {
  border: 0;
}

.app {
  width: min(1380px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

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

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.7rem, 3vw, 2.8rem);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  font-size: 1rem;
  letter-spacing: 0;
}

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

.toolbar {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

label input[type="number"] {
  width: 88px;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 6px 9px;
  background: var(--surface);
  color: var(--text);
}

label input[type="text"],
label input[type="password"] {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text);
}

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 7px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

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

.primary:not(:disabled):hover {
  background: var(--accent-strong);
}

.secondary {
  color: var(--accent);
  border: 1px solid var(--line-strong);
  background: var(--surface);
}

.danger {
  color: #fff;
  background: #9f3b3b;
}

.danger:not(:disabled):hover {
  background: #7e2c2c;
}

.ghost {
  color: var(--muted);
  background: transparent;
}

.connection {
  margin-top: -8px;
}

.wide-input {
  width: min(360px, 44vw);
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 6px 9px;
  background: var(--surface);
  color: var(--text);
}

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

.grid.dragging .panel {
  border-color: var(--accent);
}

.panel {
  display: flex;
  min-height: calc(100vh - 170px);
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.panel-head p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

textarea {
  width: 100%;
  min-height: 300px;
  flex: 1;
  resize: none;
  border: 0;
  padding: 14px;
  outline: none;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--text);
  background: #fbfcfd;
}

#output {
  min-height: 230px;
  border-top: 1px solid var(--line);
}

.status {
  min-height: 36px;
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.status.ok {
  color: var(--success);
}

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

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 14px;
}

.stats div {
  min-height: 66px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.stats strong {
  display: block;
  font-size: 1.45rem;
  line-height: 1;
}

.stats span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.table-wrap {
  max-height: 220px;
  overflow: auto;
  border-top: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #f9fbfc;
  font-size: 0.76rem;
  text-transform: uppercase;
}

td {
  font-family: var(--mono);
  word-break: break-all;
}

.empty {
  color: var(--muted);
  font-family: var(--sans);
  text-align: center;
}

.expired {
  color: var(--danger);
}

.issues {
  max-height: 130px;
  overflow: auto;
  border-top: 1px solid var(--line);
  color: var(--danger);
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.5;
}

.issues:empty {
  display: none;
}

.issues div {
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
}

.import-result {
  max-height: 150px;
  overflow: auto;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.5;
}

.import-result:empty {
  display: none;
}

.import-result div {
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
}

.import-result .ok {
  color: var(--success);
}

.import-result .error {
  color: var(--danger);
}

@media (max-width: 920px) {
  .header {
    align-items: stretch;
    flex-direction: column;
  }

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

  .panel {
    min-height: 560px;
  }
}

@media (max-width: 560px) {
  .app {
    width: min(100vw - 20px, 1380px);
    padding: 14px 0;
  }

  .toolbar,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .button,
  label,
  label input[type="number"],
  .wide-input {
    width: 100%;
  }

  label {
    justify-content: space-between;
  }
}

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

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

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

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

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

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

.login-error {
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 700;
}
