@font-face {
  font-family: "VT323";
  src: url("/static/fonts/VT323-Regular.woff2") format("woff2");
  font-display: swap;
}

:root {
  --phosphor:        #4aff8f;
  --phosphor-dim:    #2a8f4f;
  --phosphor-bright: #8affb5;
  --amber:           #ffd04a;
  --red:             #ff5050;
  --bg:              #0a1a0a;
  --bg-panel:        #081408;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--phosphor);
  font-family: "VT323", "Share Tech Mono", "Courier New", monospace;
  font-size: 20px;
  line-height: 1.3;
  text-shadow: 0 0 4px rgba(74, 255, 143, 0.6);
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0) 0 2px,
    rgba(0,0,0,0.35) 3px,
    rgba(0,0,0,0) 4px
  );
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.55) 100%);
}

.frame {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 80px;
  position: relative;
  z-index: 1;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--phosphor-dim);
  margin-bottom: 12px;
  letter-spacing: 1px;
}
.header .brand { color: var(--phosphor-bright); font-weight: bold; }

.tabs {
  display: flex;
  gap: 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--phosphor-dim);
  margin-bottom: 16px;
}
.tab {
  padding: 6px 14px;
  border: 1px solid var(--phosphor-dim);
  border-bottom: none;
  color: var(--phosphor);
  text-decoration: none;
  letter-spacing: 2px;
}
.tab.active { background: var(--phosphor); color: var(--bg); text-shadow: none; }

@media (max-width: 768px) {
  /* Bottom tab bar on mobile. Dotted labels (E·M·I·S·O·R) exceed equal-flex
     width, so allow natural widths + horizontal scroll instead of squashing. */
  .tabs {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--bg);
    border-top: 1px solid var(--phosphor-dim);
    border-bottom: none;
    margin: 0;
    z-index: 10;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .tab {
    border: none;
    flex: 0 0 auto;
    text-align: center;
    padding: 12px 12px;
    font-size: 15px;
    letter-spacing: 1px;
  }
  .tab + .tab::before {
    content: "·";
    color: var(--phosphor-dim);
    padding-right: 10px;
    padding-left: 0;
  }
  .tab.active { background: transparent; color: var(--amber); text-shadow: 0 0 6px var(--amber); }
  .frame { padding-bottom: 80px; }
  /* Tables inside panels can be wider than the viewport on mobile (clientes,
     productos, facturas, factura-nueva cliente picker). Scroll within the
     panel rather than clipping action buttons offscreen. */
  .panel { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--phosphor-dim);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.panel h2 { margin: 0 0 8px; color: var(--phosphor-bright); letter-spacing: 3px; font-size: 18px; }

.form-field { margin-bottom: 14px; }
.form-field label {
  display: block;
  font-size: 16px;
  letter-spacing: 2px;
  color: var(--phosphor-bright);
  margin-bottom: 4px;
}
input[type="text"], input[type="email"], input[type="password"], textarea, select {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg);
  color: var(--phosphor);
  border: 1px solid var(--phosphor-dim);
  font-family: inherit;
  font-size: 18px;
  text-shadow: none;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.btn {
  display: inline-block;
  padding: 10px 20px;
  background: transparent;
  color: var(--phosphor);
  border: 1px solid var(--phosphor);
  font-family: inherit;
  font-size: 18px;
  letter-spacing: 2px;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--phosphor); color: var(--bg); text-shadow: none; }
.btn-primary { border-color: var(--amber); color: var(--amber); }
.btn-primary:hover { background: var(--amber); color: var(--bg); }

.alert { padding: 8px 12px; border-left: 3px solid; margin-bottom: 12px; }
.alert-error { border-color: var(--red); color: var(--red); text-shadow: 0 0 4px rgba(255,80,80,0.5); }

@media (prefers-reduced-motion: reduce) {
  body::before, body::after { display: none; }
}

.price-input { border-color: var(--amber); }

