:root {
  color-scheme: light;
  --bg: #f4f8f5;
  --card: #ffffff;
  --line: #dfe9e2;
  --line-strong: #c7dbce;
  --text: #1f2b26;
  --muted: #74857c;
  --green: #2ea56b;
  --green-dark: #187a4b;
  --green-soft: #e8f6ee;
  --green-pale: #f2faf5;
  --amber: #9d6b13;
  --amber-soft: #fff6da;
  --gray-soft: #eef3f0;
  --danger: #b64a4a;
  --shadow: 0 18px 50px rgba(26, 82, 52, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

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

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 3px; font-size: 22px; letter-spacing: -0.025em; }
h2 { margin-bottom: 8px; letter-spacing: -0.025em; }
.muted { color: var(--muted); }
.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.brand-mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 14px;
  color: #fff;
  background: var(--green);
  font-size: 24px;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(46, 165, 107, 0.2);
}
.brand-mark-small { width: 42px; height: 42px; border-radius: 11px; font-size: 18px; }

.app-shell { min-height: 100vh; }
.login-shell {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
  background:
    radial-gradient(circle at 10% 10%, rgba(46, 165, 107, 0.12), transparent 30rem),
    radial-gradient(circle at 90% 0%, rgba(118, 198, 153, 0.14), transparent 32rem),
    var(--bg);
}
.login-card {
  width: min(520px, 100%);
  padding: 38px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 24px 0 12px; font-size: clamp(28px, 5vw, 40px); line-height: 1.08; }
.login-card .muted { margin-bottom: 28px; line-height: 1.7; }
.login-form label, .field > span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}
input[type="password"], input[type="search"], textarea, select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  outline: none;
  color: var(--text);
  background: #fff;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
