/* ===== OGRIH APP — GLOBAL STYLES ===== */
:root {
  --navy: #021b65;
  --blue: #667fc9;
  --orange: #ff914d;
  --white: #ffffff;
  --black: #000000;
  --bg: #f4f6fb;
  --bg-card: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: rgba(0,0,0,0.08);
  --border-md: rgba(0,0,0,0.14);
  --radius: 8px;
  --radius-lg: 12px;
  --sidebar-w: 220px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Segoe UI', system-ui, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { cursor: pointer; text-decoration: none; }
input, select, textarea, button { font-family: inherit; font-size: 13px; }

/* ===== LOGIN ===== */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #021b65 0%, #667fc9 100%); }
.login-box { background: white; border-radius: 16px; padding: 40px; width: 360px; box-shadow: 0 20px 60px rgba(0,0,0,0.2); text-align: center; }
.login-logo { margin-bottom: 12px; }
.login-title { font-size: 24px; font-weight: 700; color: var(--navy); letter-spacing: 3px; font-family: Georgia, serif; }
.login-sub { font-size: 11px; color: var(--text-muted); margin-bottom: 28px; letter-spacing: 1px; }
.login-form { text-align: left; }
.field-group { margin-bottom: 14px; }
.field-label { display: block; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 5px; }
input[type=email], input[type=password], input[type=text], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border-md); border-radius: var(--radius);
  background: white; color: var(--text); font-size: 13px; outline: none; transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(102,127,201,0.12); }
textarea { resize: vertical; min-height: 80px; }
.btn-login { width: 100%; padding: 11px; background: var(--navy); color: white; border: none; border-radius: var(--radius); font-size: 14px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 8px; transition: background 0.15s; }
.btn-login:hover { background: var(--blue); }
.error-msg { background: #fce8e8; color: #a00; padding: 8px 12px; border-radius: var(--radius); font-size: 12px; margin-bottom: 10px; }

/* ===== APP LAYOUT ===== */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ===== SIDEBAR ===== */
.sidebar { width: var(--sidebar-w); background: var(--navy); display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto; }
.sidebar-logo { padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,0.1); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.sidebar-brand { text-align: center; }
.brand-name { display: block; color: white; font-size: 11px; font-weight: 500; }
.brand-llc { display: block; color: rgba(255,255,255,0.4); font-size: 9px; letter-spacing: 1px; }
.nav { flex: 1; padding: 10px 0; }
.nav-section { padding: 14px 16px 5px; color: rgba(255,255,255,0.3); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 16px; color: rgba(255,255,255,0.6); font-size: 13px; cursor: pointer; border-left: 3px solid transparent; transition: all 0.15s; }
.nav-item:hover { color: white; background: rgba(255,255,255,0.07); }
.nav-item.active { color: white; background: rgba(102,127,201,0.2); border-left-color: var(--orange); }
.nav-item i { font-size: 17px; }
.sidebar-user { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,0.1); display: flex; align-items: center; gap: 8px; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--blue); display: flex; align-items: center; justify-content: center; font-size: 11px; color: white; font-weight: 600; flex-shrink: 0; }
.user-name { color: rgba(255,255,255,0.85); font-size: 12px; font-weight: 500; }
.user-role { color: rgba(255,255,255,0.4); font-size: 10px; }
.logout-btn { margin-left: auto; background: transparent; border: none; color: rgba(255,255,255,0.4); cursor: pointer; font-size: 17px; padding: 4px; display: flex; }
.logout-btn:hover { color: white; }

/* ===== MAIN CONTENT ===== */
.main-content { flex: 1; overflow-y: auto; background: var(--bg); }
.page { display: none; }
.page.active { display: block; }

