@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/inter-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/assets/fonts/inter-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/assets/fonts/inter-700.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/jetbrains-mono-400.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/assets/fonts/jetbrains-mono-600.woff2') format('woff2');
}

:root {
  --bg: #eef2f6;
  --card: #ffffff;
  --border: #94a3b8;
  --border-light: #cbd5e1;
  --text: #0f172a;
  --muted: #334155;
  --blue: #075985;
  --blue-hover: #0c4a6e;
  --red: #b91c1c;
  --red-hover: #991b1b;
}

* {
  box-sizing: border-box;
}

html, body {
  overflow-x: clip;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 13.5px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

:focus-visible {
  outline: 3px solid #0284c7;
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

header {
  position: static;
  background: #ffffff;
  border-bottom: 2px solid var(--border);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e0f2fe;
  color: var(--blue);
  border: 1.5px solid #7dd3fc;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.01em;
}

.brand p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

select, input[type="text"], input[type="password"], input[type="email"], input[type="number"], textarea {
  padding: 7px 10px;
  border: 1.5px solid #64748b;
  border-radius: 6px;
  font-size: 13px;
  color: #0f172a;
  background: #ffffff;
  font-family: inherit;
  min-width: 0;
  max-width: 100%;
}

input:disabled {
  background: #e2e8f0;
  color: #64748b;
  cursor: not-allowed;
}

.btn {
  padding: 7px 12px;
  border-radius: 6px;
  border: 1.5px solid #64748b;
  background: #ffffff;
  color: #0f172a;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: #f1f5f9;
  border-color: #334155;
}

.btn-primary {
  background: var(--blue);
  color: #ffffff;
  border-color: var(--blue);
}

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

.btn-danger {
  background: var(--red);
  color: #ffffff;
  border-color: var(--red);
}

.btn-danger:hover {
  background: var(--red-hover);
  border-color: var(--red-hover);
}

.btn-sm {
  padding: 4px 8px;
  font-size: 12px;
}

.btn-active-toggle {
  background: #e0f2fe;
  border-color: #0284c7;
  color: #0c4a6e;
}

.login-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: #ffffff;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 28px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.1);
}

main {
  display: block;
  flex: 1;
}

.col-picker-wrap {
  position: relative;
  display: inline-block;
  z-index: 200;
}

.col-picker-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 38px;
  background: #ffffff;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.22);
  z-index: 250;
  min-width: 255px;
  max-height: 75vh;
  overflow-y: auto;
}

.col-picker-menu label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #0f172a;
}

.sub-bar {
  padding: 14px 24px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.sub-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.sub-bar h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
}

.sub-bar .count {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 2px;
}

.top-hscroll-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  margin: 0 20px;
  max-width: calc(100vw - 40px);
  overflow-x: auto;
  overflow-y: hidden;
  height: 15px;
  background: #e2e8f0;
  border: 1.5px solid var(--border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  scrollbar-width: auto;
  scrollbar-color: #64748b #e2e8f0;
}

