/* NECTables.com — electrical code reference tables and calculators */

:root {
  --ink:          #0F172A;
  --ink-soft:     #1E293B;
  --amber:        #F59E0B;
  --amber-dark:   #B45309;
  --blue:         #1D4ED8;
  --bg:           #F8FAFC;
  --surface:      #FFFFFF;
  --text:         #1E293B;
  --text-muted:   #64748B;
  --th-bg:        #EEF2F7;
  --row-alt:      #F8FAFC;
  --border:       #CBD5E1;
  --border-soft:  #E2E8F0;
  --ok:           #15803D;
  --ok-bg:        #DCFCE7;
  --bad:          #B91C1C;
  --bad-bg:       #FEE2E2;
  --warn-bg:      #FEF3C7;
  --radius:       8px;
  --shadow:       0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);
  --maxw:         1160px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.62;
  color: var(--text);
  background: var(--bg);
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: -.017em;
  color: var(--ink);
  margin: 0 0 .5em;
}
h1 { font-size: clamp(1.65rem, 1.2rem + 2vw, 2.3rem); }
h2 { font-size: clamp(1.25rem, 1.1rem + 1vw, 1.5rem); margin-top: 2.4rem; }
h3 { font-size: 1.06rem; margin-top: 1.5rem; }

p { margin: 0 0 1rem; }
ul, ol { margin: 0 0 1.2rem; padding-left: 1.3rem; }
li { margin-bottom: .35rem; }

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9em;
  background: var(--th-bg);
  padding: .1em .35em;
  border-radius: 3px;
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 1.1rem; }
.narrow { max-width: 780px; }
.muted { color: var(--text-muted); font-size: .9rem; }
.nowrap { white-space: nowrap; }

/* ---------- header ---------- */

.site-header {
  background: var(--ink);
  color: #fff;
  border-bottom: 3px solid var(--amber);
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 58px;
}
.brand {
  display: flex;
  align-items: center;
  gap: .55rem;
  color: #fff;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -.02em;
}
.brand:hover { text-decoration: none; }
.brand svg { width: 32px; height: 32px; flex: none; }
.brand .dot { color: var(--amber); }

.site-nav { display: flex; flex-wrap: wrap; gap: .1rem .2rem; }
.site-nav a {
  color: #CBD5E1;
  font-size: .9rem;
  font-weight: 500;
  padding: .45rem .6rem;
  border-radius: 6px;
}
.site-nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); text-decoration: none; }
.site-nav a.active { color: var(--amber); }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid rgba(255, 255, 255, .25);
  color: #fff;
  border-radius: 6px;
  padding: .4rem .55rem;
  cursor: pointer;
}
.nav-toggle svg { width: 22px; height: 22px; display: block; }

@media (max-width: 900px) {
  .nav-toggle { display: block; }
  .site-nav {
    display: none;
    position: absolute;
    left: 0; right: 0; top: 100%;
    background: var(--ink);
    border-bottom: 3px solid var(--amber);
    padding: .5rem 1rem 1rem;
    flex-direction: column;
  }
  .site-nav.open { display: flex; }
  .site-nav a { font-size: 1rem; padding: .65rem .5rem; }
}

/* ---------- breadcrumbs ---------- */

.breadcrumbs { background: var(--surface); border-bottom: 1px solid var(--border-soft); font-size: .85rem; }
.breadcrumbs ol { list-style: none; margin: 0; padding: .6rem 0; display: flex; flex-wrap: wrap; gap: .2rem .4rem; }
.breadcrumbs li { margin: 0; color: var(--text-muted); }
.breadcrumbs li + li::before { content: "›"; margin-right: .4rem; color: var(--border); }

/* ---------- page head ---------- */

