* { box-sizing: border-box; }

:root {
  --bg: #f5f5f5;
  --text: #111;
  --muted: #64748b;
  --header-bg: #111;
  --header-text: #fff;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --surface-row: #f9fafb;
  --surface-hover: #eef2ff;
  --border: #ddd;
  --border-soft: #e5e7eb;
  --sidebar-bg: #fff;
  --sidebar-border: #ddd;
  --sidebar-link: #111;
  --sidebar-hover: #eee;
  --btn-bg: #f3f4f6;
  --btn-border: #d1d5db;
  --btn-text: #111;
  --input-bg: #fff;
  --input-border: #d1d5db;
  --focus-ring: rgba(96,165,250,0.25);
  --modal-bg: #fff;
  --notif-new-bg: #eff6ff;
  --notif-new-border: #93c5fd;
  --accent: #2563eb;
  --danger: #ef4444;
}

.hidden {
  display: none !important;
}

.kameh-banner {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 200px;
  background: var(--surface-alt);
  border: 1px solid var(--pos-border-soft);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.12);
  z-index: 50;
}

.kameh-banner-close {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border-soft);
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  line-height: 20px;
}

.kameh-banner-icon {
  width: 96px;
  height: 28px;
  border-radius: 50%;
  background: #22c55e;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 11px;
  margin-bottom: 6px;
  padding: 0 8px;
  border-radius: 999px;
}

.kameh-banner-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.kameh-banner-text {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}

.kameh-banner-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  border-radius: 10px;
  padding: 8px 10px;
  text-decoration: none;
  background: #22c55e;
  color: white;
  font-weight: 700;
  font-size: 13px;
}

.kameh-banner-mini {
  position: fixed;
  right: 16px;
  bottom: 16px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: #22c55e;
  color: #fff;
  font-weight: 800;
  font-size: 11px;
  z-index: 50;
  cursor: pointer;
}

@media (max-width: 720px) {
  .kameh-banner,
  .kameh-banner-mini {
    display: none;
  }
}

body {
  margin: 0;
  font-family: system-ui, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--modal-bg);
  border-radius: 16px;
  padding: 16px;
  width: 420px;
  max-width: 92vw;
  box-shadow: 0 12px 30px rgba(0,0,0,0.18);
}

@media (max-width: 720px) {
  .modal-content {
    max-height: calc(100vh - 140px);
    overflow: auto;
  }
}

.sync-clip-btn {
  margin-left: 6px;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
}

.app-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4000;
}

.app-overlay.hidden {
  display: none;
}

.app-overlay-card {
  background: var(--surface);
  padding: 16px 20px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  box-shadow: 0 18px 40px rgba(0,0,0,0.2);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid var(--border-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.sandbox-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 193, 7, 0.18);
  color: #f8d26a;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid rgba(255, 193, 7, 0.4);
  letter-spacing: 0.3px;
}

.current-view-pill {
  display: none;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--header-text);
  font-size: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  letter-spacing: 0.2px;
}

.sidebar-toggle {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: var(--header-text);
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
}

.layout {
  display: flex;
  height: calc(100vh - 56px);
}

aside {
  width: 220px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  padding: 12px;
  transition: width 0.2s ease, transform 0.2s ease;
}

.brand {
  display: flex;
  align-items: center;
  margin: 6px 0 16px;
  padding: 6px 8px;
  border-radius: 12px;
  background: #fafafa;
  border: 1px solid #eee;
  justify-content: center;
}

.brand-mark {
  width: 46px;
  height: 46px;
  object-fit: contain;
  display: block;
}

aside a {
  display: flex;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--sidebar-link);
  margin-bottom: 4px;
  gap: 8px;
  cursor: pointer;
}

aside a:hover {
  background: var(--sidebar-hover);
}

.nav-icon {
  width: 24px;
  text-align: center;
}

.nav-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #22c55e;
  display: none;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25);
}

.online-dot.active {
  display: inline-block;
}

body.sidebar-collapsed aside {
  width: 72px;
  padding: 12px 8px;
}

body.sidebar-collapsed aside h2 {
  justify-content: center;
  padding: 6px 0;
}

body.sidebar-collapsed .nav-label {
  display: none;
}

body.sidebar-collapsed aside a {
  justify-content: center;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 1500;
}

main {
  flex: 1;
  padding: 16px;
  overflow: auto;
}

.mobile-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 1px solid var(--border-soft);
  box-shadow: 0 -10px 24px var(--shadow-2);
  z-index: 1600;
}

.mobile-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 6px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}

