:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #f5f7fa;
  --navy: #111a2c;
  --navy-soft: #1b2943;
  --ink: #172033;
  --muted: #6f7b8f;
  --line: #e4e8ef;
  --surface: #fff;
  --canvas: #f5f7fa;
  --green: #1db889;
  --green-dark: #108262;
  --green-soft: #e9f9f4;
  --red: #d94b59;
  --red-soft: #fff0f1;
  --amber: #d98a15;
  --shadow: 0 14px 45px rgba(28, 39, 61, .08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--canvas); }
button, input, select { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, p { margin-top: 0; }
.muted { color: var(--muted); }
.overline { margin: 0 0 7px; color: var(--green-dark); font-size: .68rem; font-weight: 800; letter-spacing: .14em; }
.brand-mark { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 11px; background: var(--green); color: white; font-weight: 900; box-shadow: 0 8px 20px rgba(29,184,137,.28); }

/* Login
   La rejilla del fondo son las frecuencias DTMF reales: filas = tonos bajos,
   columnas = tonos altos. No es decoración, es el teclado que descodifica el IVR. */
.login-page { position: relative; overflow: hidden; min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; place-items: center; padding: 32px; background: #0b1220; color: #e8edf6; }

.dtmf { position: absolute; inset: 0; pointer-events: none; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.dtmf-row, .dtmf-col { position: absolute; background: rgba(232,237,246,.16); }
.dtmf-row { left: 0; right: 0; top: var(--at); height: 1px; transform: scaleX(0); transform-origin: left; animation: draw-x .9s cubic-bezier(.2,.8,.2,1) forwards; }
.dtmf-col { top: 0; bottom: 0; left: var(--at); width: 1px; transform: scaleY(0); transform-origin: top; animation: draw-y .9s cubic-bezier(.2,.8,.2,1) forwards; }
.dtmf-row:nth-child(2) { animation-delay: .06s; }
.dtmf-row:nth-child(3) { animation-delay: .12s; }
.dtmf-row:nth-child(4) { animation-delay: .18s; }
.dtmf-col { animation-delay: .24s; }
.dtmf-col:nth-child(6) { animation-delay: .3s; }
.dtmf-col:nth-child(7) { animation-delay: .36s; }
.dtmf-row i, .dtmf-col i { position: absolute; color: rgba(232,237,246,.42); font-size: .58rem; font-style: normal; letter-spacing: .08em; opacity: 0; animation: fade-in .5s .7s forwards; }
.dtmf-row i { left: 18px; top: -14px; }
.dtmf-col i { top: 18px; left: 8px; }
/* El nodo late al ritmo de un tono de marcado: presencia, no adorno. */
.dtmf-node { position: absolute; left: var(--x); top: var(--y); width: 5px; height: 5px; margin: -2px 0 0 -2px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(29,184,137,.5); animation: tone 3.4s 1s ease-out infinite; }

@keyframes draw-x { to { transform: scaleX(1); } }
@keyframes draw-y { to { transform: scaleY(1); } }
@keyframes fade-in { to { opacity: 1; } }
@keyframes tone { 0% { box-shadow: 0 0 0 0 rgba(29,184,137,.45); } 60%, 100% { box-shadow: 0 0 0 26px rgba(29,184,137,0); } }

.login-brand { position: relative; z-index: 1; justify-self: start; display: flex; align-items: center; gap: 11px; font-size: .95rem; font-weight: 600; letter-spacing: -.01em; }
.login-brand b { font-weight: 400; color: #8794ab; }

/* Tarjeta de consola: oscura sobre la rejilla, no una tarjeta blanca flotando. */
.login-card { position: relative; z-index: 1; width: min(392px, 100%); padding: 38px 36px 34px; background: rgba(14, 22, 38, .82); backdrop-filter: blur(14px); border: 1px solid rgba(232,237,246,.12); border-radius: 3px; box-shadow: 0 50px 120px -30px rgba(0,0,0,.9); }
.login-eyebrow { margin: 0 0 16px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .6rem; font-weight: 500; letter-spacing: .32em; color: var(--green); }
.login-card h1 { margin-bottom: 6px; color: #fff; font-size: 1.85rem; font-weight: 650; letter-spacing: -.035em; }
.login-sub { margin-bottom: 28px; color: #7d8aa1; font-size: .86rem; }
.login-card form { display: grid; gap: 16px; }
.login-card label { color: #8b98b0; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .64rem; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; }
.login-card input { min-height: 44px; color: #e8edf6; background: rgba(232,237,246,.05); border: 1px solid rgba(232,237,246,.14); border-radius: 3px; font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .02em; }
.login-card input::placeholder { color: #5b6880; }
.login-card input:focus { background: rgba(232,237,246,.07); border-color: var(--green); box-shadow: 0 0 0 3px rgba(29,184,137,.14); }
.login-card .primary { margin-top: 6px; border-radius: 3px; box-shadow: none; font-weight: 650; letter-spacing: .01em; }
.login-card .primary:hover { transform: none; background: #22cd99; }

.field-reveal { position: relative; display: block; }
.field-reveal input { width: 100%; padding-right: 46px; }
#toggle-password { position: absolute; top: 50%; right: 4px; transform: translateY(-50%); display: grid; place-items: center; width: 38px; height: 38px; padding: 0; color: #6d7a92; background: none; border: 0; border-radius: 3px; }
#toggle-password:hover { color: #b9c4d6; }
#toggle-password:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }
#toggle-password svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
#toggle-password .eye-slash { opacity: 0; transition: opacity .15s; }
#toggle-password[aria-pressed="true"] { color: var(--green); }
#toggle-password[aria-pressed="true"] .eye-slash { opacity: 1; }

.form-error { margin: 16px 0 0; padding: 10px 12px; color: #ff9aa4; background: rgba(217,75,89,.12); border-left: 2px solid var(--red); border-radius: 0 3px 3px 0; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .72rem; }

.login-foot { position: relative; z-index: 1; display: flex; align-items: center; gap: 9px; margin: 0; color: #6d7a92; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .68rem; letter-spacing: .1em; }
.tone { width: 5px; height: 5px; border-radius: 50%; background: var(--green); }

@media (prefers-reduced-motion: reduce) {
  .dtmf-row, .dtmf-col { transform: none; animation: none; }
  .dtmf-row i, .dtmf-col i { opacity: 1; animation: none; }
  .dtmf-node, .tone { animation: none; }
}

/* Layout */
.app-shell { display: grid; grid-template-columns: 242px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; height: 100vh; padding: 26px 18px 20px; color: #d9e0ec; background: var(--navy); z-index: 20; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 28px; }
.brand strong, .brand small { display: block; }
.brand strong { color: white; font-size: 1rem; }
.brand small { margin-top: 2px; color: #748198; font-size: .68rem; }
.main-nav { display: grid; gap: 5px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 13px; color: #8996aa; background: transparent; border: 0; border-radius: 10px; text-align: left; font-weight: 650; font-size: .87rem; transition: .18s ease; }
.nav-item span { width: 19px; color: #75839a; font-size: 1.05rem; text-align: center; }
.nav-item:hover { color: white; background: rgba(255,255,255,.05); }
.nav-item.active { color: white; background: var(--navy-soft); }
.nav-item.active span { color: var(--green); }
.sidebar-foot { display: grid; gap: 13px; margin-top: auto; }
.system-state { display: flex; align-items: center; gap: 10px; padding: 13px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06); border-radius: 12px; }
.system-state > i, .online i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(29,184,137,.13); }
.system-state strong, .system-state small { display: block; }
.system-state strong { color: #dfe6f0; font-size: .72rem; }
.system-state small { margin-top: 3px; color: #718098; font-size: .65rem; }
.workspace { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 15; display: flex; align-items: center; justify-content: space-between; min-height: 78px; padding: 14px 32px; background: rgba(255,255,255,.93); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.topbar h2 { margin: 0; font-size: 1.18rem; letter-spacing: -.02em; }
.top-actions { display: flex; align-items: center; gap: 18px; }
.online { display: flex; align-items: center; gap: 8px; color: var(--green-dark); font-size: .76rem; font-weight: 750; }
.content { width: min(1260px, 100%); margin: 0 auto; padding: 34px; }
.welcome-row, .section-head, .client-hero, .resource-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.welcome-row { margin-bottom: 26px; }
.welcome-row h1, .page-head h1 { margin-bottom: 6px; font-size: clamp(1.7rem, 3vw, 2.25rem); letter-spacing: -.045em; }
.welcome-row p, .page-head p { margin-bottom: 0; }
.date-pill { padding: 9px 13px; color: var(--muted); background: white; border: 1px solid var(--line); border-radius: 10px; font-size: .78rem; }

/* Buttons and inputs */
.primary, .secondary, .icon-button, .text-button, .back-button { border: 0; border-radius: 9px; font-weight: 720; transition: .16s ease; }
.primary { padding: 10px 15px; color: white; background: var(--green); box-shadow: 0 7px 18px rgba(29,184,137,.18); }
.primary:hover { background: #18a97e; transform: translateY(-1px); }
.primary.wide { width: 100%; padding: 12px 16px; }
.secondary { padding: 9px 13px; color: #536075; background: #fff; border: 1px solid var(--line); }
.secondary:hover { border-color: #c8d0dc; background: #f8f9fb; }
.secondary:disabled { color: #a5adba; background: #f5f6f8; cursor: not-allowed; }
.text-button, .back-button { padding: 7px 0; color: var(--green-dark); background: transparent; }
.text-button:hover, .back-button:hover { color: #075b44; }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; color: var(--muted); background: white; border: 1px solid var(--line); }
label { display: grid; gap: 7px; color: #566277; font-size: .78rem; font-weight: 650; }
label small { color: #8b95a6; font-size: .68rem; font-weight: 450; }
input, select { width: 100%; min-height: 42px; padding: 10px 12px; color: var(--ink); background: #fff; border: 1px solid #dce1e9; border-radius: 9px; outline: none; }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(29,184,137,.1); }

/* Dashboard */
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 28px; }
.metric-card { padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 5px 20px rgba(28,39,61,.035); }
.metric-top { display: flex; justify-content: space-between; color: var(--muted); font-size: .75rem; }
.metric-icon { display: grid; place-items: center; width: 32px; height: 32px; color: var(--green-dark); background: var(--green-soft); border-radius: 9px; font-weight: 800; }
.metric-card strong { display: block; margin: 13px 0 3px; color: var(--ink); font-size: 1.85rem; letter-spacing: -.05em; }
.metric-card small { color: #97a0ae; font-size: .7rem; }
.panel-section { padding: 24px; background: white; border: 1px solid var(--line); border-radius: 17px; box-shadow: var(--shadow); }
.section-head h3 { margin-bottom: 4px; font-size: 1.05rem; }
.section-head p { margin-bottom: 0; font-size: .78rem; }
.client-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; margin-top: 20px; }
.client-card { position: relative; padding: 18px; background: #fff; border: 1px solid var(--line); border-radius: 14px; cursor: pointer; transition: .18s ease; }
.client-card:hover { border-color: #b9dfd3; box-shadow: 0 12px 32px rgba(28,39,61,.08); transform: translateY(-2px); }
.client-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.client-avatar { display: grid; place-items: center; width: 40px; height: 40px; color: var(--green-dark); background: var(--green-soft); border-radius: 11px; font-weight: 850; }
.client-card h4 { margin: 14px 0 4px; font-size: .94rem; }
.client-card code { color: #8691a2; font-size: .7rem; }
.client-stats { display: flex; gap: 16px; margin-top: 17px; padding-top: 14px; border-top: 1px solid #edf0f4; }
.client-stats span { color: var(--muted); font-size: .7rem; }
.client-stats strong { color: var(--ink); }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; color: var(--green-dark); background: var(--green-soft); border-radius: 999px; font-size: .63rem; font-weight: 780; }
.badge.suspended { color: #9a6715; background: #fff6df; }
.empty-state { grid-column: 1 / -1; padding: 52px 20px; color: var(--muted); text-align: center; border: 1px dashed #d6dce5; border-radius: 14px; }
.search-box { display: flex; align-items: center; gap: 8px; width: min(280px, 100%); padding-left: 12px; color: #8d97a7; background: white; border: 1px solid var(--line); border-radius: 10px; }
.search-box input { min-height: 40px; padding-left: 0; border: 0; box-shadow: none; }
.page-head { margin-bottom: 4px; }

/* Client detail */
.back-button { margin-bottom: 17px; }
.client-hero { padding: 24px; background: linear-gradient(135deg, #fff, #f8fbfa); border: 1px solid var(--line); border-radius: 17px; }
.client-identity { display: flex; align-items: center; gap: 15px; }
.client-identity .client-avatar { width: 50px; height: 50px; font-size: 1.12rem; }
.client-identity h1 { margin: 0 0 5px; font-size: 1.4rem; }
.client-identity code { color: var(--muted); font-size: .75rem; }
.hero-actions { display: flex; align-items: center; gap: 10px; }
.tabs { display: flex; gap: 5px; margin: 22px 0 14px; padding: 5px; overflow-x: auto; background: #e9edf2; border-radius: 11px; }
.tab { flex: 1; min-width: max-content; padding: 9px 13px; color: #667286; background: transparent; border: 0; border-radius: 8px; font-size: .76rem; font-weight: 720; }
.tab.active { color: var(--ink); background: white; box-shadow: 0 3px 10px rgba(31,42,62,.08); }
.tab-content { min-height: 260px; padding: 23px; background: white; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.resource-head { margin-bottom: 18px; }
.resource-head h3 { margin-bottom: 4px; font-size: 1rem; }
.resource-head p { margin-bottom: 0; font-size: .75rem; }
.resource-list { display: grid; gap: 9px; }
.resource-card { display: flex; align-items: center; gap: 13px; padding: 14px; border: 1px solid #e8ebf0; border-radius: 12px; transition: .15s ease; }
.resource-card:hover { border-color: #d3dbE5; background: #fbfcfd; }
.resource-symbol { display: grid; place-items: center; flex: 0 0 auto; width: 38px; height: 38px; color: var(--green-dark); background: var(--green-soft); border-radius: 10px; font-size: .75rem; font-weight: 850; }
.resource-info { flex: 1; min-width: 0; }
.resource-info strong, .resource-info small { display: block; }
.resource-info strong { margin-bottom: 3px; font-size: .83rem; }
.resource-info small { color: var(--muted); font-size: .7rem; overflow-wrap: anywhere; }
.resource-actions { display: flex; align-items: center; gap: 7px; }
.danger { padding: 7px 9px; color: var(--red); background: transparent; border: 1px solid #f1d9dc; border-radius: 8px; font-size: .68rem; font-weight: 720; }
.danger:hover { background: var(--red-soft); }
.credentials { padding: 12px 14px; background: #f8fafb; border: 1px solid var(--line); border-radius: 11px; }
.credentials summary { cursor: pointer; color: var(--green-dark); font-size: .7rem; font-weight: 750; }
.credentials dl { display: grid; grid-template-columns: auto 1fr auto; gap: 8px 10px; margin: 12px 0 0; font-size: .7rem; }
.credentials dt { color: var(--muted); }
.credentials dd { margin: 0; overflow-wrap: anywhere; }
.copy-button { padding: 3px 7px; color: var(--green-dark); background: white; border: 1px solid var(--line); border-radius: 6px; font-size: .62rem; }
.routing-block { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.routing-wide { grid-column: 1 / -1; }
.subsection-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 11px; }
.subsection-head h4 { margin: 0; font-size: .82rem; }
.subsection-head small { display: block; margin-top: 3px; color: var(--muted); font-size: .65rem; }
.subsection-head button { padding: 7px 10px; font-size: .68rem; }
.resource-card audio { width: min(240px, 32vw); height: 32px; }

/* Modals */
.modal { width: min(540px, calc(100% - 28px)); padding: 0; color: var(--ink); background: white; border: 0; border-radius: 18px; box-shadow: 0 30px 100px rgba(14,23,39,.3); }
.modal::backdrop { background: rgba(12,20,34,.55); backdrop-filter: blur(3px); }
.modal form { display: grid; gap: 15px; padding: 25px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.modal-head h3 { margin: 0; font-size: 1.25rem; letter-spacing: -.03em; }
.modal > form > .muted { margin: -5px 0 3px; font-size: .78rem; }
.close-modal { display: grid; place-items: center; width: 31px; height: 31px; padding: 0; color: #7b8798; background: #f2f4f7; border: 0; border-radius: 8px; font-size: 1.2rem; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 5px; padding-top: 16px; border-top: 1px solid #edf0f3; }
fieldset { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 11px; }
legend { padding: 0 6px; color: var(--muted); font-size: .7rem; font-weight: 650; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.choice-grid label { display: flex; align-items: center; gap: 7px; padding: 8px; background: #f7f9fb; border-radius: 8px; }
.choice-grid input, .days-list input { width: auto; min-height: auto; accent-color: var(--green); }
.route-box { display: grid; grid-template-columns: 72px 1fr; align-items: center; gap: 10px; padding: 9px; background: #f7f9fb; border-radius: 10px; }
.route-box span { color: var(--muted); font-size: .72rem; font-weight: 750; }
.days-list { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.days-list label { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 8px 3px; background: #f6f8fa; border-radius: 7px; }
.file-drop { padding: 22px; text-align: center; background: #f8fbfa; border: 1px dashed #acd9cc; border-radius: 12px; }
.file-drop input { margin-top: 10px; padding: 8px; background: white; }

/* Toast */
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 100; display: flex; align-items: flex-start; gap: 11px; width: min(370px, calc(100% - 32px)); padding: 14px; background: var(--navy); color: white; border-radius: 12px; box-shadow: 0 18px 55px rgba(12,20,34,.3); }
.toast > span { display: grid; place-items: center; width: 25px; height: 25px; color: var(--navy); background: var(--green); border-radius: 50%; font-size: .7rem; font-weight: 900; }
.toast strong { font-size: .78rem; }
.toast p { margin: 3px 0 0; color: #9ca8ba; font-size: .7rem; }
.toast.error > span { color: white; background: var(--red); }
.mobile-only { display: none; }

@media (max-width: 1050px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .client-grid { grid-template-columns: repeat(2, 1fr); }
  .routing-block { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -250px; width: 242px; transition: .2s ease; box-shadow: 20px 0 50px rgba(0,0,0,.2); }
  .sidebar.open { left: 0; }
  .mobile-only { display: grid; }
  .topbar { padding: 12px 16px; }
  .topbar > div:nth-child(2) { margin-right: auto; margin-left: 11px; }
  .online { display: none; }
  .app-shell[data-current-view="client"] .top-actions .primary { display: none; }
  .content { padding: 22px 16px; }
  .welcome-row, .page-head { align-items: flex-start; flex-direction: column; }
  .date-pill { display: none; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .metric-card { padding: 15px; }
  .metric-card strong { margin-top: 9px; font-size: 1.5rem; }
  .metric-card small { line-height: 1.25; }
  .client-grid { grid-template-columns: 1fr; }
  .panel-section, .tab-content { padding: 17px; }
  .client-hero { align-items: flex-start; flex-direction: column; }
  .hero-actions { width: 100%; }
  .hero-actions button { flex: 1; }
  .resource-card { align-items: flex-start; flex-wrap: wrap; }
  .resource-info { flex-basis: calc(100% - 55px); }
  .resource-actions, .resource-card audio, .credentials { flex-basis: 100%; width: 100%; }
  .resource-actions { justify-content: flex-end; }
  .two-cols, .choice-grid { grid-template-columns: 1fr; }
  .modal form { padding: 20px; }
  .login-page { padding: 20px; }
  .login-card { padding: 30px 24px; }
}

