/*
 * AppSGM — Rediseño visual 2026
 * Capa de presentación basada en las referencias de Stitch.
 * Este archivo no modifica lógica, datos, validaciones ni integraciones.
 */

:root {
  --sgm-ink: #03131f;
  --sgm-navy: #061b2b;
  --sgm-navy-2: #09263c;
  --sgm-panel: rgba(10, 44, 70, 0.82);
  --sgm-panel-strong: rgba(11, 49, 78, 0.94);
  --sgm-panel-soft: rgba(16, 57, 87, 0.64);
  --sgm-line: rgba(87, 161, 209, 0.34);
  --sgm-line-strong: rgba(107, 186, 235, 0.58);
  --sgm-copy: #f4f8fc;
  --sgm-copy-2: #c3d4e2;
  --sgm-copy-3: #7f9bb0;
  --sgm-red: #ed1b2f;
  --sgm-red-hot: #ff4050;
  --sgm-blue: #147ec1;
  --sgm-cyan: #53b8ef;
  --sgm-green: #38d081;
  --sgm-warning: #ffc24b;
  --sgm-radius-xl: 28px;
  --sgm-radius-lg: 22px;
  --sgm-radius-md: 16px;
  --sgm-shadow: 0 24px 70px rgba(0, 7, 15, 0.42);
  --sgm-shadow-soft: 0 14px 34px rgba(0, 7, 15, 0.24);

  --mobil-dark: var(--sgm-ink);
  --glass: var(--sgm-panel);
  --glass-2: var(--sgm-panel-strong);
  --glass-input: rgba(4, 24, 39, 0.84);
  --glass-card: var(--sgm-panel);
  --glass-kpi: var(--sgm-panel-strong);
  --glass-header: rgba(3, 19, 31, 0.88);
  --glass-table: rgba(5, 28, 45, 0.9);
  --glass-thead: rgba(8, 40, 64, 0.98);
  --border: var(--sgm-line);
  --border-2: var(--sgm-line-strong);
  --border-mid: var(--sgm-line);
  --text-primary: var(--sgm-copy);
  --text-secondary: var(--sgm-copy-2);
  --text-muted: var(--sgm-copy-3);
  --text-faint: #648399;
  --radius: var(--sgm-radius-lg);
  --radius-sm: var(--sgm-radius-md);
  --radius-xs: 12px;
  --texture-bg: none;
  --texture-wm: none;
  --texture-login: none;
  --texture-card: none;
}

html {
  background: var(--sgm-ink);
}

