:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --ink: #171923;
  --muted: #697386;
  --line: #dde3ee;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --danger: #b42318;
  --success: #0f9f6e;
  --shadow: 0 22px 70px rgba(24, 35, 66, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff 0, var(--bg) 180px), var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

.admin-shell {
  min-height: 100vh;
  padding: 28px;
}

.login-panel,
.admin-app {
  max-width: 1180px;
  margin: 0 auto;
}

.login-panel {
  width: min(420px, 100%);
  margin-top: 12vh;
  display: grid;
  gap: 28px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 900;
}

.brand-row strong,
.brand-row small {
  display: block;
}

.brand-row strong {
  font-size: 20px;
  line-height: 1.2;
}

.brand-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

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

label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: #ffffff;
  font-weight: 500;
}

textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.6;
}

input:focus,
textarea:focus {
  outline: 2px solid rgba(37, 99, 235, 0.16);
  border-color: var(--accent);
}

button,
.header-actions a,
.avatar-upload {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0 14px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

button:hover,
.header-actions a:hover,
.avatar-upload:hover {
  background: var(--accent-strong);
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

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

.form-message.is-success {
  color: var(--success);
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 14px 40px rgba(24, 35, 66, 0.08);
}

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

.header-actions button {
  border-color: var(--line);
  color: var(--ink);
  background: #ffffff;
}

.header-actions button:hover {
  color: var(--accent-strong);
  background: #f1f5ff;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 18px;
}

.agent-admin-list,
.editor-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.agent-admin-list {
  padding: 16px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title h1 {
  margin: 0;
  font-size: 22px;
}

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

.admin-agent-item {
  width: 100%;
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  color: var(--ink);
  background: #ffffff;
  text-align: left;
  cursor: pointer;
}

.admin-agent-item:hover,
.admin-agent-item.is-active {
  border-color: rgba(37, 99, 235, 0.28);
  background: #f1f5ff;
}

.admin-agent-item.is-disabled {
  opacity: 0.58;
}

.admin-agent-avatar,
.avatar-preview {
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 10px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 900;
}

.admin-agent-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
}

.admin-agent-avatar img,
.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.admin-agent-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.admin-agent-copy strong,
.admin-agent-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-agent-copy small {
  color: var(--muted);
  font-size: 12px;
}

.editor-panel {
  padding: 20px;
}

.avatar-editor {
  display: flex;
  align-items: center;
  gap: 14px;
}

.avatar-preview {
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  font-size: 24px;
}

.avatar-upload input {
  display: none;
}

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

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

.checkbox-line input {
  width: 18px;
  height: 18px;
}

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

.danger-button {
  border-color: rgba(180, 35, 24, 0.28);
  color: var(--danger);
  background: #fff1f0;
}

.danger-button:hover {
  color: #ffffff;
  background: var(--danger);
}

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

  .admin-header,
  .admin-grid {
    grid-template-columns: 1fr;
  }

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

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