:root {
  --ink: #102338;
  --ink-soft: #526273;
  --navy: #0b2137;
  --navy-2: #12344f;
  --teal: #147d73;
  --teal-dark: #0e625b;
  --mint: #dff4ee;
  --sky: #eef5f8;
  --paper: #ffffff;
  --line: #dce5e9;
  --danger: #b33a3a;
  --warning: #ad6d16;
  --success: #147d54;
  --shadow: 0 18px 45px rgba(16, 35, 56, 0.09);
  --radius: 18px;
  font-family: "IBM Plex Sans", Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #f4f7f8;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { min-height: 100vh; margin: 0; background: #f4f7f8; }
button, input, select { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: -0.025em; }
p { line-height: 1.6; }
[hidden] { display: none !important; }

.eyebrow {
  margin-bottom: 8px;
  color: var(--teal);
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.muted { color: var(--ink-soft); }
.stack-lg > * + * { margin-top: 20px; }
.stack-xl > * + * { margin-top: 28px; }

.login-page { background: var(--navy); }
.login-layout { display: grid; min-height: 100vh; grid-template-columns: minmax(0, 1.05fr) minmax(420px, 0.95fr); }
.login-brand { position: relative; display: flex; flex-direction: column; justify-content: center; overflow: hidden; padding: 9vw; color: white; background: radial-gradient(circle at 20% 20%, rgba(49, 190, 165, 0.25), transparent 34%), linear-gradient(145deg, var(--navy-2), var(--navy)); }
.login-brand::after { position: absolute; right: -17vw; bottom: -22vw; width: 48vw; height: 48vw; border: 1px solid rgba(255,255,255,.13); border-radius: 50%; box-shadow: 0 0 0 70px rgba(255,255,255,.025), 0 0 0 140px rgba(255,255,255,.02); content: ""; }
.brand-logo { display: block; max-width: 100%; height: auto; }
.brand-title-logo { width: min(100%, 560px); margin: 0 0 38px; line-height: 0; }
.brand-logo-login { width: 100%; border-radius: 14px; box-shadow: 0 14px 34px rgba(0, 15, 35, .2); }
.brand-logo-sidebar { width: 100%; border-radius: 8px; }
.login-brand .eyebrow { color: #7ee0c9; }
.login-lead { max-width: 590px; color: #c9d8e2; font-size: 1.16rem; }
.trust-list { display: flex; gap: 28px; padding: 0; margin: 36px 0 0; list-style: none; color: #d6e5ea; font-size: .88rem; }
.trust-list li::before { color: #67d4bd; content: "●"; margin-right: 9px; }
.login-panel { display: grid; align-content: center; justify-items: center; padding: 7vw; background: #f4f7f8; }
.login-card { width: min(100%, 450px); padding: 42px; border: 1px solid rgba(220,229,233,.8); border-radius: 24px; background: white; box-shadow: var(--shadow); }
.login-card h2 { margin-bottom: 10px; font-size: 2rem; }
.privacy-note { max-width: 430px; margin: 24px auto 0; color: var(--ink-soft); font-size: .78rem; text-align: center; }

.field { display: grid; gap: 8px; margin-bottom: 18px; }
.field-medium { max-width: 520px; }
.field-compact { min-width: 180px; margin: 0; }
label, legend { color: #2d4356; font-size: .84rem; font-weight: 700; }
fieldset { padding: 0; border: 0; }
input, select { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #cfdadd; border-radius: 10px; outline: none; color: var(--ink); background: white; transition: border-color .18s, box-shadow .18s; }
input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(20,125,115,.12); }
.form-error { padding: 11px 13px; border-radius: 10px; color: #8d2929; background: #fff0f0; font-size: .86rem; }

.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; padding: 10px 17px; border: 1px solid transparent; border-radius: 10px; font-weight: 700; transition: transform .15s, background .15s, border-color .15s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .5; transform: none; }
.button-primary { color: white; background: var(--teal); }
.button-primary:hover { background: var(--teal-dark); }
.button-secondary { border-color: #b8d7d2; color: var(--teal-dark); background: #effaf7; }
.button-ghost { border-color: var(--line); color: var(--ink); background: transparent; }
.button-wide { width: 100%; }
.icon-button { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid var(--line); border-radius: 9px; color: var(--ink-soft); background: white; font-size: 1.25rem; }
.icon-button:hover { border-color: #e2b4b4; color: var(--danger); background: #fff5f5; }

.app-shell { display: grid; min-height: 100vh; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; display: flex; height: 100vh; flex-direction: column; padding: 26px 20px; color: white; background: var(--navy); }
.sidebar-brand { display: grid; gap: 9px; padding: 0 6px 34px; }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand span { margin-top: 2px; color: #96adbc; font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; }
.nav-list { display: grid; gap: 7px; }
.nav-item { padding: 12px 14px; border: 0; border-radius: 10px; color: #afc1cc; background: transparent; text-align: left; }
.nav-item:hover, .nav-item.is-active { color: white; background: rgba(255,255,255,.09); }
.nav-item.is-active { box-shadow: inset 3px 0 0 #52c9ae; }
.sidebar-footer { display: grid; gap: 16px; margin-top: auto; }
.user-chip { display: flex; align-items: center; gap: 11px; padding: 12px; border-top: 1px solid rgba(255,255,255,.1); }
.user-chip strong, .user-chip small { display: block; }
.user-chip strong { max-width: 130px; overflow: hidden; font-size: .82rem; text-overflow: ellipsis; }
.user-chip small { margin-top: 3px; color: #8fa6b5; }
.avatar { display: grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; border-radius: 50%; color: var(--navy); background: #78d6c2; font-weight: 800; }
.sidebar .button-ghost { border-color: rgba(255,255,255,.17); color: #dce7ed; }

.workspace { min-width: 0; padding: 36px clamp(28px, 4vw, 64px) 72px; }
.workspace-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 34px; }
.workspace-header h1 { margin: 0; font-size: 2rem; }
.environment-badge { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid #cce4de; border-radius: 999px; color: var(--teal-dark); background: #effaf7; font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: .72rem; font-weight: 700; }
.environment-badge span { width: 7px; height: 7px; border-radius: 50%; background: #27a77f; box-shadow: 0 0 0 4px rgba(39,167,127,.12); }
.app-message { position: sticky; z-index: 5; top: 14px; margin-bottom: 20px; padding: 13px 16px; border: 1px solid #b7dcd2; border-radius: 11px; color: #0c5d47; background: #eaf9f4; box-shadow: 0 10px 25px rgba(16,35,56,.08); }
.app-message.is-error { border-color: #edcaca; color: #8d2929; background: #fff1f1; }
.page-section { animation: reveal .22s ease-out; }
@keyframes reveal { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.hero-card { display: flex; min-height: 260px; align-items: flex-end; justify-content: space-between; gap: 32px; overflow: hidden; padding: 42px; border-radius: 24px; color: white; background: radial-gradient(circle at 90% 10%, rgba(71,194,168,.45), transparent 35%), linear-gradient(135deg, #123a56, var(--navy)); box-shadow: var(--shadow); }
.hero-card h2 { max-width: 670px; margin-bottom: 15px; font-size: clamp(2rem, 4vw, 3.5rem); line-height: 1.04; }
.hero-card p:not(.eyebrow) { max-width: 650px; margin-bottom: 0; color: #c7d9e3; }
.hero-card .eyebrow { color: #7ee0c9; }
.hero-card .button { flex: 0 0 auto; background: #55c9af; }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 22px; }
.metric-card { padding: 25px; border: 1px solid var(--line); border-radius: var(--radius); background: white; }
.metric-card > span { color: var(--teal); font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: .74rem; font-weight: 700; }
.metric-card h3 { margin: 24px 0 6px; }
.metric-card p { margin: 0; color: var(--ink-soft); font-size: .88rem; }
.info-banner { display: grid; grid-template-columns: 180px 1fr; gap: 24px; margin-top: 22px; padding: 22px 26px; border: 1px solid #cfe7e1; border-radius: var(--radius); background: var(--mint); }
.info-banner p { margin: 0; color: #385b56; font-size: .88rem; }

.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 36px; margin-bottom: 26px; }
.section-heading h2 { margin: 0; font-size: 2rem; }
.section-heading > p { max-width: 520px; margin: 0; color: var(--ink-soft); font-size: .9rem; }
.panel { padding: 26px; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: 0 8px 25px rgba(16,35,56,.04); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.panel-heading h3 { margin-bottom: 5px; }
.panel-heading p { margin: 0; color: var(--ink-soft); font-size: .84rem; }
.config-list { display: grid; gap: 10px; }
.config-list:empty::after { padding: 24px; border: 1px dashed #cbd8dc; border-radius: 12px; color: #71808d; content: "Aún no hay elementos configurados."; font-size: .84rem; text-align: center; }
.config-row { display: grid; grid-template-columns: minmax(180px, 1fr) 110px 100px 40px; gap: 10px; align-items: center; padding: 11px; border: 1px solid #e5ecef; border-radius: 12px; background: #f9fbfb; }
.activity-config-row { grid-template-columns: minmax(150px, .8fr) minmax(180px, 1fr) 110px 100px 40px; }
.date-range, .exception-fields { display: grid; grid-template-columns: repeat(2, minmax(180px, 1fr)); gap: 16px; }
.date-range .field, .exception-fields .field { margin: 0; }
.field-help { display: block; margin: 0; color: var(--ink-soft); font-size: .75rem; font-weight: 400; line-height: 1.45; }
.form-guide { margin: -8px 0 16px; padding: 11px 13px; border-left: 3px solid #b8d7d2; border-radius: 0 8px 8px 0; color: var(--ink-soft); background: #f7fafb; font-size: .78rem; line-height: 1.55; }
.form-guide strong { color: #2d4356; }
.coverage-table-wrap { max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.coverage-help { padding: 18px 20px; border: 1px solid #cfe7e1; border-radius: 12px; color: #2e514b; background: #f1faf7; }
.coverage-help > strong { display: block; margin-bottom: 7px; color: var(--teal-dark); }
.coverage-help p { margin: 0; font-size: .84rem; }
.coverage-help ul { display: grid; gap: 6px; padding-left: 20px; margin: 12px 0; font-size: .84rem; line-height: 1.5; }
.coverage-matrix { min-width: 920px; }
.coverage-matrix th, .coverage-matrix td { vertical-align: middle; }
.coverage-matrix td:nth-child(1), .coverage-matrix td:nth-child(2) { width: 18%; font-weight: 600; }
.coverage-matrix td:nth-child(3) { width: 18%; }
.coverage-matrix td:nth-child(4), .coverage-matrix td:nth-child(5) { width: 17%; }
.coverage-matrix td:nth-child(6) { width: 12%; font-family: "IBM Plex Mono", ui-monospace, monospace; font-weight: 700; }
.coverage-matrix input, .coverage-matrix select { min-width: 130px; }
.muted-cell { color: var(--ink-soft); font-weight: 400 !important; text-align: center; }
.preview-toolbar { display: flex; align-items: end; gap: 12px; }
.table-action { padding: 4px 7px; border: 0; color: var(--teal); background: transparent; font-weight: 700; }
.table-action-danger { color: var(--danger); }
.compact-check, .check-row { display: inline-flex; align-items: center; gap: 9px; }
.compact-check input, .check-row input { width: 18px; min-height: 18px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; }
.split-layout { display: grid; grid-template-columns: minmax(300px, .75fr) minmax(520px, 1.25fr); gap: 22px; align-items: start; }
.sticky-panel { position: sticky; top: 24px; }
.check-list { display: grid; gap: 8px; max-height: 220px; overflow: auto; }
.check-list:empty::after { color: var(--ink-soft); content: attr(data-empty-message); font-size: .84rem; }
.check-list:not([data-empty-message]):empty::after { content: "Configura primero las actividades."; }
.session-editor { display: grid; gap: 14px; padding-top: 6px; border-top: 1px solid var(--line); }
.session-editor h4 { margin: 0; }
.session-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.session-fields .field { margin: 0; }
.session-weekdays { display: flex; flex-wrap: wrap; gap: 8px; }
.session-weekdays .check-row { width: auto; }
.inactive-reference { color: #6e7780; font-size: .75rem; font-style: italic; }
.spaces-table { min-width: 680px; }
.table-panel { min-width: 0; padding: 0; overflow: hidden; }
.table-panel .panel-heading { padding: 24px 24px 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th, td { padding: 14px 16px; border-top: 1px solid #e7edef; text-align: left; vertical-align: top; }
th { color: #647583; background: #f8fafb; font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; }
tbody:empty::after { display: table-cell; padding: 28px 16px; color: var(--ink-soft); content: "No hay registros."; }
tbody[data-empty-message]:empty::after { content: attr(data-empty-message); }
.status-pill { display: inline-flex; padding: 4px 8px; border-radius: 999px; color: var(--success); background: #e7f7f0; font-size: .72rem; font-weight: 700; }
.status-pill.is-inactive { color: #6e7780; background: #edf0f2; }
.clinical-notice { margin-bottom: 22px; padding: 18px 20px; border: 1px solid #cfe7e1; border-radius: 12px; color: #2e514b; background: #f1faf7; }
.clinical-notice strong { color: var(--teal-dark); }
.clinical-notice p { margin: 7px 0 0; font-size: .84rem; }
.next-delivery { display: grid; gap: 12px; max-width: 760px; padding: 30px; border: 1px dashed #a9c9c2; border-radius: var(--radius); background: #f1faf7; }
.next-delivery h3, .next-delivery p { margin: 0; }
.next-delivery p { color: #385b56; }
.catalog-grid { display: grid; grid-template-columns: minmax(280px, .8fr) minmax(420px, 1.2fr); gap: 22px; margin-bottom: 22px; align-items: start; }
.catalog-grid-wide { grid-template-columns: repeat(2, minmax(280px, 1fr)); }
.catalog-grid-wide > :last-child { grid-column: 1 / -1; }
.catalog-form { display: grid; gap: 14px; }
.catalog-form .panel-heading, .catalog-form .field { margin: 0; }
.form-two-columns, .form-three-columns { display: grid; gap: 14px; }
.form-two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.link-button { padding: 0; border: 0; color: var(--teal); background: transparent; font-weight: 700; }
.danger-button { color: var(--danger); }

.planner-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 22px; margin-bottom: 22px; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.empty-state { display: grid; min-height: 320px; place-items: center; align-content: center; padding: 30px; border: 1px dashed #c7d5da; border-radius: var(--radius); color: var(--ink-soft); text-align: center; }
.empty-state > span { display: grid; width: 58px; height: 58px; place-items: center; margin-bottom: 18px; border-radius: 17px; color: var(--teal-dark); background: var(--mint); font-family: "IBM Plex Mono", ui-monospace, monospace; font-weight: 800; }
.empty-state h3 { margin-bottom: 5px; color: var(--ink); }
.empty-state p { max-width: 480px; margin: 0; }
.result-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.result-metrics article { padding: 22px; border: 1px solid var(--line); border-radius: 15px; background: white; }
.result-metrics span { display: block; margin-bottom: 5px; font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 2rem; font-weight: 700; }
.result-metrics p { margin: 0; color: var(--ink-soft); font-size: .82rem; }
.daily-schedule th { background: #f6fafb; }
.daily-schedule th[scope="row"] { min-width: 180px; color: var(--ink); }
.daily-schedule td { min-width: 220px; line-height: 1.45; }
.daily-schedule-empty { color: var(--ink-soft); text-align: center; }
.daily-schedule-gap { color: #9b3434; background: #fff5f5; }

@media (max-width: 1000px) {
  .app-shell { grid-template-columns: 210px minmax(0, 1fr); }
  .split-layout { grid-template-columns: 1fr; }
  .session-fields { grid-template-columns: 1fr; }
  .catalog-grid, .catalog-grid-wide { grid-template-columns: 1fr; }
  .catalog-grid-wide > :last-child { grid-column: auto; }
  .sticky-panel { position: static; }
}

@media (max-width: 760px) {
  .login-layout { grid-template-columns: 1fr; }
  .login-brand { min-height: 48vh; padding: 54px 28px; }
  .brand-title-logo { width: min(100%, 500px); margin-bottom: 28px; }
  .login-panel { padding: 30px 20px 46px; }
  .trust-list { flex-direction: column; gap: 8px; }
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; }
  .nav-list { grid-template-columns: repeat(2, 1fr); }
  .sidebar-footer { margin-top: 24px; }
  .workspace { padding: 26px 18px 56px; }
  .workspace-header, .section-heading, .hero-card, .planner-toolbar, .info-banner { align-items: stretch; flex-direction: column; grid-template-columns: 1fr; }
  .metric-grid, .result-metrics { grid-template-columns: 1fr; }
  .config-row { grid-template-columns: 1fr; }
  .config-row .icon-button { grid-column: 1; justify-self: end; }
  .date-range, .exception-fields { grid-template-columns: 1fr; }
  .form-two-columns, .form-three-columns { grid-template-columns: 1fr; }
  .preview-toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-actions { display: grid; }
}