body {
  background:
    radial-gradient(circle at 14% 9%, rgba(25, 126, 193, 0.17), transparent 31rem),
    radial-gradient(circle at 86% 21%, rgba(237, 27, 47, 0.08), transparent 26rem),
    linear-gradient(145deg, #03131f 0%, #061b2b 46%, #041622 100%);
  color: var(--sgm-copy);
}

body::before {
  background:
    radial-gradient(circle at 10% 0%, rgba(58, 158, 219, 0.18), transparent 34%),
    linear-gradient(180deg, rgba(0, 20, 34, 0.06), rgba(0, 7, 14, 0.24)),
    var(--texture-bg) center / cover no-repeat;
  filter: saturate(0.72) contrast(1.05);
  mix-blend-mode: screen;
  opacity: 0.09;
}

body::after {
  background-size: 62px 108px;
  opacity: 0.3;
  mask-image: linear-gradient(to bottom, #000, transparent 88%);
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent 88%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.tab,
.seg-btn,
.btn-isla {
  touch-action: manipulation;
}

.material-symbols-rounded {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: "Material Symbols Rounded";
  font-size: 20px;
  font-style: normal;
  font-weight: 400;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "liga";
  font-variation-settings: "FILL" 0, "wght" 450, "GRAD" 0, "opsz" 24;
}

.field-leading-icon {
  position: absolute;
  top: 50%;
  left: 16px;
  z-index: 2;
  color: #8dacbf;
  pointer-events: none;
  transform: translateY(-50%);
}

/* App shell */
#header {
  height: 72px;
  padding: 0 28px;
  background: rgba(3, 19, 31, 0.88);
  border-bottom: 1px solid rgba(77, 153, 202, 0.28);
  box-shadow: 0 16px 44px rgba(0, 7, 14, 0.32);
  backdrop-filter: blur(22px) saturate(145%);
  -webkit-backdrop-filter: blur(22px) saturate(145%);
}

#header::after {
  background: linear-gradient(90deg, transparent 4%, rgba(79, 178, 235, 0.56), rgba(237, 27, 47, 0.6), transparent 96%);
  opacity: 0.48;
}

.logo-group {
  gap: 13px;
}

.logo-badge {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  background: linear-gradient(145deg, #f73346 0%, #d31127 72%, #8f0c1a 100%);
  box-shadow: 0 9px 28px rgba(237, 27, 47, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.logo-text .brand {
  font-size: 18px;
  letter-spacing: -0.35px;
}

.logo-text .sub {
  color: #7796aa;
  letter-spacing: 2.8px;
}

.header-right {
  gap: 12px;
}

.badge-live {
  padding: 5px 11px;
  background: rgba(42, 190, 114, 0.1);
  border-color: rgba(72, 225, 143, 0.25);
  color: #67eda8;
}

#app {
  max-width: 1280px;
  padding: 26px 24px 96px;
}

/* Type hierarchy */
.h1,
.h2,
.h3,
.kpi-val,
.logo-text .brand {
  font-family: var(--font-d), var(--font), sans-serif;
}

.h1 {
  font-size: clamp(28px, 4vw, 43px);
  line-height: 1.05;
}

.h2 {
  font-size: clamp(22px, 3vw, 31px);
  line-height: 1.1;
}

.h3 {
  font-size: 17px;
}

.label {
  color: #88a4b7;
  letter-spacing: 2.2px;
}

.sec-header {
  align-items: flex-end;
  margin-bottom: 22px;
}

/* Glass panels */
.card,
.login-card,
.kpi-card,
.tbl-wrap {
  border: 1px solid var(--sgm-line);
  background:
    linear-gradient(145deg, rgba(15, 57, 88, 0.9), rgba(6, 31, 50, 0.88)),
    rgba(7, 37, 59, 0.9);
  box-shadow: var(--sgm-shadow-soft), inset 0 1px 0 rgba(220, 243, 255, 0.08);
  backdrop-filter: blur(22px) saturate(125%);
  -webkit-backdrop-filter: blur(22px) saturate(125%);
}

.card {
  padding: 24px;
  border-radius: var(--sgm-radius-lg);
}

.card::after,
.kpi-card::after {
  opacity: 0.018;
}

.card-accent,
.card-blue,
.card-green,
.card-gold,
.card-alert {
  border-left-width: 1px;
}

.card-accent {
  box-shadow: inset 4px 0 0 rgba(237, 27, 47, 0.95), var(--sgm-shadow-soft);
}

.card-blue {
  box-shadow: inset 4px 0 0 rgba(58, 161, 224, 0.85), var(--sgm-shadow-soft);
}

.card-green {
  box-shadow: inset 4px 0 0 rgba(56, 208, 129, 0.82), var(--sgm-shadow-soft);
}

.card-gold {
  box-shadow: inset 4px 0 0 rgba(255, 194, 75, 0.88), var(--sgm-shadow-soft);
}

.card-alert {
  background: linear-gradient(135deg, rgba(237, 27, 47, 0.13), rgba(10, 47, 75, 0.86) 52%);
  box-shadow: inset 4px 0 0 var(--sgm-red), var(--sgm-shadow-soft);
}

/* KPI dashboard */
.kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
}

.kpi-card {
  min-height: 142px;
  padding: 24px;
  border-radius: var(--sgm-radius-lg);
  background:
    radial-gradient(circle at 92% 5%, color-mix(in srgb, var(--accent) 17%, transparent), transparent 42%),
    linear-gradient(145deg, rgba(15, 58, 90, 0.96), rgba(7, 33, 53, 0.94));
}

.kpi-card::before {
  top: 16px;
  right: 18px;
  left: auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 75%, transparent);
}

.kpi-label {
  margin-bottom: 16px;
  color: #87a5b9;
  font-size: 10px;
  letter-spacing: 2.1px;
}

.kpi-val {
  font-size: clamp(30px, 4vw, 40px);
  letter-spacing: -1.4px;
}

.kpi-sub {
  margin-top: 9px;
  color: #92aabd;
  font-size: 12px;
}

#admin-resumen > div[style*="grid-template-columns:1fr auto"] {
  grid-template-columns: minmax(0, 1fr) minmax(240px, 280px) !important;
}