.banner { padding: 8px 16px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
.banner-yellow { background: var(--amber); color: #000; }
.banner-red { background: var(--red); color: #fff; }
.banner-block { font-weight: bold; }

.btn-confirm { background: var(--red); color: #fff; }
.awaiting-pac { margin-top: 8px; font-style: italic; opacity: 0.8; }

/* Inline CSD expiration hint shown under the CSD date field on /emisor.
   The layout-level banner still handles the page-top alert; this is the
   per-field reminder that mirrors the same state language. */
.csd-hint { margin-top: 6px; font-size: 14px; opacity: 0.8; }
.csd-hint-watch { color: var(--amber); opacity: 1; }
.csd-hint-warning { color: var(--red); opacity: 1; }
.csd-hint-expired { color: var(--phosphor-dim); text-decoration: line-through; }

/* Palette swaps — default (green) defined in :root from Session 1. */
body.palette-amber {
    --phosphor: #ffb000;
    --phosphor-dim: #8a5d00;
    --phosphor-bright: #ffd77a;
    --bg: #1a0a00;
    --bg-panel: #140700;
}
body.palette-white {
    --phosphor: #e8e8e8;
    --phosphor-dim: #6a6a6a;
    --phosphor-bright: #ffffff;
    --bg: #0a0a0a;
    --bg-panel: #050505;
}

/* Global `html, body { text-shadow: ... }` was hardcoded green in Session 1.
   Override per palette so the phosphor glow follows the active palette. */
body.palette-amber { text-shadow: 0 0 4px rgba(255, 176, 0, 0.6); }
body.palette-white { text-shadow: 0 0 4px rgba(232, 232, 232, 0.5); }

/* Scanlines off — strip the overlay. */
body.scanlines-off::before { display: none !important; }

.boot-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg, #0a1a0a);
    color: var(--phosphor, #7fff7f);
    z-index: 9999;
    display: none;
    transition: opacity .4s;
}
.boot-overlay .boot-line {
    padding: 24px;
    font-family: inherit;
    white-space: pre-wrap;
}

.first-stamp-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.85);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; cursor: pointer;
}
.first-stamp-inner {
    background: var(--bg, #0a1a0a);
    border: 1px solid var(--phosphor);
    padding: 32px; max-width: 480px; text-align: center;
}

/* SAT-catalog autocomplete (views.SATSearchInput). */
.sat-search { position: relative; display: block; }
.sat-search .sat-search-input { width: 100%; box-sizing: border-box; }
.sat-search .sat-search-pill {
    margin-top: 4px;
    font-size: 0.85em;
    color: var(--phosphor-dim, #3a7a3a);
}
.sat-search .sat-search-pill code {
    background: var(--bg-panel, #0a1a0a);
    color: var(--phosphor, #7fff7f);
    padding: 1px 5px;
    border: 1px solid var(--phosphor-dim, #3a7a3a);
}
.sat-search .sat-muted { color: var(--phosphor-dim, #3a7a3a); font-style: italic; }
.sat-search .sat-dropdown {
    list-style: none;
    margin: 2px 0 0;
    padding: 0;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 100;
    background: var(--bg-panel, #0a1a0a);
    border: 1px solid var(--phosphor, #7fff7f);
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
    max-height: 320px;
    overflow-y: auto;
}
.sat-search .sat-dropdown:empty { display: none; }
.sat-search .sat-opt,
.sat-search .sat-err,
.sat-search .sat-empty {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.95em;
    color: var(--phosphor, #7fff7f);
    border-bottom: 1px solid rgba(127, 255, 127, 0.15);
}
.sat-search .sat-opt:last-child,
.sat-search .sat-err:last-child,
.sat-search .sat-empty:last-child { border-bottom: none; }
.sat-search .sat-opt:hover { background: var(--phosphor, #7fff7f); color: var(--bg, #0a1a0a); }
.sat-search .sat-err { color: var(--red, #d44); cursor: default; }
.sat-search .sat-empty { color: var(--phosphor-dim, #3a7a3a); cursor: default; font-style: italic; }

/* Product picker reuses .sat-search layout; each .sat-opt wraps a <form>
   whose submit button is the clickable row. Flatten the button so it
   behaves like the plain <li> hover target used by SAT autocomplete. */
.sat-search .product-opt { padding: 0; }
.sat-search .product-opt-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    background: transparent;
    color: inherit;
    border: none;
    font: inherit;
    cursor: pointer;
}
.sat-search .product-opt:hover .product-opt-btn { color: var(--bg, #0a1a0a); }
.sat-search .sat-section {
    padding: 6px 12px;
    font-size: 0.8em;
    letter-spacing: 0.1em;
    color: var(--phosphor-dim, #3a7a3a);
    background: rgba(127, 255, 127, 0.04);
    border-bottom: 1px solid rgba(127, 255, 127, 0.15);
    cursor: default;
}

/* Collapsible "+ PARTIDA" panel on the invoice items editor. */
.add-item-panel { margin-top: .5em; }
.add-item-panel > summary {
    list-style: none;
    cursor: pointer;
    display: inline-block;
}
.add-item-panel > summary::-webkit-details-marker { display: none; }
.add-item-panel[open] > summary { margin-bottom: .6em; }
.add-item-body {
    border: 1px solid var(--phosphor-dim, #3a7a3a);
    padding: .8em;
    background: rgba(127, 255, 127, 0.03);
}
.add-item-heading { margin: 0 0 .4em 0; font-size: .95em; }
.add-item-alt {
    margin-top: .8em;
    display: flex;
    align-items: center;
    gap: 1em;
    flex-wrap: wrap;
}
.btn-link {
    background: none;
    border: none;
    color: var(--phosphor-dim, #3a7a3a);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
    font-size: .9em;
}
.btn-link:hover { color: var(--phosphor, #7fff7f); }

/* Clickable table rows on the facturas list. */
.row-clickable:hover { background: rgba(127, 255, 127, 0.06); }

/* Plain anchors inside list tables (not .btn). Default browser link color
   (blue/purple) is unreadable against the phosphor-green background. Use
   amber + underline so the link stands out from surrounding white/phosphor
   cell text and matches the .btn-primary accent. */
table.list a:not(.btn) {
    color: var(--amber, #ffcf4a);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}
table.list a:not(.btn):hover {
    color: var(--phosphor-bright, #a8ffa8);
    text-shadow: 0 0 6px rgba(127, 255, 127, 0.6);
}
.row-actions { white-space: nowrap; }
.row-actions .btn { margin-right: .3em; }

/* Read-only SAT-code display inside line-item cards. */
.readonly-field {
    display: inline-block;
    padding: .4em .6em;
    color: var(--phosphor-dim, #3a7a3a);
    border: 1px dashed rgba(127, 255, 127, 0.2);
    font-family: inherit;
    font-size: .95em;
    min-width: 5em;
}
