/* ── Reset & base ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:       #2563eb;
  --brand-light: #3b82f6;
  --brand-dark:  #1e3a8a;
  --ok:          #16a34a;
  --warn:        #d97706;
  --danger:      #dc2626;
  --bg:          #f0f6ff;
  --surface:     #ffffff;
  --border:      #e2e8f0;
  --text:        #1e293b;
  --text-muted:  #64748b;
  --sidebar-w:   240px;
  --radius:      16px;
  --shadow:      0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.08);
  --transition:  .2s ease;
  --accent:      #3b82f6;
}

html { font-size: 15px; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
       background: var(--bg); color: var(--text); min-height: 100vh;
       display: flex; overflow-x: hidden; }

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: linear-gradient(175deg, #0f172a 0%, #1e293b 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
}
.brand small { font-weight: 400; opacity: .65; font-size: .72rem; display: block; }
.brand-icon {
  width: 28px; height: 28px; flex-shrink: 0;
  filter: drop-shadow(0 0 8px rgba(96,165,250,.7));
}

nav { padding: 12px 10px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: .9rem;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  margin-bottom: 2px;
  border-left: 3px solid transparent;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active {
  background: rgba(255,255,255,.1);
  color: #fff;
  font-weight: 600;
  border-left-color: #60a5fa;
  position: relative;
}
.nav-item.active::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(96,165,250,.12) 0%, transparent 100%);
  pointer-events: none;
}

.sidebar-footer {
  padding: 14px 18px;
  font-size: .75rem;
  opacity: .35;
  border-top: 1px solid rgba(255,255,255,.08);
}

/* ── Main ────────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ──────────────────────────────────────────────────────── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}
.topbar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, #2563eb, #7c3aed, #3b82f6);
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.page-title { font-size: 1.15rem; font-weight: 700; color: var(--brand); }
.timestamp { font-size: .8rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.menu-toggle {
  display: none;
  background: none; border: none; cursor: pointer;
  color: var(--text); padding: 6px;
}
.menu-toggle svg { width: 22px; height: 22px; }

/* ── Sections ────────────────────────────────────────────────────── */
.section { display: none; padding: 24px; flex: 1; }
.section.active { display: block; }

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 22px;
  transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover { box-shadow: 0 2px 4px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.1); }