#dash-alertas-panel {
  width: 100% !important;
  min-width: 0 !important;
}

/* Controls */
.inp,
textarea {
  min-height: 50px;
  padding: 13px 16px;
  border: 1px solid rgba(102, 171, 214, 0.32);
  border-radius: 14px;
  background: rgba(3, 25, 41, 0.72);
  color: #f7fbff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.inp:hover,
textarea:hover {
  border-color: rgba(115, 190, 236, 0.5);
}

.inp:focus,
textarea:focus {
  border-color: #5bb8ed;
  box-shadow: 0 0 0 4px rgba(41, 144, 203, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.inp::placeholder,
textarea::placeholder {
  color: #6c879a;
}

select.inp,
select.inp option {
  background-color: #071f32 !important;
  color: #f4f8fc !important;
}

.inp-sm {
  min-height: 40px;
  padding: 9px 12px;
}

.inp-pin,
.inp-admin {
  font-variant-numeric: tabular-nums;
}

.btn {
  min-height: 44px;
  padding: 11px 19px;
  border-radius: 14px;
  font-size: 13px;
  letter-spacing: 0.25px;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.btn:focus-visible,
.tab:focus-visible,
.seg-btn:focus-visible,
.btn-isla:focus-visible {
  outline: 3px solid rgba(86, 187, 244, 0.48);
  outline-offset: 2px;
}

.btn-red {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(180deg, var(--sgm-red-hot), var(--sgm-red) 47%, #c61024);
  box-shadow: 0 14px 28px rgba(237, 27, 47, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.btn-red:hover {
  box-shadow: 0 17px 34px rgba(237, 27, 47, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.btn-blue {
  border: 1px solid rgba(110, 194, 244, 0.28);
  background: linear-gradient(180deg, #208fd2, #096ca8);
}

.btn-ghost {
  border-color: rgba(106, 175, 217, 0.3);
  background: rgba(10, 47, 75, 0.64);
  color: #c9dbe7;
}

.btn-ghost:hover {
  border-color: rgba(119, 197, 244, 0.55);
  background: rgba(17, 68, 105, 0.72);
  color: #fff;
}

.btn-sm {
  min-height: 36px;
  padding: 8px 13px;
}

/* Navigation */
.tabs,
.seg-ctrl {
  gap: 5px;
  padding: 6px;
  border: 1px solid rgba(93, 167, 213, 0.24);
  border-radius: 17px;
  background: rgba(3, 24, 39, 0.62);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.tab,
.seg-btn {
  min-height: 43px;
  padding: 9px 14px;
  border-radius: 12px;
  color: #8ea8ba;
  font-size: 11px;
}

.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.tab .material-symbols-rounded {
  font-size: 19px;
}

.tab.active,
.seg-btn.active {
  background: linear-gradient(180deg, rgba(30, 101, 148, 0.86), rgba(12, 64, 99, 0.9));
  color: #fff;
  box-shadow: 0 8px 20px rgba(0, 10, 22, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.tab.active::after {
  bottom: -1px;
  left: 22%;
  right: 22%;
  height: 3px;
  background: var(--sgm-red);
}

#view-admin > .tabs,
#view-cliente > .tabs {
  position: sticky;
  top: 86px;
  z-index: 180;
  margin-bottom: 24px;
  background: rgba(3, 22, 36, 0.88);
  box-shadow: 0 14px 32px rgba(0, 7, 15, 0.3);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* Tables */
.tbl-wrap {
  border-radius: 18px;
  background: rgba(4, 27, 44, 0.88);
}

thead {
  background: rgba(8, 43, 69, 0.98);
}

th {
  padding: 14px 16px;
  border-bottom-color: rgba(99, 173, 216, 0.25);
  color: #8eacbf;
  font-size: 9px;
  letter-spacing: 1.55px;
}

td {
  padding: 14px 16px;
  border-top-color: rgba(109, 174, 212, 0.1);
  color: #bed0dc;
}

tbody tr:nth-child(even) td {
  background: rgba(17, 62, 93, 0.12);
}

tr:hover td {
  background: rgba(40, 121, 173, 0.12);
}

/* Login */
#login-screen {
  padding: 36px 22px;
  background:
    radial-gradient(circle at 50% -10%, rgba(40, 143, 205, 0.23), transparent 36%),
    linear-gradient(180deg, rgba(2, 17, 28, 0.18), rgba(2, 14, 23, 0.55));
}

#login-screen::after {
  background-size: min(78vw, 890px);
  opacity: 0.035;
  filter: saturate(0) contrast(1.2);
}

.login-card {
  width: min(100%, 610px);
  max-width: 610px;
  padding: 48px 52px 40px;
  border: 1px solid rgba(83, 163, 213, 0.42);
  border-radius: 30px;
  background:
    radial-gradient(circle at 86% 7%, rgba(56, 151, 213, 0.19), transparent 32%),
    linear-gradient(145deg, rgba(11, 48, 76, 0.96), rgba(4, 25, 41, 0.94));
  box-shadow: 0 34px 100px rgba(0, 4, 11, 0.58), inset 0 1px 0 rgba(224, 246, 255, 0.12);
}

.login-card::before {
  right: -42px;
  bottom: -55px;
  width: 310px;
  height: 310px;
  opacity: 0.04;
}

.login-card::after {
  top: 18px;
  left: 24%;
  right: 24%;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(85, 184, 239, 0.9), rgba(237, 27, 47, 0.95), transparent);
}

#login-screen .logo-badge {
  width: 54px !important;
  height: 54px !important;
  border-radius: 15px !important;
}

#login-screen .logo-text .brand {
  font-size: 25px !important;
}

#login-screen .seg-ctrl {
  margin-bottom: 20px;
}

#login-screen .seg-btn {
  min-height: 49px;
  border-radius: 13px;
  font-size: 13px;
}

#login-screen .seg-btn.active {
  background: linear-gradient(180deg, #ff3d4d, #d8152a);
  box-shadow: 0 10px 22px rgba(237, 27, 47, 0.25);
}

#login-screen .inp {
  min-height: 58px;
  border-radius: 16px;
}

#login-screen .btn-red {
  min-height: 58px;
  border-radius: 16px;
  font-size: 14px;
}

.btn-isla {
  aspect-ratio: auto;
  min-height: 83px;
  border-color: rgba(97, 172, 218, 0.32);
  border-radius: 16px;
  background: rgba(5, 31, 50, 0.8);
}

.btn-isla:hover {
  border-color: rgba(111, 194, 241, 0.54);
  background: rgba(15, 58, 89, 0.9);
}

.btn-isla.active {
  border-color: var(--sgm-red);
  background: linear-gradient(145deg, rgba(237, 27, 47, 0.2), rgba(10, 54, 86, 0.92));
  box-shadow: 0 0 0 1px rgba(237, 27, 47, 0.62), 0 14px 32px rgba(0, 7, 15, 0.34);
}

/* Agent flow */
.step-dots {
  max-width: 560px;
  margin-right: auto;
  margin-left: auto;
}

.step-dot {
  box-shadow: 0 0 0 5px rgba(36, 115, 165, 0.12);
}

.step-dot.active,
.step-dot.done {
  box-shadow: 0 0 0 5px rgba(237, 27, 47, 0.12), 0 8px 22px rgba(237, 27, 47, 0.18);
}

.photo-zone {
  min-height: 140px;
  display: grid;
  place-items: center;
  border-color: rgba(105, 178, 222, 0.4);
  border-radius: 18px;
  background: rgba(5, 32, 51, 0.55);
}

/* Catalog modal */
#modal-unidad {
  background: rgba(0, 9, 17, 0.8) !important;
  backdrop-filter: blur(13px);
  -webkit-backdrop-filter: blur(13px);
}

#app:has(#modal-unidad:not(.hidden)) {
  z-index: 600;
}

#modal-unidad > .card {
  width: min(100%, 760px) !important;
  max-width: 760px !important;
  max-height: min(92vh, 860px) !important;
  padding: 28px !important;
  border-radius: 26px !important;
}

#modal-unidad-titulo {
  font-size: 24px;
}