.page-head { padding: 1.8rem 0 .4rem; }
.page-head .lede { font-size: 1.08rem; color: #334155; max-width: 820px; }
.answer {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-left: 4px solid var(--amber);
  border-radius: var(--radius);
  padding: .9rem 1.1rem;
  margin: 0 0 1.4rem;
  max-width: 860px;
  font-size: 1.05rem;
}
.answer strong { color: var(--ink); }

.hero {
  background: linear-gradient(160deg, var(--ink) 0%, #1E3A8A 100%);
  color: #E2E8F0;
  padding: 2.8rem 0 2.6rem;
}
.hero h1 { color: #fff; max-width: 800px; }
.hero p { max-width: 720px; font-size: 1.1rem; margin-bottom: 1.4rem; }
.hero .btn { margin: 0 .5rem .5rem 0; }

.btn {
  display: inline-block;
  background: var(--amber);
  color: var(--ink);
  font-weight: 600;
  padding: .65rem 1.1rem;
  border-radius: var(--radius);
  border: 0;
  cursor: pointer;
  font-size: .97rem;
  font-family: inherit;
}
.btn:hover { background: #FBBF24; text-decoration: none; }
.btn.ghost { background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, .4); }
.btn.ghost:hover { background: rgba(255, 255, 255, .1); }
.btn.small { padding: .4rem .7rem; font-size: .85rem; }
.btn.plain { background: var(--th-bg); color: var(--ink); }

/* ---------- cards ---------- */

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 1rem; margin: 1.2rem 0 2rem; }
.grid.tight { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1.05rem 1.15rem;
  box-shadow: var(--shadow);
  color: var(--text);
  transition: border-color .15s, transform .15s;
}
a.card:hover { border-color: var(--amber); transform: translateY(-2px); text-decoration: none; }
.card .kicker { font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--amber-dark); }
.card h3 { margin: .15rem 0 .3rem; font-size: 1.05rem; }
.card p { margin: 0; font-size: .9rem; color: var(--text-muted); }
.grid.tight .card { padding: .7rem .85rem; text-align: center; font-weight: 600; color: var(--ink); }
.grid.tight .card small { display: block; font-weight: 400; color: var(--text-muted); font-size: .78rem; }

/* ---------- tables ---------- */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 1rem 0 1.6rem;
}
table.data { border-collapse: collapse; width: 100%; font-size: .93rem; font-variant-numeric: tabular-nums; }
table.data caption { caption-side: top; text-align: left; padding: .8rem 1rem .6rem; font-weight: 600; color: var(--ink); }
table.data th, table.data td { padding: .5rem .8rem; text-align: right; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th { background: var(--th-bg); color: var(--ink); font-weight: 600; font-size: .84rem; position: sticky; top: 0; }
table.data thead tr.group th { text-align: center; border-bottom: 1px solid var(--border); }
table.data tbody tr:nth-child(even) { background: var(--row-alt); }
table.data tbody tr:hover { background: #FEF9E7; }
table.data tbody th { font-weight: 600; color: var(--ink); background: inherit; }
table.data td.left, table.data th.left { text-align: left; }
table.data td.wrap, table.data th.wrap { white-space: normal; min-width: 14rem; }
table.data td.hl { background: #FEF3C7; font-weight: 700; color: var(--ink); }
table.data td.none { color: #94A3B8; }
table.data tr.sep td, table.data tr.sep th { border-top: 2px solid var(--border); }

.swatch { display: inline-block; width: 1.05em; height: 1.05em; border-radius: 3px; border: 1px solid rgba(0, 0, 0, .25); vertical-align: -.15em; margin-right: .4em; }

/* ---------- calculators ---------- */

.calc {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-top: 4px solid var(--amber);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem 1.25rem 1.3rem;
  margin: 1rem 0 2rem;
}
.calc h2 { margin-top: 0; font-size: 1.2rem; }
.calc-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem 1rem; }
.field label { display: block; font-size: .8rem; font-weight: 600; color: #475569; margin-bottom: .25rem; }
.field select, .field input {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: .55rem .6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  min-height: 44px;
}
.field select:focus, .field input:focus { outline: 2px solid var(--amber); outline-offset: 1px; border-color: var(--amber); }

.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs button {
  font: inherit; font-size: .9rem; font-weight: 600;
  padding: .5rem .85rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: #fff; color: #475569;
}
.tabs button[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

.wire-rows { margin: 1rem 0 .4rem; display: grid; gap: .5rem; }
.wire-row { display: grid; grid-template-columns: 5rem 1fr 1fr 2.6rem; gap: .5rem; align-items: end; }
.wire-row .field label { font-size: .72rem; }
.wire-row button { min-height: 44px; border: 1px solid var(--border); background: #fff; border-radius: 6px; cursor: pointer; font-size: 1.1rem; color: var(--bad); }
@media (max-width: 520px) { .wire-row { grid-template-columns: 4rem 1fr 1fr 2.4rem; gap: .35rem; } }

.result {
  margin-top: 1.1rem;
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  background: var(--th-bg);
  border: 1px solid var(--border-soft);
}
.result.ok { background: var(--ok-bg); border-color: #86EFAC; }
.result.bad { background: var(--bad-bg); border-color: #FCA5A5; }
.result .big { font-size: 1.7rem; font-weight: 700; color: var(--ink); line-height: 1.15; }
.result .big small { font-size: .95rem; font-weight: 500; color: #475569; }
.result p { margin: .35rem 0 0; font-size: .93rem; }
.result ul { margin: .5rem 0 0; font-size: .92rem; }
.meter { height: 12px; border-radius: 999px; background: #fff; border: 1px solid var(--border); overflow: hidden; margin-top: .7rem; position: relative; }
.meter span { display: block; height: 100%; background: var(--ok); width: 0; transition: width .2s; }
.meter.over span { background: var(--bad); }
.meter i { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink); }

/* ---------- prose & misc ---------- */

.prose { max-width: 820px; }
.prose h2:first-child { margin-top: 1rem; }
.note {
  background: var(--warn-bg);
  border: 1px solid #FCD34D;
  border-radius: var(--radius);
  padding: .8rem 1rem;
  font-size: .92rem;
  margin: 1.2rem 0;
  max-width: 860px;
}
.formula {
  background: var(--ink);
  color: #F1F5F9;
  border-radius: var(--radius);
  padding: .9rem 1.1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .92rem;
  overflow-x: auto;
  margin: 1rem 0 1.3rem;
  max-width: 860px;
}
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .7rem; margin: 1rem 0 1.6rem; }
.stat { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: .75rem .9rem; box-shadow: var(--shadow); }
.stat .k { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 600; }
.stat .v { font-size: 1.35rem; font-weight: 700; color: var(--ink); line-height: 1.25; }
.stat .v small { font-size: .8rem; font-weight: 500; color: var(--text-muted); }

.pager { display: flex; justify-content: space-between; gap: 1rem; margin: 2rem 0 1rem; font-size: .93rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .6rem 0 1.4rem; padding: 0; list-style: none; }
.chips li { margin: 0; }
.chips a, .chips span { display: inline-block; padding: .3rem .7rem; border: 1px solid var(--border); border-radius: 999px; font-size: .86rem; background: #fff; color: var(--ink); }
.chips a:hover { border-color: var(--amber); text-decoration: none; }
.chips span { background: var(--ink); color: #fff; border-color: var(--ink); }

.faq { max-width: 860px; margin-bottom: 2rem; }
.faq details { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); margin-bottom: .5rem; }
.faq summary { cursor: pointer; font-weight: 600; padding: .8rem 1rem; color: var(--ink); }
.faq details p { padding: 0 1rem .9rem; margin: 0; }

.disclaimer { font-size: .84rem; color: var(--text-muted); border-top: 1px solid var(--border-soft); padding-top: 1rem; margin: 2.5rem 0 2rem; max-width: 900px; }

main { min-height: 60vh; padding-bottom: 1rem; }

/* ---------- footer ---------- */

.site-footer { background: var(--ink); color: #94A3B8; margin-top: 3rem; padding: 2.4rem 0 1.6rem; font-size: .9rem; }
.site-footer h3 { color: #fff; font-size: .82rem; text-transform: uppercase; letter-spacing: .07em; margin: 0 0 .7rem; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer a { color: #CBD5E1; }
.site-footer a:hover { color: var(--amber); }
.footer-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1.6rem; }
.footer-legal { border-top: 1px solid #334155; margin-top: 2rem; padding-top: 1.2rem; font-size: .8rem; line-height: 1.55; }
.footer-legal p { margin-bottom: .5rem; }

@media print {
  .site-header, .site-footer, .breadcrumbs, .calc, .pager, .nav-toggle { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .table-wrap { box-shadow: none; border: 0; overflow: visible; }
}
