/* Chatello Cortes — Portal de cierre de turno y faltantes
   Paleta oficial Chatello (manual de marca 2022):
     #121619 (charcoal)  - fondo oscuro principal
     #2A2C2D (gris)      - acentos oscuros
     #DBD2CB (beige)     - color corporativo / fondo cálido
     #FFFFFF             - blanco
   Tipografia editorial: Fira Sans (Google Fonts)
*/

@import url('https://fonts.googleapis.com/css2?family=Fira+Sans:wght@300;400;500;600;700&display=swap');

:root {
  /* Marca */
  --chatello-charcoal: #121619;
  --chatello-gray: #2A2C2D;
  --chatello-beige: #DBD2CB;
  --chatello-beige-light: #ECE6E0;
  --chatello-beige-soft: #F5F1ED;
  --chatello-white: #FFFFFF;

  /* Aplicacion */
  --bg: #F5F1ED;            /* fondo principal calido */
  --surface: #FFFFFF;        /* tarjetas */
  --surface-2: #FAF7F4;      /* zebra / paneles secundarios */
  --border: #E2DAD2;         /* borde sutil sobre beige */
  --border-strong: #C9BFB5;
  --text: #121619;           /* texto principal */
  --text-2: #4A4D50;         /* texto secundario */
  --muted: #7A7670;          /* labels y secundario */

  --accent: #121619;         /* charcoal como "primario" */
  --accent-hover: #2A2C2D;
  --accent-text: #DBD2CB;    /* beige sobre charcoal */

  /* Estados (estos NO son colores de marca pero son funcionales/contextuales) */
  --ok: #3E7B4F;
  --ok-bg: #E1EFE4;
  --warn: #B4781B;
  --warn-bg: #FBEFD8;
  --danger: #A62A1F;
  --danger-bg: #F8E1DD;
  --info: #4A4D50;
  --info-bg: #ECE6E0;

  --shadow-sm: 0 1px 2px rgba(18, 22, 25, 0.06);
  --shadow: 0 1px 3px rgba(18, 22, 25, 0.08), 0 1px 2px rgba(18, 22, 25, 0.04);
  --shadow-lg: 0 10px 30px rgba(18, 22, 25, 0.12);
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Fira Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============== LAYOUT ============== */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--chatello-charcoal);
  color: var(--chatello-beige);
  padding: 28px 20px 20px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--chatello-gray);
}

.sidebar .brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 8px;
}
.sidebar .brand img {
  width: 130px;
  height: auto;
  margin-bottom: 8px;
}
.sidebar h1 {
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin: 0 0 2px;
  color: var(--chatello-beige);
  font-weight: 500;
}
.sidebar .subtitle {
  font-size: 11px;
  color: rgba(219, 210, 203, 0.55);
  margin-bottom: 28px;
  letter-spacing: 0.5px;
}

.sidebar nav { margin-top: 4px; }
.sidebar nav a {
  display: flex;
  align-items: center;
  padding: 11px 14px;
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
  color: rgba(219, 210, 203, 0.78);
  font-weight: 500;
  font-size: 13.5px;
  letter-spacing: 0.2px;
  transition: background 0.15s, color 0.15s;
}
.sidebar nav a:hover {
  background: rgba(219, 210, 203, 0.08);
  color: var(--chatello-beige);
  text-decoration: none;
}
.sidebar nav a.active {
  background: var(--chatello-beige);
  color: var(--chatello-charcoal);
  font-weight: 600;
}

.sidebar .user {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(219, 210, 203, 0.12);
  font-size: 12px;
  color: rgba(219, 210, 203, 0.65);
}
.sidebar .user strong {
  display: block;
  color: var(--chatello-beige);
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 2px;
}
.sidebar .user button {
  margin-top: 12px;
  background: transparent;
  border: 1px solid rgba(219, 210, 203, 0.25);
  color: rgba(219, 210, 203, 0.85);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 11.5px;
  font-family: inherit;
  width: 100%;
  letter-spacing: 0.3px;
  transition: background 0.15s, border-color 0.15s;
}
.sidebar .user button:hover {
  background: rgba(219, 210, 203, 0.08);
  border-color: rgba(219, 210, 203, 0.5);
}

.main {
  flex: 1;
  padding: 36px 40px;
  max-width: 1440px;
}
.main h2 {
  margin: 0 0 28px;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.4px;
  color: var(--chatello-charcoal);
}

/* ============== KPIs ============== */

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 32px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 22px 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.kpi .label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
}
.kpi .value {
  font-size: 30px;
  font-weight: 600;
  margin-top: 6px;
  letter-spacing: -0.5px;
  color: var(--chatello-charcoal);
}
.kpi .delta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* ============== CARDS ============== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  overflow: hidden;
}
.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
}
.card-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.1px;
  color: var(--chatello-charcoal);
}
.card-header a {
  font-size: 12.5px;
  color: var(--text-2);
  font-weight: 500;
}
.card-body { padding: 22px; }

/* ============== TABLES ============== */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
th, td {
  text-align: left;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}
th {
  background: var(--surface-2);
  font-weight: 600;
  color: var(--muted);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--border-strong);
}
tbody tr {
  transition: background 0.1s;
}
tbody tr:hover {
  background: var(--chatello-beige-soft);
  cursor: pointer;
}
td.right { text-align: right; }
td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

