:root {
  --bg: #0f0f10;
  --panel: #1a1a1d;
  --panel-2: #222226;
  --border: #33333a;
  --text: #ececf1;
  --muted: #9a9aa5;
  --accent: #e50914;
  --accent-hover: #f6121d;
  --green: #2ecc71;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: #6ea8fe; text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand { font-weight: 700; letter-spacing: .3px; }
.topbar .brand span { color: var(--accent); }
.topbar .user { color: var(--muted); font-size: 14px; display: flex; gap: 12px; align-items: center; }

.container { max-width: 960px; margin: 0 auto; padding: 20px 16px 60px; }
.narrow { max-width: 420px; }

h1 { font-size: 22px; margin: 8px 0 18px; }
h2 { font-size: 18px; margin: 0 0 16px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}

.flash {
  background: #14351f;
  border: 1px solid #245c38;
  color: #b8f0cd;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
}
.errors {
  background: #3a1416;
  border: 1px solid #6b2226;
  color: #f4c2c5;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
}
.errors ul { margin: 0; padding-left: 18px; }

label { display: block; margin-top: 16px; font-size: 13px; color: var(--muted); }
input[type="text"],
input[type="password"],
input[type="number"],
textarea {
  width: 100%;
  padding: 10px 12px;
  margin-top: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  font-size: 15px;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea {
  resize: vertical;
  min-height: 140px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.4;
}

.btn {
  display: inline-block;
  padding: 9px 16px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  text-align: center;
}
.btn:hover { border-color: #55555f; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: #ff8a8f; border-color: #6b2226; }
.btn-danger:hover { background: #3a1416; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 13px; }

.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.row-actions form { display: inline; margin: 0; }

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

/* Profiles as cards (mobile-friendly, no wide tables) */
.profiles { display: grid; gap: 14px; }
.profile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.profile.active { border-color: var(--green); box-shadow: 0 0 0 1px rgba(46,204,113,.25); }
.profile .p-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.profile .p-title { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }

.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.badge.active { background: rgba(46,204,113,.15); border-color: #245c38; color: #7ee2a8; }

.meta { color: var(--muted); font-size: 13px; }
.meta code {
  background: var(--panel-2);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 12px;
  color: #cfcfd6;
}
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 4px 10px; font-size: 13px; margin: 8px 0 14px; }
.kv .k { color: var(--muted); }

/* Toggle switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { display: none; }
.switch .track {
  width: 42px; height: 24px; border-radius: 999px;
  background: #3a3a42; position: relative; transition: background .15s;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #ddd; transition: transform .15s;
}
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch .switch-label { font-size: 13px; color: var(--muted); }

.hint { color: var(--muted); font-size: 12px; margin-top: 6px; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

@media (max-width: 480px) {
  .kv { grid-template-columns: 1fr; }
  .kv .k { margin-top: 6px; }
  .header-row { flex-direction: column; align-items: stretch; }
}
