/* ==========================================================================
   RH Flow — Design System
   Estilo ejecutivo minimalista (inspiración Apple) · Tipografía Work Sans
   Paleta: --ink, --muted, --line, --surface, --canvas, --blue, --green,
           --amber, --red
   ========================================================================== */

:root {
  --ink: #18212f;
  --muted: #6d7786;
  --line: #e5e9ef;
  --surface: #ffffff;
  --canvas: #f6f7f9;
  --blue: #2563eb;
  --soft-blue: #eff6ff;
  --green: #19764a;
  --amber: #a66200;
  --red: #bd3a3a;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Work Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
.m-0 { margin: 0; }

/* App shell -------------------------------------------------------------- */
.app-shell { width: 100%; min-height: 100vh; display: flex; }

.sidebar {
  width: 248px;
  flex: 0 0 248px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(10px);
  padding: 24px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
}

.brand-mark {
  width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--ink); color: #fff; flex: 0 0 32px;
}
.brand-mark svg { width: 18px; height: 18px; }

.nav-item {
  width: 100%; border: 0; background: transparent; border-radius: 10px;
  color: #596474; display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; text-align: left; transition: .18s ease;
  font-size: 14px; font-weight: 500; cursor: pointer;
}
.nav-item:hover { background: #f1f4f8; color: var(--ink); }
.nav-item.active { background: #eaf1ff; color: #174ea6; font-weight: 600; }
.nav-item svg { width: 18px; height: 18px; flex: 0 0 18px; }

.main-area { width: 100%; min-width: 0; padding: 24px 32px 36px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; padding-bottom: 28px;
}

.searchbox {
  display: flex; align-items: center; gap: 10px;
  width: min(380px, 100%); border: 1px solid var(--line);
  border-radius: 11px; background: #fff; padding: 10px 13px;
  transition: box-shadow .18s ease, border-color .18s ease;
}
.searchbox:focus-within { border-color: #8fb5f4; box-shadow: 0 0 0 3px rgba(37, 99, 235, .1); }
.searchbox input { border: 0; outline: 0; width: 100%; color: var(--ink); background: transparent; }

.icon-button {
  position: relative; width: 40px; height: 40px; border: 1px solid var(--line);
  display: grid; place-items: center; background: #fff; border-radius: 11px;
  transition: .18s ease; cursor: pointer;
}
.icon-button:hover { background: #f4f6f8; }
.icon-button svg { width: 18px; height: 18px; }

.notification-dot {
  position: absolute; right: -5px; top: -5px; min-width: 18px; height: 18px;
  padding: 0 4px; border-radius: 20px; background: var(--red); color: #fff;
  border: 2px solid #fff; font-size: 10px; display: grid; place-items: center; font-weight: 700;
}

/* Views (server-rendered: always visible) -------------------------------- */
.view { display: block; animation: reveal .25s ease both; }
@keyframes reveal { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }

/* Cards & panels --------------------------------------------------------- */
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.metric-card, .panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 6px 20px rgba(31, 42, 55, .035);
}
.metric-card {
  padding: 18px; text-align: left; transition: transform .18s ease, box-shadow .18s ease;
  cursor: pointer; display: block; width: 100%;
}
.metric-card:hover { transform: translateY(-2px); box-shadow: 0 13px 25px rgba(31, 42, 55, .08); }
.panel { padding: 21px; }
.metric-value { font-size: 29px; line-height: 1; font-weight: 700; letter-spacing: -.05em; margin: 12px 0 7px; }

.eyebrow { font-size: 11px; color: var(--muted); letter-spacing: .07em; text-transform: uppercase; font-weight: 700; }
.muted { color: var(--muted); }

.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-heading h2 { margin: 0; font-size: 23px; letter-spacing: -.035em; font-weight: 700; }
.section-heading p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

/* Buttons ---------------------------------------------------------------- */
.button-primary, .button-secondary {
  border-radius: 10px; padding: 10px 14px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; transition: .18s ease; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
}
.button-primary { background: var(--ink); color: #fff; }
.button-primary:hover { background: #2d3a4e; }
.button-primary:disabled { opacity: .55; cursor: wait; }
.button-secondary { background: #fff; border-color: var(--line); color: #344054; }
.button-secondary:hover { background: #f5f7fa; }

/* Status pills ----------------------------------------------------------- */
.status {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 99px;
  padding: 5px 9px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-green { color: var(--green); background: #eaf8f0; }
.status-amber { color: var(--amber); background: #fff7e6; }
.status-red { color: var(--red); background: #fff0f0; }
.status-blue { color: #1d5abf; background: #edf4ff; }

/* Rows & avatars --------------------------------------------------------- */
.simple-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 13px 0; border-bottom: 1px solid #edf0f4; }
.simple-row:last-child { border-bottom: 0; padding-bottom: 0; }
.simple-row:first-child { padding-top: 0; }

.avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: #e8edf4; }
.avatar.large { width: 46px; height: 46px; }

/* Dashboard -------------------------------------------------------------- */
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .9fr); gap: 18px; margin-top: 18px; }
.mini-bars { display: flex; align-items: end; gap: 10px; height: 130px; padding: 12px 0 0; border-bottom: 1px solid var(--line); }
.mini-bars span { display: block; flex: 1; background: #dfe7f5; border-radius: 6px 6px 0 0; transition: height .4s ease; }
.mini-bars span:nth-child(4), .mini-bars span:nth-child(5) { background: #8fafd9; }
.soft-card { border: 1px solid var(--line); padding: 16px; border-radius: 13px; background: #fbfcfd; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.user-card { border: 1px solid var(--line); border-radius: 13px; padding: 16px; background: #fff; }

/* Files (expediente) ----------------------------------------------------- */
.file-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.file-card { padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfd; }
.file-card svg { width: 16px; height: 16px; }

/* Org chart -------------------------------------------------------------- */
.org-chart { display: flex; flex-direction: column; align-items: center; gap: 25px; }
.org-team { display: flex; width: 100%; justify-content: center; gap: 14px; position: relative; }
.org-team::before {
  content: ""; position: absolute; top: -14px; width: 68%; height: 14px;
  border-top: 1px solid #cad3df; border-left: 1px solid #cad3df; border-right: 1px solid #cad3df;
}
.org-card { width: 180px; padding: 15px; text-align: center; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.org-card img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; margin: 0 auto 9px; }

/* Calendar --------------------------------------------------------------- */
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.calendar div { min-height: 39px; padding: 8px; border-radius: 9px; background: #f7f8fa; font-size: 13px; }
.calendar .week { min-height: auto; background: transparent; color: var(--muted); padding: 2px 8px; font-weight: 600; }
.calendar .marked { background: #e9f1ff; color: #1857bb; font-weight: 700; }

/* Filters & fields ------------------------------------------------------- */
.filter-row { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.filter-row select, .field {
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  padding: 10px 11px; outline-color: #8fb5f4; color: var(--ink);
}
.field:focus, .filter-row select:focus { border-color: #8fb5f4; box-shadow: 0 0 0 3px rgba(37, 99, 235, .1); }

/* Alerts ----------------------------------------------------------------- */
.alert-item { border-left: 3px solid #d1d9e4; padding: 13px 14px; background: #fbfcfd; border-radius: 0 11px 11px 0; margin-bottom: 10px; }
.alert-item.high { border-left-color: #d65b5b; }
.alert-item.medium { border-left-color: #d99b30; }
.alert-item.low { border-left-color: #5d91cf; }

/* Legal ------------------------------------------------------------------ */
.legal-result { padding: 16px 0; border-bottom: 1px solid #edf0f4; }
.legal-result:last-child { border-bottom: 0; }

/* Forms ------------------------------------------------------------------ */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
label { display: block; font-size: 13px; font-weight: 600; color: #3e4857; margin-bottom: 6px; }
textarea.field { width: 100%; min-height: 104px; resize: vertical; }

/* Incident reports ------------------------------------------------------- */
.report-row { display: grid; grid-template-columns: 1.2fr 2fr auto auto auto; align-items: center; gap: 13px; padding: 14px 0; border-bottom: 1px solid #edf0f4; }
.report-row:last-child { border-bottom: 0; }
.report-detail { display: none; padding: 13px; background: #f8fafc; border-radius: 10px; margin: 2px 0 12px; color: #536072; font-size: 13px; }
.report-detail.open { display: block; }

/* Notices ---------------------------------------------------------------- */
.notice { border-radius: 11px; padding: 12px 14px; font-size: 13px; margin-top: 14px; display: none; }
.notice.show { display: block; }
.notice.info { background: #edf4ff; color: #1958b6; }
.notice.error { background: #fff1f1; color: #b52f2f; }
.notice.success { background: #ebf8f0; color: #17683f; }

/* Toast flotante --------------------------------------------------------- */
.toast-stack { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 90; }
.toast {
  min-width: 240px; max-width: 340px; background: var(--ink); color: #fff;
  border-radius: 12px; padding: 13px 15px; font-size: 13px; font-weight: 500;
  box-shadow: 0 14px 34px rgba(24, 33, 47, .24); display: flex; align-items: center; gap: 10px;
  animation: toast-in .28s cubic-bezier(.22, 1, .36, 1) both;
}
.toast.success { background: #14532d; }
.toast.error { background: #7f1d1d; }
.toast svg { width: 18px; height: 18px; flex: 0 0 18px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ==========================================================================
   Auth / Login — split screen ejecutivo
   ========================================================================== */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; background: var(--canvas); }

.auth-brand {
  background:
    linear-gradient(180deg, rgba(24,33,47,.93) 0%, rgba(24,33,47,.72) 42%, rgba(24,33,47,.96) 100%),
    url('../img/login-hero.png') center/cover no-repeat;
  color: #fff; padding: 56px 52px; display: flex; flex-direction: column;
  justify-content: space-between; position: relative; overflow: hidden;
}
.auth-brand::after {
  content: ""; position: absolute; right: -120px; bottom: -120px;
  width: 420px; height: 420px; border-radius: 50%; z-index: 0;
  background: radial-gradient(circle, rgba(37,99,235,.38), transparent 70%);
  animation: brand-float 9s ease-in-out infinite alternate;
}
@keyframes brand-float { from { transform: translate3d(0,0,0) scale(1); } to { transform: translate3d(-26px,-18px,0) scale(1.08); } }
.auth-brand > * { position: relative; z-index: 1; }
.auth-brand .brand-top { display: flex; align-items: center; gap: 12px; }
.auth-brand .brand-mark {
  background: rgba(255,255,255,.14); width: 44px; height: 44px; border-radius: 13px;
  display: grid; place-items: center; box-shadow: inset 0 0 0 1px rgba(255,255,255,.16);
}
.auth-brand .brand-mark svg { width: 24px; height: 24px; }
.auth-brand .brand-name { font-size: 21px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.auth-brand .brand-kicker { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: rgba(255,255,255,.55); font-weight: 700; margin: 5px 0 0; }
.auth-hero-title {
  font-size: clamp(32px, 4.4vw, 50px); line-height: 1.03; letter-spacing: -.045em;
  font-weight: 800; margin: 0 0 16px; max-width: 15ch;
}
.auth-hero-title .grad {
  background: linear-gradient(92deg, #ffffff 6%, #93c5fd 52%, #60a5fa 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.auth-badge {
  display: inline-flex; align-items: center; gap: 7px; margin-bottom: 20px;
  padding: 6px 12px; border-radius: 99px; font-size: 12px; font-weight: 600;
  color: #cfe0ff; background: rgba(37,99,235,.16);
  border: 1px solid rgba(147,197,253,.3); backdrop-filter: blur(6px);
}
.auth-badge svg { width: 14px; height: 14px; }
.auth-brand .brand-lead { color: rgba(255,255,255,.74); font-size: 15px; line-height: 1.65; margin: 0; max-width: 430px; }
.auth-brand .brand-foot { position: relative; z-index: 1; }
.auth-feature-list { display: grid; gap: 11px; margin-top: 30px; position: relative; z-index: 1; }
.auth-feature {
  display: flex; align-items: center; gap: 12px; color: rgba(255,255,255,.9);
  font-size: 14px; font-weight: 500;
}
.auth-feature .dot {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: rgba(255,255,255,.12); box-shadow: inset 0 0 0 1px rgba(255,255,255,.1);
}
.auth-feature .dot svg { width: 16px; height: 16px; }

.auth-form-side { display: grid; place-items: center; padding: 32px; }
.auth-card {
  width: min(400px, 100%); background: rgba(255,255,255,.86); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 20px; padding: 34px 30px;
  box-shadow: 0 24px 60px rgba(24,33,47,.09);
}
.auth-card .eyebrow { margin-bottom: 10px; }
.auth-card h2 { font-size: 27px; letter-spacing: -.035em; font-weight: 700; margin: 0 0 6px; }
.auth-card .auth-sub { color: var(--muted); font-size: 14px; margin: 0 0 26px; }

.auth-field { margin-bottom: 16px; }
.auth-input-wrap { position: relative; display: flex; align-items: center; }
.auth-input-wrap > svg.lead { position: absolute; left: 13px; width: 17px; height: 17px; color: var(--muted); pointer-events: none; }
.auth-input {
  width: 100%; border: 1px solid var(--line); border-radius: 11px; background: #fff;
  padding: 12px 13px 12px 40px; outline: 0; color: var(--ink); transition: .18s ease;
}
.auth-input:focus { border-color: #8fb5f4; box-shadow: 0 0 0 3px rgba(37, 99, 235, .1); }
.auth-toggle-pass { position: absolute; right: 8px; width: 32px; height: 32px; border: 0; background: transparent; border-radius: 8px; display: grid; place-items: center; color: var(--muted); cursor: pointer; }
.auth-toggle-pass:hover { background: #f1f4f8; color: var(--ink); }
.auth-toggle-pass svg { width: 17px; height: 17px; }
.auth-submit {
  width: 100%; padding: 13px; margin-top: 6px;
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
  border: 0; box-shadow: 0 12px 24px rgba(37,99,235,.28);
}
.auth-submit:hover { background: linear-gradient(135deg, #1d4ed8 0%, #1b3a99 100%); transform: translateY(-1px); }
.auth-hint {
  margin-top: 20px; padding: 12px 14px; border-radius: 11px; background: var(--soft-blue);
  color: #1d5abf; font-size: 12.5px; display: flex; gap: 9px; align-items: flex-start;
}
.auth-hint svg { width: 16px; height: 16px; flex: 0 0 16px; margin-top: 1px; }
.auth-error { margin-bottom: 16px; }

/* Controles de rango y utilidades ---------------------------------------- */
input[type="range"] { accent-color: var(--blue); cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Responsive ------------------------------------------------------------- */
@media (max-width: 980px) {
  .sidebar { width: 70px; flex-basis: 70px; padding: 20px 10px; }
  .brand-name, .nav-label, .sidebar-foot { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .main-area { padding: 20px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid, .two-col { grid-template-columns: 1fr; }
  .file-grid { grid-template-columns: repeat(2, 1fr); }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
}

/* Login en pantallas pequeñas: conserva la imagen hero como fondo del formulario. */
@media (max-width: 980px) {
  .auth-form-side {
    background:
      linear-gradient(180deg, rgba(24,33,47,.9), rgba(24,33,47,.82)),
      url('../img/login-hero.png') center/cover no-repeat;
    min-height: 100vh;
  }
  .auth-card { box-shadow: 0 26px 70px rgba(0,0,0,.42); }
}

@media (max-width: 640px) {
  .topbar { align-items: flex-start; flex-wrap: wrap; }
  .searchbox { order: 3; width: 100%; }
  .main-area { padding: 16px; }
  .metric-grid, .three-col, .form-grid { grid-template-columns: 1fr; }
  .org-team { align-items: center; flex-direction: column; }
  .org-team::before { display: none; }
  .report-row { grid-template-columns: 1fr; gap: 7px; }
  .file-grid { grid-template-columns: 1fr; }
}
