/* CONFIDENCIAL - AIT Group | AITPROD (produccion). CTA 15/07/2026, AITPROD, green accent to tell it apart from AITC (costs). | AITC Costes stylesheet | CTA 2026-06-04 */

/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --primary:      #14503c;
  --primary-lt:   #21785a;
  --primary-bg:   #e6f3ed;
  --sidebar-w:    220px;
  --topbar-h:     52px;
  --radius:       6px;
  --shadow:       0 1px 4px rgba(0,0,0,.12);
  --font:         -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --body-bg:      #f2f5f9;
  --card-bg:      #ffffff;
  --text:         #1e2d3d;
  --text-muted:   #6b7f96;
  --border:       #d4dde8;
  --success-bg:   #e6f4ea;
  --success-text: #1e6b35;
  --error-bg:     #fdecea;
  --error-text:   #b71c1c;
  --warn-bg:      #fff8e1;
  --warn-text:    #7c5200;
}

/* ── Reset mínimo ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: var(--font); color: var(--text); background: var(--body-bg); }
a { color: var(--primary-lt); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── LOGIN ──────────────────────────────────────────────────────────────── */
.body-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--primary);
}

.login-wrap { width: 100%; max-width: 380px; padding: 1rem; }

.login-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0,0,0,.25);
  padding: 2.5rem 2rem 2rem;
}

.login-brand {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo { display: block; width: 80%; max-width: 250px; height: auto; margin: 0 auto .5rem; }
.login-brand-name {
  display: block;
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: .04em;
}
.login-brand-sub {
  display: block;
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: .25rem;
}

.login-footer {
  text-align: center;
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: 1.5rem;
}

/* ── APP LAYOUT ─────────────────────────────────────────────────────────── */
.body-app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--primary);
  color: #c8dff2;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
}