/* ===== TOPBAR ===== */
.topbar { background: white; border-bottom: 1px solid var(--border); padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
.topbar-title { font-size: 16px; font-weight: 600; color: var(--text); }
.topbar-sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ===== CONTENT AREA ===== */
.content { padding: 20px 24px; }

/* ===== BUTTONS ===== */
.btn { padding: 8px 16px; border-radius: var(--radius); font-size: 13px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; border: none; transition: all 0.15s; }
.btn-primary { background: var(--orange); color: white; }
.btn-primary:hover { background: #e8803d; }
.btn-secondary { background: var(--blue); color: white; }
.btn-secondary:hover { background: #5a6fb5; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border-md); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: #fce8e8; color: #a00; border: 1px solid #f7c1c1; }
.btn-danger:hover { background: #f7c1c1; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { width: 30px; height: 30px; padding: 0; border-radius: var(--radius); background: transparent; border: 1px solid var(--border-md); color: var(--text-muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; transition: all 0.15s; }
.btn-icon:hover { background: var(--bg); color: var(--blue); }

/* ===== CARDS ===== */
.card { background: white; border-radius: var(--radius-lg); border: 1px solid var(--border); padding: 16px; }
.metric-card { background: white; border-radius: var(--radius-lg); border: 1px solid var(--border); padding: 16px; }
.metric-icon { width: 36px; height: 36px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-size: 18px; margin-bottom: 10px; }
.metric-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.metric-value { font-size: 22px; font-weight: 600; color: var(--text); }
.metric-sub { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.ic-blue { background: #e8edf9; color: var(--navy); }
.ic-orange { background: #fff0e8; color: #d4691a; }
.ic-green { background: #e3f7ee; color: #0a6e3b; }
.ic-purple { background: #f0eaff; color: #5b30b5; }
.ic-red { background: #fce8e8; color: #a00; }
.ic-teal { background: #e0f5f5; color: #0d6e6e; }

/* ===== GRIDS ===== */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
@media (max-width: 900px) { .grid-4 { grid-template-columns: repeat(2,1fr); } .grid-3 { grid-template-columns: repeat(2,1fr); } }

/* ===== TABLE ===== */
.table-wrap { background: white; border-radius: var(--radius-lg); border: 1px solid var(--border); overflow: hidden; }
.table-wrap table { width: 100%; border-collapse: collapse; }
.table-wrap thead tr { background: #f8f9fc; border-bottom: 1px solid var(--border); }
.table-wrap thead th { padding: 10px 14px; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; text-align: left; white-space: nowrap; }
.table-wrap tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
.table-wrap tbody tr:last-child { border-bottom: none; }
.table-wrap tbody tr:hover { background: #f8f9fc; }
.table-wrap tbody td { padding: 11px 14px; font-size: 13px; color: var(--text); vertical-align: middle; }

/* ===== BADGES ===== */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-mx { background: #e8edf9; color: var(--navy); }
.badge-us { background: #fff0e8; color: #c0550a; }
.badge-active { background: #e3f7ee; color: #0a6e3b; }
.badge-prospect { background: #fef9e8; color: #a07000; }
.badge-paused { background: #f0f0f0; color: #666; }
.badge-approved { background: #e3f7ee; color: #0a6e3b; }
.badge-review { background: #fef9e8; color: #a07000; }
.badge-sent { background: #e8edf9; color: var(--navy); }
.badge-rejected { background: #fce8e8; color: #a00; }
.badge-paid { background: #e3f7ee; color: #0a6e3b; }
.badge-partial { background: #fef9e8; color: #a07000; }
.badge-pending { background: #fce8e8; color: #a00; }
.badge-overdue { background: #fce8e8; color: #a00; }
.badge-draft { background: #f0f0f0; color: #666; }

/* ===== AVATAR ===== */
.avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.av-1{background:#e8edf9;color:#021b65} .av-2{background:#fff0e8;color:#d4691a}
.av-3{background:#e8f5ee;color:#0d6e3f} .av-4{background:#f0eaff;color:#5b30b5}
.av-5{background:#fef9e8;color:#a07000} .av-6{background:#fce8f3;color:#9b2065}
.av-7{background:#e8f5f5;color:#0d6e6e} .av-8{background:#f5ebe8;color:#7a3520}
.av-9{background:#eaf3de;color:#3b6d11}

/* ===== FILTERS ===== */
.filters-bar { display: flex; gap: 8px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.search-input-wrap { flex: 1; min-width: 200px; display: flex; align-items: center; gap: 8px; background: white; border: 1px solid var(--border-md); border-radius: var(--radius); padding: 7px 12px; }
.search-input-wrap i { color: var(--text-muted); font-size: 16px; flex-shrink: 0; }
.search-input-wrap input { border: none; background: transparent; outline: none; flex: 1; font-size: 13px; color: var(--text); }
.filter-chip { padding: 7px 12px; border-radius: var(--radius); font-size: 12px; font-weight: 500; cursor: pointer; border: 1px solid var(--border-md); background: white; color: var(--text-muted); transition: all 0.15s; white-space: nowrap; }
.filter-chip.active { background: var(--navy); color: white; border-color: var(--navy); }
.filter-chip.mx { background: #e8f0fe; color: var(--navy); border-color: var(--blue); }
.filter-chip.us { background: #fff0e8; color: #c0550a; border-color: var(--orange); }

/* ===== PANEL (side drawer) ===== */
.panel-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 100; display: none; }
.panel-overlay.open { display: block; }
.side-panel { position: fixed; right: 0; top: 0; bottom: 0; width: 360px; background: white; box-shadow: -4px 0 20px rgba(0,0,0,0.12); z-index: 101; display: flex; flex-direction: column; transform: translateX(100%); transition: transform 0.25s ease; }
.side-panel.open { transform: translateX(0); }
.panel-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.panel-title { font-size: 15px; font-weight: 600; color: var(--text); }
.panel-close { background: transparent; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); display: flex; padding: 2px; }
.panel-close:hover { color: var(--text); }
.panel-body { flex: 1; overflow-y: auto; padding: 20px; }
.panel-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-shrink: 0; }

/* ===== MODAL ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { background: white; border-radius: var(--radius-lg); max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.modal-header { padding: 18px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 16px; font-weight: 600; color: var(--text); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ===== TOAST ===== */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--navy); color: white; padding: 12px 20px; border-radius: var(--radius); font-size: 13px; font-weight: 500; z-index: 300; box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 8px; }
.toast.success { background: #0a6e3b; }
.toast.error { background: #a00; }

/* ===== SECTION TITLE ===== */
.section-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }

/* ===== SUMMARY CHIPS ===== */
.summary-chips { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.summary-chip { background: white; border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 12px; font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }
.summary-chip strong { color: var(--text); font-weight: 600; }
.chip-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

/* ===== TABS ===== */
.tabs { display: flex; gap: 4px; background: #f0f2f8; padding: 4px; border-radius: var(--radius); margin-bottom: 16px; width: fit-content; }
.tab-btn { padding: 6px 16px; border-radius: 6px; font-size: 13px; cursor: pointer; color: var(--text-muted); border: none; background: transparent; transition: all 0.15s; font-weight: 500; }
.tab-btn.active { background: white; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* ===== FORM HELPERS ===== */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.currency-toggle { display: flex; gap: 4px; background: #f0f2f8; padding: 3px; border-radius: var(--radius); }
.ct-btn { flex: 1; padding: 7px; border-radius: 6px; font-size: 12px; cursor: pointer; border: none; background: transparent; color: var(--text-muted); font-weight: 500; transition: all 0.15s; }
.ct-btn.active { background: white; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* ===== METHOD GRID ===== */
.method-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.method-opt { border: 1px solid var(--border-md); border-radius: var(--radius); padding: 10px 6px; cursor: pointer; text-align: center; background: white; transition: all 0.15s; }
.method-opt:hover { border-color: var(--blue); }
.method-opt.selected { border-color: var(--blue); background: #e8edf9; }
.method-opt i { font-size: 20px; display: block; margin-bottom: 4px; }
.method-opt span { font-size: 10px; color: var(--text-muted); display: block; }
.method-opt.selected span { color: var(--navy); font-weight: 600; }

/* ===== SERVICE CARD ===== */
.service-card { background: white; border-radius: var(--radius-lg); border: 1px solid var(--border); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.service-card:hover { border-color: var(--blue); }
.svc-card-top { display: flex; align-items: flex-start; justify-content: space-between; }
.svc-icon { width: 38px; height: 38px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.svc-name { font-size: 13px; font-weight: 600; color: var(--text); }
.svc-desc { font-size: 11px; color: var(--text-muted); line-height: 1.5; }
.price-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.price-pill { background: var(--bg); border-radius: var(--radius); padding: 5px 10px; }
.price-currency { font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.price-value { font-size: 14px; font-weight: 600; color: var(--text); }
.svc-footer { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--border); padding-top: 10px; }
.svc-used { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }

/* ===== LOADING ===== */
.loading { display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--text-muted); gap: 10px; }
.spinner { width: 20px; height: 20px; border: 2px solid var(--border-md); border-top-color: var(--blue); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state i { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 14px; margin-bottom: 16px; }

/* ===== NAME CELL ===== */
.name-cell { display: flex; align-items: center; gap: 10px; }
.name-cell .cell-name { font-weight: 600; color: var(--text); font-size: 13px; }
.name-cell .cell-sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* ===== RESPONSIVE ===== */
/* Hamburger button - hidden on desktop */
.hamburger-btn {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--navy);
  cursor: pointer;
  padding: 4px 8px;
  margin-right: 8px;
  flex-shrink: 0;
}

/* Menu overlay */
.menu-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}
.menu-overlay.active { display: block; }

@media (max-width: 768px) {
  /* Hide sidebar by default on mobile */
  .sidebar {
    position: fixed;
    left: -240px;
    top: 0;
    bottom: 0;
    width: 220px;
    z-index: 100;
    transition: left 0.25s ease;
  }
  .sidebar.open { left: 0; }

  /* Show all sidebar content */
  .sidebar-logo, .nav-section, .brand-name, .brand-llc,
  .nav-item span, .user-name, .user-role { display: flex; }
  .nav-section { display: block; }
  .brand-name, .brand-llc, .user-name, .user-role { display: block; }

  /* Show hamburger */
  .hamburger-btn { display: inline-flex; align-items: center; }

  /* Main content full width */
  .app { flex-direction: column; }
  .main-content { width: 100%; min-width: 0; overflow-x: hidden; }

  /* Topbar with hamburger */
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; align-items: center; }
  .topbar > div:first-child { display: flex; align-items: center; }
  .topbar-actions { flex-wrap: wrap; gap: 6px; }
  .topbar-actions .btn { font-size: 12px; padding: 6px 10px; }

  /* Grid-4 en 2 columnas, resto en 1 */
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }

  /* Tablas scroll horizontal */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Modales full width */
  .modal-box { width: 95vw; max-width: 95vw; margin: 10px; max-height: 92vh; }

  /* Contenido padding menor */
  .content { padding: 12px; }

  /* Summary chips wrap */
  .summary-chips { flex-wrap: wrap; gap: 6px; }

  .side-panel { width: 100%; }

  /* Form rows en 1 columna */
  .form-row { flex-direction: column; gap: 8px; }
}

@media (max-width: 480px) {
  .metric-card { padding: 14px; }
  .metric-value { font-size: 20px; }
  .topbar-title { font-size: 16px; }
}

/* ===== CALENDARIO ===== */
.cal-cell {
  aspect-ratio: 1;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: default;
  position: relative;
  min-height: 38px;
  background: var(--bg);
  transition: background 0.15s;
}
.cal-cell.cal-tiene-pagos {
  cursor: pointer;
  background: #fff3e0;
}
.cal-cell.cal-tiene-pagos:hover {
  background: #ffe0b2;
}
.cal-cell.cal-hoy {
  background: var(--blue);
}
.cal-cell.cal-hoy .cal-dia-num {
  color: #fff !important;
  font-weight: 700;
}
.cal-cell.cal-pasado .cal-dia-num {
  color: var(--text-muted);
}
.cal-cell.empty {
  background: transparent;
}
.cal-dia-num {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1;
}
.cal-dots {
  display: flex;
  gap: 2px;
  margin-top: 3px;
}
.cal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--orange);
}
