/* ============================================================
   WEC Panel Schedule Generator
   Screen UI + print stylesheet (letter portrait, laminate-ready)
   ============================================================ */

:root {
  --ink: #111111;
  --line: #000000;
  --muted: #666666;
  --bg: #f4f5f7;
  --card: #ffffff;
  --border: #d7dbe0;
  --accent: #00529B;      /* WEC accent — swap here to restyle */
  --accent-ink: #ffffff;
  --phase-a: #e8f0fb;
  --phase-b: #eaf7ec;
  --phase-c: #fdf0e8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

/* ---------- App bar ---------- */
.appbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; background: #fff; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.appbar-brand { display: flex; align-items: center; gap: 12px; }
.appbar-logo { height: 26px; width: auto; }
.appbar-title { font-weight: 700; font-size: 15px; letter-spacing: .2px; }
.appbar-actions { display: flex; gap: 8px; }

.btn {
  font: inherit; font-weight: 600; font-size: 13px; cursor: pointer;
  border-radius: 6px; padding: 8px 14px; border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-secondary { background: #eef1f5; color: var(--ink); border-color: var(--border); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn:hover { filter: brightness(.96); }

/* ---------- Layout ---------- */
.layout {
  display: grid; grid-template-columns: minmax(420px, 560px) 1fr;
  gap: 20px; padding: 20px; align-items: start;
}
@media (max-width: 1024px) { .layout { grid-template-columns: 1fr; } }

.panel-inputs { display: flex; flex-direction: column; gap: 16px; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px 16px; margin: 0;
}
.card legend { font-weight: 700; font-size: 13px; padding: 0 6px; color: var(--accent); }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0 12px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.grid2 .span2 { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; font-size: 12px; font-weight: 600; color: #333; gap: 4px; }
input, select {
  font: inherit; font-size: 13px; font-weight: 400; padding: 7px 9px;
  border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ---------- Photo ---------- */
.photo-row { display: flex; align-items: center; gap: 12px; }
.photo-status { font-size: 12px; color: var(--muted); }
.photo-status.working { color: var(--accent); }
.photo-status.error { color: #b42b34; }
.photo-preview { display: block; max-width: 100%; max-height: 180px; margin-top: 10px; border: 1px solid var(--border); border-radius: 6px; }

/* ---------- Circuit editor rows ---------- */
.circuit-head, .crow {
  display: grid; grid-template-columns: 40px 1fr 52px 46px 52px; gap: 6px; align-items: center;
}
.circuit-head { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; margin-bottom: 6px; padding: 0 2px; }
.crow { margin-bottom: 5px; }
.crow .ckt-num { font-size: 12px; font-weight: 700; text-align: center; color: var(--muted); }
.crow input, .crow select { padding: 5px 7px; font-size: 12px; }
.crow .ph-in { text-align: center; text-transform: uppercase; }

/* ============================================================
   THE SHEET (preview + print). Sized to US Letter portrait.
   ============================================================ */
.preview-scaler { position: sticky; top: 76px; }
.sheet {
  width: 8.5in; min-height: 11in; background: #fff; color: #000;
  padding: 0.35in 0.4in; margin: 0 auto;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
  transform-origin: top center;
  font-size: 9.5pt; line-height: 1.15;
}
/* scale down to fit the preview column on screen only */
@media screen and (max-width: 1400px) { .sheet { transform: scale(.82); } }
@media screen and (max-width: 1180px) { .sheet { transform: scale(.66); } }

/* Sheet header */
.sh-head { display: flex; align-items: flex-start; gap: 14px; border-bottom: 2.5px solid #000; padding-bottom: 8px; }
.sh-logo { height: 46px; width: auto; }
.sh-titlewrap { flex: 1; }
.sh-title { font-size: 17pt; font-weight: 800; letter-spacing: .3px; text-transform: uppercase; }
.sh-sub { font-size: 8.5pt; color: #333; }
.sh-panelbadge {
  border: 2px solid #000; border-radius: 4px; padding: 4px 12px; text-align: center; min-width: 120px;
}
.sh-panelbadge .lbl { font-size: 7pt; text-transform: uppercase; color: #444; letter-spacing: .5px; }
.sh-panelbadge .val { font-size: 18pt; font-weight: 800; line-height: 1; }

/* Header info grid */
.sh-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border: 1px solid #000; border-top: none; margin-bottom: 8px; }
.sh-meta .m { border-top: 1px solid #000; border-right: 1px solid #000; padding: 3px 6px; }
.sh-meta .m:nth-child(4n) { border-right: none; }
.sh-meta .k { font-size: 6.5pt; text-transform: uppercase; color: #555; letter-spacing: .4px; }
.sh-meta .v { font-size: 9pt; font-weight: 700; min-height: 12px; }

/* Circuit table (two columns of circuits) */
.sh-table { width: 100%; border-collapse: collapse; }
.sh-table th, .sh-table td { border: 1px solid #000; padding: 2px 4px; font-size: 8pt; }
.sh-table thead th { background: #000; color: #fff; font-size: 6.8pt; text-transform: uppercase; letter-spacing: .3px; }
.sh-table td.c-ckt { text-align: center; font-weight: 800; width: 26px; }
.sh-table td.c-amp { text-align: center; width: 34px; }
.sh-table td.c-pole { text-align: center; width: 24px; }
.sh-table td.c-ph { text-align: center; width: 20px; font-weight: 700; }
.sh-table td.c-desc { text-align: left; }
.sh-table .mid { border-left: 2.5px solid #000; }
.sh-table td.c-empty { background: #fafafa; }
.ph-A { background: var(--phase-a); }
.ph-B { background: var(--phase-b); }
.ph-C { background: var(--phase-c); }

/* Footer branding */
.sh-foot {
  margin-top: 10px; border-top: 2.5px solid #000; padding-top: 7px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.sh-foot .msg { font-size: 8.5pt; font-weight: 600; max-width: 62%; }
.sh-foot .contact { text-align: right; font-size: 8.5pt; }
.sh-foot .contact .big { font-size: 12pt; font-weight: 800; }

/* ============================================================
   PRINT
   ============================================================ */
@page { size: letter portrait; margin: 0.3in; }
@media print {
  .no-print { display: none !important; }
  html, body { background: #fff; }
  .preview-scaler { position: static; top: auto; }
  .sheet {
    transform: none !important; box-shadow: none; width: auto; min-height: 0;
    padding: 0; margin: 0;
  }
  /* keep phase shading in print */
  .ph-A, .ph-B, .ph-C, .sh-table thead th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
