/* ============================================================
   MetalStock Pro — Estilos principales  (Light mode)
   Paleta: verde menta (#b2dfdb) header · verde (#26a69a) acento
   ============================================================ */

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

:root {
  color-scheme: light;

  --accent:        #26a69a;
  --accent-dark:   #00695c;
  --accent-light:  #e0f2f1;
  --danger:        #e53935;
  --danger-light:  #fdecea;
  --amber:         #e65100;
  --amber-light:   #fff3e0;

  --bg:            #ffffff;
  --bg-secondary:  #f5f5f5;
  --bg-app:        #f0f4f3;
  --header-bg:     #b2dfdb;

  --text:          #212121;
  --text-mid:      #555555;
  --text-muted:    #9e9e9e;
  --border:        rgba(0,0,0,0.09);
  --border-mid:    rgba(0,0,0,0.16);

  --radius-md: 8px;
  --radius-lg: 10px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08), 0 0 0 0.5px rgba(0,0,0,0.05);
  --font: 'Segoe UI', -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif;
}

html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg-app);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.app { min-height: 100vh; }

.section {
  display: none;
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
  padding: 1.25rem 1.25rem 0;
}
.section.active { display: block; }

/* ============================================================
   HEADER — barra verde menta a todo el ancho
   ============================================================ */
.header {
  background: var(--header-bg);
  padding: .9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
}

.logo { display: flex; align-items: center; gap: .75rem; }

.logo-icon {
  width: 36px; height: 36px;
  background: #00695c;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-icon svg { width: 20px; height: 20px; }

.logo-text { font-size: 17px; font-weight: 700; color: #1a3c39; line-height: 1.2; }
.logo-sub  { font-size: 11px; color: #4a706d; }

.date-badge {
  font-size: 13px;
  color: #2e5250;
  font-weight: 500;
  text-transform: capitalize;
}

/* ============================================================
   TABS — barra blanca pegada debajo del header
   ============================================================ */
.tabs {
  display: flex;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 1.25rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* ancho total */
  width: 100%;
  max-width: 100%;
}

.tab {
  padding: .8rem 1.1rem;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-mid);
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font);
  transition: color .15s, border-color .15s;
  margin-bottom: -1px;
}
.tab:hover:not(.active) { color: var(--accent); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}
.card-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* ============================================================
   STATS — 4 tarjetas blancas con sombra
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
}
.stat-label { font-size: 12px; color: var(--text-mid);   margin-bottom: .3rem; }
.stat-val   { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-sub   { font-size: 11px; color: var(--text-muted); margin-top: .2rem; }

/* ============================================================
   SEARCH BOX
   ============================================================ */
.search-box {
  display: block;
  width: 100%;
  max-width: 320px;
  height: 36px;
  padding: 0 .85rem 0 2.2rem;
  border: 1px solid var(--border-mid);
  border-radius: 22px;
  font-size: 13px;
  background: var(--bg-secondary)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23aaa' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E")
    no-repeat .75rem center;
  color: var(--text);
  font-family: var(--font);
  outline: none;
  margin-bottom: 1rem;
  transition: border-color .15s;
}
.search-box:focus { border-color: var(--accent); background-color: var(--bg); }

/* ============================================================
   TABLE
   ============================================================ */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 580px; }

thead th {
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: .5rem .85rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: .65rem .85rem;
  border-bottom: 0.5px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg-secondary); }

.mat-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: .2rem .65rem;
  border-radius: 999px;
}