.top-hscroll-bar::-webkit-scrollbar { height: 13px; }
.top-hscroll-bar::-webkit-scrollbar-track { background: #e2e8f0; border-radius: 8px 8px 0 0; }
.top-hscroll-bar::-webkit-scrollbar-thumb { background: #64748b; border-radius: 6px; border: 2px solid #e2e8f0; }
.top-hscroll-bar::-webkit-scrollbar-thumb:hover { background: #334155; }
.top-hscroll-inner { height: 1px; }

.table-wrap {
  margin: 0 20px 24px;
  max-width: calc(100vw - 40px);
  background: #ffffff;
  border: 1.5px solid var(--border);
  border-radius: 0 0 8px 8px;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: auto;
  scrollbar-color: #64748b #e2e8f0;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
}

.table-wrap::-webkit-scrollbar { height: 13px; }
.table-wrap::-webkit-scrollbar-track { background: #e2e8f0; border-radius: 0 0 8px 8px; }
.table-wrap::-webkit-scrollbar-thumb { background: #64748b; border-radius: 6px; border: 2px solid #e2e8f0; }
.table-wrap::-webkit-scrollbar-thumb:hover { background: #334155; }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th, td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--border-light);
  text-align: left;
  vertical-align: middle;
}

thead {
  position: relative;
  z-index: 45;
  will-change: transform;
}

thead th {
  background: #e2e8f0;
  border-bottom: 2px solid #64748b;
  font-weight: 700;
  font-size: 12.5px;
  color: #0f172a;
  white-space: normal;
  line-height: 1.25;
}

thead th:hover, thead th:focus-within {
  z-index: 60;
}

th[data-col="host"], td[data-col="host"] {
  position: sticky;
  left: 0;
  z-index: 15;
  border-right: 2px solid #cbd5e1;
}

thead th[data-col="host"] {
  z-index: 55;
  background: #e2e8f0;
}

thead th[data-col="host"]:hover, thead th[data-col="host"]:focus-within {
  z-index: 65;
}

tbody tr:nth-child(odd) td[data-col="host"] { background: #ffffff; }
tbody tr:nth-child(even) td[data-col="host"] { background: #f8fafc; }
tbody tr:hover td[data-col="host"] { background: #e0f2fe; }
tbody tr:nth-child(even) { background: #f8fafc; }
tbody tr:hover { background: #e0f2fe66; }

tr.group-header-row {
  background: #dbeafe !important;
  cursor: pointer;
  user-select: none;
}

tr.group-header-row:hover {
  background: #bfdbfe !important;
}

tr.group-header-row td {
  padding: 9px 12px;
  border-top: 2px solid #93c5fd;
  border-bottom: 2px solid #93c5fd;
  font-weight: 700;
  color: #0c4a6e;
  font-size: 13px;
}

.group-sticky-cell {
  position: sticky;
  left: 0;
  z-index: 20;
  background: inherit;
  white-space: nowrap;
}

.th-head-row {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.th-sort-btn {
  background: transparent;
  border: none;
  padding: 2px 4px;
  font: inherit;
  font-weight: 700;
  color: #0f172a;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 4px;
}

.th-sort-btn:hover {
  color: var(--blue);
  background: #cbd5e166;
}

.sort-arrow {
  font-size: 11px;
  color: #334155;
}

.sort-arrow.active {
  color: var(--blue);
  font-weight: 700;
}

.help-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid #475569;
  background: #ffffff;
  color: #0f172a;
  font-size: 11px;
  font-weight: 700;
  cursor: help;
  flex-shrink: 0;
  padding: 0;
}

.help-tip:hover, .help-tip:focus {
  background: var(--blue);
  color: #ffffff;
  border-color: var(--blue);
}

.help-tip .tip-box {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: 265px;
  white-space: normal;
  background: #0f172a;
  color: #ffffff;
  font-weight: 400;
  font-size: 12px;
  line-height: 1.45;
  padding: 9px 11px;
  border-radius: 6px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
  z-index: 100;
  pointer-events: none;
  transition: opacity 0.15s ease;
  text-align: left;
}

.help-tip:hover .tip-box, .help-tip:focus .tip-box {
  visibility: visible;
  opacity: 1;
}

th:first-child .help-tip .tip-box {
  left: 0;
  transform: none;
}

th:last-child .help-tip .tip-box, th:nth-last-child(2) .help-tip .tip-box {
  left: auto;
  right: 0;
  transform: none;
}

th .filter-ctrl {
  display: block;
  margin-top: 7px;
  width: 100%;
  font-weight: 500;
}

.clearable-input-wrap {
  position: relative;
  margin-top: 7px;
  display: flex;
  align-items: center;
}

.clearable-input-wrap input {
  width: 100%;
  padding-right: 26px;
}

.clearable-input-wrap input[list] {
  padding-right: 34px;
}

.clear-btn {
  position: absolute;
  right: 6px;
  cursor: pointer;
  color: #334155;
  font-weight: 700;
  font-size: 13px;
  display: none;
  border: none;
  background: transparent;
  padding: 2px 4px;
  line-height: 1;
}

.clearable-input-wrap input[list] + datalist + .clear-btn {
  right: 20px;
}

.clear-btn:hover {
  color: var(--red);
}

.badge {
  padding: 4px 9px;
  border-radius: 5px;
  font-weight: 700;
  font-size: 11.5px;
  display: inline-block;
  text-align: center;
  letter-spacing: 0.02em;
}

.b-oui { background: #dcfce7; color: #14532d; border: 1.5px solid #16a34a; }
.b-non { background: #fee2e2; color: #7f1d1d; border: 1.5px solid #dc2626; }
.b-neutral { background: #f1f5f9; color: #0f172a; border: 1.5px solid #64748b; }
.b-type { background: #e0f2fe; color: #0c4a6e; border: 1.5px solid #0284c7; font-family: 'JetBrains Mono', monospace; }
.b-exp-ok { background: #dcfce7; color: #14532d; border: 1.5px solid #16a34a; }
.b-exp-warn { background: #fef3c7; color: #78350f; border: 1.5px solid #d97706; }
.b-exp-bad { background: #fee2e2; color: #7f1d1d; border: 1.5px solid #dc2626; }

.cell-action-btn {
  background: transparent;
  border: 1px solid transparent;
  padding: 2px 5px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--blue);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}

.cell-action-btn:hover {
  background: #e0f2fe;
  border-color: #7dd3fc;
  color: var(--blue-hover);
}

.mono-btn {
  font-family: 'JetBrains Mono', monospace;
}

.link {
  color: var(--blue);
  text-decoration: underline;
  font-weight: 600;
  font-size: 13.5px;
}

.link:hover {
  color: var(--blue-hover);
}

.redir-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid transparent;
  vertical-align: middle;
}

.redir-ok { background: #e0f2fe; color: #0c4a6e; border-color: #0284c7; }
.redir-warn { background: #fef3c7; color: #78350f; border-color: #d97706; }

.whois-link {
  text-decoration: none;
  margin-left: 6px;
  font-size: 13px;
  color: var(--blue);
  font-weight: 600;
}

.sub-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.scan-panel {
  background: #e0f2fe;
  border-bottom: 2px solid #0284c7;
  color: #0c4a6e;
  padding: 11px 24px;
  display: none;
}

.scan-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 7px;
  font-weight: 600;
  font-size: 13px;
  gap: 10px;
  flex-wrap: wrap;
}

.progress-track {
  width: 100%;
  height: 9px;
  background: #bae6fd;
  border-radius: 5px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--blue);
  width: 15%;
  transition: width 0.4s ease;
}

.modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.65);
  z-index: 300;
  align-items: center;
  justify-content: center;
}

.modal {
  background: #ffffff;
  border-radius: 10px;
  width: 94%;
  max-width: 880px;
  max-height: 88vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.3);
}

.modal > * {
  max-width: 100%;
  min-width: 0;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1.5px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1.5px solid var(--border);
  margin-bottom: 16px;
  flex-wrap: wrap;
  min-width: 0;
}

.tab-btn {
  padding: 8px 13px;
  border: none;
  background: transparent;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}

.tab-btn.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.tab-pane {
  display: none;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.tab-pane.active {
  display: block;
}

.tab-pane > * {
  max-width: 100%;
  min-width: 0;
}

.cert-card {
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  margin-bottom: 14px;
  background: #f8fafc;
  min-width: 0;
}

.cert-card h4 {
  margin: 0 0 10px;
  color: var(--blue);
  font-size: 15px;
}

.cert-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px 12px;
  font-size: 13px;
}

pre.pem {
  background: #0f172a;
  color: #f8fafc;
  padding: 12px;
  border-radius: 6px;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  overflow-x: auto;
  margin-top: 10px;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 12px;
  border: 1.5px solid var(--border-light);
  border-radius: 6px;
  margin-bottom: 8px;
  background: #f8fafc;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.hop-item {
  padding: 10px 12px;
  border-left: 4px solid var(--blue);
  background: #f8fafc;
  margin-bottom: 8px;
  border-radius: 0 6px 6px 0;
}

.hop-item.err {
  border-left-color: var(--red);
  background: #fef2f2;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.form-grid > * {
  min-width: 0;
  max-width: 100%;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.form-field label {
  font-weight: 600;
  font-size: 12.5px;
  color: #0f172a;
}

.chip-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #e0f2fe;
  border: 1.5px solid #0284c7;
  color: #0c4a6e;
  padding: 4px 9px;
  border-radius: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  margin: 3px;
}

.chip-tag button {
  border: none;
  background: transparent;
  color: #0c4a6e;
  cursor: pointer;
  font-weight: 700;
  padding: 0 2px;
}

.chip-tag button:hover {
  color: var(--red);
}

footer.app-footer {
  position: static;
  background: #ffffff;
  border-top: 2px solid var(--border);
  padding: 14px 24px;
  text-align: center;
  font-size: 13px;
  color: #0f172a;
  margin-top: auto;
}

footer.app-footer a {
  color: var(--blue);
  font-weight: 600;
  text-decoration: underline;
}

footer.app-footer a:hover {
  color: var(--blue-hover);
}

.form-field label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.smtp-port-enc-row {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.modal-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  margin-bottom: 12px;
}

.form-grid-2 > * {
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 680px) {
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}