/* AI analyst */
.ia-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ia-title .material-symbols-rounded {
  color: #70c6f4;
  font-size: 28px;
  font-variation-settings: "FILL" 1, "wght" 450, "GRAD" 0, "opsz" 28;
}

#admin-ia .card[style*="height:520px"],
#cli-ia .card[style*="height:520px"] {
  height: min(66vh, 680px) !important;
  min-height: 520px;
  background:
    radial-gradient(circle at 6% 10%, rgba(33, 135, 199, 0.24), transparent 28%),
    linear-gradient(145deg, rgba(11, 50, 79, 0.96), rgba(4, 25, 40, 0.96));
}

.ia-msg {
  gap: 12px;
}

.ia-avatar {
  width: 44px;
  height: 44px;
  overflow: hidden;
  border: 2px solid rgba(237, 27, 47, 0.72);
  border-radius: 50%;
  background: url("assets/sgm-ai-analyst.png") center / cover no-repeat !important;
  box-shadow: 0 8px 22px rgba(0, 6, 13, 0.34);
  color: transparent !important;
  font-size: 0 !important;
}

.ia-msg-user .ia-avatar {
  display: grid;
  border-color: rgba(91, 184, 237, 0.72);
  background: linear-gradient(145deg, #287fb6, #0b4167) !important;
  color: #fff !important;
  font-size: 12px !important;
}

.ia-bubble {
  max-width: min(82%, 760px);
  padding: 14px 17px;
  border-color: rgba(100, 169, 211, 0.25);
  border-radius: 18px;
  border-top-left-radius: 6px;
  background: rgba(7, 33, 52, 0.92);
  color: #c6d6e1;
  font-size: 13px;
}

.ia-msg-user .ia-bubble {
  border-color: rgba(237, 27, 47, 0.31);
  background: rgba(141, 18, 35, 0.26);
}

#ia-input,
#cli-ia-input {
  min-height: 52px !important;
  border-radius: 16px !important;
  background: rgba(3, 23, 38, 0.92) !important;
}