.sidebar-brand {
  padding: 1.1rem 1rem .9rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sb-logo { background: #fff; border-radius: 6px; padding: .5rem .6rem; margin-bottom: .5rem; }
.sb-logo img { width: 100%; height: auto; display: block; }
.sb-name {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .06em;
}
.sb-sub {
  display: block;
  font-size: .7rem;
  color: rgba(255,255,255,.5);
  margin-top: .15rem;
}

.sidebar-nav {
  flex: 1;
  padding: .75rem 0;
}
.nav-item {
  display: block;
  padding: .6rem 1.2rem;
  color: #c8dff2;
  font-size: .88rem;
  transition: background .15s;
}
.nav-item:hover, .nav-item.active {
  background: rgba(255,255,255,.12);
  color: #fff;
  text-decoration: none;
}
.nav-admin {
  margin-top: 1rem;
  border-top: 1px solid rgba(255,255,255,.1);
  padding-top: 1rem;
  color: #ffd580;
}
.nav-admin:hover { color: #ffe8a0; }

.sidebar-footer {
  padding: .9rem 1.2rem;
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .78rem;
}
.sf-user { color: rgba(255,255,255,.7); overflow: hidden; text-overflow: ellipsis; }
.sf-logout { color: #f0a0a0; }
.sf-logout:hover { color: #ffcaca; text-decoration: none; }

/* Main content */
.app-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  min-height: var(--topbar-h);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
  padding: .4rem 1.5rem;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 10;
}

/* Global selector in the topbar */
.selector { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.selector select {
  padding: .35rem .5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .82rem;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
.selector select:focus { outline: none; border-color: var(--primary-lt); box-shadow: 0 0 0 2px rgba(45,106,159,.18); }
.topbar-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary);
}

.content-area {
  padding: 1.5rem;
  flex: 1;
}

/* ── FORMS ──────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: .35rem; color: var(--text-muted); }

.form-control {
  width: 100%;
  padding: .55rem .8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .92rem;
  font-family: var(--font);
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary-lt);
  box-shadow: 0 0 0 3px rgba(45,106,159,.18);
}

/* ── BUTTONS ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: .55rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: var(--font);
  cursor: pointer;
  font-weight: 600;
  transition: background .15s, box-shadow .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-lt); }
.btn-block { display: block; width: 100%; margin-top: 1.2rem; }

/* ── ALERTS ─────────────────────────────────────────────────────────────── */
.alert {
  padding: .7rem 1rem;
  border-radius: var(--radius);
  font-size: .88rem;
  margin-bottom: 1rem;
}
.alert-error   { background: var(--error-bg);   color: var(--error-text);   border-left: 4px solid var(--error-text); }
.alert-success { background: var(--success-bg); color: var(--success-text); border-left: 4px solid var(--success-text); }
.alert-warn    { background: var(--warn-bg);    color: var(--warn-text);    border-left: 4px solid var(--warn-text); }

/* ── DASHBOARD KPI CARDS ────────────────────────────────────────────────── */
.dash-welcome {
  color: var(--text-muted);
  font-size: .92rem;
  margin-bottom: 1.5rem;
}
.dash-welcome strong { color: var(--text); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.kpi-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.4rem;
  border-top: 3px solid var(--primary);
}
.kpi-placeholder { border-top-color: var(--border); }
.kpi-label { font-size: .75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 1.9rem; font-weight: 700; color: var(--primary); margin: .4rem 0 .25rem; }
.kpi-placeholder .kpi-value { color: var(--border); }
.kpi-sub { font-size: .75rem; color: var(--text-muted); }

/* ── TABLES (usadas en bloques siguientes) ──────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: .86rem; background: var(--card-bg); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.data-table th { background: var(--primary-bg); color: var(--primary); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; padding: .6rem .85rem; text-align: left; border-bottom: 2px solid var(--border); }
.data-table td { padding: .5rem .85rem; border-bottom: 1px solid var(--border); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--primary-bg); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── CARD ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1rem;
}

/* ── DASHBOARD: consolidado + tarjetas planta (Bloque 3) ──────────────────── */
.section-h { font-size: 1rem; color: var(--primary); margin: 1.4rem 0 .8rem; font-weight: 600; }

.consol-card { border-top: 3px solid var(--primary); }
.consol-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; margin-bottom: .8rem; }
.consol-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.consol-grid > div { display: flex; flex-direction: column; }
.consol-grid .kpi-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); }
.consol-grid .kpi-value { font-size: 1.5rem; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }

.plant-head { display: flex; align-items: baseline; gap: .5rem; margin-bottom: .6rem; border-bottom: 1px solid var(--border); padding-bottom: .5rem; }
.plant-code { font-size: 1.1rem; font-weight: 700; color: var(--primary); }
.plant-name { font-size: .8rem; color: var(--text-muted); }

.kpi-mini { width: 100%; border-collapse: collapse; font-size: .9rem; }
.kpi-mini td { padding: .3rem 0; }
.kpi-mini td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.kpi-mini tr.kpi-desv td { border-top: 1px solid var(--border); padding-top: .5rem; }

.kpi-up { color: #b91c1c; }     /* coste real por encima del teorico = malo (rojo) */
.kpi-down { color: #15803d; }   /* por debajo = bueno (verde) */
/* CTA 31/07/2026, AITPROD QA-PM, SEMANTIC sign classes. The kpi-up/kpi-down pair
   is for "real cost vs theoretical" ONLY (up=bad). For plain signed figures
   (margins, deviations, gaps) use these instead: a NEGATIVE margin must be RED.
   The old ternaries put negatives in kpi-down (green) - inverted colors bug. */
.pos { color: #15803d; }        /* positive = good (green) */
.neg { color: #b91c1c; }        /* negative = bad (red) */
/* CTA AITPROD QA-PM */

.kpi-empty { opacity: .7; }
.no-data { text-align: center; color: var(--text-muted); font-style: italic; padding: 1.5rem 0; font-size: .9rem; }

/* ── CONCILIACION / DRILL / OF (Bloque 4) ─────────────────────────────────── */
.page-intro { color: var(--text-muted); font-size: .88rem; margin-bottom: 1rem; }
.muted { color: var(--text-muted); font-weight: 400; font-size: .85em; }
.data-table tfoot .total-row td { font-weight: 700; background: var(--primary-bg); border-top: 2px solid var(--primary); color: var(--primary); }
.drill-link { font-size: .82rem; font-weight: 600; white-space: nowrap; }
.row-active td { background: var(--primary-bg) !important; }

.of-search { display: flex; gap: .5rem; margin-bottom: 1.5rem; max-width: 480px; }
.of-search .form-control { flex: 1; }
.of-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .9rem 1.5rem; }
.of-grid > div { display: flex; flex-direction: column; gap: .15rem; }
.of-grid .kpi-label { font-size: .7rem; }
.of-grid > div > span:last-child { font-size: .95rem; color: var(--text); font-variant-numeric: tabular-nums; }
.suggest-list { list-style: none; padding: 0; margin: .5rem 0; }
.suggest-list li { padding: .35rem 0; }

/* ── EJE TABS (Teorico/Clientes, Bloque 5) ────────────────────────────────── */
.axis-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: 1rem; }
.axis-label { font-size: .8rem; color: var(--text-muted); font-weight: 600; }
.axis-tab { padding: .35rem .8rem; border: 1px solid var(--border); border-radius: 999px; font-size: .82rem; color: var(--primary-lt); background: #fff; }
.axis-tab:hover { background: var(--primary-bg); text-decoration: none; }
.axis-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── ADMIN (Bloque 6) ─────────────────────────────────────────────────────── */
.admin-nav { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.admin-tile { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.3rem; background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); border-left: 3px solid var(--primary); color: var(--text); font-weight: 600; font-size: .95rem; }
.admin-tile:hover { background: var(--primary-bg); text-decoration: none; }
.at-ico { font-size: 1.3rem; color: var(--primary); }

.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-err { background: #fee2e2; color: #991b1b; }
.badge-run { background: #fef9c3; color: #854d0e; }
.msg { font-size: .78rem; color: var(--text-muted); }

.estado-matrix td.estado-cell { text-align: right; font-size: .8rem; font-variant-numeric: tabular-nums; }
.cell-ok { background: #f0fdf4; color: #166534; }
.cell-err { background: #fef2f2; color: #991b1b; font-weight: 700; }
.cell-empty { color: var(--border); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; margin-right: 3px; }
.dot-ok { background: #16a34a; } .dot-err { background: #dc2626; } .dot-empty { background: var(--border); }

.div-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.div-filters { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.div-filters select, .div-filters input { padding: .4rem .5rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .85rem; }
.div-edit { margin-bottom: 1.2rem; }
.div-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.chk { font-size: .82rem; color: var(--text-muted); display: flex; align-items: center; gap: .35rem; }
.proc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px,1fr)); gap: 1rem; }
.cli-output { background: #0f172a; color: #cbd5e1; padding: 1rem 1.2rem; border-radius: var(--radius); font-family: Consolas, monospace; font-size: .82rem; overflow-x: auto; white-space: pre-wrap; line-height: 1.5; max-height: 60vh; }
.link-danger { background: none; border: none; color: #b91c1c; cursor: pointer; font-size: .82rem; font-weight: 600; padding: 0 0 0 .6rem; }
.link-danger:hover { text-decoration: underline; }

/* ── PIVOT + EXPORT (Bloque 7) ────────────────────────────────────────────── */
.pivot-bar { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; margin-bottom: 1rem; }
.pivot-bar label { display: flex; flex-direction: column; font-size: .72rem; color: var(--text-muted); font-weight: 600; gap: .2rem; }
.pivot-bar select { padding: .35rem .5rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .85rem; }
.pivot-bar .btn { margin-left: auto; }
.pivot-table th, .pivot-table td { white-space: nowrap; }
.export-btn { font-size: .8rem; font-weight: 600; padding: .3rem .7rem; border: 1px solid var(--primary); border-radius: var(--radius); color: var(--primary); display: inline-block; margin-bottom: .8rem; }
.export-btn:hover { background: var(--primary); color: #fff; text-decoration: none; }

/* ── EXTRAS: produccion filtros + chart (E1/E4) ───────────────────────────── */
.prod-filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; align-items: center; }
.chart { display: flex; align-items: flex-end; gap: .5rem; height: 220px; padding: 1rem; background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.chart-bar { width: 70%; background: linear-gradient(180deg, var(--primary-lt), var(--primary)); border-radius: 3px 3px 0 0; min-height: 2px; transition: height .3s; }
.chart-x { font-size: .7rem; color: var(--text-muted); margin-top: .35rem; }

/* ── ORDENACION + FILTRO de columnas (2026-06-06) ─────────────────────────── */
.data-table th.sortable { cursor: pointer; user-select: none; position: relative; padding-right: 1.4rem; }
.data-table th.sortable:hover { background: #d6e4f2; }
.data-table th.sortable::after { content: '⇅'; position: absolute; right: .5rem; opacity: .35; font-size: .85em; }
.data-table th.sort-asc::after  { content: '▲'; opacity: 1; }
.data-table th.sort-desc::after { content: '▼'; opacity: 1; }
.filter-banner { background: var(--warn-bg); color: var(--warn-text); padding: .5rem .9rem; border-radius: var(--radius) var(--radius) 0 0; font-size: .85rem; border-left: 4px solid var(--warn-text); margin-bottom: -1px; }
.filter-banner a { margin-left: .5rem; font-weight: 600; color: var(--warn-text); }