.card + .card { margin-top: 16px; }
.card-header { margin-bottom: 20px; }
.card-header h2 { font-size: 1.15rem; font-weight: 700; color: var(--brand); }
.card-header p { color: var(--text-muted); font-size: .88rem; margin-top: 4px; }
.card-title {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ── Lookup form ─────────────────────────────────────────────────── */
.lookup-card { max-width: 680px; }
.lookup-form { display: flex; flex-direction: column; gap: 16px; }
.input-group label { display: block; font-size: .82rem; font-weight: 600;
                      color: var(--text-muted); margin-bottom: 6px; }
.input-row { display: flex; gap: 10px; }
.input-row input[type=text] { flex: 1; }
.port-group { display: flex; flex-direction: column; }
.port-group label { font-size: .82rem; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.port-group input { width: 90px; }

input[type=text], input[type=number] {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .92rem;
  color: var(--text);
  background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  width: 100%;
}
input:focus { border-color: var(--brand-light); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }

.check-options { display: flex; gap: 20px; }
.checkbox-label {
  display: flex; align-items: center; gap: 8px;
  font-size: .9rem; font-weight: 500; cursor: pointer; user-select: none;
}
.checkbox-label input[type=checkbox] { display: none; }
.checkmark {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-radius: 4px;
  display: grid; place-items: center;
  transition: background var(--transition), border-color var(--transition);
  flex-shrink: 0;
}
.checkbox-label input:checked + .checkmark {
  background: var(--brand); border-color: var(--brand);
}
.checkbox-label input:checked + .checkmark::after {
  content: "";
  width: 9px; height: 5px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
  display: block;
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: 8px;
  font-size: .9rem; font-weight: 600;
  border: none; cursor: pointer;
  transition: opacity var(--transition), transform .1s, box-shadow var(--transition);
}
.btn:active { transform: scale(.98); }
.btn svg { width: 16px; height: 16px; }
.btn-lg { padding: 12px 28px; font-size: 1rem; align-self: flex-start; }
.btn-primary {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
}
.btn-primary:hover {
  box-shadow: 0 4px 14px rgba(59,130,246,.4);
  transform: translateY(-1px);
}
.btn-primary:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; transform: none; }
.btn-pdf { background: #dc2626; color: #fff; width: 100%; justify-content: center; }
.btn-pdf:hover { background: #b91c1c; box-shadow: 0 4px 14px rgba(220,38,38,.35); }
.btn-csv { background: #16a34a; color: #fff; width: 100%; justify-content: center; }
.btn-csv:hover { background: #15803d; box-shadow: 0 4px 14px rgba(22,163,74,.35); }

/* ── Stats grid ──────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-top: 20px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: default;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 2px 4px rgba(0,0,0,.06), 0 10px 28px rgba(0,0,0,.12);
}
.stat-card.clickable { cursor: pointer; }
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(37,99,235,.15), rgba(59,130,246,.08));
  display: grid; place-items: center;
  flex-shrink: 0;
  color: var(--brand);
  margin-bottom: 8px;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-label { font-size: .74rem; color: var(--text-muted); font-weight: 600;
               text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--text); line-height: 1.1; }
.stat-link { font-size: .76rem; color: var(--brand-light); margin-top: 4px; font-weight: 500; text-decoration: none; }
.stat-card.ok    .stat-icon { background: linear-gradient(135deg, rgba(22,163,74,.15), rgba(34,197,94,.08)); color: var(--ok); }
.stat-card.warn  .stat-icon { background: linear-gradient(135deg, rgba(217,119,6,.15), rgba(245,158,11,.08)); color: var(--warn); }
.stat-card.danger .stat-icon { background: linear-gradient(135deg, rgba(220,38,38,.15), rgba(239,68,68,.08)); color: var(--danger); }

/* ── Progress ────────────────────────────────────────────────────── */
.progress-wrap { margin-top: 20px; text-align: center; }
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand-light));
  border-radius: 99px;
  width: 0%;
  transition: width .4s ease;
}
#progressText { font-size: .85rem; color: var(--text-muted); }

/* ── Placeholder card ────────────────────────────────────────────── */
.placeholder-card {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 16px;
  padding: 64px 24px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 2px dashed var(--border);
  color: var(--text-muted);
  text-align: center;
}
.placeholder-card svg { width: 64px; height: 64px; opacity: .35; }
.placeholder-card p { font-size: .95rem; }

/* ── Cert banner ─────────────────────────────────────────────────── */
.cert-banner {
  border-radius: var(--radius);
  padding: 22px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 18px;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.cert-banner::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,.12) 0%, transparent 60%);
  pointer-events: none;
}
.cert-banner.valid   { background: linear-gradient(135deg, #15803d, #22c55e); }
.cert-banner.warning { background: linear-gradient(135deg, #b45309, #f59e0b); }
.cert-banner.critical,
.cert-banner.expired { background: linear-gradient(135deg, #991b1b, #ef4444); }

.cert-banner-main { display: flex; align-items: center; gap: 18px; }
.cert-banner-icon { font-size: 2.5rem; }
.cert-banner-title { font-size: 1.4rem; font-weight: 800; }
.cert-banner-sub { font-size: .9rem; opacity: .85; margin-top: 4px; }

.gauge-svg { width: 120px; height: 60px; }
.cert-expiry-gauge { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.gauge-label { font-size: .8rem; font-weight: 600; opacity: .9; }

/* ── Cert grid ───────────────────────────────────────────────────── */
.cert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

/* ── KV list ─────────────────────────────────────────────────────── */
.kv-list { display: flex; flex-direction: column; gap: 8px; }
.kv-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  font-size: .88rem;
  padding: 6px 0;
  border-bottom: 1px solid var(--bg);
}
.kv-row:last-child { border-bottom: none; }
.kv-key { color: var(--text-muted); font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.kv-val { color: var(--text); text-align: right; word-break: break-all; font-family: "SF Mono", "Fira Code", monospace; font-size: .84rem; }

/* ── SANs ────────────────────────────────────────────────────────── */
.sans-list { display: flex; flex-wrap: wrap; gap: 8px; }
.san-chip {
  background: rgba(37,99,235,.08);
  color: var(--brand);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: .82rem;
  font-weight: 600;
  font-family: "SF Mono", "Fira Code", monospace;
}

/* ── DNS ─────────────────────────────────────────────────────────── */
.dns-filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.dns-summary { font-size: .9rem; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.dns-filter-chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.filter-chip {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
  user-select: none;
}
.filter-chip.all   { background: var(--brand);        color: #fff; }
.filter-chip.type-A     { background: #dbeafe; color: #1d4ed8; }
.filter-chip.type-AAAA  { background: #ede9fe; color: #6d28d9; }
.filter-chip.type-MX    { background: #fce7f3; color: #be185d; }
.filter-chip.type-CNAME { background: #d1fae5; color: #065f46; }
.filter-chip.type-TXT   { background: #fef9c3; color: #854d0e; }
.filter-chip.type-NS    { background: #ffedd5; color: #c2410c; }
.filter-chip.type-SOA   { background: #f1f5f9; color: #475569; }
.filter-chip.type-SRV   { background: #ecfdf5; color: #065f46; }
.filter-chip.type-CAA   { background: #fdf2f8; color: #9d174d; }
.filter-chip.type-PTR   { background: #f0fdf4; color: #166534; }
.filter-chip.inactive { opacity: .45; }
.search-input {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: .88rem;
  width: 200px;
  background: var(--bg);
  outline: none;
}
.search-input:focus { border-color: var(--brand-light); }

.dns-table-wrap { padding: 0; overflow-x: auto; }
.dns-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.dns-table thead { position: sticky; top: 60px; z-index: 10; }
.dns-table thead th {
  background: #f8fafc;
  padding: 11px 14px;
  text-align: left;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.dns-table tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
.dns-table tbody tr:nth-child(even) { background: #f8fafc; }
.dns-table tbody tr:last-child { border-bottom: none; }
.dns-table tbody tr:hover { background: #eef4ff; }
.dns-table td { padding: 10px 14px; vertical-align: middle; }
.dns-table td:nth-last-child(2) { color: var(--text-muted); font-size: .82rem; }
.dns-value { font-family: "SF Mono", "Fira Code", monospace; font-size: .83rem;
              word-break: break-all; max-width: 360px; }
.dns-ttl { color: var(--text-muted); font-size: .82rem; }
.dns-empty { padding: 40px; text-align: center; color: var(--text-muted); font-size: .92rem; }

/* ── SSL badges (DNS table) ──────────────────────────────────────── */
.ssl-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .76rem;
  font-weight: 700;
  white-space: nowrap;
}
.ssl-badge.valid    { background: #dcfce7; color: #16a34a; }
.ssl-badge.warning  { background: #fef9c3; color: #854d0e; }
.ssl-badge.critical { background: #ffedd5; color: #c2410c; }
.ssl-badge.expired  { background: #fee2e2; color: #dc2626; }
.ssl-badge.checking { background: #f1f5f9; color: #94a3b8; animation: pulse-fade 1.2s ease-in-out infinite; }
.ssl-badge.na       { background: transparent; color: #cbd5e1; }
@keyframes pulse-fade { 0%,100% { opacity:1; } 50% { opacity:.45; } }

/* ── Type badges ─────────────────────────────────────────────────── */
.type-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .03em;
}
.type-A     { background: #dbeafe; color: #1d4ed8; }
.type-AAAA  { background: #ede9fe; color: #6d28d9; }
.type-MX    { background: #fce7f3; color: #be185d; }
.type-CNAME { background: #d1fae5; color: #065f46; }
.type-TXT   { background: #fef9c3; color: #854d0e; }
.type-NS    { background: #ffedd5; color: #c2410c; }
.type-SOA   { background: #f1f5f9; color: #475569; }
.type-SRV   { background: #ecfdf5; color: #065f46; }
.type-CAA   { background: #fdf2f8; color: #9d174d; }
.type-PTR   { background: #f0fdf4; color: #166534; }

/* ── SSL badges ──────────────────────────────────────────────────── */
.ssl-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}
.ssl-badge.valid    { background: #dcfce7; color: #16a34a; }
.ssl-badge.warning  { background: #fef9c3; color: #854d0e; }
.ssl-badge.critical { background: #ffedd5; color: #c2410c; }
.ssl-badge.expired  { background: #fee2e2; color: #dc2626; }
.ssl-badge.checking { background: #f1f5f9; color: #64748b; animation: pulse 1.4s ease-in-out infinite; }
.ssl-badge.na       { background: #f1f5f9; color: #94a3b8; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .45; }
}

/* ── Export ──────────────────────────────────────────────────────── */
.export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.export-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform var(--transition), box-shadow var(--transition);
}
.export-card:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.1); }
.export-card h3 { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.export-card p { font-size: .88rem; color: var(--text-muted); line-height: 1.5; }
.export-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: grid; place-items: center;
  color: #fff;
}
.export-icon svg { width: 26px; height: 26px; }
.export-icon-pdf { background: linear-gradient(135deg, #dc2626, #ef4444); }
.export-icon-csv { background: linear-gradient(135deg, #16a34a, #22c55e); }
.export-features { padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.export-features li { font-size: .85rem; color: var(--text-muted); }

/* ── Toast ───────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--text);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: .88rem;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn .25s ease;
  max-width: 340px;
}
.toast.ok      { background: var(--ok); }
.toast.warning { background: var(--warn); }
.toast.error   { background: var(--danger); }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
@keyframes slideIn { from { transform: translateX(100%); opacity:0; } to { transform: none; opacity:1; } }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .menu-toggle { display: flex; }
  .cert-grid { grid-template-columns: 1fr; }
  .cert-banner { flex-direction: column; }
  .input-row { flex-direction: column; }
  .port-group input { width: 100%; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .section { padding: 14px; }
}
