:root {
  --bg: #f3f6f2;
  --bg-accent: #e7efe4;
  --panel: #ffffff;
  --ink: #1c2a22;
  --muted: #5d6f64;
  --line: #d5e0d7;
  --brand: #0f6b4c;
  --brand-deep: #0a4d37;
  --warn: #c47a12;
  --danger: #b42318;
  --ok: #18794e;
  --sidebar: #123528;
  --sidebar-ink: #e8f3ec;
  --shadow: 0 10px 30px rgba(18, 53, 40, 0.08);
  --radius: 14px;
  --font: "Segoe UI", "Avenir Next", "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(15, 107, 76, 0.12), transparent 28%),
    linear-gradient(180deg, #f7faf6 0%, var(--bg) 45%, #eef4ec 100%);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, var(--sidebar) 0%, #0d281e 100%);
  color: var(--sidebar-ink);
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  padding: 8px 10px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-kicker {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.7;
  margin-bottom: 8px;
}

.brand h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
  font-weight: 700;
}

.brand p {
  margin: 8px 0 0;
  color: rgba(232, 243, 236, 0.72);
  font-size: 13px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav a,
.nav-link-btn {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: rgba(232, 243, 236, 0.88);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.nav a:hover,
.nav-link-btn:hover {
  background: rgba(255,255,255,0.08);
  transform: translateX(2px);
}

.nav a.active {
  background: rgba(255,255,255,0.14);
  color: #fff;
  font-weight: 600;
}

.nav-logout-form {
  margin: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  font-size: 12px;
  line-height: 1.5;
  color: rgba(232, 243, 236, 0.75);
}

.login-body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
}

.login-shell {
  width: min(420px, 100%);
  margin: 0 auto;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
}

.login-brand {
  margin-bottom: 22px;
  text-align: center;
}

.login-brand .brand-kicker {
  color: var(--muted);
}

.login-brand h1 {
  margin: 0;
  font-size: 28px;
  color: var(--ink);
}

.login-brand p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.login-form .field {
  margin-bottom: 14px;
}

.login-submit {
  width: 100%;
  margin-top: 6px;
}

.login-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.content {
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 22px;
}

.topbar h2 {
  margin: 0;
  font-size: 30px;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 13px;
}

.badge.ok { color: var(--ok); }
.badge.bad { color: var(--danger); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.panel + .panel { margin-top: 18px; }

.panel h3 {
  margin: 0 0 16px;
  font-size: 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head h3 {
  margin: 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 18px;
}

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="url"],
input[type="number"],
input[type="time"],
input[type="date"],
input[type="password"],
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
  background: #fbfffb;
  color: var(--ink);
  outline: none;
}

input[type="text"]:focus,
input[type="url"]:focus,
input[type="number"]:focus,
input[type="time"]:focus,
input[type="date"]:focus,
input[type="password"]:focus,
select:focus {
  border-color: #79b799;
  box-shadow: 0 0 0 3px rgba(15, 107, 76, 0.12);
}

.input-shell {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbf8 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  min-height: 46px;
  padding: 0 10px;
}

.input-shell:focus-within {
  border-color: #79b799;
  box-shadow: 0 0 0 3px rgba(15, 107, 76, 0.12);
}

.input-shell input,
.input-shell select {
  padding: 10px 4px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.input-shell input:focus,
.input-shell select:focus {
  border: 0;
  box-shadow: none;
}

.input-prefix {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--brand);
  background: #e8f4ee;
  border-radius: 7px;
  padding: 5px 7px;
}

.reveal-btn {
  border: 0;
  background: #eef4ef;
  color: var(--brand-deep);
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.reveal-btn:hover {
  background: #e1eee6;
}

.field { margin-bottom: 14px; }

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 18px;
  color: var(--ink);
}

.checkbox input { width: auto; }

.modern-check {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7fbf8;
  margin: 0;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 11px 16px;
  font: inherit;
  cursor: pointer;
  background: var(--brand);
  color: white;
  transition: background 0.2s ease, transform 0.15s ease;
}

.btn:hover {
  background: var(--brand-deep);
  transform: translateY(-1px);
}

.btn.secondary {
  background: #eef4ef;
  color: var(--brand-deep);
  border: 1px solid var(--line);
}

.btn.danger {
  background: var(--danger);
}

.btn.small {
  padding: 7px 10px;
  font-size: 12px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.flash {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
}

.flash.ok {
  background: #e8f7ef;
  color: var(--ok);
  border: 1px solid #bfe5ce;
}

.flash.err {
  background: #fdecec;
  color: var(--danger);
  border: 1px solid #f3c1c1;
}

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.pill.on { background: #e7f7ee; color: var(--ok); }
.pill.off { background: #f1f3f1; color: var(--muted); }
.pill.active { background: #fff4e5; color: var(--warn); }
.pill.cleared { background: #eef2ff; color: #364fc7; }

.empty {
  padding: 28px 10px;
  color: var(--muted);
  text-align: center;
}

.help {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.comparator-box {
  margin: 4px 0 16px;
  padding: 14px;
  border: 1px dashed #b9d0c1;
  border-radius: 12px;
  background: #f5faf6;
}

.filter-panel {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(15, 107, 76, 0.04), transparent 42%),
    #fbfefc;
}

.filter-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.filter-panel-head strong {
  display: block;
  font-size: 15px;
}

.filter-panel-head span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: 12px;
}

.filter-grid .field {
  margin-bottom: 0;
}

.filter-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.settings-panel {
  padding: 0;
  overflow: hidden;
}

.settings-form {
  padding: 0;
}

.settings-section {
  padding: 22px 22px 8px;
  border-bottom: 1px solid var(--line);
}

.settings-section:last-of-type {
  border-bottom: 0;
}

.section-title {
  margin-bottom: 16px;
}

.section-title h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.section-title p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.credential-card {
  margin: 4px 0 16px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid #cfe0d5;
  background:
    radial-gradient(circle at top right, rgba(15, 107, 76, 0.08), transparent 40%),
    #f4faf6;
}

.credential-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.credential-card-head strong {
  display: block;
  font-size: 14px;
}

.credential-card-head span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.credential-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.credential-grid .field {
  margin-bottom: 0;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #c9d7ce;
  position: relative;
  transition: background 0.15s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  transition: transform 0.15s ease;
}

.switch input:checked + .switch-track {
  background: var(--brand);
}

.switch input:checked + .switch-track::after {
  transform: translateX(18px);
}

.switch-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-deep);
}

.settings-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 22px 22px;
  flex-wrap: wrap;
}

.settings-footer .help {
  margin: 0;
  max-width: 520px;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.select-banner {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #eef7f2;
  border: 1px solid #cfe3d7;
  color: var(--ink);
  font-size: 14px;
}

.select-banner .linkish {
  margin-left: 10px;
  border: 0;
  background: transparent;
  color: var(--brand);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

.checkbox.tight {
  margin: 0;
}

.col-check {
  width: 36px;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.pagination-meta {
  color: var(--muted);
  font-size: 13px;
}

.pagination-links {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.page-link {
  min-width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fbfffb;
  padding: 0 8px;
  font-size: 13px;
}

.page-link.current {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}

.page-ellipsis {
  color: var(--muted);
  padding: 0 4px;
}

.btn.disabled,
.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}

a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.row-editing {
  background: #eef8f1;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(12, 28, 20, 0.48);
  z-index: 1000;
}

.modal-overlay.is-open {
  display: flex;
}

.modal-card {
  width: min(720px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(12, 28, 20, 0.28);
  animation: modal-in 0.18s ease-out;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 18px 20px 0;
}

.modal-head h3 {
  margin: 0;
  font-size: 20px;
}

.modal-close {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.modal-body {
  padding: 16px 20px 20px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { padding-bottom: 18px; }
  .grid-2, .row, .filter-grid, .credential-grid { grid-template-columns: 1fr; }
  .content { padding: 18px; }
  .topbar { flex-direction: column; align-items: start; }
  .filter-panel-head, .settings-footer, .credential-card-head {
    flex-direction: column;
    align-items: stretch;
  }
}