/* Estado */
.badge-red    { background: #fdecea; color: #c62828; }
.badge-amber  { background: #fff3e0; color: #bf360c; }
.badge-green  { background: #e8f5e9; color: #2e7d32; }

/* Categoría genérica */
.badge-blue   { background: #e8eaf6; color: #283593; }

/* Categorías específicas (coinciden con la foto) */
.badge-cat-radiadores { background: #e8eaf6; color: #283593; }
.badge-cat-aluminio   { background: #e0f2f1; color: #00695c; }
.badge-cat-cobre      { background: #fff8e1; color: #e65100; }

/* ============================================================
   MOVEMENT TYPE — tarjetas de selección (opción C)
   ============================================================ */
.movement-type {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  margin-bottom: 1rem;
}

.mt-btn {
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  padding: .9rem 1rem;
  background: var(--bg);
  cursor: pointer;
  font-family: var(--font);
  text-align: left;
  transition: background .15s, border-color .15s;
}
.mt-btn:hover { background: var(--bg-secondary); }

.mt-btn-icon  { font-size: 20px; margin-bottom: .25rem; line-height: 1; }
.mt-btn-title { font-size: 14px; font-weight: 600; }
.mt-btn-sub   { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.mt-btn.sel-in  { border-color: var(--accent); border-width: 1.5px; background: var(--accent-light); }
.mt-btn.sel-in  .mt-btn-title { color: var(--accent-dark); }

.mt-btn.sel-out  { border-color: var(--danger); border-width: 1.5px; background: var(--danger-light); }
.mt-btn.sel-out .mt-btn-title { color: var(--danger); }

/* ============================================================
   FORMS
   ============================================================ */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .75rem;
  margin-bottom: .85rem;
}
.form-group { display: flex; flex-direction: column; gap: 3px; }
.form-group label { font-size: 11px; font-weight: 600; color: var(--text-mid); }

.form-group input,
.form-group select {
  height: 36px;
  padding: 0 .8rem;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(38,166,154,.15);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  padding: .55rem 1.2rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-mid);
  background: var(--bg);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  color: var(--text);
  transition: background .15s, border-color .15s;
}
.btn:hover  { background: var(--bg-secondary); }
.btn:active { transform: scale(.97); }

.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn-sm { padding: .35rem .85rem; font-size: 12px; }

.btn-danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn-danger:hover { background: var(--danger-light); }

.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }

/* ============================================================
   ALERT
   ============================================================ */
.alert {
  display: none;
  padding: .65rem 1rem;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 500;
  margin-bottom: .85rem;
}
.alert-success { background: #e8f5e9; color: #2e7d32; }
.alert-error   { background: var(--danger-light); color: var(--danger); }

/* ============================================================
   CALC RESULT
   ============================================================ */
.calc-result {
  background: var(--amber-light);
  border-radius: var(--radius-md);
  padding: .75rem 1rem;
  margin-top: .75rem;
  display: none;
  font-size: 13px;
  color: var(--amber);
}
.calc-result .big { font-size: 24px; font-weight: 700; color: var(--amber); }

/* ============================================================
   MOVEMENTS LIST
   ============================================================ */
.mov-list { max-height: 340px; overflow-y: auto; }

.mov-item {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .65rem 0;
  border-bottom: 0.5px solid var(--border);
  font-size: 12px;
}
.mov-item:last-child { border-bottom: none; }

.mov-icon {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700;
  flex-shrink: 0;
}
.mov-in  { background: #e8f5e9; color: #2e7d32; }
.mov-out { background: var(--danger-light); color: var(--danger); }

.mov-info        { flex: 1; }
.mov-info strong { display: block; font-size: 12px; color: var(--text); }
.mov-info span   { font-size: 10px; color: var(--text-muted); }

.mov-weight       { font-weight: 700; text-align: right; font-size: 13px; }
.mov-weight small { display: block; font-size: 10px; color: var(--text-muted); font-weight: 400; }

/* ============================================================
   PRICE CHIPS
   ============================================================ */
.cat-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin: 1rem 0 .5rem;
}
.cat-label:first-child { margin-top: 0; }

.price-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 7px;
}

.price-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .65rem .9rem;
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
}
.price-chip-name {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 500; color: var(--text);
}
.pcdot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

.price-chip-right { text-align: right; }
.price-chip-val   { font-size: 13px; font-weight: 600; color: var(--accent-dark); }
.price-chip-change { font-size: 10px; }
.up   { color: var(--accent); }
.down { color: var(--danger); }

/* ============================================================
   INVOICE
   ============================================================ */
.invoice-preview {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: var(--radius-md);
  padding: 1.25rem;
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  line-height: 1.9;
  color: #111;
}
.invoice-preview h3 {
  font-size: 14px;
  text-align: center;
  font-family: inherit;
  margin-bottom: 2px;
}
.inv-row    { display: flex; justify-content: space-between; }
.sep        { border-top: 1px dashed #bbb; margin: 5px 0; }
.inv-footer { text-align: center; font-size: 11px; color: #777; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-val   { font-size: 22px; }
}

@media (max-width: 480px) {
  .header     { flex-direction: column; align-items: flex-start; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row   { grid-template-columns: 1fr; }
  .section    { padding: 1rem .85rem 0; }
}