.mobile-nav-icon {
  font-size: 18px;
}

.mobile-nav-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

body.caja-no-scroll .mobile-nav {
  display: none;
}

.card {
  background: var(--surface);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid var(--border);
}

.req-detail {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.sales-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.sales-filters .field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.sales-filters .field.actions {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.sales-filters input,
.sales-filters select {
  width: 100%;
}

.sales-filters input[type="date"],
.sales-filters input[type="month"] {
  color: var(--text);
  background: var(--input-bg);
}

.sales-filters input[type="date"]::-webkit-datetime-edit,
.sales-filters input[type="month"]::-webkit-datetime-edit {
  color: var(--text);
}

.sales-filters input[type="date"]::-webkit-calendar-picker-indicator,
.sales-filters input[type="month"]::-webkit-calendar-picker-indicator {
  opacity: 0.7;
}

.sales-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.module-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.module-header h3 {
  margin: 0;
}

main .card + .card {
  margin-top: 12px;
}

body:not(.caja-no-scroll) main input,
body:not(.caja-no-scroll) main select,
body:not(.caja-no-scroll) main textarea {
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  font-size: 14px;
}

body:not(.caja-no-scroll) main input:focus,
body:not(.caja-no-scroll) main select:focus,
body:not(.caja-no-scroll) main textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

body:not(.caja-no-scroll) main button {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-text);
  cursor: pointer;
}

@media (max-width: 900px) {
  .layout {
    height: auto;
    min-height: calc(100vh - 56px);
  }

  aside {
    position: fixed;
    top: 56px;
    left: 0;
    height: calc(100vh - 56px);
    transform: translateX(-100%);
    z-index: 2000;
  }

  body.sidebar-open aside {
    transform: translateX(0);
  }

  body.sidebar-collapsed aside {
    width: 220px;
  }
}

@media (max-width: 720px) {
  header {
    position: sticky;
    top: 0;
    z-index: 1700;
  }

  .current-view-pill {
    display: inline-flex;
  }

  main {
    padding: 12px;
    padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  }

  body.caja-no-scroll main {
    padding-bottom: 12px;
  }

  body:not(.caja-no-scroll) main input,
  body:not(.caja-no-scroll) main select,
  body:not(.caja-no-scroll) main textarea {
    padding: 12px;
    font-size: 16px;
  }

  body:not(.caja-no-scroll) main button {
    padding: 12px 14px;
    font-size: 15px;
  }

  .mobile-nav {
    display: flex;
  }

  .sales-filters {
    grid-template-columns: 1fr;
  }

  .sales-filters .field.actions {
    width: 100%;
  }

  .sales-filters .field.actions button {
    flex: 1 1 160px;
  }

  .sales-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .sales-toolbar button {
    width: 100%;
  }

  .module-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .table-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .table-actions > * {
    flex: 1 1 180px;
    min-width: 0;
  }

  .row {
    flex-direction: column;
  }

  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 640px;
  }

  .table-scroll th,
  .table-scroll td {
    white-space: nowrap;
  }

  #invSearch,
  #adjustProduct,
  #adjustNote,
  #reqProduct,
  #reqNote,
  #liqSearch,
  #liqMonth,
  #liqFrom,
  #liqTo,
  #userName,
  #userPass {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 480px) {
  .card {
    padding: 10px;
  }

  .table-actions > * {
    flex: 1 1 100%;
  }
}

body:not(.caja-no-scroll) main button:hover {
  background: var(--surface-hover);
}

body:not(.caja-no-scroll) main button.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

body:not(.caja-no-scroll) main button.btn-secondary {
  background: var(--surface);
  border-color: var(--btn-border);
  color: var(--btn-text);
}

body:not(.caja-no-scroll) main button.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--danger-contrast);
}

body:not(.caja-no-scroll) main button.btn-danger-lite {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger-text);
}

main h2,
main h3 {
  margin: 0 0 10px;
}

main .card > h2,
main .card > h3 {
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-soft);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  overflow: hidden;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

th, td {
  padding: 8px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  font-size: 14px;
}

thead th {
  background: var(--surface-alt);
  font-weight: 700;
}

tbody tr:nth-child(even) {
  background: var(--surface-row);
}

tbody tr:hover {
  background: var(--surface-hover);
}


