/* === Base Reset & Fonts === */
@import url('https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&display=swap');

* {
  box-sizing: border-box; /* Include padding/borders in width */
}

body {
  margin: 0;
  font-family: 'Google Sans', Arial, sans-serif;
  background: #f3f6f9;
  font-size: 0.8rem !important;
  color: #1e1e1e;
  height: 100vh;
  width: 100%;
  overflow-x: hidden; /* No horizontal scrolling */
  overscroll-behavior: none; /* Disable mobile pull-to-refresh */
}

/* Hide everything except the global loader while auth/boot runs */
body.hidden-until-validated > *:not(#globalLoader) {
  display: none !important;
}

/* === Global Loader === */
.loader-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.6);
  z-index: 10000;
}

/* Hidden must always win */
.loader-overlay[hidden] {
  display: none !important;
}

/* Spinner (grayscale) */
.loader {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: #666;
  box-shadow: 32px 0 #999, -32px 0 #ccc;
  position: relative;
  animation: flash 0.5s ease-out infinite alternate;
}

@keyframes flash {
  0%   { background:#ccc; box-shadow: 32px 0 #eee, -32px 0 #999; }
  50%  { background:#999; box-shadow: 32px 0 #ccc, -32px 0 #eee; }
  100% { background:#ccc; box-shadow: 32px 0 #999, -32px 0 #ccc; }
}

/* Keep body mounted so loader can show during auth/bootstrap */
body.hidden-until-validated > *:not(#globalLoader) {
  display: none !important;
}

body.drawer-open {
  overflow: hidden; /* Lock all scrolling when drawer is open */
}

/* === Drawer === */
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 80vw;
  max-width: 420px;
  height: 100vh;
  max-height: 100vh;
  background: #fff;
  border-right: 1px solid #d8dde6;
  border-radius: 0 12px 12px 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  overflow-x: hidden; /* No horizontal scrolling */
  overflow-y: auto; /* Allow vertical scrolling if content overflows */
}

.drawer.open {
  transform: translateX(0);
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 999;
}

body.drawer-open .drawer-overlay {
  opacity: 1;
  pointer-events: auto;
}

.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e7e9ee;
}

.drawer__title {
  font-size: 1rem;
  margin: 0;
  color: #000;
}

.drawer__close {
  border: none;
  background: transparent;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  color: #03363d;
}

.drawer__content {
  padding: 0.5rem 0.75rem;
}

.drawer-menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

.drawer-menu li {
  margin: 0.375rem 0;
}

.drawer-menu a,
.drawer-menu button {
  display: block;
  max-width: calc(100% - 1.5rem); /* Account for 0.75rem padding on each side */
  padding: 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid #e7e9ee;
  background: #fff;
  color: #1e1e1e;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.8rem;
  cursor: pointer;
  text-align: left;
  overflow-x: hidden;
}

.drawer-menu a:hover,
.drawer-menu button:hover {
  background: #f4f6f9;
}

@media (max-width: 768px) {
  .drawer {
    width: 80vw;
    max-width: 320px; /* Smaller for mobile */
    overflow-x: hidden;
    overflow-y: auto; /* Allow vertical scrolling if needed */
  }
  body.drawer-open .main {
    overflow: hidden; /* Lock main content */
  }
  body {
    width: 100%;
    overflow-x: hidden;
  }
}

/* === Login Page === */
.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: #f3f6f9;
  overflow-x: hidden;
}

