:root {
  /* Spacing */
  --gap: 1rem;
  --radius: 8px;

  /* Light theme */
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --code-bg: #f1f3f5;
  --code-text: #1a1a2e;
  --highlight: #fef3c7;
  --cisco-bg: #e8f4fd;
  --forti-bg: #fef2f2;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-hover: 0 4px 12px rgba(0,0,0,.10);
}

[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #1a1b26;
  --text: #e4e4e7;
  --text-muted: #9ca3af;
  --border: #2e3039;
  --code-bg: #12131d;
  --code-text: #d4d4d8;
  --highlight: #422006;
  --cisco-bg: #0c1929;
  --forti-bg: #1f0a0a;
  --shadow: 0 1px 3px rgba(0,0,0,.3);
  --shadow-hover: 0 4px 12px rgba(0,0,0,.4);
}

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

html {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ========================================================================= */
/* Layout                                                                     */
/* ========================================================================= */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: var(--gap) 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-inner {
  max-width: 1340px;
  margin: 0 auto;
  padding: 0 var(--gap);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  flex-wrap: wrap;
}

.app-title {
  font-size: 1.25rem;
  font-weight: 700;
  white-space: nowrap;
}

.app-title .subtitle {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-left: 0.5rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Search */
.search-wrap {
  position: relative;
}

.search-wrap input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.45rem 0.75rem 0.45rem 2rem;
  font-size: 0.9rem;
  color: var(--text);
  width: 220px;
  transition: border-color 0.2s, width 0.2s;
}

.search-wrap input:focus {
  outline: none;
  border-color: #6366f1;
  width: 280px;
}

.search-wrap::before {
  content: "🔍";
  position: absolute;
  left: 0.55rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem;
  pointer-events: none;
}

/* Theme toggle */
.icon-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  color: var(--text);
  font-size: 1rem;
  transition: background 0.2s;
}
.icon-btn:hover { background: var(--border); }

/* Platform selector */
.platform-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.platform-btn {
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.platform-btn:hover {
  border-color: var(--pcolor);
  background: var(--bg);
}

.platform-btn.active {
  border-color: var(--pcolor);
  background: var(--pcolor);
  color: #fff;
}

.platform-btn.active:hover {
  opacity: 0.9;
}

/* Section nav */
.section-nav {
  max-width: 1340px;
  margin: 0 auto;
  padding: 0.75rem var(--gap);
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  overflow-x: auto;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.78rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius);
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  background: var(--surface);
  color: var(--text);
}

/* Main content */
main {
  max-width: 1340px;
  margin: 0 auto;
  padding: 0 var(--gap) 3rem;
}

/* ========================================================================= */
/* Cards                                                                      */
/* ========================================================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--gap);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card h2 {
  font-size: 1.1rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 1;
}

.section-icon { display: flex; align-items: center; }

/* Notes */
.notes {
  padding: 0.65rem 1rem;
  background: var(--highlight);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.notes p { margin-bottom: 0.25rem; }
.notes p:last-child { margin-bottom: 0; }

/* ========================================================================= */
/* Tables                                                                     */
/* ========================================================================= */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

thead th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--bg);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  white-space: nowrap;
}

/* Platform column header accent */
th.col-platform {
  border-top: 3px solid var(--pcolor);
}

tbody td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover { background: color-mix(in srgb, var(--text) 3%, transparent); }

.col-task {
  font-weight: 500;
  white-space: nowrap;
  min-width: 140px;
}

.col-platform {
  min-width: 180px;
}

/* Family coloring */
td.family-cisco  { background: color-mix(in srgb, var(--cisco-bg) 50%, transparent); }
td.family-fortinet { background: color-mix(in srgb, var(--forti-bg) 50%, transparent); }

/* N/A */
.na {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.85em;
}

/* Step numbers */
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: #6366f1;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  margin-right: 0.4rem;
  flex-shrink: 0;
}

/* ========================================================================= */
/* Code                                                                       */
/* ========================================================================= */
code {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
  font-size: 0.82rem;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  word-break: break-word;
}

.code-blocks {
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.code-block {}

.code-title {
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.platform-badge {
  font-size: 0.7rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--pcolor);
  color: #fff;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  overflow-x: auto;
  position: relative;
}

pre code {
  background: transparent;
  padding: 0;
  font-size: 0.82rem;
  line-height: 1.5;
}

.copy-btn {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
  opacity: 0;
}

pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--text); border-color: var(--text-muted); }

/* ========================================================================= */
/* Footer                                                                     */
/* ========================================================================= */
.app-footer {
  max-width: 1340px;
  margin: 0 auto;
  padding: 1rem var(--gap) 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.app-footer button {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s;
}

.app-footer button:hover { background: var(--bg); }

#update-status {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem var(--gap);
  color: var(--text-muted);
  font-size: 1.1rem;
}

/* ========================================================================= */
/* Responsive                                                                 */
/* ========================================================================= */
@media (max-width: 768px) {
  html { font-size: 14px; }

  .app-title .subtitle { display: none; }

  .search-wrap input {
    width: 150px;
  }
  .search-wrap input:focus {
    width: 180px;
  }

  .section-nav {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }

  .nav-link { font-size: 0.72rem; padding: 0.2rem 0.5rem; }

  .col-task { min-width: 100px; font-size: 0.82rem; }
  .col-platform { min-width: 140px; }
}

@media (max-width: 480px) {
  .header-top { flex-direction: column; align-items: flex-start; }
  .header-actions { width: 100%; justify-content: space-between; }

  .search-wrap input { width: 100%; }
  .search-wrap input:focus { width: 100%; }

  .platform-btn { font-size: 0.72rem; padding: 0.3rem 0.65rem; }
}

/* Print */
@media print {
  .app-header, .section-nav, .app-footer, .copy-btn { display: none !important; }
  .card { break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
  body { background: #fff; }
}