.badge {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.badge.ok {
  background: var(--success-bg);
  color: var(--success-text);
}

.badge.off {
  background: var(--danger-bg);
  color: var(--danger-text);
}


.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.notif-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.header-gear-btn {
  border: none;
  background: rgba(255,255,255,0.1);
  color: var(--header-text);
  font-size: 18px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
}

.notif-btn {
  border: none;
  background: rgba(255,255,255,0.1);
  color: var(--header-text);
  font-size: 18px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
}

.header-guide-btn {
  border: none;
  background: rgba(255,255,255,0.1);
  color: var(--header-text);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.header-guide-icon {
  font-size: 16px;
  line-height: 1;
}

.header-secondary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.header-menu-btn {
  display: none;
}

.header-menu {
  position: absolute;
  right: 0;
  top: 44px;
  display: grid;
  gap: 6px;
  padding: 8px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--pos-border-soft);
  box-shadow: 0 12px 30px rgba(0,0,0,0.12);
  z-index: 20;
}

.header-menu.hidden {
  display: none;
}

.header-menu button {
  border: 1px solid var(--pos-border-soft);
  background: var(--pos-panel);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  text-align: left;
}

@media (max-width: 720px) {
  .header-guide-text {
    display: none;
  }
  .header-secondary {
    display: none;
  }
  .header-menu-btn {
    display: inline-flex;
  }
}

.changelog-modal {
  width: 520px;
  max-width: 92vw;
}

.changelog-body {
  display: grid;
  gap: 10px;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 4px;
}

.changelog-item {
  border: 1px solid var(--pos-border-soft);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--surface-alt);
}

.changelog-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.changelog-tag {
  background: var(--pos-panel);
  border: 1px solid var(--pos-border-soft);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
}

.notif-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: var(--danger-contrast);
  font-size: 11px;
  display: none;
  align-items: center;
  justify-content: center;
}

.notif-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.notif-header h3 {
  margin: 0;
}

.notif-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}

.notif-actions button {
  border: 1px solid var(--border-soft);
  background: var(--surface);
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
}

.notif-body {
  margin-top: 10px;
  max-height: 420px;
  overflow: auto;
}

.notif-item {
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
  background: var(--surface);
  color: var(--text);
}

.notif-item.new {
  border-color: var(--notif-new-border);
  background: var(--notif-new-bg);
}

.notif-msg {
  font-weight: 600;
  color: var(--text);
}

.notif-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.notif-detail {
  font-size: 12px;
  color: var(--muted);
  opacity: 1;
  margin-top: 6px;
}

.notif-detail div {
  color: var(--muted);
}

.notif-actions-inline {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.notif-actions-inline button {
  border: 1px solid var(--border-soft);
  background: var(--surface);
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
}

.clip-detail-btn {
  margin-left: 6px;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
}


.notif-actions select {
  border: 1px solid var(--border-soft);
  background: var(--surface);
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.modal-header h3 {
  margin: 0;
}

.modal .btn-primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: var(--accent-contrast);
}

.inv-pass-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.inv-pass-field {
  position: relative;
  flex: 1 1 220px;
}

.inv-pass-field input {
  width: 100%;
  padding-right: 44px;
}

.inv-pass-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  opacity: 0.7;
}

.inv-pass-toggle:hover {
  opacity: 1;
  background: rgba(0,0,0,0.05);
}

#providerPassModalGlobal .modal-content {
  max-width: 520px;
  max-height: 80vh;
  overflow: auto;
}

.view-delay-modal {
  max-width: 860px;
  max-height: 80vh;
  overflow: auto;
  padding: 18px;
}

.recursos-modal {
  max-width: 860px;
  max-height: 80vh;
  overflow: auto;
}

.view-delay-subtitle {
  margin: 0 0 12px 0;
  color: var(--muted);
  font-size: 13px;
}

.view-delay-list {
  display: grid;
  gap: 10px;
}

.view-delay-row {
  display: grid;
  grid-template-columns: 1fr 90px 120px;
  gap: 10px;
  align-items: center;
}

.view-delay-row label {
  font-size: 13px;
}

.view-delay-row input {
  width: 100%;
}

.view-delay-hint {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.view-delay-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
}

.provider-pass-modal {
  padding: 18px;
}

.provider-pass-subtitle {
  margin: 0 0 12px 0;
  color: var(--muted);
  font-size: 13px;
}

.provider-pass-grid {
  display: grid;
  gap: 12px;
}

.provider-pass-field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.provider-pass-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}


#notifHistoryModal .modal-content {
  max-width: 520px;
}

.insights-table table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
}

.insights-table th,
.insights-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12px;
  text-align: left;
}

.insights-table th {
  font-size: 11px;
  opacity: 0.7;
}

.liq-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  align-items: flex-end;
}

.liq-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
}
