:root {
  --bg: #0f1419;
  --bg-elev: #171e26;
  --line: #2a3542;
  --text: #e8eef4;
  --muted: #93a1b0;
  --accent: #3d9b8f;
  --accent-2: #2f7a71;
  --danger: #d46a6a;
  --radius: 12px;
  --font: "IBM Plex Sans", system-ui, sans-serif;
}

html[lang="fa"] {
  --font: "Vazirmatn", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 90% -10%, #1c3a36 0%, transparent 55%),
    radial-gradient(900px 400px at 0% 100%, #1a2430 0%, transparent 50%),
    var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.lang-bar {
  display: flex;
  justify-content: flex-end;
  padding: 0.65rem 1.25rem 0;
}

.lang-form select {
  width: auto;
  min-width: 8rem;
  padding: 0.4rem 0.65rem;
  font-size: 0.85rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

html[dir="ltr"] .cred-table th,
html[dir="ltr"] .cred-table td {
  text-align: left;
}

html[dir="ltr"] .warn-list {
  padding-left: 1rem;
  padding-right: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 20, 25, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
}

.brand {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user { color: var(--muted); font-size: 0.9rem; }

.wrap {
  width: min(1100px, calc(100% - 2rem));
  margin: 2rem auto 3rem;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-head h1 {
  margin: 0 0 0.35rem;
  font-size: 1.6rem;
}

.page-head p,
.lead,
.muted {
  color: var(--muted);
  margin: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 10px;
  padding: 0.55rem 1rem;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover { text-decoration: none; filter: brightness(1.08); }

.btn.primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #061210;
  font-weight: 600;
}

.btn.ghost {
  background: transparent;
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
}

.linkish,
.danger-text {
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding: 0;
}

.danger-text { color: var(--danger); }

.inline { display: inline; margin: 0; }

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.auth-panel,
.form-card {
  width: min(420px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.75rem;
}

.auth-panel h1 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
}

.auth-panel .lead { margin-bottom: 1.25rem; }

.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.92rem;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #0c1116;
  color: var(--text);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  font: inherit;
}

input:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  border-color: var(--accent);
}

.error, .errorlist {
  color: var(--danger);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.88rem;
}

.cred-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.cred-table th,
.cred-table td {
  text-align: right;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.cred-table th {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
  background: #121820;
}

.cred-table tr:last-child td { border-bottom: 0; }

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92rem;
}

.secret-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  white-space: nowrap;
}

.actions form { margin: 0; }

.empty {
  text-align: center;
  padding: 3rem 1rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(23, 30, 38, 0.5);
}

.empty p { margin: 0 0 1rem; color: var(--muted); }

.flash {
  list-style: none;
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
  background: #16302c;
  border: 1px solid #2f5f56;
  border-radius: 10px;
}

.form-card { width: min(560px, 100%); }

.head-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.check-all {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.92rem;
}

.badge {
  display: inline-block;
  font-size: 0.78rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.badge.ok {
  background: #16302c;
  border-color: #2f5f56;
  color: #9fd4c8;
}

.badge.warn {
  background: #2a2218;
  border-color: #5a4630;
  color: #e0c08a;
}

.warn-list {
  margin: 0;
  padding-right: 1rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1.25rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  background: transparent;
}

.chip:hover { color: var(--text); text-decoration: none; }
.chip.active {
  color: #061210;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-color: transparent;
  font-weight: 600;
}

.server-group { margin-bottom: 2rem; }
.group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.group-head h2 {
  margin: 0;
  font-size: 1.15rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
}
.empty.compact { padding: 1.25rem; }
.import-hint { margin: 0 0 1rem; font-size: 0.9rem; }

@media (max-width: 800px) {
  .cred-table, .cred-table thead, .cred-table tbody,
  .cred-table th, .cred-table td, .cred-table tr {
    display: block;
  }
  .cred-table thead { display: none; }
  .cred-table tr {
    padding: 1rem;
    border-bottom: 1px solid var(--line);
  }
  .cred-table td {
    border: 0;
    padding: 0.35rem 0;
  }
  .page-head { flex-direction: column; }
}