#ia-send-btn,
#cli-ia-send-btn {
  min-width: 54px;
  height: 52px;
  border-radius: 15px;
}

/* Utility surfaces */
.msg,
.pill,
.chip-ok,
.chip-warn,
.chip-danger {
  border-radius: 999px;
}

.msg {
  padding: 12px 15px;
  border-radius: 14px;
}

.divider {
  border-top-color: rgba(101, 168, 207, 0.14);
}

::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-thumb {
  background: rgba(97, 165, 207, 0.34);
  border-radius: 999px;
}

/* Light mode remains available and legible */
body.light {
  --sgm-copy: #10283b;
  --sgm-copy-2: #365268;
  --sgm-copy-3: #668094;
  --sgm-line: rgba(31, 102, 146, 0.18);
  --sgm-line-strong: rgba(31, 102, 146, 0.34);
  background: linear-gradient(145deg, #edf5fa, #f8fbfd 52%, #eaf3f8);
}

body.light::before {
  opacity: 0.025;
}

body.light::after {
  opacity: 0.08;
}

body.light #header {
  background: rgba(247, 251, 253, 0.9);
  border-bottom-color: rgba(29, 106, 153, 0.18);
}

body.light .card,
body.light .login-card,
body.light .kpi-card,
body.light .tbl-wrap {
  border-color: rgba(35, 108, 151, 0.16);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 18px 48px rgba(22, 62, 88, 0.11), inset 0 1px 0 #fff;
}

body.light .inp,
body.light textarea,
body.light select.inp {
  border-color: rgba(35, 108, 151, 0.22) !important;
  background: rgba(241, 247, 250, 0.94) !important;
  color: #10283b !important;
}

body.light select.inp option {
  background: #f4f8fa !important;
  color: #10283b !important;
}

body.light .tabs,
body.light .seg-ctrl,
body.light #view-admin > .tabs,
body.light #view-cliente > .tabs {
  border-color: rgba(35, 108, 151, 0.16);
  background: rgba(241, 247, 250, 0.9);
}