.login-box {
  width: 90%;
  max-width: 320px;
  padding: 1.5rem;
  border-radius: 0.5rem;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* === Forms & Inputs === */
input[type="text"],
input[type="email"],
input[type="password"],
select {
  width: 100%;
  height: 2.25rem;
  padding: 0 0.75rem;
  font-size: 0.8rem;
  color: #333;
  background: #f9fafb;
  border: 1px solid #d8dde6;
  border-radius: 0.25rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus {
  border-color: #009688;
  box-shadow: 0 0 0 3px rgba(0, 150, 136, 0.2);
  outline: none;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg fill='%23333' height='16' viewBox='0 0 24 24' width='16' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
}

.form-ui {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1rem;
  background: #fff;
  border: 1px solid #d8dde6;
  border-radius: 0.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* === Buttons === */
button,
.form-ui .btn-primary,
.table-ui button {
  max-height: 35px;
    min-height: 25px;
  max-width: 70px;
  padding: 0 1rem;
  border: none;
  border-radius: 0.25rem;
  background: #22333B;
  color: white;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

button:hover,
.form-ui .btn-primary:hover,
.table-ui button:hover {
  background: #19535F;
}

.special-logout {
  background: linear-gradient(135deg, #d83a00, #ff5f2e);
  padding: 0.5rem;
  max-width: calc(100% - 1.5rem); /* Fit within drawer padding */
  border-radius: 1rem;
  box-shadow: 0 4px 8px rgba(216, 58, 0, 0.3);
  transition: background 0.3s ease, transform 0.2s ease;
}

.special-logout:hover {
  background: linear-gradient(135deg, #b32e00, #e64b1a);
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(216, 58, 0, 0.4);
}

.special-logout:active {
  transform: translateY(0);
  box-shadow: 0 3px 6px rgba(216, 58, 0, 0.3);
}

/* === Tables (scrollable) === */
.table-wrapper {
  margin-top: 1rem;
  background: #fff;
  border: 1px solid #d8dde6;
  border-radius: 0.5rem;
  padding: 1rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);

  /* key changes */
  overflow-x: auto;              /* was hidden → allow horizontal scroll */
  overflow-y: visible;           /* keep selects/menus visible */
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.table-ui {
  width: 100%;
  min-width: 980px;              /* force scroll if columns don’t fit */
  border-collapse: collapse;
  font-size: 0.8rem;
  position: relative;

  /* let columns size naturally; avoids over-squashing */
  table-layout: auto;            /* was fixed */
}

.table-ui thead {
  background: #f4f6f9;
}

.table-ui thead th {
  text-align: left;
  padding: 0.75rem;
  font-weight: 600;
  color: #333;
  border-bottom: 1px solid #d8dde6;
  white-space: nowrap;           /* prevent header wrapping */
}

.table-ui tbody tr:nth-child(odd) { background: #fafafa; }
.table-ui tbody tr:hover       { background: #f0f7f7; }

.table-ui td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid #e4e7eb;
  min-width: 0;
  position: relative;
  white-space: nowrap;           /* avoid cramped multi-line cells */
}

/* Allow the "Líneas" column to wrap if needed; others stay single-line */
.table-ui td:nth-child(2) {
  min-width: 220px;              /* room for long summaries/links */
  white-space: normal;           /* allow wrapping only here */
}

/* Keep selects usable in narrow cells */
.table-ui select {
  height: 2rem;
  padding: 0 1.5rem 0 0.5rem;
  font-size: 0.85rem;
  background-image: url("data:image/svg+xml;utf8,<svg fill='%23333' height='14' viewBox='0 0 24 24' width='14' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
  background-position: right 0.5rem center;
  background-size: 0.875rem;
  position: relative;
  width: 100%;
  display: block;
  z-index: 1000;                 /* dropdown above scroller */
  scroll-margin-top: 4rem;
}

/* Optional: subtle horizontal scrollbar styling */
.table-wrapper::-webkit-scrollbar {
  height: 10px;
}
.table-wrapper::-webkit-scrollbar-thumb {
  background: #cfd6df;
  border-radius: 6px;
}
.table-wrapper::-webkit-scrollbar-track {
  background: #f4f6f9;
}

/* === Main Layout === */
.main {
  margin-left: 0;
  background: #f5f6f7;
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto; /* Allow vertical scrolling when drawer is closed */
  scroll-padding-top: 4rem; /* Ensure select is in view when focused */
}

.main-panel,
.main-panel-detail {
  background: #fff;
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  padding: 1.5rem;
  max-width: 100%;
  overflow-x: hidden;
  position: relative; /* Stable context for dropdown */
  overflow-y: visible; /* Prevent clipping dropdown */
}

.main-panel-detail {
  flex: 1; /* Grow to fill remaining space */
}

.main-panel h2,
.main-panel-detail h2 {
  margin-top: 0;
  font-size: 1.25rem;
  color: #1e1e1e;
}

.main-panel h3 {
  margin-top: 1rem;
  font-size: 1rem;
  color: #1e1e1e;
}

.main-panel pre {
  background: #f4f6f9;
  padding: 0.75rem;
  border-radius: 0.25rem;
  border: 1px solid #d8dde6;
  overflow-x: auto;
}

/* === Header === */
.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0A0908;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #d8dde6;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  overflow-x: hidden;
}

.main-header h1 {
  font-size: 1.25rem;
  color: #fff;
  margin: 0;
}

.main-header .actions {
  display: flex;
  gap: 0.5rem;
}

.main-header .actions button {
  padding: 0.5rem 0.75rem;
  background: #fff;
  color: #000;
  border: none;
  border-radius: 0.25rem;
  cursor: pointer;
  font-size: 0.8rem;
}

.main-header .actions button:hover {
  background: #005fb2;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-logo {
  height: 2rem;
  width: auto;
}

@media (max-width: 768px) {
  .main-header {
    gap: 0.75rem;
    overflow-x: hidden;
  }
  .drawer-toggle {
    order: -1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.25rem;
    padding: 0.375rem 0.5rem;
    border: none;
    background: transparent;
    cursor: pointer;
  }
  .header-logo {
    height: 1.5rem;
  }
}

/* === Sidebar & Side Panel === */
.sidebar,
.side-panel {
  background: #fff;
  padding: 1rem;
  border-radius: 0.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  overflow-x: hidden;
}

.sidebar {
  width: 90%;
  max-width: 20rem;
  border-right: 1px solid #d8dde6;
}

.side-panel {
  width: 20%;
  max-width: 20rem;
}

.sidebar h3,
.side-panel h3 {
  margin-top: 0;
  font-size: 1rem;
  color: black;
  margin-bottom: 0 !important;
}

.sidebar ul,
.side-panel ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar li,
.side-panel li {
  padding: 0.625rem;
  margin: 0.25rem 0;
  cursor: pointer;
  border-radius: 0.25rem;
}

.sidebar li:hover,
.side-panel li:hover {
  background: #f4f6f9;
}

.nav-back {
  display: inline-block;
  margin-bottom: 1rem;
  text-decoration: none;
  color: #0070d2;
  font-size: 0.8rem;
}

.nav-back:hover {
  text-decoration: underline;
}

/* === Tables === */
.table-wrapper {
  margin-top: 1rem;
  background: #fff;
  border: 1px solid #d8dde6;
  border-radius: 0.5rem;
  padding: 0rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  overflow-x: hidden;
  overflow-y: visible; /* Allow dropdown to render outside wrapper */
  position: relative; /* Stable positioning context */
}

.table-ui {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  position: relative;
  table-layout: fixed; /* Stabilize column widths */
}

.table-ui thead {
  background: #f4f6f9;
}

.table-ui thead th {
  text-align: left;
  padding: 0.75rem;
  font-weight: 600;
  color: #333;
  border-bottom: 1px solid #d8dde6;
}

.table-ui tbody tr:nth-child(odd) {
  background: #fafafa;
}

.table-ui tbody tr:hover {
  background: #f0f7f7;
}

.table-ui td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid #e4e7eb;
  min-width: 0;
  position: relative;
}

.table-ui td:nth-child(2) {
  min-width: 140px; /* Increased for select stability */
  min-height: 3rem; /* More room for dropdown */
}

.table-ui select {
  height: 2rem;
  padding: 0 1.5rem 0 0.5rem;
  font-size: 0.85rem;
  background-image: url("data:image/svg+xml;utf8,<svg fill='%23333' height='14' viewBox='0 0 24 24' width='14' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
  background-position: right 0.5rem center;
  background-size: 0.875rem;
  position: relative;
  width: 100%;
  display: block;
  z-index: 1000; /* High z-index to prioritize dropdown */
  scroll-margin-top: 4rem; /* Ensure select is in view when focused */
}

/* === Main Layout === */
.main {
  margin-left: 0;
  background: #f5f6f7;
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto; /* Allow vertical scrolling when drawer is closed */
  scroll-padding-top: 4rem; /* Ensure select is in view when focused */
}

.main-panel,
.main-panel-detail {
  background: #f4f6f8 !important;
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  padding: 1.5rem;
  max-width: 100%;
  overflow-x: hidden;
  position: relative; /* Stable context for dropdown */
  overflow-y: visible; /* Prevent clipping dropdown */
}

.main-panel-detail {
  flex: 1; /* Grow to fill remaining space */
}

.main-panel h2,
.main-panel-detail h2 {
  margin-top: 0;
  font-size: 1.25rem;
  color: #1e1e1e;
}

.main-panel h3 {
  margin-top: 1rem;
  font-size: 1rem;
  color: #1e1e1e;
}

.main-panel pre {
  background: #f4f6f9;
  padding: 0.75rem;
  border-radius: 0.25rem;
  border: 1px solid #d8dde6;
  overflow-x: auto;
}

/* === Detail Container === */
.detail-container {
  display: flex;
  height: calc(100vh - 3rem); /* Adjust for header */
  overflow-x: hidden;
  overflow-y: visible; /* Allow dropdown to render fully */
}

@media (max-width: 768px) {
  .detail-container {
    flex-direction: column; /* Stack vertically on mobile */
    overflow-y: visible; /* Allow dropdown to render fully */
  }
  .side-panel {
    width: 100%;
    max-width: none;
    margin: 1rem;
  }
  .main-panel-detail {
    width: 100%;
    max-width: none;
    margin: 0 1rem 1rem;
    overflow-y: visible;
  }
}

/* ===== Modal (clientes) ===== */
.modal {
  position: fixed;
  inset: 0; /* top:0; right:0; bottom:0; left:0 */
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
}
.modal[hidden] {
  display: none;
}

.modal__dialog {
  background: #fff;
  border-radius: 12px;
  max-width: 720px;
  width: clamp(320px, 90vw, 720px);
  max-height: 90vh;
  display: flex;
  overflow:auto;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  animation: modalFadeIn 0.25s ease;
}

.modal__header,
.modal__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: #f9f9f9;
  border-bottom: 1px solid #e2e2e2;
}
.modal__footer {
  border-top: 1px solid #e2e2e2;
  border-bottom: none;
}

.modal__title {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal__close {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  color: #555;
}
.modal__close:hover {
  color: #000;
}

.modal__body {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
}

.modal__footer button {
  min-width: 90px;
}

/* Simple grid for form fields */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 700px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Row actions (Ver/Editar/Borrar en línea) */
.row-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: nowrap;
}

/* Animación de entrada */
@keyframes modalFadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* ===== Responsive tables (Clientes) ===== */

/* The wrapper enables horizontal scroll on narrow screens */
.table-wrapper {
  width: 100%;
  overflow-x: auto;              /* allow horizontal scroll */
  -webkit-overflow-scrolling: touch; /* smooth scrolling on iOS */
}

/* Keep table layout stable; on mobile we’ll force a min-width */
.table-ui {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  table-layout: auto;            /* or fixed; see note below */
}

/* Cells behave nicely in a scrollable table */
.table-ui th,
.table-ui td {
  vertical-align: middle;
  white-space: normal;           /* default on desktop */
}

/* Actions row stays on a single line */
.row-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: nowrap;
}

/* Mobile: force the table to be wider than the viewport so it scrolls,
   and prevent content from stacking on top of each other. */
@media (max-width: 768px) {
  .table-ui {
    min-width: 720px;            /* adjust as needed (>= total column widths) */
  }
  .table-ui th,
  .table-ui td {
    white-space: nowrap;         /* keep each cell on one line for horizontal scroll */
  }
}


/* ===== Split Detail Layout ===== */
.detail-container {
  display: flex;
  height: calc(100vh - 60px); /* minus header */
}

.side-panel {
  flex: 0 0 20%;
  min-width: 180px;
  max-width: 240px;
  border-right: 1px solid #e2e2e2;
  padding: 1rem;
  background: white;
}

.side-panel h3 {
  margin-top: 0;
  font-size: 1rem;
  font-weight: 600;
}

.side-panel ul {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}
.side-panel li {
  padding: 0.5rem 0;
  cursor: pointer;
  color: #0070d2;
}
.side-panel li:hover {
  text-decoration: underline;
}

.side-panel .nav-back {
  display: block;
  margin-top: 2rem;
  font-size: 0.8rem;
  color: #444;
}

/* Main detail panel */
.main-panel-detail {
  flex: 1;
  padding: 1rem 1.25rem;
  overflow-y: auto;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid #ddd;
  margin-bottom: 1rem;
}
.tab {
  padding: 0.5rem 1rem;
  border: none;
  background: none;
  cursor: pointer;
  font-weight: 500;
}
.tab.active {
  border-bottom: 3px solid #0070d2;
  color: #0070d2;
  font-weight: 600;
}
.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

/* Responsive: stack panels on mobile */
@media (max-width: 768px) {
  .detail-container {
    flex-direction: column;
  }
  .side-panel {
    flex: none;
    width: 100%;
    max-width: 100%;
    border-right: none;
    border-bottom: 1px solid #e2e2e2;
  }
}

.client-summary {
  background: #fff;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: .75rem .8rem;
  margin-bottom: .75rem;
}

.kv > div {
  padding: .25rem 0;
  border-bottom: 1px dashed #eee;
}
.kv > div:last-child { border-bottom: none; }

.client-summary--stacked {
  background: #fff;
  border: 1px solid #eee;
  border-radius: 10px;
  padding: .75rem .8rem;
  margin-top: .5rem;
}

.client-field { margin-bottom: .75rem; }
.client-field:last-child { margin-bottom: 0; }

.client-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #666;
  margin-bottom: 0.15rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.client-value {
  font-size: .8rem;
  color: #111;
  word-break: break-word;
}

.client-value.multiline {
  white-space: pre-wrap;  /* preserves line breaks */
}


/* Right drawer variant */
.drawer--right { right: -420px; left: auto; width: 420px; position: fixed; top:0; bottom:0; background:#fff; box-shadow: -8px 0 24px rgba(0,0,0,.08); transition: right .2s ease; z-index: 1100; }
.drawer--right.open { right: 0; }
.drawer--right .drawer__content{ padding: 1rem; overflow-y:auto; height: calc(100vh - 60px); }

/* Job lines grid: Categoría | Precio | Remove */
.job-lines .line {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 120px 36px;
  gap: .5rem;
  align-items: center;
  margin-bottom: .5rem;
}
.job-lines .line select,
.job-lines .line input[type="number"] { width: 100%; }
.job-lines .line button { width: 36px; }


/* ===== Right job drawer (independent from global .drawer) ===== */
.job-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  right: -420px;           /* hidden off-screen by default */
  width: 420px;
  background: #fff;
  box-shadow: -8px 0 24px rgba(0,0,0,.08);
  z-index: 1100;
  transition: right .2s ease;
  display: flex;
  flex-direction: column;
}
.job-drawer.open {
  right: 0;                /* slide in */
}
.job-drawer .drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #eee;
}
.job-drawer .drawer__title { font-size: 1rem; font-weight: 600; margin: 0; }
.job-drawer .drawer__close { background: transparent; border: 0; font-size: 1.1rem; cursor: pointer; }
.job-drawer .drawer__content {
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
}


/* Side panel fields */
.client-summary.client-summary--stacked {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

/* On small screens, show fields in 2 columns */
@media (max-width: 768px) {
  .client-summary.client-summary--stacked {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .5rem .75rem; /* row-gap / column-gap */
  }

  .client-summary.client-summary--stacked .client-field {
    margin: 0;
  }

  /* Labels smaller, values take more weight */
  .client-summary.client-summary--stacked .client-label {
    font-size: .75rem;
    color: #666;
    margin-bottom: .25rem;
    display: block;
  }
  .client-summary.client-summary--stacked .client-value {
    font-size: .8rem;
    font-weight: 500;
  }

  /* Make Ubicación span across both columns */
  .client-summary.client-summary--stacked .client-field:last-child {
    grid-column: 1 / -1;
  }
}

/* ===== Job Edit Drawer base (desktop) ===== */
.job-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;              /* desktop width */
  max-width: 100vw;
  height: 100dvh;
  transform: translateX(100%);
  transition: transform .25s ease;
  background: #fff;
  box-shadow: -6px 0 16px rgba(0,0,0,.12);
  z-index: 1050;
  display: flex;
  flex-direction: column;
}

.job-drawer.open { transform: translateX(0); }

.job-drawer .drawer__head {
  padding: .8rem 1rem;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Safe areas for iPhone notch */
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
}

.job-drawer .drawer__content {
  padding: 1rem;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/* Form elements inside drawer */
#jobEditForm label { display:block; }
#jobEditForm select,
#jobEditForm input[type="text"],
#jobEditForm input[type="tel"],
#jobEditForm input[type="email"],
#jobEditForm input[type="number"],
#jobEditForm input[type="datetime-local"],
#jobEditForm textarea {
  width: 100%;
  max-width: 100%;
  font-size: 16px;           /* prevent iOS zoom on focus */
  box-sizing: border-box;
}

/* Lines editor: stack on small screens */
.job-lines .line {
  display: grid;
  grid-template-columns: 1fr 120px auto; /* category | price | remove */
  gap: .5rem;
  align-items: center;
  margin-bottom: .5rem;
}
@media (max-width: 480px) {
  .job-lines .line {
    grid-template-columns: 1fr 1fr auto; /* more balanced on very small */
  }
}

/* Make primary button full width on mobile */
#jobEditSave { width: 100%; }

/* ===== Mobile sheet behavior ===== */
@media (max-width: 768px) {
  .job-drawer {
    width: 100vw;                /* take full width */
    max-width: 100vw;
    height: 100dvh;              /* viewport height with iOS dyn. bars */
    border-radius: 0;            /* no rounded corners on sheet */
  }
  .job-drawer .drawer__content {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  }
}

/* Ensure no horizontal scroll leaks on body when drawer is open */
body.drawer-open {
  overflow: hidden;
  touch-action: none;
}

/* Optional: make table cells wrap nicely to avoid expanding the viewport */
.table-ui td, .table-ui th {
  word-break: break-word;
}

.client-value a.client-link { text-decoration: underline; color: inherit; }
.client-link.is-disabled { opacity:.6; pointer-events:none; text-decoration: none; }

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #f9f9f9;
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  color: inherit;
  transition: background 0.2s;
}
.action-btn:hover {
  background: #ececec;
}
.action-btn svg {
  flex-shrink: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 70px;
  height: 2.25rem;
  background: #f9f9f9;
  border-radius: 6px;
  transition: background 0.2s;
  cursor: pointer;
  border: none;
}
.icon-btn:hover {
  background: #ececec;
}
.icon-btn svg {
  pointer-events: none;
}

#jobEditRecurringChk:disabled,
#jobEditRecurringMonths:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* === Sidebar Totals === */
#sidebarTotals {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #e4e7eb;
  display: flex;
  flex-direction: column;  /* default desktop layout */
  gap: 1rem;
}

/* On small/mobile screens: show totals side by side */
@media (max-width: 768px) {
  #sidebarTotals {
    flex-direction: row;
    justify-content: space-between;
    gap: 2rem;
  }
  .sidebar-total {
    flex: 1;
    text-align: center;
  }
}
.sidebar-total {
  display: flex;
  flex-direction: column;
}
.sidebar-total .label {
  font-size: 0.8rem;
  color: #666;
  font-weight: 500;
  margin-bottom: 0.25rem;
}
.sidebar-total .value {
  font-size: 1.4rem;
  font-weight: 700;
  color: #111;
}

/* === Login Logo === */
.login-logo img {
  max-height: 30px !important;   /* control logo height */
  width: auto;        /* keep aspect ratio */
  display: inline-block;
}

.login-logo {
  text-align: center;
  margin-bottom: 1rem;
}

/* === Login Form === */
#loginForm {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;   /* space between inputs and button */
}