/* ============== BADGES ============== */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: 1px solid transparent;
}
.badge-ok       { background: var(--ok-bg);     color: var(--ok);     border-color: rgba(62, 123, 79, 0.2); }
.badge-alta     { background: var(--danger-bg); color: var(--danger); border-color: rgba(166, 42, 31, 0.2); }
.badge-media    { background: var(--warn-bg);   color: var(--warn);   border-color: rgba(180, 120, 27, 0.2); }
.badge-baja     { background: var(--info-bg);   color: var(--info);   border-color: rgba(74, 77, 80, 0.2); }
.badge-info     { background: var(--info-bg);   color: var(--info);   border-color: rgba(74, 77, 80, 0.2); }
.badge-pendiente{ background: var(--warn-bg);   color: var(--warn);   border-color: rgba(180, 120, 27, 0.2); }

/* ============== BUTTONS ============== */

.btn {
  display: inline-block;
  padding: 9px 16px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover {
  background: var(--surface-2);
  border-color: var(--muted);
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--chatello-charcoal);
  color: var(--chatello-beige);
  border-color: var(--chatello-charcoal);
}
.btn-primary:hover {
  background: var(--chatello-gray);
  border-color: var(--chatello-gray);
  color: var(--chatello-beige);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover {
  background: #8a1f17;
  border-color: #8a1f17;
}
.btn-success {
  background: var(--ok);
  color: #fff;
  border-color: var(--ok);
}
.btn-success:hover {
  background: #2f5f3c;
  border-color: #2f5f3c;
}
.btn-sm { padding: 5px 11px; font-size: 12px; }

/* ============== FORM CONTROLS ============== */

input, select, textarea {
  padding: 9px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--chatello-charcoal);
  box-shadow: 0 0 0 3px rgba(18, 22, 25, 0.08);
}
.filters {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 18px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ============== DISCREPANCIAS ============== */

.discrepancia {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 12px;
  background: var(--surface-2);
  border-left-width: 4px;
  transition: background 0.15s;
}
.discrepancia.alta        { border-left-color: var(--danger); }
.discrepancia.media       { border-left-color: var(--warn); }
.discrepancia.baja        { border-left-color: var(--info); }
.discrepancia.informativa { border-left-color: var(--muted); }
.discrepancia.resuelto    { opacity: 0.55; background: var(--surface); }

.discrepancia .top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 12px;
}
.discrepancia .titulo {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--chatello-charcoal);
  display: flex;
  gap: 10px;
  align-items: center;
}
.discrepancia .monto {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 16px;
  color: var(--chatello-charcoal);
}
.discrepancia .desc {
  color: var(--text-2);
  margin: 6px 0;
  font-size: 13px;
}
.discrepancia .sugerencia {
  color: var(--muted);
  font-style: italic;
  font-size: 12px;
  margin-top: 4px;
}
.discrepancia .actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

/* ============== KEY-VALUE PAIRS ============== */

.kvp {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 18px;
  font-size: 13px;
}
.kvp dt { color: var(--muted); font-size: 12.5px; }
.kvp dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  text-align: right;
  color: var(--chatello-charcoal);
}

.totals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.totals-grid .panel {
  background: var(--surface-2);
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.totals-grid h4 {
  margin: 0 0 10px;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.7px;
  font-weight: 600;
}

/* ============== EMPTY STATES ============== */

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 13px;
}

/* ============== LOGIN ============== */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--chatello-charcoal);
  background-image:
    radial-gradient(circle at 20% 30%, rgba(219, 210, 203, 0.04) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(219, 210, 203, 0.03) 0%, transparent 50%);
}
.login-card {
  background: var(--surface);
  padding: 48px 44px 40px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 380px;
  border: 1px solid var(--border);
}
.login-card .brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-card .brand img {
  width: 130px;
  height: auto;
}
.login-card h1 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--chatello-charcoal);
}
.login-card .sub {
  color: var(--muted);
  margin-bottom: 28px;
  font-size: 12px;
  text-align: center;
  letter-spacing: 0.3px;
}
.login-card label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  margin-top: 14px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
}
.login-card input { width: 100%; }
.login-card .btn {
  width: 100%;
  margin-top: 24px;
  padding: 12px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.login-card .error {
  color: var(--danger);
  font-size: 12px;
  margin-top: 14px;
  text-align: center;
}

/* ============== MODALS ============== */

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(18, 22, 25, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 460px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.modal h3 {
  margin: 0 0 18px;
  color: var(--chatello-charcoal);
  font-size: 17px;
  font-weight: 600;
}
.modal .form-row { margin-bottom: 14px; }
.modal label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.modal .actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 22px;
}
.modal input, .modal select, .modal textarea { width: 100%; }
.modal textarea {
  font-family: inherit;
  min-height: 70px;
  resize: vertical;
}

/* ============== RESPONSIVE ============== */

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    padding: 16px 20px;
    border-right: none;
    border-bottom: 1px solid var(--chatello-gray);
  }
  .sidebar .brand { margin-bottom: 0; flex-direction: row; gap: 10px; }
  .sidebar .brand img { width: 36px; margin-bottom: 0; }
  .sidebar .subtitle { display: none; }
  .sidebar nav {
    display: flex;
    margin-left: auto;
    gap: 4px;
  }
  .sidebar nav a { padding: 8px 12px; margin-bottom: 0; font-size: 12px; }
  .sidebar .user { display: none; }
  .main { padding: 24px 20px; }
}
