:root {
  color-scheme: light;
  --navy:   #1a2d4f;
  --navy-2: #162444;
  --green:  #3a9e5f;
  --ink:    #1a2533;
  --muted:  #5a6a7e;
  --line:   #e2e8f0;
  --page:   #f4f6f9;
  --surface:#ffffff;
  --accent: #1a2d4f;
  --accent-light: #eef2f8;
  --ok:     #166338;
  --ok-bg:  #d4edda;
  --warn:   #856404;
  --warn-bg:#fff3cd;
  --red:    #842029;
  --red-bg: #f8d7da;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
}

a { color: inherit; text-decoration: none; }

/* ── LOGIN ── */
.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 440px);
  min-height: 100vh;
}

.brand-panel {
  display: grid;
  align-items: center;
  padding: 72px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(10,20,50,.88), rgba(20,80,45,.72)),
    url("https://images.unsplash.com/photo-1558494949-ef010cbdcc31?auto=format&fit=crop&w=1800&q=82")
    center/cover;
}

.brand-content { display: grid; gap: 40px; max-width: 760px; }

.login-logo { width: min(260px,100%); height: auto; margin-bottom: 36px; }

.brand-mark {
  width: 72px; height: 72px;
  display: grid; place-items: center;
  border: 1px solid rgba(255,255,255,.5);
  border-radius: 10px;
  background: rgba(255,255,255,.14);
  font-weight: 800;
}
.brand-mark.small {
  width: 36px; height: 36px;
  color: #fff; background: var(--navy);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }

.brand-panel h1 {
  max-width: 780px;
  margin-bottom: 18px;
  color: #fff;
  font-size: clamp(3rem,6.5vw,6.5rem);
  line-height: 0.92;
}

.lead {
  max-width: 680px;
  margin-bottom: 0;
  color: rgba(255,255,255,.85);
  font-size: 1.15rem;
  line-height: 1.65;
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
  padding: 56px 48px;
  background: var(--surface);
  border-left: 1px solid var(--line);
}

.login-panel h2 { margin-bottom: 8px; color: var(--navy); font-size: 2rem; }
.login-panel p  { color: var(--muted); }

.status { width: fit-content; margin-bottom: 28px; padding: 7px 10px; border-radius: 6px; font-size: 0.84rem; font-weight: 700; }
.status-ready   { color: var(--ok);   background: var(--ok-bg); }
.status-warning { color: var(--warn); background: var(--warn-bg); }

/* ── BUTTONS ── */
.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s, background .15s;
}

.primary-action {
  width: 100%;
  margin: 24px 0 12px;
  color: #fff;
  background: var(--navy);
}
.primary-action:hover { background: var(--navy-2); }

.primary-action.compact {
  width: auto;
  min-height: 32px;
  margin: 0;
  padding: 0 14px;
  border-radius: 5px;
  background: var(--navy);
  color: #fff;
  font-size: 0.84rem;
}
.primary-action.compact:hover { background: var(--navy-2); }