#loginForm input,
#loginForm button {
  padding: 0.6rem 0.8rem;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 6px;
}

#loginForm button {
  background: #135f56;   /* your brand color */
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  border: none;
}

#loginForm button:hover {
  background: #0f4c45;
}

/* ===== Cashflow Table (fill card, compact columns) ===== */
.cashflow-page .table-wrapper {
  margin-top: 0.5rem;
  overflow-x: auto;
}

.cashflow-page .table-ui {
  width: 100%;                 /* table fills the card */
  border-collapse: collapse;
  font-size: 0.8rem;
  table-layout: fixed;          /* distribute columns based on width */
}

.cashflow-page .table-ui th,
.cashflow-page .table-ui td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid #e6e8ec;
  line-height: 1.3;
}

.cashflow-page .table-ui th {
  background: #f6f7f9;
  font-weight: 600;
  text-align: left;
}

.cashflow-page .table-ui th:first-child,
.cashflow-page .table-ui td:first-child {
  width: 70%;                   /* concept column takes most */
  text-align: left;
}

.cashflow-page .table-ui th:last-child,
.cashflow-page .table-ui td:last-child {
  width: 30%;                   /* amount column shrinks */
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cashflow-page .table-ui tbody tr:nth-child(odd) {
  background: #fafafa;
}

.cashflow-page .table-ui tbody tr:hover {
  background: #f1f7ff;
}

/* ===== Cashflow: KPI strip ===== */
.cashflow-page .kpi-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 0.75rem 0 1.25rem;
}

.cashflow-page .kpi {
  flex: 1 1 200px;                  /* each box grows/shrinks */
  background: #fff;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.cashflow-page .kpi .label {
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 0.35rem;
}

.cashflow-page .kpi .value {
  font-weight: 700;
  font-size: 1.25rem;
  color: #111;
}

.cashflow-page .kpi .value.result-positive {
  color: #0a7a2f;   /* green for positive results */
}

.cashflow-page .kpi .value.result-negative {
  color: #b00020;   /* red for negative results */
}

/* Mobile: stack KPIs full width */
@media (max-width: 700px) {
  .cashflow-page .kpi {
    flex: 1 1 100%;
  }
}