body.light .tab.active,
body.light .seg-btn.active {
  background: linear-gradient(180deg, #e4f1f8, #d8eaf4);
  color: #0e3d59;
}

body.light thead {
  background: #e8f2f7;
}

body.light td {
  color: #375469;
}

/* Compact desktop */
@media (max-width: 980px) {
  #header {
    padding: 0 18px;
  }

  #app {
    padding-right: 16px;
    padding-left: 16px;
  }

  #view-admin > .tabs,
  #view-cliente > .tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    justify-content: flex-start;
    scrollbar-width: none;
  }

  #view-admin > .tabs::-webkit-scrollbar,
  #view-cliente > .tabs::-webkit-scrollbar {
    display: none;
  }

  #view-admin > .tabs .tab,
  #view-cliente > .tabs .tab {
    flex: 0 0 auto;
  }
}

/* Mobile app treatment */
@media (max-width: 680px) {
  :root {
    --sgm-radius-xl: 24px;
    --sgm-radius-lg: 20px;
    --sgm-radius-md: 15px;
  }

  body {
    background:
      radial-gradient(circle at 8% 4%, rgba(37, 139, 201, 0.18), transparent 26rem),
      linear-gradient(160deg, #03131f, #061b2b 55%, #041520);
  }

  #header {
    height: 64px;
    padding: 0 13px;
  }

  .logo-group {
    gap: 8px;
  }

  .logo-badge {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    font-size: 10px;
  }

  .logo-text .brand {
    font-size: 14px;
  }

  .logo-text .sub {
    max-width: 150px;
    overflow: hidden;
    font-size: 6px;
    letter-spacing: 1.7px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header-right {
    gap: 6px;
  }

  #header .badge-live,
  #header #mode-label,
  #header #theme-label {
    display: none;
  }

  #header .btn-icon {
    min-width: 38px;
    min-height: 38px;
    padding: 7px 9px !important;
  }

  #app {
    width: 100%;
    padding: 20px 14px 112px;
  }

  .sec-header {
    align-items: center;
    margin-bottom: 18px;
  }

  .h1 {
    font-size: 31px;
  }

  .h2 {
    font-size: 24px;
  }

  .h3 {
    font-size: 16px;
  }

  .card,
  .login-card {
    padding: 19px;
  }

  .grid-2,
  .grid-3,
  #bloomberg-kpis {
    grid-template-columns: 1fr !important;
  }

  #admin-resumen > div[style*="grid-template-columns:1fr auto"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 13px;
  }

  .kpi-card {
    min-height: 132px;
    padding: 21px 22px;
  }

  .kpi-val {
    font-size: 36px;
  }

  #view-admin > .tabs,
  #view-cliente > .tabs {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 420;
    height: 84px;
    margin: 0;
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap !important;
    gap: 3px;
    border: 0;
    border-top: 1px solid rgba(83, 159, 207, 0.34);
    border-radius: 20px 20px 0 0;
    background: rgba(3, 21, 34, 0.96);
    box-shadow: 0 -18px 44px rgba(0, 6, 13, 0.43);
    backdrop-filter: blur(25px) saturate(145%);
    -webkit-backdrop-filter: blur(25px) saturate(145%);
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  #view-admin > .tabs::-webkit-scrollbar,
  #view-cliente > .tabs::-webkit-scrollbar {
    display: none;
  }

  #view-admin > .tabs .tab,
  #view-cliente > .tabs .tab {
    flex: 0 0 78px;
    min-width: 78px;
    min-height: 66px;
    padding: 7px 4px;
    flex-direction: column;
    gap: 5px;
    border-radius: 14px;
    font-size: 8.5px;
    letter-spacing: 0.1px;
  }

  #view-admin > .tabs .tab .material-symbols-rounded,
  #view-cliente > .tabs .tab .material-symbols-rounded {
    font-size: 23px;
  }

  #view-admin > .tabs .tab.active,
  #view-cliente > .tabs .tab.active {
    background: rgba(16, 69, 104, 0.86);
    color: #fff;
  }

  #view-admin > .tabs .tab.active::after,
  #view-cliente > .tabs .tab.active::after {
    top: 3px;
    bottom: auto;
    left: 31%;
    right: 31%;
    height: 3px;
  }

  /* Login follows the portrait Stitch composition */
  #login-screen {
    min-height: 100dvh;
    padding: 10px 14px;
    place-items: center;
  }

  .login-card {
    width: 100%;
    max-width: 430px;
    padding: 27px 20px 24px;
    border-radius: 25px;
  }

  #login-screen .logo-badge {
    width: 48px !important;
    height: 48px !important;
  }

  #login-screen .logo-text .brand {
    font-size: 20px !important;
  }

  #login-screen .logo-text .sub {
    max-width: 250px;
    font-size: 6.5px !important;
    letter-spacing: 2px !important;
  }

  #login-screen .login-tagline {
    display: none;
  }

  #login-screen .seg-btn {
    min-height: 46px;
    padding: 8px 6px;
  }

  #login-screen .inp {
    min-height: 54px;
  }

  #login-screen .btn-red {
    min-height: 56px;
  }

  .btn-isla {
    min-height: 72px;
    border-radius: 15px;
  }

  .btn-isla .isla-num {
    font-size: 22px;
  }

  /* Record table becomes readable cards without changing the table data */
  #admin-bitacora .tbl-wrap,
  #cli-bitacora .tbl-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  #admin-bitacora table,
  #admin-bitacora tbody,
  #admin-bitacora tr,
  #admin-bitacora td,
  #cli-bitacora table,
  #cli-bitacora tbody,
  #cli-bitacora tr,
  #cli-bitacora td {
    display: block;
    width: 100%;
  }

  #admin-bitacora thead,
  #cli-bitacora thead {
    display: none;
  }

  #admin-bitacora tbody,
  #cli-bitacora tbody {
    display: grid;
    gap: 14px;
  }

  #admin-bitacora tbody tr,
  #cli-bitacora tbody tr {
    overflow: hidden;
    border: 1px solid rgba(89, 163, 209, 0.34);
    border-radius: 19px;
    background: linear-gradient(145deg, rgba(15, 57, 88, 0.94), rgba(6, 31, 50, 0.92));
    box-shadow: 0 15px 34px rgba(0, 7, 15, 0.26);
  }

  #admin-bitacora tbody td,
  #cli-bitacora tbody td {
    display: flex;
    min-height: 43px;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 10px 15px;
    border-top: 1px solid rgba(100, 168, 209, 0.12);
    background: transparent !important;
    text-align: right;
  }

  #admin-bitacora tbody td:first-child,
  #cli-bitacora tbody td:first-child {
    border-top: 0;
  }

  #admin-bitacora tbody td::before,
  #cli-bitacora tbody td::before {
    min-width: 92px;
    color: #7899ae;
    content: "Dato";
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 1.4px;
    text-align: left;
    text-transform: uppercase;
  }

  #admin-bitacora tbody td:nth-child(1)::before,
  #cli-bitacora tbody td:nth-child(1)::before { content: "Fecha"; }
  #admin-bitacora tbody td:nth-child(2)::before,
  #cli-bitacora tbody td:nth-child(2)::before { content: "Hora"; }
  #admin-bitacora tbody td:nth-child(3)::before,
  #cli-bitacora tbody td:nth-child(3)::before { content: "Ticket"; }
  #admin-bitacora tbody td:nth-child(4)::before,
  #cli-bitacora tbody td:nth-child(4)::before { content: "Folio vale"; }
  #admin-bitacora tbody td:nth-child(5)::before { content: "Cliente"; }
  #admin-bitacora tbody td:nth-child(6)::before,
  #cli-bitacora tbody td:nth-child(5)::before { content: "Chofer"; }
  #admin-bitacora tbody td:nth-child(7)::before,
  #cli-bitacora tbody td:nth-child(6)::before { content: "Placas"; }
  #admin-bitacora tbody td:nth-child(8)::before,
  #cli-bitacora tbody td:nth-child(7)::before { content: "Producto"; }
  #admin-bitacora tbody td:nth-child(9)::before,
  #cli-bitacora tbody td:nth-child(8)::before { content: "Litros"; }
  #admin-bitacora tbody td:nth-child(10)::before,
  #cli-bitacora tbody td:nth-child(9)::before { content: "Monto"; }
  #admin-bitacora tbody td:nth-child(11)::before,
  #cli-bitacora tbody td:nth-child(10)::before { content: "Odómetro"; }
  #admin-bitacora tbody td:nth-child(12)::before,
  #cli-bitacora tbody td:nth-child(11)::before { content: "Foto placa"; }
  #admin-bitacora tbody td:nth-child(13)::before,
  #cli-bitacora tbody td:nth-child(12)::before { content: "Foto ticket"; }
  #admin-bitacora tbody td:nth-child(14)::before,
  #cli-bitacora tbody td:nth-child(13)::before { content: "Firma"; }

  /* Keep tables in other modules scrollable */
  .tbl-wrap {
    margin-right: -3px;
    margin-left: -3px;
  }

  table {
    min-width: 720px;
  }

  #admin-bitacora table,
  #cli-bitacora table {
    min-width: 0;
  }

  /* Full-height unit editor */
  #modal-unidad {
    align-items: stretch !important;
    padding: 0 !important;
  }

  #modal-unidad > .card {
    width: 100% !important;
    max-width: none !important;
    max-height: 100dvh !important;
    padding: 24px 18px calc(118px + env(safe-area-inset-bottom)) !important;
    border: 0 !important;
    border-radius: 0 !important;
  }

  #modal-unidad > .card > .grid-2:not(:last-child) {
    gap: 14px;
    margin-bottom: 14px;
    padding: 14px;
    border: 1px solid rgba(102, 173, 216, 0.18);
    border-radius: 17px;
    background: rgba(203, 224, 238, 0.055);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
  }

  #modal-unidad > .card > .grid-2:last-child {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 12;
    grid-template-columns: minmax(105px, 0.7fr) minmax(0, 1.3fr) !important;
    gap: 10px;
    margin: 0;
    padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(92, 166, 211, 0.3);
    background: rgba(3, 22, 36, 0.97);
    box-shadow: 0 -18px 36px rgba(0, 7, 15, 0.38);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  #modal-unidad-titulo {
    position: sticky;
    top: 0;
    z-index: 2;
    margin: -24px -18px 22px;
    padding: 22px 18px 17px;
    border-bottom: 1px solid rgba(91, 166, 211, 0.26);
    background: rgba(4, 25, 41, 0.96);
    font-size: 22px;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }

  /* AI quick actions and chat */
  #admin-ia .card > div[style*="flex-wrap:wrap"],
  #cli-ia .card > div[style*="flex-wrap:wrap"] {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    padding-bottom: 5px;
    scrollbar-width: none;
  }

  #admin-ia .card > div[style*="flex-wrap:wrap"]::-webkit-scrollbar,
  #cli-ia .card > div[style*="flex-wrap:wrap"]::-webkit-scrollbar {
    display: none;
  }

  #admin-ia .card > div[style*="flex-wrap:wrap"] .btn,
  #cli-ia .card > div[style*="flex-wrap:wrap"] .btn {
    flex: 0 0 auto;
  }

  #admin-ia .card[style*="height:520px"],
  #cli-ia .card[style*="height:520px"] {
    min-height: 570px;
    height: calc(100dvh - 250px) !important;
    max-height: 680px;
    padding: 16px;
  }

  .ia-avatar {
    width: 39px;
    height: 39px;
  }

  .ia-bubble {
    max-width: calc(100% - 51px);
    padding: 12px 14px;
  }

  #ia-send-btn,
  #cli-ia-send-btn {
    min-width: 50px;
    padding: 10px 14px !important;
  }

  .btn-full {
    min-height: 52px;
  }
}

@media (max-width: 390px) {
  #app {
    padding-right: 11px;
    padding-left: 11px;
  }

  .login-card {
    padding-right: 17px;
    padding-left: 17px;
  }

  #login-screen .logo-text .brand {
    font-size: 18px !important;
  }

  #login-screen .logo-text .sub {
    max-width: 205px;
    letter-spacing: 1.5px !important;
  }

  .header-right .theme-toggle {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