.primary-action.disabled { pointer-events: none; background: #a7b0c1; }

.action-sync {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: 0 14px;
  min-height: 32px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: .84rem;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: var(--green);
  transition: background .15s, opacity .15s;
  margin-left: auto;
}
.action-sync:hover { background: #2e8a4f; }
.action-sync:disabled { opacity: .55; cursor: not-allowed; }

.secondary-action { color: var(--ink); background: #e9edf3; }
.secondary-action:hover { background: #dde3ed; }

.login-help { margin-bottom: 0; color: #9a5b00; font-size: 0.9rem; }

code {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  color: var(--navy);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.86rem;
}

.metadata-box span { color: var(--muted); font-size: 0.76rem; font-weight: 800; text-transform: uppercase; }

/* ── CONSOLE SHELL ── */
.console-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 640px;
  overflow: hidden;
}

/* Header: navy sólido, logo a la izquierda, user+signout a la derecha */
.console-header {
  display: flex;
  flex: 0 0 auto;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 20px;
  background: var(--navy);
  border-bottom: 1px solid var(--navy-2);
}

.console-logo-wrap {
  display: inline-flex;
  align-items: center;
  background: #fff;
  border-radius: 6px;
  padding: 4px 10px;
}
.console-logo { height: 26px; width: auto; display: block; }

.console-title { display: flex; align-items: center; }

.console-user {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  color: rgba(255,255,255,.8);
  font-size: 0.88rem;
}
.console-user span {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.console-button {
  min-height: 28px;
  padding: 0 12px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 5px;
  color: rgba(255,255,255,.9);
  background: transparent;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.console-button:hover { background: rgba(255,255,255,.1); }

/* ── BODY / SIDEBAR ── */
.console-body { display: flex; flex: 1 1 auto; min-height: 0; min-width: 0; }

.console-sidebar {
  flex: 0 0 200px;
  min-width: 200px;
  overflow: auto;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 12px 0;
}

.console-sidebar nav { display: grid; }

.console-sidebar a {
  display: block;
  padding: 9px 20px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background .12s, color .12s;
}
.console-sidebar a:hover { color: var(--ink); background: var(--page); }
.console-sidebar a.active {
  color: var(--navy);
  background: var(--accent-light);
  border-left-color: var(--green);
  font-weight: 700;
}

/* ── MAIN CONTENT ── */
.console-main {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 24px;
  background: var(--page);
}

.console-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.console-page-header h1 {
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 1.5rem;
  font-weight: 700;
}
.console-page-header p { margin-bottom: 0; color: var(--muted); font-size: 0.9rem; }

.identity-chip {
  flex: 0 0 auto;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ── PANELS ── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px,1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.metric-grid article {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}
.metric-grid span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 0.83rem; }
.metric-grid strong { font-size: 1.25rem; color: var(--ink); }

.console-panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  overflow: hidden;
}

.stack-panel { margin-top: 18px; }

.section-heading {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.section-heading h2 { margin: 0; font-size: 1rem; font-weight: 700; color: var(--ink); }
.section-heading p  { margin: 0; color: var(--muted); font-size: 0.86rem; }

.service-list { display: grid; }
.service-list a {
  display: grid;
  gap: 3px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  transition: background .1s;
}
.service-list a:hover { background: var(--page); }
.service-list span { color: var(--muted); font-size: 0.88rem; }

/* ── FORMS ── */
.console-form {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 14px;
  padding: 16px 18px 18px;
}
.console-form label { display: grid; gap: 5px; min-width: 0; }
.console-form label span { color: var(--muted); font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }

.console-form input,
.console-form select,
.console-form textarea {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.console-form input:focus,
.console-form select:focus,
.console-form textarea:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(26,45,79,.1);
}
.console-form textarea { min-height: 80px; padding: 8px 10px; resize: vertical; }
.console-form input:disabled { color: var(--ok); background: var(--ok-bg); border-color: #9ad1b4; font-weight: 700; }

.people-form { grid-template-columns: repeat(4,minmax(0,1fr)); }
.wide-field, .access-fieldset { grid-column: 1 / -1; }

.access-fieldset {
  min-width: 0; margin: 0; padding: 12px;
  border: 1px solid var(--line); border-radius: 6px;
}
.access-fieldset legend { padding: 0 6px; color: var(--muted); font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }

.access-form-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; }

.form-actions { display: flex; align-items: flex-end; justify-content: flex-start; }

.compact-secondary { width: auto; min-height: 34px; padding: 0 12px; border-radius: 5px; cursor: pointer; }

.alert-message {
  margin-bottom: 14px;
  padding: 10px 14px;
  border: 1px solid #f5c2c7;
  border-radius: 6px;
  color: var(--red);
  background: var(--red-bg);
  font-weight: 600;
  font-size: 0.88rem;
}

/* ── TOOLBAR ── */
.table-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.search-field { display: grid; flex: 1 1 auto; gap: 5px; max-width: 520px; }
.search-field span { color: var(--muted); font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.search-field input {
  width: 100%; min-height: 36px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 5px;
  color: var(--ink); background: var(--surface); font: inherit; font-size: 0.9rem; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search-field input:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(26,45,79,.1); }

.result-count { display: inline-flex; align-items: baseline; gap: 5px; min-height: 36px; color: var(--muted); font-size: 0.86rem; }
.result-count strong { color: var(--ink); font-size: 1rem; }

/* ── DATA TABLE ── */
.data-table { display: grid; overflow-x: auto; }

.data-row {
  display: grid;
  min-width: 760px;
  border-bottom: 1px solid var(--line);
}
.data-row[hidden] { display: none !important; }
.data-row:hover:not(.data-head):not(.empty) { filter: brightness(.97); }

.server-row   { grid-template-columns: 1.2fr .85fr 1.1fr .8fr .9fr; }
.storage-row  { grid-template-columns: 1.1fr .7fr 1fr 1.2fr; }
.people-row   { grid-template-columns: 1.1fr 1.35fr .75fr 1.05fr .75fr 1fr; }

.data-row span {
  min-width: 0;
  padding: 11px 16px;
  color: var(--muted);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}
.data-row strong { color: var(--ink); }

.data-head { background: #f1f4f8; }
.data-head span { color: var(--ink); font-weight: 700; font-size: 0.83rem; }

.data-row.empty { grid-template-columns: 1fr; }
.data-row.empty span { color: var(--muted); font-style: italic; }

/* ── BADGES ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 20px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.status-badge.ok      { color: var(--ok);   background: var(--ok-bg);   }
.status-badge.problem { color: var(--red);   background: var(--red-bg);  }
.status-badge.neutral { color: var(--muted); background: #e9edf3;        }

.svc-expiry-icon {
  font-size: 1rem;
  cursor: default;
  flex-shrink: 0;
}
.svc-near-expiry  { background: #fffbe6 !important; }
.svc-expired      { background: #fde8e8 !important; }

/* ── ROW ACTIONS ── */
.row-actions { display: flex; align-items: flex-start; gap: 6px; }

.detail-action {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--navy);
  background: var(--surface);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background .12s;
}
.detail-action:hover { background: var(--page); }

/* ── BACKUP TABLE ── */
.backup-table { display: grid; }
.backup-row {
  display: grid;
  grid-template-columns: 1.2fr .8fr 1fr .8fr;
  min-width: 720px;
  border-bottom: 1px solid var(--line);
}
.backup-row span { padding: 11px 16px; color: var(--muted); font-size: 0.88rem; }
.backup-head { background: #f1f4f8; }
.backup-head span { color: var(--ink); font-weight: 700; }
.backup-row.empty span { color: var(--muted); }

.backup-workspace {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 18px;
  margin-bottom: 18px;
}

/* ── MODALS ── */
.modal-details > summary { list-style: none; }
.modal-details > summary::-webkit-details-marker { display: none; }

.modal-backdrop {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  align-items: start;
  justify-items: center;
  overflow: auto;
  padding: 64px 28px 32px 228px;
  background: rgba(10,18,40,.45);
  backdrop-filter: blur(2px);
}

.modal-panel {
  width: min(1100px,100%);
  max-height: calc(100vh - 96px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 16px 48px rgba(10,18,40,.18);
}

.modal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: #f7f9fc;
}
.modal-heading h2 { margin-bottom: 3px; font-size: 1.1rem; color: var(--navy); }
.modal-heading p:last-child { margin-bottom: 0; color: var(--muted); font-size: 0.88rem; }

.create-person-details { display: inline-block; margin-bottom: 18px; }

.wizard-form > input,
.person-detail-panel > input { position: fixed; opacity: 0; pointer-events: none; }

.wizard-tabs, .detail-tabs { padding-top: 0; }
.wizard-pages, .detail-tab-pages { padding: 16px 18px 18px; }
.wizard-page, .detail-tab-page { display: none; }

#person-create-step-identity:checked ~ .wizard-tabs .create-tab-identity,
#person-create-step-work:checked ~ .wizard-tabs .create-tab-work,
#person-create-step-subscriptions:checked ~ .wizard-tabs .create-tab-subscriptions,
.detail-general-toggle:checked ~ .detail-tabs .detail-tab-general,
.detail-work-toggle:checked ~ .detail-tabs .detail-tab-work,
.detail-subscriptions-toggle:checked ~ .detail-tabs .detail-tab-subscriptions,
.detail-workspace-toggle:checked ~ .detail-tabs .detail-tab-workspace {
  color: var(--navy);
  border-bottom-color: var(--green);
  background: var(--surface);
}

#person-create-step-identity:checked ~ .wizard-pages .create-page-identity,
#person-create-step-work:checked ~ .wizard-pages .create-page-work,
#person-create-step-subscriptions:checked ~ .wizard-pages .create-page-subscriptions,
.detail-general-toggle:checked ~ .detail-tab-pages .detail-page-general,
.detail-work-toggle:checked ~ .detail-tab-pages .detail-page-work,
.detail-subscriptions-toggle:checked ~ .detail-tab-pages .detail-page-subscriptions,
.detail-workspace-toggle:checked ~ .detail-tab-pages .detail-page-workspace { display: block; }

.modal-form-grid { padding: 0; }

.wizard-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

.subscription-note {
  margin-top: 12px; padding: 10px 12px;
  border: 1px solid #ffe0a3; border-radius: 6px;
  color: #5f3b00; background: #fff7e6;
  font-size: 0.88rem; line-height: 1.45;
}

.workspace-actions-panel {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; margin-bottom: 12px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 6px; background: #f7f9fc;
}
.workspace-actions-panel strong { display: block; margin-bottom: 3px; color: var(--ink); }
.workspace-actions-panel span  { color: var(--muted); font-size: 0.88rem; }

.workspace-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.workspace-actions form { margin: 0; }
.workspace-actions button { gap: 8px; }
.workspace-actions button.is-loading { position: relative; min-width: 150px; overflow: hidden; }
.workspace-actions button:disabled { cursor: wait; opacity: .72; }

.workspace-alert { margin: 10px 0; }
.workspace-success {
  margin-bottom: 10px; padding: 10px 14px;
  border: 1px solid #a3cfbb; border-radius: 6px;
  color: var(--ok); background: var(--ok-bg); font-weight: 700; font-size: 0.88rem;
}

/* ── BUTTON PROGRESS ── */
.button-progress {
  position: relative; display: inline-flex;
  width: 34px; height: 6px; overflow: hidden; flex: 0 0 auto;
  border-radius: 999px; background: color-mix(in srgb,currentColor 22%,transparent);
}
.button-progress span {
  width: 42%; height: 100%;
  border-radius: inherit; background: currentColor;
  animation: progress-slide .9s ease-in-out infinite;
}
@keyframes progress-slide {
  from { transform: translateX(-120%); }
  to   { transform: translateX(240%);  }
}

/* ── DETAIL GRIDS ── */
.detail-grid, .access-detail-grid {
  display: grid;
  grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 8px;
}

.detail-grid div, .access-detail-grid div, .observations-box {
  min-width: 0; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 6px; background: #f7f9fc;
}

.detail-grid span, .access-detail-grid span {
  display: block; margin-bottom: 4px;
  color: var(--muted); font-size: 0.74rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
}
.detail-grid strong, .access-detail-grid strong {
  display: block; overflow-wrap: anywhere; color: var(--ink); font-size: 0.88rem;
}

.observations-box { margin: 10px 0; }
.observations-box strong { display: block; margin-bottom: 5px; }
.observations-box p { margin-bottom: 0; color: var(--muted); line-height: 1.45; font-size: 0.9rem; }

.danger-action {
  min-height: 28px; padding: 0 10px;
  border: 1px solid #d13212; border-radius: 5px;
  color: #d13212; background: var(--surface);
  font: inherit; font-weight: 700; font-size: 0.84rem; cursor: pointer;
  transition: background .12s, color .12s;
}
.danger-action:hover { color: #fff; background: #d13212; }

/* ── TABS ── */
.tab-system > input { position: absolute; opacity: 0; pointer-events: none; }

.tabs {
  display: flex; gap: 0;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: #f7f9fc;
}
.tab {
  display: inline-flex; align-items: center;
  min-height: 42px; padding: 0 16px;
  border-bottom: 3px solid transparent;
  color: var(--muted); font-weight: 600; font-size: 0.88rem; cursor: pointer;
  transition: color .12s;
}
.tab:hover { color: var(--ink); border-bottom-color: #ccd5e0; }

#bi-tab-usuarios:checked ~ .tabs .tab-usuarios,
#bi-tab-automatizaciones:checked ~ .tabs .tab-automatizaciones,
#bi-tab-reportes:checked ~ .tabs .tab-reportes {
  color: var(--navy); border-bottom-color: var(--green); background: var(--surface);
}

.tab-pages { padding: 18px; }
.tab-page {
  display: none; min-height: 300px; padding: 16px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface);
}

#bi-tab-usuarios:checked ~ .tab-pages .page-usuarios,
#bi-tab-automatizaciones:checked ~ .tab-pages .page-automatizaciones,
#bi-tab-reportes:checked ~ .tab-pages .page-reportes { display: block; }

.tab-page span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 0.76rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.tab-page h2   { margin-bottom: 8px; font-size: 1.1rem; color: var(--navy); }
.tab-page p    { margin-bottom: 0; color: var(--muted); line-height: 1.55; font-size: 0.9rem; }

.work-surface {
  display: grid; min-height: 160px; margin-top: 16px;
  place-items: center; border: 1px dashed var(--line);
  border-radius: 6px; color: var(--muted); background: #f7f9fc; font-weight: 600;
}

/* ── RESPONSIVE ── */
@media (max-width: 860px) {
  .login-shell { grid-template-columns: 1fr; }
  .console-shell { height: auto; min-height: 100vh; overflow: visible; }
  .console-body { display: block; min-height: auto; }
  .brand-panel { min-height: 40vh; padding: 32px; }
  .brand-content { gap: 22px; }
  .login-panel { min-height: auto; padding: 36px 24px; }
  .modal-backdrop { padding: 16px; }
  .console-sidebar { flex: 0 0 auto; width: 100%; min-width: 0; border-right: none; border-bottom: 1px solid var(--line); }
  .console-form { grid-template-columns: 1fr; }
  .people-form { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .detail-grid, .access-detail-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .access-form-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .backup-workspace { grid-template-columns: 1fr; }
}