/* ==== Dashboard (home) ==== */
.dashboard-page .kpi-strip {
  display: flex; gap: .75rem; flex-wrap: wrap; margin: .25rem 0 1rem;
}
.dashboard-page .kpi {
  flex: 1 1 160px; background:#fff; border:1px solid #d8dde6; border-radius:8px; padding:.6rem .8rem;
}
.dashboard-page .kpi .label { font-size:.85rem; color:#555; margin-bottom:.2rem; }
.dashboard-page .kpi .value { font-weight:700; font-size:1.15rem; }

.dashboard-page .card {
  background:#fff; border:1px solid #d8dde6; border-radius:8px; ;padding:1rem;
  box-shadow: 0 2px 4px rgba(0,0,0,.04);
}
.dashboard-page .flex-between { display:flex; align-items:center; justify-content:space-between; gap:.5rem; }

.dashboard-page .table-wrapper.compact .table-ui th,
.dashboard-page .table-wrapper.compact .table-ui td {
  padding: .4rem .5rem;
  white-space: nowrap;
}

/* Week grid */
.week-grid {
  display:grid; grid-template-columns: repeat(7, 1fr); gap:.5rem; margin-top:.5rem;
}
@media (max-width: 900px){
  .week-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px){
  .week-grid { grid-template-columns: 1fr; }
}
.week-col { border:1px solid #e6e8ec; border-radius:8px; overflow:hidden; background:#fff; }
.week-col-head { font-weight:600; padding:.5rem .6rem; background:#f6f7f9; border-bottom:1px solid #e6e8ec; }
.week-col-body { padding:.5rem; display:flex; flex-direction:column; gap:.4rem; }
.slot {
  display:block; text-decoration:none; border:1px solid #e6e8ec; border-radius:8px; padding:.45rem .55rem;
  background:#fff;
}
.slot:hover { background:#f5fafc; }
.slot-time { font-size:.8rem; color:#444; }
.slot-title { font-weight:600; }
.slot-sub { font-size:.8rem; color:#666; }
.slot--empty { color:#888; font-style:italic; border:1px dashed #e0e0e0; background:#fafafa; }
.week-label { font-weight:600; }

/* Filters inline */
.dashboard-page .filters {
  display:flex;
  gap:.5rem;
  align-items:flex-end;
}
.dashboard-page .filters label {
  font-size:.85rem;
  display:flex;
  flex-direction:column;
}
.dashboard-page .filters select {
  padding:.3rem .4rem;
}

/* Modal */
.modal {
  position:fixed; inset:0;
  background:rgba(0,0,0,.5);
  display:flex; align-items:center; justify-content:center;
  z-index:2000;
}
.modal-content {
  background:#fff;
  padding:1rem;
  border-radius:8px;
  width:100%; max-width:400px;
}
.modal-content h3 { margin-top:0; }
.modal-actions { display:flex; gap:.5rem; justify-content:flex-end; margin-top:.75rem; }


/* Make iframe fill its wrapper */
.iframe-wrapper {
  width: 100%;
  height: calc(100vh - 200px); /* adjust depending on header/footer size */
  min-height: 400px;
  display: flex;
}

.iframe-wrapper iframe {
  flex: 1;
  width: 100%;
  height: 100%;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent;
}
}

/* Date pickers */

/* ===== Common date picker styles ===== */
.side-panel .date-filter {
  display: grid;
  grid-template-columns: 1fr;      /* stack on narrow sidepanel */
  gap: 0.5rem;
  margin-top: 0.5rem;
}

@media (min-width: 720px) {
  /* if your sidepanel is wide enough, show two columns */
  .side-panel .date-filter.two-cols {
    grid-template-columns: 1fr 1fr; /* Desde | Hasta side by side */
    align-items: end;
  }
}

.side-panel .date-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.side-panel .date-field label {
  font-size: 0.88rem;
  color: #444;
}

.side-panel input[type="date"],
.side-panel input[type="datetime-local"],
.side-panel input[type="time"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  font: inherit;
  line-height: 1.2;
  padding: 0.45rem 0.6rem;
  border: 1px solid #d8dde6;
  border-radius: 6px;
  background: #fff;
  color: #111;
  box-sizing: border-box;          /* critical to avoid overflow */
}

.side-panel input[type="date"]:focus,
.side-panel input[type="datetime-local"]:focus,
.side-panel input[type="time"]:focus {
  outline: none;
  border-color: #6aa5ff;
  box-shadow: 0 0 0 3px rgba(106,165,255,0.2);
}

/* Compact row with the apply button aligned right */
.side-panel .date-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* Make buttons and selects in sidepanel align visually */
.side-panel select,
.side-panel button {
  width: 100%;
  box-sizing: border-box;
}
@media (min-width: 720px) {
  .side-panel .date-actions button { width: auto; }
}


.datepicker-input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.8rem;
}


/* collapse sidepanel in mobile */

/* ===== Mobile collapsible side-panel ===== */
.sidepanel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .5rem;
}

.sp-toggle {
  display: none;                 /* hidden on desktop */
  border: 1px solid #d8dde6;
  background: #009688;
  border-radius: 6px;
  padding: .35rem .6rem;
  font-size: .85rem;
  line-height: 1;
  cursor: pointer;
}
.sp-toggle:hover { background: #00796b; }

.sidepanel-content {
  max-height: none;
  overflow: visible;
  transition: max-height .25s ease;
}

/* Mobile behavior */
@media (max-width: 900px) {
  .sp-toggle { display: inline-block; }      /* show toggle only on mobile */
  .sidepanel-content {
    max-height: 1200px;                      /* enough for typical filters */
    overflow: hidden;
  }
  .side-panel.collapsed .sidepanel-content {
    max-height: 0;                           /* collapsed */
  }
}

@media (max-width: 900px) {
  .sidepanel-content.is-collapsed {
    max-height: 0;
    overflow: hidden;
  }
}

/* Sidebar form labels */
.side-panel label {
  font-size: 0.8rem;   /* adjust as you like */
  font-weight: 500;    /* optional, makes it stand out */
  display: block;      /* keeps input below the label */
  margin-top: 0.5rem;  /* space above each label */
}


 .calendar-grid { display:grid; grid-template-columns: 80px repeat(7, 1fr); border:1px solid #e6e9ef; border-radius:10px; overflow:hidden; background:#fff; }
    .cal-head { display:contents; }
    .cal-head div { background:#f4f6f9; padding:.5rem .75rem; font-weight:600; border-right:1px solid #e6e9ef; }
    .cal-head div:last-child{ border-right:none; }
    .cal-row { display:contents; }
    .cal-time { background:#fafafa; color:#666; font-size:.85rem; padding:.5rem .5rem; border-top:1px solid #eef1f5; border-right:1px solid #e6e9ef; }
    .cal-cell { min-height:56px; position:relative; border-top:1px solid #eef1f5; border-right:1px solid #f1f3f8; }
    .cal-cell:last-child{ border-right:none; }
    .slot-add { position:absolute; inset:auto .25rem .25rem auto; border:1px dashed #cfd6df; background:#fff; color:#2b6cb0; font-size:.8rem; padding:.15rem .4rem; border-radius:6px; }

    .badge { display:inline-flex; align-items:center; gap:.35rem; padding:.35rem .5rem; border-radius:8px; font-size:.8rem; font-weight:600; color:#0c0c0c; background:#e8f0fe; border:1px solid #d6e2ff; box-shadow:0 1px 0 rgba(0,0,0,.04); }
    .pill { border-radius:10px; padding:.08rem .4rem; font-size:.75rem; background:#eef2f7; color:#444; border:1px solid #e2e8f0; }

    /* Assignment chip inside a cell */
    .assign { position:absolute; left:.25rem; right:.25rem; top:.25rem; padding:.35rem .5rem; border-radius:8px; background:#d1fae5; border:1px solid #10b98133; box-shadow:0 2px 6px rgba(0,0,0,.06); cursor:pointer; }
    .assign .name { font-weight:700; font-size:.85rem; }
    .assign .meta { font-size:.7rem; color:#374151; }

    .legend { display:flex; flex-wrap:wrap; gap:.35rem; }
    .legend .chip { display:inline-flex; align-items:center; gap:.35rem; padding:.25rem .5rem; border-radius:999px; background:#f5f5f5; border:1px solid #e6e6e6; font-size:.8rem; }
    .legend .dot { width:10px; height:10px; border-radius:50%; }

    .side-hours { display:flex; flex-direction:column; gap:.35rem; }
    .hours-item { display:flex; align-items:center; justify-content:space-between; padding:.4rem .55rem; border:1px solid #edf0f5; border-radius:8px; background:#fff; }
    .hours-item .name { display:flex; align-items:center; gap:.4rem; font-weight:600; }

    .toolbar { display:flex; flex-wrap:wrap; gap:.5rem; align-items:center; }
    .toolbar .btn { height:2.1rem; }
    .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }

    /* ensure absolute blocks are positioned relative to the grid */
.calendar-grid { position: relative; }



.mom-grid {
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: .75rem;
}
.mom-card {
  background:#fff; border:1px solid #e5e7eb; border-radius:12px; padding:.8rem;
  box-shadow:0 1px 2px rgba(0,0,0,.05);
}
.mom-title { font-weight:600; margin-bottom:.35rem; color:#111827; }
.mom-row { display:flex; justify-content:space-between; gap:.5rem; font-size:.8rem; color:#374151; }
.mom-row + .mom-row { margin-top:.25rem; }
.mom-big { font-size:1.45rem; font-weight:800; color:#0b1220; }
.mom-delta { font-weight:600; }
.mom-up { color:#16a34a; }     /* green */
.mom-down { color:#dc2626; }   /* red */
.muted { color:#6b7280; }


.widget-chart { width:100%; height:180px; }
.widget-card { position:relative; }
.widget-actions { position:absolute; top:.6rem; right:.6rem; display:flex; gap:.1rem !important; }
.widget-table { width:100%; border-collapse:collapse; font-size:.8rem; }
.widget-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8rem;
  table-layout: fixed;      /* force equal distribution */
}

.widget-table th,
.widget-table td {
  border-bottom: 1px solid #e5e7eb;
  padding: .4rem .5rem;
  text-align: right;
  white-space: nowrap;      /* prevent breaking numbers */
  overflow: hidden;
  text-overflow: ellipsis;
}

.widget-table th:first-child,
.widget-table td:first-child {
  text-align: left;
  width: 40%;               /* give month column more space */
}

/* Larger width for chart and table widgets */
.kpi-grid { 
  grid-auto-rows: 1fr; /* force equal row height */
}

.widget-card.large {
  grid-column: span 2;
  max-height: 260px; /* same as normal cards */
  overflow:hidden;
}

.widget-card.large .widget-table {
  max-height: 180px;
  overflow-y: auto;
  display:block;
}

.catalog-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8rem;
  table-layout: fixed;  /* enforce defined widths */
}

.catalog-table th,
.catalog-table td {
  border-bottom: 1px solid #e5e7eb;
  padding: .35rem .5rem;
}

.catalog-table th:nth-child(1),
.catalog-table td:nth-child(1) {
  width: 45%;   /* Nombre column big */
}

.catalog-table th:nth-child(2),
.catalog-table td:nth-child(2) {
  width: 15%;   /* Unidad small */
  text-align: center;
}

.catalog-table th:nth-child(3),
.catalog-table td:nth-child(3) {
  width: 25%;   /* Precio medium */
  text-align: right;
}

.catalog-table th:nth-child(4),
.catalog-table td:nth-child(4) {
  width: 15%;   /* Trash icon column */
  text-align: center;
}

.catalog-table input,
.catalog-table select {
  width: 100%;
  box-sizing: border-box;
}

/* --- Calendar --- */
.cal { display: grid; gap: .6rem; }

.cal-weekdays,
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0,1fr));
  gap: .35rem;
}

.cal-weekdays div {
  text-align: center;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  font-size: .75rem;
  letter-spacing: .02em;
}

/* square-ish cells that still shrink on small screens */

.cal-cell:hover { border-color:#94a3b8; box-shadow:0 2px 6px rgba(0,0,0,.06); }

.cal-cell.dim { background:#f9fafb; color:#9ca3af; }
.cal-num { font-weight: 700; color:#0b1220; }
.cal-cell.dim .cal-num { color:#9ca3af; }

/* today ring */
.cal-cell.today { outline: 2px solid #16a34a; outline-offset: 2px; }

/* crossed day (two diagonals, scaled for small cells) */
.cal-cell.blocked::before,
.cal-cell.blocked::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60%;             /* adjust to cell size */
  height: 2px;            /* thinner line */
  background-color: #dc2626;
  opacity: .9;
  transform: translate(-50%, -50%) rotate(0deg);
}

.cal-cell.blocked::after {
  transform: translate(-50%, -50%) rotate(90deg);
}
/* legend */
.cal-legend{
  margin-top:.35rem; color:#6b7280; font-size:.875rem; display:flex; align-items:center; gap:1rem;
}
.cal-legend .swatch{ display:inline-block; width:14px; height:14px; border-radius:4px; margin-right:.35rem; border:1px solid #e5e7eb; }
.cal-legend .swatch.blocked{ background:#fee2e2; border-color:#fecaca; }
.cal-legend .swatch.today{ background:#dcfce7; border-color:#bbf7d0; }

 /* Layout */
    .two-col {
      display:grid;
      grid-template-columns: 500px 1fr;
      gap:1rem;
    }
    @media (max-width: 980px){
      .two-col { grid-template-columns: 1fr; }
    }

    .card { background:#fff; border-radius:12px; padding:1rem; }
    .card h3 { margin:.1rem 0 .6rem 0; font-size:1rem; }

    .muted { color:#6b7280; }
    .danger { color:#b91c1c; }
    .ok { color:#16a34a; }

    .form-ui label { display:flex; flex-direction:column; gap:.35rem; }
    .form-row { display:grid; gap:.5rem; }

    .table {
      width:100%; border-collapse:collapse; font-size:.8rem; table-layout:fixed;
    }
    .table th,.table td {
      border-bottom:1px solid #e5e7eb; padding:.45rem .5rem; text-overflow:ellipsis; overflow:hidden; white-space:nowrap;
    }
    .table th { text-align:left; color:#374151; font-weight:600; }
    .table td:last-child, .table th:last-child { text-align:right; }

    .pill {
      display:inline-block; border-radius:999px; padding:.2rem .5rem; font-size:.75rem; border:1px solid #e5e7eb; background:#f9fafb;
    }

    .toolbar { display:flex; gap:.5rem; align-items:center; flex-wrap:wrap; }
    .toolbar > * { flex:0 0 auto; }

    textarea.bulk {
      width:100%; min-height:160px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
      border:1px solid #e5e7eb; border-radius:8px; padding:.6rem;
    }

    .sticky-footer {
      display:flex; gap:.5rem; justify-content:flex-end; margin-top:.75rem;
    }

    .hint { font-size:.82rem; color:#6b7280; }

    .totals { display:grid; gap:.35rem; }
    .totals .row { display:flex; border-bottom: 0.5px dotted grey;justify-content:space-between; }
    .totals .grand { font-weight:800; }

    /* highlight rows missing price */
    .row-missing { background:#fff7ed; }

    /* Special style for delete buttons in rotura */
.btn-delete {
  background: transparent;
  border: 1px solid transparent;
  color: #dc2626;          /* Tailwind red-600 */
  padding: .35rem .5rem;
  border-radius: 8px;
  font-size: .8rem;
  display: flex; 
  align-items: center;
  gap: .35rem;
  transition: all .15s ease;
}

.btn-delete:hover {
  background: #fee2e2;     /* Tailwind red-100 */
  border-color: #fecaca;   /* Tailwind red-200 */
  color: #b91c1c;          /* Tailwind red-700 */
  cursor: pointer;
}

.btn-delete i {
  font-size: .95rem;
}

#catPrice {
  height: 2.25rem;
  padding: 0 0.75rem;
  font-size: 0.8rem;
  color: #333;
  background: #f9fafb;
  border: 1px solid #d8dde6;
  border-radius: 0.25rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
  box-sizing: border-box;
}

#catPrice:focus {
  border-color: #4f46e5;     /* Indigo focus border */
  box-shadow: 0 0 0 2px rgba(79,70,229,0.2);
  outline: none;
}

/* Shared style for standard + catalog price inputs */
#catPrice,
.catalog-table input[type="number"] {
  height: 2.25rem;
  padding: 0 0.75rem;
  font-size: 0.8rem;
  color: #333;
  background: #f9fafb;
  border: 1px solid #d8dde6;
  border-radius: 0.25rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
  box-sizing: border-box;
}

#catPrice:focus,
.catalog-table input[type="number"]:focus {
  border-color: #4f46e5; /* Indigo */
  box-shadow: 0 0 0 2px rgba(79,70,229,0.2);
  outline: none;
}

/* Actions column */
.acciones-head { text-align: right; }
.acciones-cell { text-align: right; white-space: nowrap; }

/* Icon-only buttons */
.icon-btn {
  background: none;
  border: none;
  padding: 0;
  margin-left: .5rem;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  color: #000;              /* black by default */
  vertical-align: middle;   /* keep same row alignment */
  transition: color .15s ease;
}
.icon-btn:first-child { margin-left: 0; }
.icon-btn:hover { color: #333; }       /* subtle hover */

.table-ui .acciones-head { text-align: right; }
.table-ui .acciones-cell { text-align: right; white-space: nowrap; }
.table-ui .row-actions { display: inline-flex; gap: .4rem; align-items: center; justify-content: flex-end; }

.totals-toolbar-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:1rem;
  flex-wrap:wrap;           /* keeps layout nice on small screens */
}

.totals-left{
  display:flex;
  align-items:center;
  gap:1rem;
}

.totals-title{ margin:0; }

.actions.toolbar{
  display:flex;
  align-items:center;
  gap:.5rem;
}

.actions.toolbar label{ display:flex; align-items:center; gap:.4rem; margin:0; }

/* Normalize selects so arrow doesn’t overlap text */
select {
  appearance: none;          /* removes native arrow */
  -webkit-appearance: none;
  -moz-appearance: none;
  padding: 0.4rem 1.8rem 0.4rem 0.6rem; /* add right padding for custom arrow */
  font-size: .8rem;
  border: 1px solid #d8dde6;
  border-radius: 0.25rem;
  background: #f9fafb url("data:image/svg+xml;utf8,<svg fill='black' height='20' viewBox='0 0 24 24' width='20' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>") no-repeat right 0.5rem center;
  background-size: 1rem;
  font-weight: 700;
  color: #333;
}



.cal-cell { cursor: pointer; }
.cal-cell.dim { cursor: default; }


/* === Calendar (rotura upload modal) === */
.cal {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 40vh;     /* smaller visible area */
  overflow-y: auto;     /* add vertical scroll when too tall */
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.25rem;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: #555;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.25rem;
}

.cal-cell {
  height: 28px;         /* even smaller cells */
  font-size: 0.65rem;   /* shrink text */
  padding: 0;           /* remove extra padding */
  border: 1px solid #ddd;
  border-radius: 3px;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cal-cell.today {
  border-color: #135f56;
  font-weight: 600;
}

.cal-cell.blocked {
  background: #fce7e7;
}

/* --- Budget Inspect Popover --- */
.budget-inspect {
  position: absolute;
  z-index: 10000;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0,0,0,.12);
  padding: .75rem .85rem;
  width: 320px;
}
.budget-inspect h4 { margin: 0 0 .5rem; font-size: .95rem; }
.budget-inspect .row { display:flex; justify-content:space-between; margin:.2rem 0; font-size:.92rem; }
.budget-inspect .muted { color:#6b7280; font-size:.85rem; }
.budget-inspect .close { position:absolute; top:.35rem; right:.45rem; background:transparent; border:0; cursor:pointer; font-size:1rem; }
.kpi-card .btn-icon {
  border: 0; background: transparent; cursor: pointer;
  font-size: 1rem; line-height: 1; padding: .2rem .35rem; color: #22333B;
}
.kpi-card .widget-actions { gap: .35rem; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.btn-icon i {
  font-size: 1rem;
}

/* KPI value coloring */
.kpi-value { color:#111; }            /* default (OK) */
.kpi-value.kpi-bad { color:#e6002a !important; }  /* red when target not met */

/* Homepage panel */
.home-panel {
  margin-top: 30px; /* 30px below the fixed header */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 2rem;
      background: #0A0908;
    margin-left: 50px;
    margin-right: 50px;
    border-radius: 12px;
}

.home-panel-title {
  margin-bottom: 2rem;
  font-size: 1.5rem;
  font-weight: 600;
  color: white;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 2rem;
  width: 100%;
  max-width: 800px;
}

.home-grid a {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  background: #22333B;
  padding: 1.5rem;
  border-radius: 1rem;
  transition: background 0.2s, transform 0.2s;
}

.home-grid a:hover {
  background: #f9fafb;
  transform: translateY(-2px);
}

.home-grid i {
  font-size: 3rem; /* much bigger icons */
  color: #ff5b07;  /* dark blue accent */
}

.menu-label { color:white; transition: color .2s; }
.menu-link:hover .menu-label { color:black; }

/* wide cards for tables */
.kpi-card.table-card {
  grid-column: span 2;
}
.kpi-card .widget-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}
.kpi-card .widget-table th,
.kpi-card .widget-table td {
  padding: .5rem .6rem;
  border-bottom: 1px solid #e5e7eb;
  text-align: right;
}
.kpi-card .widget-table th:first-child,
.kpi-card .widget-table td:first-child {
  text-align: left;
}

.scenario-bar{
  display:flex; gap:.5rem; align-items:center; margin:.5rem 0 1rem;
}
.scenario-bar input{
  flex:1; min-width: 220px; padding:.5rem .6rem;
  border:1px solid #e6e6e6; border-radius:.5rem;
}
.scenario-bar button{ white-space:nowrap; }

.btn-edit,
.btn-delete {
  background: none !important;
  border: none;
  padding: 0;
  cursor: pointer;
}

.btn-edit:hover i,
.btn-delete:hover i {
  color: #444; /* slightly darker on hover */
  transform: scale(1.1);
  transition: color 0.2s, transform 0.2s;
}

  .mt-scroll{
    display:flex; flex-wrap:nowrap; overflow-x:auto;
    gap:16px; margin-top:.75rem; padding-bottom:8px;
    scroll-snap-type:x mandatory;
  }
  .mt-card{
    flex:0 0 280px;
    border:1px solid #e5e7eb; border-radius:12px; background:#fff;
    padding:14px; scroll-snap-align:start;
    display:flex; flex-direction:column; justify-content:space-between; min-height:140px;
  }
  .mt-head{
    display:flex; align-items:baseline; justify-content:space-between; gap:.5rem;
  }
  .mt-month{ font-weight:600; }
  .mt-total{
    font-size:2rem; line-height:1.1; font-weight:800;
    letter-spacing:-0.02em;
  }
  .muted{ color:#6b7280; font-size:.9em; }


/* === Scenario Picker (scoped) === */
#scenarioPicker .modal {
  position: static;          /* override global .modal (overlay) */
  inset: auto;
  background: #fff;
  display: flex;
  flex-direction: column;
  width: clamp(320px, 92vw, 760px);
  max-height: 90vh;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0,0,0,.18);
  overflow: hidden;          /* header fixed, body scrolls */
}

#scenarioPicker .modal-body {
  box-sizing: border-box;    /* include padding in width */
  width: 100%;
  max-width: 100%;
  padding: 12px 16px 16px;
  overflow: auto;
}

/* Keep the table from forcing extra width inside the modal */
#scenarioPicker .table-ui {
  width: 100%;
  table-layout: fixed;
  min-width: 0;              /* beat any global min-width */
}

@media (max-width: 768px) {
  #scenarioPicker .table-ui { min-width: 0; } /* cancel global 720px rule */
}

/* === KPI Strip (Simulación & Dashboard panels) === */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 1rem 0 1.25rem;
}

.kpi {
  background: #fff;
  border: 1px solid var(--border, #e6e6e6);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 76px;
}

.kpi .label {
  font-size: 0.8rem;
  color: var(--muted, #666);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.kpi .value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
  word-break: break-word;
}

.kpi .value.editable {
  cursor: text;
  border-bottom: 1px dashed transparent;
  outline: none;
}

.kpi .value.editable:focus {
  border-color: #bbb;
  background: #fffbe6;
}

/* Color states for result KPIs */
.result-positive { color: #2e7d32; }
.result-negative { color: #b00020; }

/* === Main Content Wrapper === */
.main-wrap {
  padding: 20px 24px;
  margin: 0 auto;
  box-sizing: border-box;
}

/* === Scenario Picker Centered Modal === */
#scenarioPicker.modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5); /* dimmed background */
  z-index: 2000;
}

#scenarioPicker.modal-overlay.active {
  display: flex;
}

/* Centered modal box */
#scenarioPicker .modal {
  position: relative;
  background: #fff;
  border-radius: 16px;
  width: clamp(320px, 92vw, 760px);
  max-height: 90vh;
  box-shadow: 0 20px 40px rgba(0,0,0,.18);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(1);
  animation: modalPopIn .2s ease-out;
}

/* Smooth appear animation */
@keyframes modalPopIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Icon-only delete button (no background) */
.row-del {
  background: transparent !important;
  border: none !important;
  padding: 0;
  margin: 0;
  cursor: pointer;
  line-height: 1;
}

.row-del i {
  font-size: 1rem;
  color: #000;
  pointer-events: none; /* click registers on button */
  transition: color 0.2s ease;
}

.row-del:hover i {
  color: #b00020; /* red hover */
}

/* Scenario picker icon buttons */
#scenarioPicker .sc-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

#scenarioPicker .sc-actions button {
  background: transparent;
  border: none;
  padding: 4px;
  cursor: pointer;
  line-height: 1;
}

#scenarioPicker .sc-actions button i {
  font-size: 1rem;
  color: #000;
  pointer-events: none;
  transition: color 0.2s ease;
}

#scenarioPicker .sc-actions button:hover i {
  color: #b00020; /* red hover */
}

/* === Scenario Picker modal header === */
#scenarioPicker .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between; /* title left, close right */
  padding: 14px 18px;
  border-bottom: 1px solid #eee;
}

#scenarioPicker .modal-header h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

#scenarioPicker .modal-close {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  color: #333;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#scenarioPicker .modal-close:hover {
  background: #f2f2f2;
  color: #b00020;
}

/* Home analytics layout: keep on one row */
.home-analytics{
  display:flex;
  gap:16px;
  margin-top:1rem;
  flex-wrap:nowrap;           /* stay on one row */
}
.analytics-left{ flex:0 0 30%; min-width:260px; }
.analytics-right{ flex:1 1 70%; min-width:320px; }

/* (Optional) allow wrapping only on very small screens */
@media (max-width: 720px){
  .home-analytics{ flex-wrap:wrap; }
}

/* ===== Profit Card ===== */
.profit-card {
  background: #fff;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
}

.profit-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #333;
  margin: 0 0 .5rem;
}

.profit-value {
  font-size: 2rem;
  font-weight: 700;
  color: #135F56; /* your teal tone */
  margin: 0;
}

.profit-label {
  margin-top: .25rem;
  font-size: .9rem;
  color: #666;
}

/* ===== Profit Chart ===== */
.chart-box {
  background: #fff;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  height: 100%;
  display: flex;
  flex-direction: column;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .5rem;
}

.chart-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.chart-header select {
  font-size: .9rem;
  padding: .25rem .5rem;
  border-radius: 6px;
  border: 1px solid #ccc;
  outline: none;
  background: #fafafa;
}

.chart-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

#profitChart {
  width: 100%;
  height: 260px;
}

/* ===== Chart Styling (SVG) ===== */
.chart-grid line {
  stroke: #eee;
  stroke-width: 1;
}

.chart-zero {
  stroke: #bbb;
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke: #135F56; /* your brand teal */
  stroke-width: 2;
}

.chart-dot {
  fill: #FB7602; /* your brand orange accent */
}

.chart-axis {
  fill: #555;
  font-size: 11px;
  font-family: system-ui, sans-serif;
}

/* Card shell */
.profit-card{
  background:#fff;
  border:1px solid #e6e8eb;
  border-radius:16px;
  padding:18px 20px;
  box-shadow:0 2px 10px rgba(0,0,0,.04);
  display:flex;
  flex-direction:column;
  gap:.35rem;
  height:100%;
}

/* Header row */
.profit-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:.75rem;
  margin-bottom:.25rem;
}
.profit-head h3{
  margin:0;
  font-size:1.25rem;
  font-weight:700;
  color:#111827;
}

/* Link button */
.btn-ghost{
  display:inline-flex;
  align-items:center;
  gap:.4rem;
  border:1px solid #e5e7eb;
  background:#fff;
  padding:.4rem .7rem;
  border-radius:10px;
  text-decoration:none;
  color:#1f2937;
  font-weight:600;
  line-height:1;
}
.btn-ghost:hover{
  background:#f8fafc;
  border-color:#dbe1e6;
}

/* Values */
.profit-value{
  font-size:2.25rem;
  font-weight:800;
  letter-spacing:-.02em;
  color:#0f766e;           /* positive/brand tone */
  margin-top:.1rem;
}

/* Subtext row */
.profit-sub{
  color:#6b7280;
  font-size:.95rem;
  margin-top:.1rem;
}

/* Optional color states if you ever need them */
.profit-positive .profit-value{ color:#0f766e; }
.profit-negative .profit-value{ color:#b00020; }



/* ===== Homepage Menu ===== */
.home-menu {
  margin: 2rem 50px;
  background: #fff;
  border-radius: 20px;
  padding: 2rem 2.5rem;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.home-menu-title {
  text-align: center;
  font-size: 1.6rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 2rem;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1.5rem;
  justify-items: center;
}

.menu-card {
  background: #ffffff;
  border: 1px solid #e6e8eb;
  border-radius: 14px;
  width: 100%;
  max-width: 200px;
  height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #1f2937;
  font-weight: 600;
  font-size: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  transition: all 0.25s ease;
}

.menu-card i {
  font-size: 2rem;
  color: #FB7602;
  margin-bottom: .5rem;
  transition: color 0.2s ease, transform 0.2s ease;
}

.menu-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border-color: #d1d5db;
}

.menu-card:hover i {
  color: #135F56; /* teal accent on hover */
  transform: scale(1.1);
}

.menu-card span {
  display: block;
  text-align: center;
}

/* Responsive tweaks */
@media (max-width: 600px) {
  .home-menu {
    padding: 1.5rem;
    margin: 1rem 20px;
  }
  .menu-card {
    max-width: 100%;
    height: 120px;
  }
}

/* Left column becomes a vertical stack that fills the chart's height */
.left-stack{
  display:flex;
  flex-direction:column;
  gap:16px;
  height:100%;
}

/* Make both left cards share the column height equally */
.profit-card,
.agg-card{
  flex:1 1 0;
  background:#fff;
  border:1px solid #e6e8eb;
  border-radius:16px;
  padding:20px 24px;
  box-shadow:0 2px 10px rgba(0,0,0,0.05);
  display:flex;
  flex-direction:column;
  gap:.5rem;
}

/* Reuse header style */
.profit-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:.25rem;
}
.profit-head h3{ margin:0; font-size:1.15rem; font-weight:700; color:#111827; }

/* Value + sub */
.profit-value{ font-size:2rem; font-weight:800; color:#0f766e; margin:.2rem 0 0; }
.profit-sub{ color:#6b7280; font-size:.95rem; }

/* Button + select styling */
.btn-ghost{
  display:inline-flex; align-items:center;
  border:1px solid #e5e7eb; background:#fff;
  padding:.4rem .7rem; border-radius:8px;
  text-decoration:none; color:#1f2937; font-weight:600; font-size:.9rem;
}
.btn-ghost:hover{ background:#f8fafc; border-color:#d1d5db; }

.agg-select{
  font-size:.9rem; padding:.35rem .55rem;
  border:1px solid #d1d5db; border-radius:8px;
  background:#fafafa; outline:none;
}

/* tiny circular info button */
.info-icon{
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1px solid #d1d5db;
  background: #fff;
  color:#374151;
  font-weight:700;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji","Segoe UI Emoji";
  line-height: 1;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer;
}
.info-icon:hover{ background:#f8fafc; }

/* One source of truth for page side spacing */
.home-container {
  padding-left: 50px;
  padding-right: 50px;
}

/* Remove side margins from sections; keep vertical rhythm only */
.home-menu,
.home-analytics {
  margin: 2rem 0;        /* was 2rem 50px or inline margins */
}

/* Keep your analytics row behavior */
.home-analytics{
  display:flex;
  gap:20px;
  flex-wrap:nowrap;
  align-items:stretch;
}

@media (max-width: 800px){
  .home-container { padding-left: 20px; padding-right: 20px; }
  .home-analytics { flex-wrap:wrap; }
}

/* ================================
   GASTOS — Tabs & "Por Nombre" UI
   Append to styles.css
================================ */

/* Tabs header */
.tabs {
  display: flex;
  gap: .25rem;
  border-bottom: 1px solid #e5e7eb;
  margin: .5rem 0 .75rem;
}

.tabs .tab-btn {
  appearance: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: .5rem .75rem;
  font-weight: 600;
  color: #374151;
  border-bottom: 2px solid transparent;
  border-top-left-radius: .5rem;
  border-top-right-radius: .5rem;
  transition: color .15s ease, border-color .15s ease, background-color .15s ease;
}

.tabs .tab-btn:hover {
  color: #111827;
  background: #f9fafb;
}

.tabs .tab-btn.active,
.tabs .tab-btn[aria-selected="true"] {
  color: #111827;
  border-bottom-color: #111827;
  background: #ffffff;
}

/* Panels */
.tab-panel {
  display: none;
}

.tab-panel[hidden] {
  display: none !important;
}

.tab-panel.is-visible,
#gastosTab1,
#gastosTab2 {
  /* let inline JS toggle block/none; this ensures proper spacing & rounded edges */
  background: #ffffff;
}

/* Split layout (left list + right timeline) */
.nombre-split {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 12px;
  align-items: start;
}

@media (max-width: 900px) {
  .nombre-split {
    grid-template-columns: 1fr;
  }
}

/* Left list */
.nombre-list {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #ffffff;
  padding: .5rem;
  max-height: 70vh;
  overflow: auto;
}

.nombre-list input[type="search"] {
  width: 100%;
  height: 2rem;
  padding: .25rem .5rem;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  outline: none;
}

.nombre-list input[type="search"]:focus {
  border-color: #c7cdd4;
  box-shadow: 0 0 0 3px rgba(17, 24, 39, .05);
}

#nombreList {
  list-style: none;
  margin: 0;
  padding: 0;
}

#nombreList li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .35rem .5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color .12s ease, font-weight .12s ease;
}

#nombreList li:hover {
  background: #f3f4f6;
}

#nombreList li.is-active {
  background: #f3f4f6;
  font-weight: 600;
}

/* Right: timeline */
.nombre-timeline {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #ffffff;
  padding: .5rem;
}

.nombre-timeline header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: .5rem;
}

.nombre-timeline .toolbar {
  display: flex;
  align-items: center;
  gap: .25rem;
}

.nombre-timeline .toolbar .btn-plain {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: .25rem .5rem;
  border-radius: .375rem;
  transition: background-color .12s ease;
}

.nombre-timeline .toolbar .btn-plain:hover {
  background: #f3f4f6;
}

.nombre-timeline .toolbar select {
  height: 2rem;
  padding: 0 .4rem;
  border: 1px solid #e5e7eb;
  border-radius: .375rem;
  background: #fff;
}

/* Months grid (latest on the right; horizontal scroll if needed) */
.months-grid,
#nmGrid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(110px, 1fr);
  gap: 8px;
  overflow-x: auto;
  padding-bottom: .25rem;
  scrollbar-width: thin;
}

/* Month column cards */
.months-grid > div,
#nmGrid > div {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  padding: .5rem;
  min-width: 110px;
}

.months-grid > div .month-title,
#nmGrid > div .month-title {
  font-size: .9rem;
  color: #555;
  margin-bottom: .35rem;
}

.months-grid > div .month-value,
#nmGrid > div .month-value {
  font-weight: 700;
  text-align: right;
}

/* Subtle scrollbars (WebKit) */
.months-grid::-webkit-scrollbar,
#nmGrid::-webkit-scrollbar {
  height: 8px;
}
.months-grid::-webkit-scrollbar-track,
#nmGrid::-webkit-scrollbar-track {
  background: #f3f4f6;
  border-radius: 8px;
}
.months-grid::-webkit-scrollbar-thumb,
#nmGrid::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 8px;
}
.months-grid::-webkit-scrollbar-thumb:hover,
#nmGrid::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* --- Por Nombre: stacked grid for larger month windows --- */
#nmGrid {
  display: grid;
  grid-auto-flow: column;              /* default: horizontal row */
  grid-auto-columns: minmax(110px, 1fr);
  gap: 8px;
  overflow-x: auto;
  padding-bottom: .25rem;
  scrollbar-width: thin;
}

#nmGrid.stacked {
  /* switch to wrapped, multi-row grid */
  grid-auto-flow: row;                 /* stop forcing one row */
  grid-auto-columns: auto;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  overflow-x: visible;                 /* allow rows to expand below */
}

/* nice scrollbar (WebKit) */
#nmGrid::-webkit-scrollbar { height: 8px; }
#nmGrid::-webkit-scrollbar-track { background: #f3f4f6; border-radius: 8px; }
#nmGrid::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 8px; }
#nmGrid::-webkit-scrollbar-thumb:hover { background: #9ca3af; }





/* ================================
   CONTROL PAGE LAYOUT
================================ */

.control-layout {
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  gap: 1rem;
  padding: 1rem;
  align-items: start;
}

/* ====== breakpoint: large tablet / small laptop
   We drop to 2 columns: 
   [prices sidebar] [center workspace]
   and push the library (Facturas guardadas) full-width below.
*/
@media (max-width: 1200px) {
  .control-layout {
    grid-template-columns: 260px 1fr;
  }

  /* keep prices on the left column */
  .control-prices {
    order: 1;
  }

  /* center workspace stays in the second column */
  .control-center {
    order: 2;
  }

  /* library moves below and spans full width */
  .control-library {
    order: 3;
    grid-column: 1 / -1;
  }
}

/* ====== breakpoint: mobile / narrow tablet
   We go fully vertical:
   1. center workspace (main thing you work on)
   2. prices
   3. invoice library
*/
@media (max-width: 800px) {
  .control-layout {
    grid-template-columns: 1fr;
  }

  .control-center {
    order: 1;
    width: 100%;
  }

  .control-prices {
    order: 2;
    width: 100%;
  }

  .control-library {
    order: 3;
    width: 100%;
  }
}

/* Panels general look */
.panel-title {
  font-size: 1rem;
  font-weight: 600;
  color: #111827;
  margin: 0;
}

.panel-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: .5rem;
  gap: .5rem;
}

.panel-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.secondary {
  background: black;
  border: 1px solid #e5e7eb;
  border-radius: .5rem;
  padding: .4rem .6rem;
  font-size: .7rem;
  cursor: pointer;
  color:white;
}
.secondary:hover {
  background: #f9fafb;
}

.danger {
  background: #fff;
  color: #b91c1c;
  border: 1px solid #ef4444;
  border-radius: .5rem;
  padding: .4rem .6rem;
  font-size: .9rem;
  cursor: pointer;
}
.danger:hover {
  background: #fef2f2;
}

/* LEFT SIDEBAR: SALES PRICES */
.control-prices {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: .75rem;
  padding: .75rem;
  display: flex;
  flex-direction: column;
  min-height: 60vh;
  max-height: 80vh;
}

@media (max-width: 800px) {
  .control-prices {
    min-height: auto;
    max-height: none;
  }
}

.control-prices__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: .5rem;
}

.control-prices__toolbar {
  display: flex;
  gap: .4rem;
}

.control-prices__search {
  margin-bottom: .5rem;
}
.control-prices__search input {
  width: 100%;
  height: 2rem;
  border: 1px solid #e5e7eb;
  border-radius: .5rem;
  padding: .25rem .5rem;
  font-size: .9rem;
}

/* scrollable price table */
.control-prices__tablewrap {
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: .5rem;
  background: #fff;
  max-height: calc(100vh - 12rem);
}

@media (max-width: 1200px) {
  .control-prices__tablewrap {
    max-height: 50vh;
  }
}
@media (max-width: 800px) {
  .control-prices__tablewrap {
    max-height: none;
    max-height: 40vh;
  }
}

.table-ui.slim th,
.table-ui.slim td {
  font-size: .8rem;
  line-height: 1.2rem;
  padding: .4rem .5rem;
}

/* CENTER WORKSPACE */
.control-center {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 60vh;
}

/* SUMMARY PANEL */
.summary-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(160px,1fr));
  gap: .75rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: .75rem;
  padding: .75rem;
}

.summary-block {
  display: flex;
  flex-direction: column;
}
.summary-label {
  font-size: .8rem;
  color: #6b7280;
  margin-bottom: .25rem;
}
.summary-value {
  font-size: 1rem;
  font-weight: 600;
  color: #111827;
  line-height: 1.25rem;
}
.summary-subvalue {
  font-size: .8rem;
  color: #6b7280;
  line-height: 1rem;
}

.summary-scope {
  display: flex;
  flex-direction: column;
  font-size: .8rem;
  color: #6b7280;
}
.summary-scope label {
  margin-bottom: .25rem;
}
.summary-scope select {
  height: 2rem;
  border-radius: .5rem;
  border: 1px solid #e5e7eb;
  padding: .25rem .5rem;
  background: #fff;
  font-size: .8rem;
  color: #111827;
}

/* INVOICE HEADER CARD */
.invoice-header-panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: .75rem;
  padding: .75rem;
}

.invoice-header-form {
  display: grid;
  gap: .75rem;
  font-size: .9rem;
  color: #111827;
}
.form-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
@media (max-width: 600px){
  .form-row-2col {
    grid-template-columns: 1fr;
  }
}
.form-row-1col {
  display: grid;
  gap: .5rem;
}

.invoice-header-form label {
  font-size: .8rem;
  color: #374151;
  display: grid;
  gap: .25rem;
}
.invoice-header-form input,
.invoice-header-form textarea {
  border: 1px solid #e5e7eb;
  border-radius: .5rem;
  padding: .5rem;
  font-size: .9rem;
  width: 100%;
  background: #fff;
  color: #111827;
  line-height: 1.2rem;
}

/* ALBARANES PANEL */
.albaranes-panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: .75rem;
  padding: .75rem;
}
.albaranes-list {
  display: grid;
  gap: .5rem;
  max-height: 200px;
  overflow-y: auto;
}
@media (max-width: 800px){
  .albaranes-list {
    max-height: none;
  }
}

.albaran-card {
  text-align: left;
  width: 100%;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: .5rem;
  padding: .5rem .6rem;
  cursor: pointer;
  display: grid;
  gap: .25rem;
  font-size: .8rem;
  color: #111827;
}
.albaran-card.selected {
  background: #eef2ff;
  border-color: #6366f1;
}
.albaran-row1,
.albaran-row2 {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
}
.albaran-num {
  font-weight: 600;
  color: #111827;
}
.albaran-total {
  font-weight: 600;
  color: #111827;
}

/* ITEMS PANEL */
.items-panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: .75rem;
  padding: .75rem;
  overflow-x: auto;
}
.items-panel .table-ui {
  min-width: 700px; /* prevent columns from squishing to unreadable on phones, allow horizontal scroll */
}

.items-panel .table-ui th,
.items-panel .table-ui td {
  font-size: .8rem;
  line-height: 1.2rem;
  vertical-align: top;
  white-space: nowrap;
}
.items-panel .table-ui th:nth-child(2),
.items-panel .table-ui td:nth-child(2) {
  white-space: normal;
  max-width: 240px;
}

/* RIGHT SIDEBAR: INVOICE LIBRARY ("Facturas guardadas") */
.control-library {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: .75rem;
  padding: .75rem;
  display: flex;
  flex-direction: column;
  min-height: 60vh;
  max-height: 80vh;
}

@media (max-width: 1200px) {
  .control-library {
    max-height: none;
  }
}
@media (max-width: 800px) {
  .control-library {
    min-height: auto;
    max-height: none;
  }
}

.control-library__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: .5rem;
}

.control-library__toolbar {
  display: flex;
  gap: .4rem;
}

.control-library__search {
  margin-bottom: .5rem;
}
.control-library__search input {
  width: 100%;
  height: 2rem;
  border: 1px solid #e5e7eb;
  border-radius: .5rem;
  padding: .25rem .5rem;
  font-size: .9rem;
}

/* scroll area of "Facturas guardadas" */
.control-library__list {
  flex: 1;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: .5rem;
  background: #fff;
  padding: .5rem;
  display: grid;
  gap: .5rem;
  max-height: calc(100vh - 14rem);
}

@media (max-width: 1200px) {
  .control-library__list {
    max-height: 50vh;
  }
}
@media (max-width: 800px) {
  .control-library__list {
    max-height: 40vh;
  }
}

.invoice-card {
  width: 100%;
  text-align: left;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: .5rem;
  padding: .5rem .6rem;
  cursor: pointer;
  display: grid;
  gap: .25rem;
  font-size: .8rem;
  color: #111827;
}
.invoice-card.active {
  background: #eef2ff;
  border-color: #6366f1;
}

.invoice-card-row1,
.invoice-card-row2 {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
}
.inv-num {
  font-weight: 600;
  color: #111827;
}
.inv-total {
  font-weight: 600;
  color: #111827;
}

.control-library__footer {
  margin-top: .75rem;
  display: flex;
  justify-content: flex-end;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* exactly 3 columns */
  gap: 1px; /* 1px spacing between buttons */
}

.month-grid button {
  padding: .45rem .3rem;
  border: 1px solid #ccc;
  border-radius: .35rem;
  background: #a5a2a2;
  cursor: pointer;
  font-size: .8rem;
  text-transform: capitalize;
  transition: all .15s ease;
  width: 100%;
  box-sizing: border-box;
}

.month-grid button:hover {
  background: #f3f3f3;
}

.month-grid button.active {
  background: #009688;
  color: #fff;
  border-color: #009688;
}

