/* ===== AIBudget Gateway — look & feel Mattear ===== */
:root {
  --brand: #415A50;        /* verde bosque Mattear */
  --brand-dark: #314438;
  --brand-accent: #B46446; /* terracota Mattear */
  --bg: #F5F4EF;           /* off-white cálido (eco del crema Mattear) */
  --bg-soft: #FFFFFF;
  --card: #FFFFFF;
  --card-strong: #EEF1EE;  /* tinte verde suave */
  --border: #E5E7EB;
  --border-strong: #D1D5DB;
  --text: #111827;
  --text-dim: #6B7280;
  --text-faint: #9CA3AF;
  --accent: #415A50;
  --accent2: #314438;
  --grad: linear-gradient(135deg, #4A6458, #314438);
  --green: #5A9E22;
  --yellow: #C77700;
  --red: #D70015;
  --cyan: #415A50;
  --radius: 14px;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --shadow-card: 0 1px 3px rgba(17, 24, 39, 0.06), 0 1px 2px rgba(17, 24, 39, 0.04);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(17,24,39,.15); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ===== Login (estilo Mattear, dos paneles) ===== */
.login-screen { position: fixed; inset: 0; display: flex; background: #fff; }
.login-left {
  width: 45%; background: linear-gradient(160deg, #415A50 0%, #314438 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 3rem; position: relative; overflow: hidden;
}
.login-left-inner { position: relative; z-index: 1; max-width: 340px; }
.login-brand-logo { filter: brightness(0) invert(1); margin-bottom: 2rem; display: block; }
.login-left-title { font-size: 1.75rem; font-weight: 700; color: #fff; letter-spacing: -.03em; margin-bottom: .75rem; }
.login-left-desc { font-size: 14px; color: rgba(255,255,255,.8); line-height: 1.65; margin-bottom: 2.5rem; }
.login-features { display: flex; flex-direction: column; gap: .75rem; }
.login-feature {
  display: flex; align-items: center; gap: .625rem;
  font-size: 13px; color: rgba(255,255,255,.85); font-weight: 500;
}
.login-feature-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.6); flex-shrink: 0; }
.login-left-circle { position: absolute; border-radius: 50%; background: rgba(255,255,255,.06); }
.login-left-circle-1 { width: 400px; height: 400px; bottom: -120px; right: -120px; }
.login-left-circle-2 { width: 200px; height: 200px; top: -60px; left: -60px; }
.login-right {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 3rem; background: #fff; overflow-y: auto;
}
.login-card { width: 100%; max-width: 360px; text-align: center; }
.login-card-icon {
  width: 56px; height: 56px; background: #EEF1EE; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1.5rem; border: 1px solid #CBD8D0;
}
.login-card-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -.03em; color: #2C2C2E; margin-bottom: .5rem; }
.login-card-subtitle { color: #8E8E93; font-size: 13px; line-height: 1.6; margin-bottom: 2rem; }
.login-sso-btn {
  width: 100%; padding: .8rem 1.25rem; background: #fff; color: #3C4043;
  border: 1px solid #D1D5DB; border-radius: 11px; font-size: 14px; font-weight: 600;
  font-family: inherit; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: .625rem;
  transition: background .2s ease, transform .15s ease, box-shadow .2s ease;
  box-shadow: 0 1px 3px rgba(17,24,39,.08);
}
.login-sso-btn:hover { background: #F9FAFB; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(17,24,39,.12); }
.login-sso-btn:active { transform: scale(.98); }
.login-card .field { text-align: left; }
.login-card .field > span { color: #6B7280; }
.login-footer { color: #AEAEB2; font-size: 11px; line-height: 1.7; margin-top: 1.5rem; }
@media (max-width: 720px) {
  .login-left { display: none; }
  .login-right { padding: 2rem; }
}
.login-divider {
  display: flex; align-items: center; gap: 12px; margin: 22px 0;
  color: #AEAEB2; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
}
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: #E5E5EA; }
.login-error {
  background: rgba(255,59,48,.08); border: 1px solid rgba(255,59,48,.25);
  color: #D70015; border-radius: 9px; padding: 9px 13px; font-size: 12.5px;
  margin-bottom: 14px; text-align: left;
}

/* ===== Controles base ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  border: 1px solid var(--border-strong); border-radius: 11px;
  background: #fff; color: var(--text);
  padding: 10px 18px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: all .15s ease; font-family: inherit;
}
.btn:hover { background: #F9FAFB; transform: translateY(-1px); }
.btn-primary { background: var(--grad); border: none; color: #fff; box-shadow: 0 2px 8px rgba(65,90,80,.3); }
.btn-primary:hover { filter: brightness(1.06); background: var(--grad); }
.btn-danger { background: rgba(255,59,48,.08); border-color: rgba(255,59,48,.3); color: var(--red); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(17,24,39,.05); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-icon { width: 30px; height: 30px; padding: 0; color: var(--text-dim); }
.btn-icon:hover { color: var(--brand); border-color: rgba(65,90,80,.45); background: var(--card-strong); }
.btn-icon.btn-danger { color: var(--text-dim); background: #fff; border-color: var(--border-strong); }
.btn-icon.btn-danger:hover { color: var(--red); border-color: rgba(255,59,48,.45); background: rgba(255,59,48,.06); }
.btn-success { background: rgba(122,194,58,.12); border-color: rgba(122,194,58,.45); color: var(--green); }
.btn-success:hover { background: rgba(122,194,58,.2); }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; background: #fff; border: 1px solid var(--border-strong);
  border-radius: 10px; color: var(--text); padding: 10px 13px; font-size: 13.5px;
  font-family: inherit; outline: none; transition: border .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #C7C7CC; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(65,90,80,.12); }
textarea { font-family: var(--mono); font-size: 12.5px; min-height: 140px; resize: vertical; }
select option { background: #fff; }

/* ===== Layout ===== */
.app { display: flex; height: 100vh; }

/* Sidebar colapsable (estilo BotIA): angosta con iconos, se expande on-hover */
.sidebar {
  width: 64px; flex-shrink: 0; display: flex; flex-direction: column;
  background: linear-gradient(180deg, #415A50 0%, #314438 100%);
  box-shadow: 2px 0 8px rgba(0,0,0,.08); z-index: 20;
  transition: width .3s cubic-bezier(.4,0,.2,1); overflow: hidden;
}
.sidebar:hover { width: 240px; }
.sidebar .label {
  opacity: 0; white-space: nowrap; transition: opacity .2s ease .05s;
}
.sidebar:hover .label { opacity: 1; }
.sidebar-logo { display: flex; align-items: center; justify-content: center; padding: 18px 15px 14px; flex-shrink: 0; height: 62px; }
.sidebar-logo img { filter: brightness(0) invert(1); flex-shrink: 0; }
/* Colapsada: solo el ícono del mate. Expandida (hover): solo el wordmark Mattear. */
.sidebar-logo .sidebar-wordmark { display: none; }
.sidebar:hover .sidebar-logo { justify-content: flex-start; padding-left: 18px; }
.sidebar:hover .sidebar-logo .sidebar-mark { display: none; }
.sidebar:hover .sidebar-logo .sidebar-wordmark { display: block; }
.nav { flex: 1; padding: 6px 12px; overflow-y: auto; overflow-x: hidden; }
.nav::-webkit-scrollbar { width: 0; }
.nav-section {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em;
  color: rgba(255,255,255,.55); font-weight: 700; padding: 16px 10px 7px;
  height: 38px;
}
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 9px;
  border-radius: 10px; color: rgba(255,255,255,.8); font-weight: 500; font-size: 13.5px;
  transition: color .12s, background .12s; margin-bottom: 1px;
}
.nav a svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav a:hover { color: #fff; background: rgba(255,255,255,.1); }
.nav a.active { color: #fff; background: rgba(255,255,255,.18); }
.sidebar-foot { padding: 14px 12px; border-top: 1px solid rgba(255,255,255,.18); flex-shrink: 0; }
.side-user { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: rgba(255,255,255,.9); white-space: nowrap; }
.side-user > div:last-child { opacity: 0; transition: opacity .2s ease .05s; }
.sidebar:hover .side-user > div:last-child { opacity: 1; }
.side-user img, .avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--grad);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; color: white; flex-shrink: 0; object-fit: cover;
}
.side-user .avatar { background: rgba(255,255,255,.25); }
.side-user .faint { color: rgba(255,255,255,.65); }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 62px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.85); backdrop-filter: blur(12px);
}
.topbar h1 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.icon-btn {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  width: 36px; height: 36px; cursor: pointer; font-size: 15px; position: relative;
  color: var(--text-dim); display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--card-strong); color: var(--brand); }
.bell-wrap, .user-wrap { position: relative; }
.bell-badge {
  position: absolute; top: -5px; right: -5px; background: #FF3B30; color: white;
  font-size: 10px; font-weight: 700; border-radius: 999px; padding: 1px 5px; min-width: 16px;
}
.user-chip {
  display: flex; align-items: center; gap: 9px; background: #fff;
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 14px 5px 6px;
  color: var(--text); cursor: pointer; font-size: 13px; font-weight: 600; font-family: inherit;
}
.user-chip:hover { background: var(--card-strong); }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 280px; max-width: 380px;
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 12px 32px rgba(17,24,39,.14); z-index: 60; overflow: hidden;
  max-height: 420px; overflow-y: auto;
}
.dropdown-item { padding: 11px 16px; cursor: pointer; font-size: 13px; }
.dropdown-item:hover { background: #F9FAFB; }
.alert-item { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.alert-item:last-child { border-bottom: none; }
.alert-item .t { font-weight: 600; margin-bottom: 3px; }
.alert-item .b { color: var(--text-dim); }
.alert-item .d { color: var(--text-faint); font-size: 11px; margin-top: 4px; }
.alert-item.critical .t { color: var(--red); }
.alert-item.warning .t { color: var(--yellow); }
.content { flex: 1; overflow-y: auto; padding: 26px; }

/* ===== Cards / KPI ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-card);
}
.kpi .kpi-label { font-size: 12px; color: var(--text-dim); font-weight: 600; margin-bottom: 8px; }
.kpi .kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -.03em; }
.kpi .kpi-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 5px; }
.kpi-value.green { color: var(--green); } .kpi-value.red { color: var(--red); }
.kpi-value.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 22px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; margin-bottom: 22px; }
@media (max-width: 1100px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.card h3 { font-size: 13.5px; font-weight: 700; margin-bottom: 14px; color: var(--text-dim); }
.chart-box { position: relative; height: 260px; }

/* ===== Tablas ===== */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar > .hint { flex: 1 1 0; min-width: 220px; margin: 0; }
.toolbar > .btn { flex-shrink: 0; margin-left: auto; }
.toolbar select, .toolbar input { width: auto; min-width: 150px; padding: 8px 12px; font-size: 13px; }
table { width: 100%; border-collapse: collapse; }
.table-card { padding: 0; overflow: hidden; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-faint); font-weight: 700; padding: 13px 16px;
  border-bottom: 1px solid var(--border); background: #F9FAFB;
}
td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: #F9FAFB; }
tr.clickable { cursor: pointer; }
.num { font-family: var(--mono); font-size: 12.5px; }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); font-size: 12px; }

/* ===== Badges ===== */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
  border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .02em;
}
.badge.green { background: rgba(122,194,58,.16); color: var(--green); }
.badge.red { background: rgba(255,59,48,.1); color: var(--red); }
.badge.yellow { background: rgba(255,159,10,.14); color: var(--yellow); }
.badge.purple { background: rgba(175,82,222,.12); color: #8E44AD; }
.badge.blue { background: rgba(65,90,80,.12); color: var(--brand-dark); }
.badge.cyan { background: rgba(65,90,80,.1); color: var(--cyan); }
.badge.gray { background: rgba(17,24,39,.07); color: var(--text-dim); }

/* ===== Progress ===== */
.progress { background: #E5E7EB; border-radius: 999px; height: 7px; overflow: hidden; min-width: 90px; }
.progress > div { height: 100%; border-radius: 999px; background: var(--grad); transition: width .4s; }
.progress.warn > div { background: linear-gradient(90deg, #FF9F0A, #F08300); }
.progress.over > div { background: linear-gradient(90deg, #FF6B5E, #FF3B30); }
.budget-cell { display: flex; flex-direction: column; gap: 5px; min-width: 130px; }
.budget-cell .lbl { font-size: 11px; color: var(--text-dim); font-family: var(--mono); }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(17,24,39,.45); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 24px;
}
.modal {
  background: #fff; border: 1px solid var(--border); border-radius: 18px;
  width: 520px; max-width: 100%; max-height: 88vh; overflow-y: auto;
  box-shadow: 0 24px 64px rgba(17,24,39,.25); animation: pop .18s ease;
}
.modal.wide { width: 760px; }
@keyframes pop { from { transform: scale(.96) translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 0;
}
.modal-head h2 { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-faint); font-size: 20px; cursor: pointer; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 24px 22px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 11.5px; color: var(--text-faint); margin-top: 4px; line-height: 1.5; }

/* ===== Drawer (detalle de request) ===== */
.drawer-overlay { position: fixed; inset: 0; background: rgba(17,24,39,.35); z-index: 90; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 620px; max-width: 95vw; z-index: 95;
  background: #fff; border-left: 1px solid var(--border);
  box-shadow: -16px 0 48px rgba(17,24,39,.18); overflow-y: auto; padding: 26px;
  animation: slide .2s ease;
}
@keyframes slide { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 7px 14px; font-size: 13px; margin: 16px 0; }
.kv dt { color: var(--text-faint); }
.kv dd { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
pre.payload {
  background: #F9FAFB; border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; font-family: var(--mono); font-size: 12px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow-y: auto;
  color: #374151;
}
.section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700;
  color: var(--text-faint); margin: 20px 0 8px;
}

/* ===== Toast ===== */
.toast-root { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: #fff; border: 1px solid var(--border); border-left: 3px solid var(--brand);
  border-radius: 12px; padding: 13px 18px; font-size: 13px; min-width: 260px; max-width: 400px;
  box-shadow: 0 8px 24px rgba(17,24,39,.16); animation: pop .18s ease;
}
.toast.success { border-left-color: var(--brand-accent); }
.toast.error { border-left-color: #FF3B30; }

/* ===== Misc ===== */
.code-chip {
  font-family: var(--mono); font-size: 12px; background: #F3F4F6;
  border: 1px solid var(--border); padding: 3px 8px; border-radius: 7px;
}
.copy-block {
  display: flex; align-items: flex-start; gap: 10px; background: #F9FAFB;
  border: 1px solid var(--border); border-radius: 10px; padding: 13px 15px; margin: 8px 0 16px;
}
.copy-block code { flex: 1; font-family: var(--mono); font-size: 12px; line-height: 1.6; word-break: break-all; white-space: pre-wrap; }
.empty {
  text-align: center; color: var(--text-faint); padding: 50px 20px; font-size: 13.5px;
}
.empty .big { font-size: 34px; margin-bottom: 10px; opacity: .5; }
.provider-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.provider-card .head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.provider-card .name { font-weight: 700; font-size: 15px; }
.provider-card .meta { font-size: 12px; color: var(--text-dim); font-family: var(--mono); margin-bottom: 14px; word-break: break-all; }
.provider-card .foot { display: flex; gap: 8px; flex-wrap: wrap; }
.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; border-radius: 999px; background: #D1D5DB;
  transition: .2s; cursor: pointer;
}
.switch .slider::before {
  content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  background: white; top: 3px; left: 3px; transition: .2s;
}
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider::before { transform: translateX(16px); }
.mono { font-family: var(--mono); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.tag-list { display: flex; gap: 5px; flex-wrap: wrap; }