input[type="password"], input[type="search"], select { min-height: 44px; padding: 0 13px; }
textarea { padding: 12px 13px; resize: vertical; line-height: 1.55; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(46, 165, 107, 0.1); }
::placeholder { color: #a4b3aa; }
.button {
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 750;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}
.button:hover { transform: translateY(-1px); }
.button-wide { width: 100%; margin-top: 12px; }
.button-primary { color: #fff; background: var(--green); }
.button-primary:hover { background: var(--green-dark); }
.button-outline { border-color: var(--line-strong); color: var(--green-dark); background: #fff; }
.button-outline:hover { border-color: var(--green); background: var(--green-pale); }
.button-quiet { border-color: var(--line); color: var(--muted); background: #fff; }
.button-quiet:hover { border-color: var(--line-strong); color: var(--text); }
.form-error { min-height: 20px; margin: 12px 0 0; color: var(--danger); font-size: 13px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 74px;
  padding: 14px max(24px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
}
.topbar-brand, .topbar-actions { display: flex; align-items: center; gap: 13px; }
.topbar-brand p { margin: 0; color: var(--muted); font-size: 12px; }
.topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
.content { width: min(1180px, calc(100% - 34px)); margin: 24px auto 70px; }

.hero-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 24px 26px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background:
    linear-gradient(135deg, rgba(232, 246, 238, 0.78), rgba(255, 255, 255, 0.96) 55%),
    var(--card);
  box-shadow: 0 12px 35px rgba(26, 82, 52, 0.05);
}
.hero-copy p { margin-bottom: 0; }
.hero-stats { display: flex; gap: 10px; }
.stat-block {
  min-width: 108px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
  text-align: center;
}
.stat-block strong { display: block; color: var(--green-dark); font-size: 28px; line-height: 1; }
.stat-block span { display: block; margin-top: 7px; color: var(--muted); font-size: 11px; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 18px 0;
}
.search-field { position: relative; display: block; width: min(430px, 100%); }
.search-field input { padding-left: 38px; }
.search-icon { position: absolute; left: 14px; top: 10px; color: var(--muted); font-size: 21px; }
.status-text { white-space: nowrap; }

.alias-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.alias-card {
  display: flex;
  flex-direction: column;
  min-height: 230px;
  padding: 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 9px 26px rgba(26, 82, 52, 0.045);
  transition: transform 150ms ease, box-shadow 150ms ease;
}
.alias-card:hover { transform: translateY(-2px); box-shadow: 0 15px 32px rgba(26, 82, 52, 0.08); }
.alias-card.is-unused { border-left-color: #b8c9be; }
.alias-head, .alias-foot { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.alias-address { overflow: hidden; color: var(--green-dark); font-size: 16px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.alias-label { margin-top: 7px; color: var(--muted); font-size: 12px; }
.badge { flex: 0 0 auto; padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.badge-used { color: var(--amber); background: var(--amber-soft); }
.badge-unused { color: #697a70; background: var(--gray-soft); }
.code-row { margin: 18px 0 12px; }
.code-badge { display: inline-flex; min-height: 34px; align-items: center; padding: 0 11px; border: 1px solid #b9dfc9; border-radius: 9px; color: var(--green-dark); background: var(--green-soft); font: 800 15px/1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: 0.08em; }
.preview {
  display: -webkit-box;
  min-height: 42px;
  margin: 0 0 16px;
  overflow: hidden;
  color: #617269;
  font-size: 13px;
  line-height: 1.6;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.alias-foot { align-items: center; margin-top: auto; padding-top: 14px; border-top: 1px solid #edf2ee; }
.alias-actions { display: flex; gap: 8px; }
.button-small { min-height: 34px; padding: 0 11px; font-size: 12px; }
.text-button { padding: 0; border: 0; color: var(--green-dark); background: transparent; font-size: 12px; font-weight: 800; }
.text-button:hover { color: var(--green); }

.empty-state {
  padding: 60px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  text-align: center;
}
.empty-mark { display: grid; width: 54px; height: 54px; margin: 0 auto 16px; place-items: center; border-radius: 14px; color: #fff; background: var(--green); font-size: 23px; font-weight: 800; }
.empty-state p { max-width: 590px; margin: 0 auto 20px; color: var(--muted); line-height: 1.7; }

.modal {
  width: min(620px, calc(100% - 28px));
  max-height: calc(100vh - 28px);
  padding: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  color: var(--text);
  background: var(--card);
  box-shadow: 0 30px 80px rgba(25, 70, 45, 0.2);
}
.modal::backdrop { background: rgba(22, 44, 31, 0.35); backdrop-filter: blur(4px); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.icon-button { border: 0; color: var(--muted); background: transparent; font-size: 29px; line-height: 1; }
.icon-button:hover { color: var(--text); }
.field { display: block; margin-top: 18px; }
.field-spaced { margin-top: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.empty-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }
.hint { margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.message-meta { display: grid; gap: 6px; margin: 18px 0; color: var(--muted); font-size: 12px; }
.message-body { max-height: 52vh; margin: 0; padding: 15px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; color: #314139; background: #f7faf8; font: 12px/1.7 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(420px, calc(100% - 44px));
  padding: 12px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  color: var(--text);
  background: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: #e3b8b8; color: var(--danger); }
.clipboard-helper { position: fixed; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.user-list-wrap { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.user-list-wrap h3 { margin: 0 0 12px; font-size: 15px; }
.user-list { display: grid; gap: 9px; max-height: 280px; overflow: auto; }
.user-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--green-pale); }
.user-item strong { display: block; font-size: 13px; }
.user-item span { color: var(--muted); font-size: 11px; }
.audit-list { display: grid; gap: 8px; max-height: 62vh; margin-top: 18px; overflow: auto; }
.audit-item { padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #f8fbf9; }
.audit-item strong { display: block; font-size: 13px; }
.audit-item span { color: var(--muted); font-size: 11px; line-height: 1.6; }


@media (max-width: 840px) {
  .topbar { align-items: flex-start; flex-direction: column; padding: 16px 18px; }
  .topbar-actions { justify-content: flex-start; }
  .hero-card { align-items: flex-start; flex-direction: column; }
  .hero-stats { width: 100%; }
  .stat-block { flex: 1; min-width: 0; }
  .alias-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .content { width: min(100% - 22px, 520px); margin-top: 16px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .hero-stats { flex-direction: column; }
  .alias-actions { width: 100%; }
  .alias-actions .button { flex: 1; }
  .alias-foot { align-items: stretch; flex-direction: column; }
  .login-card { padding: 28px 20px; }
}
