:root,
[data-theme="dark"] {
  --bg: #141519;
  --text: #ece9e2;
  --muted: #a9a39a;
  --accent: #b2976b;
  --accent-strong: #c7ad7f;
  --card: #1d1f24;
  --card-alt: #191b20;
  --border: #32343a;
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.28);
}

[data-theme="light"] {
  --bg: #e8edf3;
  --text: #1f2935;
  --muted: #5d6a79;
  --accent: #2f4b67;
  --accent-strong: #416282;
  --card: #f7fafd;
  --card-alt: #f1f5fa;
  --border: #cbd5e1;
  --shadow: 0 16px 32px rgba(31, 41, 53, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", system-ui, sans-serif;
  background: radial-gradient(1200px 800px at 20% -10%, rgba(178, 151, 107, 0.1), transparent 65%),
    radial-gradient(1000px 900px at 90% 120%, rgba(47, 75, 103, 0.16), transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
}

.container {
  width: min(1120px, 92vw);
  margin: 0 auto;
}

.site-header {
  position: relative;
  z-index: 2;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 76px;
  gap: 12px;
}

.brand-title {
  font-family: "Cormorant Garamond", serif;
  letter-spacing: 0.08em;
  font-size: 28px;
  font-weight: 600;
}

.brand-subtitle {
  font-size: 13px;
  color: var(--muted);
}

.theme-toggle {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 70%, var(--border));
  background: color-mix(in srgb, var(--bg) 86%, #0e1117 14%);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.theme-icon {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 75%, #ffffff 25%);
  background: linear-gradient(90deg, #f4f6fa 0 50%, #101217 50% 100%);
}

.theme-toggle:hover {
  border-color: var(--accent-strong);
}

.theme-toggle:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 60%, #ffffff 40%);
  outline-offset: 2px;
}

.hero {
  padding: 34px 0 20px;
}

.panel {
  background: linear-gradient(160deg, var(--card), var(--card-alt));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: clamp(22px, 3vw, 36px);
  box-shadow: var(--shadow);
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
}

h1,
h2 {
  font-family: "Cormorant Garamond", serif;
  font-weight: 600;
}

h1 {
  font-size: clamp(36px, 5vw, 54px);
  margin-bottom: 12px;
}

h2 {
  font-size: clamp(30px, 4vw, 40px);
}

.lead {
  margin: 0;
  color: var(--muted);
  font-size: clamp(16px, 2vw, 19px);
  max-width: 900px;
}

.hero-actions {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 500;
}

.btn-primary {
  color: #f5f7fb;
  background: var(--accent);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

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

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.agents {
  padding: 12px 0 42px;
}

.section-head p {
  margin: 8px 0 0;
  color: var(--muted);
}

.agent-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.agent-card {
  background: linear-gradient(180deg, var(--card), var(--card-alt));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: 245px;
}

.agent-card h3 {
  font-size: 26px;
  font-family: "Cormorant Garamond", serif;
  margin-bottom: 8px;
}

.agent-card p {
  margin: 0;
  color: var(--muted);
  flex: 1;
}

.agent-tags {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tag {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  color: var(--muted);
}

.agent-actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
}

.agent-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.agent-link:hover {
  color: var(--accent-strong);
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 18px 0 26px;
}

.site-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.password-wrap {
  position: relative;
}

.pw-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border: 1px solid #b8c2cf;
  border-radius: 9px;
  background: #f8fbff;
  color: #1f2935;
  font-size: 14px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.pw-toggle:hover {
  border-color: #8fa3bc;
  background: #ffffff;
}

.pw-toggle:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 60%, #ffffff 40%);
  outline-offset: 2px;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  align-items: center;
  padding: 28px 0;
}

.auth-panel {
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}

.auth-title {
  margin-bottom: 16px;
}

.auth-error {
  margin: 0 0 12px;
  color: #d96363;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-field {
  display: grid;
  gap: 8px;
}

.auth-input {
  display: block;
  width: 100%;
  min-height: auto;
  height: 44px;
  padding-right: 42px;
}

.auth-actions {
  margin-top: 4px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.status-line {
  margin: 0 0 10px;
  font-size: 14px;
}

.status-ok {
  color: #69b47d;
}

.status-err {
  color: #d96363;
}

.admin-main {
  padding: 18px 0 26px;
}

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

.admin-field {
  display: grid;
  gap: 7px;
}

.admin-table-wrap {
  overflow: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

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

.inline-checklist {
  display: grid;
  gap: 4px;
  font-size: 13px;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
}

.profile-main {
  padding: 24px 0 30px;
}

.profile-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.2fr);
  gap: 14px;
}

.profile-kv {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.profile-kv p {
  margin: 0;
}

.profile-label {
  color: var(--muted);
  font-size: 13px;
}

.profile-value {
  font-weight: 500;
}

.rights-list {
  margin: 10px 0 0;
  padding-left: 18px;
}

@media (max-width: 760px) {
  .container {
    width: min(1120px, 94vw);
  }

  .site-header {
    border-bottom-width: 1px;
  }

  .brand-title {
    font-size: 22px;
  }

  .brand-subtitle {
    font-size: 12px;
  }

  .header-inner {
    min-height: 64px;
  }

  .theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 11px;
  }

  .hero {
    padding: 18px 0 12px;
  }

  .panel {
    border-radius: 16px;
    padding: 18px;
  }

  h1 {
    margin-bottom: 8px;
    font-size: clamp(30px, 8.2vw, 40px);
  }

  h2 {
    font-size: clamp(26px, 7vw, 34px);
  }

  .lead {
    font-size: 15px;
  }

  .hero-actions {
    margin-top: 16px;
    gap: 8px;
  }

  .btn {
    min-height: 42px;
    padding: 9px 14px;
    font-size: 14px;
  }

  .agents {
    padding: 8px 0 28px;
  }

  .agent-grid {
    margin-top: 14px;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .agent-card {
    min-height: auto;
    padding: 14px;
  }

  .agent-card h3 {
    font-size: 24px;
  }

  .agent-actions {
    flex-wrap: wrap;
    gap: 8px 12px;
  }

  .site-footer {
    padding: 14px 0 20px;
  }
}

@media (max-width: 420px) {
  .header-inner {
    min-height: 60px;
  }

  .brand-title {
    font-size: 20px;
  }

  .brand-subtitle {
    font-size: 11px;
  }

  .theme-toggle {
    width: 38px;
    height: 38px;
  }

  .btn {
    width: 100%;
  }

  .hero-actions {
    flex-direction: column;
  }

  .toolbar {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

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