/* ---------------------------------------------------------------------------
   FelizComún · Design System
   Aesthetic: editorial · financial · Latin-American · trustworthy
   Typography: Newsreader (display) · Geist (body) · Geist Mono (tabular)
   Palette:    cream paper · deep ink · terracotta accent
--------------------------------------------------------------------------- */

@import url('https://fonts.bunny.net/css?family=newsreader:400,500,600,700|geist:400,500,600,700|geist-mono:400,500&display=swap');

:root {
  /* ---- Surfaces ---- */
  --bg:           #f7f3ec;   /* cream paper */
  --bg-elev:      #fefcf7;   /* card on paper */
  --bg-sunken:    #ebe3d3;   /* hover, well */
  --bg-tint:      #fcf9f3;   /* nav rail */
  --ink:          #1a1814;   /* primary text */
  --ink-soft:     #4a423a;   /* secondary */
  --ink-mute:     #8a8074;   /* tertiary, captions */
  --ink-faint:    #b8ad9d;   /* placeholders */

  /* ---- Rules ---- */
  --rule:         #d4ccbe;
  --rule-soft:    #e6dfd2;
  --rule-strong:  #a89d8a;

  /* ---- Accent: terracotta (rojo arcilla) ---- */
  --accent:       #b3461b;
  --accent-deep:  #8c351a;
  --accent-soft:  #f3d6c3;
  --accent-tint:  #fbe6d7;

  /* ---- Semantic states ---- */
  --ok:        #2f6f3a;
  --ok-soft:   #d8e7d4;
  --warn:      #b87c00;
  --warn-soft: #f3e0b6;
  --bad:       #a62828;
  --bad-soft:  #f3d2d2;
  --info:      #1f5f8b;
  --info-soft: #d4e3ee;

  /* ---- Type ---- */
  --display: 'Newsreader', 'Times New Roman', Georgia, serif;
  --body:    'Geist', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono:    'Geist Mono', ui-monospace, 'JetBrains Mono', Menlo, monospace;

  /* ---- Spacing rhythm (px) ---- */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;

  /* ---- Radius / shadow ---- */
  --r-sm: 3px;
  --r:    6px;
  --r-lg: 10px;
  --shadow-sm: 0 1px 2px rgba(26,24,20,.05);
  --shadow:    0 4px 14px rgba(26,24,20,.06), 0 1px 2px rgba(26,24,20,.04);
  --shadow-lg: 0 24px 60px rgba(26,24,20,.10), 0 6px 18px rgba(26,24,20,.05);

  /* ---- Layout ---- */
  --rail-w: 260px;
  --bar-h:  56px;
  --content-max: 1200px;
}

/* ---------------------------------------------------------------------------
   Reset / base
--------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; tab-size: 4; }
body {
  margin: 0;
  font-family: var(--body);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  font-feature-settings: 'cv01', 'cv02', 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Subtle paper grain via radial gradients (no image needed) */
body::before {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(179,70,27,.025), transparent 60%),
    radial-gradient(900px 500px at 100% 110%, rgba(74,66,58,.04), transparent 60%);
  z-index: 0;
}

a { color: var(--accent-deep); text-decoration: none; transition: color .12s ease; }
a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 var(--s-3);
  color: var(--ink);
}
h1 { font-size: 2rem; line-height: 1.15; letter-spacing: -0.02em; }
h2 { font-size: 1.45rem; line-height: 1.2; }
h3 { font-size: 1.1rem; line-height: 1.3; }
h4 { font-size: 0.95rem; line-height: 1.35; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); }

p { margin: 0 0 var(--s-3); }
small, .muted { color: var(--ink-mute); font-size: .85em; }

hr {
  border: 0;
  height: 1px;
  background: var(--rule);
  margin: var(--s-5) 0;
}

code, kbd, pre, .num, .tabular {
  font-family: var(--mono);
  font-feature-settings: 'tnum' 1, 'zero' 1;
  font-variant-numeric: tabular-nums;
}

::selection { background: var(--accent-soft); color: var(--ink); }

/* ---------------------------------------------------------------------------
   Layout shell
--------------------------------------------------------------------------- */
.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  grid-template-rows: var(--bar-h) 1fr;
  grid-template-areas:
    "brand topbar"
    "rail  main";
  min-height: 100vh;
}

.brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-5);
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: var(--bg-tint);
}
.brand .mark {
  width: 28px; height: 28px;
  background: var(--accent);
  display: grid; place-items: center;
  color: var(--bg-elev);
  font-family: var(--display);
  font-weight: 700;
  font-style: italic;
  border-radius: 2px;
}
.brand .name {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.brand .name .accent { color: var(--accent); font-style: italic; }

.topbar {
  grid-area: topbar;
  display: flex; align-items: center;
  padding: 0 var(--s-6);
  border-bottom: 1px solid var(--rule);
  gap: var(--s-4);
  background: var(--bg);
}
.crumbs {
  font-size: .9rem;
  color: var(--ink-mute);
  display: flex; align-items: center; gap: var(--s-2);
  flex: 1; min-width: 0;
}
.crumbs .sep { color: var(--ink-faint); }
.crumbs strong { color: var(--ink); font-weight: 500; }

.userchip {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 6px var(--s-3);
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--bg-elev);
  font-size: .85rem;
}
.userchip .avatar {
  width: 22px; height: 22px;
  background: var(--accent);
  color: var(--bg-elev);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: .75rem; font-weight: 600;
}
.userchip .email { color: var(--ink-soft); }
.userchip a { color: var(--ink-mute); margin-left: var(--s-2); }
.userchip a:hover { color: var(--accent); }

/* ---- Sidebar rail ---- */
.rail {
  grid-area: rail;
  background: var(--bg-tint);
  border-right: 1px solid var(--rule);
  padding: var(--s-5) 0;
  overflow-y: auto;
}
.rail-section {
  padding: 0 var(--s-3);
  margin-bottom: var(--s-5);
}
.rail-section h4 {
  font-family: var(--body);
  font-size: .7rem;
  letter-spacing: .12em;
  font-weight: 600;
  color: var(--ink-mute);
  margin: 0 var(--s-3) var(--s-2);
}
.rail a {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 7px var(--s-3);
  border-radius: var(--r);
  color: var(--ink-soft);
  font-size: .9rem;
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 2px;
  border-left: 2px solid transparent;
}
.rail a:hover {
  background: var(--bg-sunken);
  color: var(--ink);
  text-decoration: none;
}
.rail a.is-active {
  background: var(--accent-tint);
  color: var(--accent-deep);
  border-left-color: var(--accent);
}
.rail a .ico {
  width: 16px; height: 16px;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
}

/* ---- Main content ---- */
.main {
  grid-area: main;
  padding: var(--s-6) var(--s-7);
  max-width: 100%;
  overflow-x: hidden;
}
.container {
  max-width: var(--content-max);
  margin: 0 auto;
}
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--s-5);
  margin-bottom: var(--s-6);
  padding-bottom: var(--s-5);
  border-bottom: 1px solid var(--rule);
}
.page-head h1 { margin: 0; }
.page-head .lede {
  margin-top: var(--s-2);
  color: var(--ink-soft);
  font-size: 1rem;
  max-width: 60ch;
}

/* ---------------------------------------------------------------------------
   Cards / surfaces
--------------------------------------------------------------------------- */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: var(--s-5);
  margin-bottom: var(--s-5);
}
.card.tight { padding: var(--s-4); }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: calc(-1 * var(--s-5)) calc(-1 * var(--s-5)) var(--s-5);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--rule-soft);
  background: var(--bg-tint);
  border-radius: var(--r) var(--r) 0 0;
}
.card-head h3 { margin: 0; font-family: var(--body); font-size: .9rem; font-weight: 600; letter-spacing: .02em; }

/* Metric (KPI) card */
.metric {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: var(--s-4) var(--s-5);
  position: relative;
  overflow: hidden;
}
.metric::after {
  content: '';
  position: absolute; right: -20px; top: -20px;
  width: 80px; height: 80px;
  background: radial-gradient(circle, var(--accent-tint) 0%, transparent 70%);
  pointer-events: none;
  opacity: .4;
}
.metric .label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink-mute);
  font-weight: 600;
  margin: 0 0 var(--s-2);
}
.metric .value {
  font-family: var(--mono);
  font-size: 1.75rem;
  line-height: 1.1;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.metric .value .unit {
  font-size: .7em;
  font-weight: 400;
  color: var(--ink-mute);
  margin-left: 4px;
}
.metric .delta {
  margin-top: var(--s-2);
  font-size: .8rem;
  color: var(--ink-mute);
}
.metric .delta.up { color: var(--ok); }
.metric .delta.down { color: var(--bad); }

.metric-grid {
  display: grid;
  gap: var(--s-4);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: var(--s-6);
}

/* ---------------------------------------------------------------------------
   Buttons
--------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: 8px 14px;
  border-radius: var(--r-sm);
  font: 500 .9rem var(--body);
  letter-spacing: 0;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s, border-color .12s, color .12s, transform .06s;
  user-select: none;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-deep);
  box-shadow: inset 0 -1px 0 rgba(0,0,0,.12);
}
.btn-primary:hover { background: var(--accent-deep); color: #fff; }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule);
}
.btn-ghost:hover { background: var(--bg-sunken); border-color: var(--rule-strong); color: var(--ink); }

.btn-text {
  padding: 6px 8px;
  background: transparent; border: 0;
  color: var(--accent-deep);
}
.btn-text:hover { background: var(--accent-tint); color: var(--accent-deep); text-decoration: none; }

.btn-sm { padding: 4px 10px; font-size: .82rem; }
.btn-block { display: flex; width: 100%; justify-content: center; }

/* ---------------------------------------------------------------------------
   Forms
--------------------------------------------------------------------------- */
.field { display: block; margin-bottom: var(--s-4); }
.field > label, .field-label {
  display: block;
  font-size: .82rem;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 6px;
  letter-spacing: .01em;
}
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="tel"], input[type="search"],
select, textarea, .input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  font: inherit;
  color: var(--ink);
  transition: border-color .12s, box-shadow .12s, background .12s;
}
input:focus, select:focus, textarea:focus, .input:focus {
  outline: 0;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.field-help { font-size: .8rem; color: var(--ink-mute); margin-top: 4px; }
.field-error { font-size: .82rem; color: var(--bad); margin-top: 4px; }

/* ---------------------------------------------------------------------------
   Tables (financial / data)
--------------------------------------------------------------------------- */
.table-wrap {
  border: 1px solid var(--rule);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--bg-elev);
  margin-bottom: var(--s-5);
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
table.data th, table.data td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--rule-soft);
}
table.data thead th {
  font-family: var(--body);
  font-weight: 600;
  font-size: .72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-mute);
  background: var(--bg-tint);
  border-bottom: 1px solid var(--rule);
}
table.data tbody tr:hover { background: var(--bg-tint); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .num, table.data td.num, table.data th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------------------
   Status indicators (RBAC traffic-light + general)
--------------------------------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 500;
  letter-spacing: .02em;
  white-space: nowrap;
  background: var(--bg-sunken);
  color: var(--ink-soft);
}
.pill::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .9;
}
.pill.ok    { background: var(--ok-soft);    color: var(--ok); }
.pill.warn  { background: var(--warn-soft);  color: var(--warn); }
.pill.bad   { background: var(--bad-soft);   color: var(--bad); }
.pill.info  { background: var(--info-soft);  color: var(--info); }
.pill.muted { background: var(--bg-sunken);  color: var(--ink-mute); }

/* Traffic-light dot for RBAC */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot.green  { background: var(--ok); }
.dot.amber  { background: var(--warn); }
.dot.red    { background: var(--bad); }

/* ---------------------------------------------------------------------------
   Quick actions, list items, empty states
--------------------------------------------------------------------------- */
.actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--s-3);
}
.action-card {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-4);
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  text-decoration: none;
  color: var(--ink);
  transition: border-color .12s, transform .12s, box-shadow .12s;
}
.action-card:hover {
  text-decoration: none;
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.action-card .ico-wrap {
  width: 36px; height: 36px;
  flex-shrink: 0;
  background: var(--accent-tint);
  color: var(--accent-deep);
  border-radius: var(--r-sm);
  display: grid; place-items: center;
}
.action-card .ico-wrap svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.7; fill: none; }
.action-card .title { font-weight: 600; font-size: .95rem; margin: 0; color: var(--ink); }
.action-card .desc { font-size: .82rem; color: var(--ink-mute); margin: 2px 0 0; }

.empty {
  text-align: center;
  padding: var(--s-8) var(--s-5);
  color: var(--ink-mute);
}
.empty .icon {
  width: 48px; height: 48px;
  margin: 0 auto var(--s-4);
  border: 1px dashed var(--rule-strong);
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bg-tint);
}

/* ---------------------------------------------------------------------------
   Messages / alerts
--------------------------------------------------------------------------- */
.messages { list-style: none; padding: 0; margin: 0 0 var(--s-5); }
.messages li {
  padding: 10px 14px;
  border-radius: var(--r-sm);
  border: 1px solid;
  margin-bottom: 6px;
  font-size: .9rem;
}
.messages .success { background: var(--ok-soft);   border-color: var(--ok);   color: var(--ok); }
.messages .info    { background: var(--info-soft); border-color: var(--info); color: var(--info); }
.messages .warning { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.messages .error   { background: var(--bad-soft);  border-color: var(--bad);  color: var(--bad); }

/* ---------------------------------------------------------------------------
   Auth pages (login, signup) — generous, paper-like
--------------------------------------------------------------------------- */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  position: relative; z-index: 1;
}
@media (min-width: 900px) {
  .auth { grid-template-columns: 1fr 1.2fr; }
  .auth .auth-art { display: flex; }
}
.auth-form {
  display: grid; place-items: center;
  padding: var(--s-7) var(--s-6);
}
.auth-form-inner {
  width: 100%;
  max-width: 380px;
}
.auth-brand {
  display: flex; align-items: center; gap: var(--s-3);
  margin-bottom: var(--s-6);
  font-family: var(--display);
  font-size: 1.3rem;
  font-weight: 600;
}
.auth-brand .mark {
  width: 32px; height: 32px;
  background: var(--accent);
  color: var(--bg-elev);
  display: grid; place-items: center;
  font-style: italic;
  border-radius: 2px;
}
.auth h1 {
  font-size: 2.1rem;
  margin-bottom: var(--s-2);
}
.auth .lede { color: var(--ink-soft); margin-bottom: var(--s-6); }

.auth-art {
  display: none;
  background: var(--ink);
  color: #f0e6d2;
  padding: var(--s-7);
  align-items: flex-end;
  position: relative;
  overflow: hidden;
}
.auth-art::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 30% 20%, rgba(179,70,27,.5), transparent 50%),
    radial-gradient(circle at 80% 90%, rgba(74,66,58,.6), transparent 60%);
  opacity: .85;
}
.auth-art-content {
  position: relative;
  max-width: 460px;
}
.auth-art h2 {
  color: #fff;
  font-size: 2.4rem;
  letter-spacing: -0.02em;
  margin-bottom: var(--s-4);
}
.auth-art .quote {
  font-style: italic;
  color: rgba(255,255,255,.78);
  font-size: 1.05rem;
  border-left: 2px solid var(--accent);
  padding-left: var(--s-4);
  margin-bottom: var(--s-5);
}
.auth-art .meta {
  color: rgba(255,255,255,.55);
  font-size: .85rem;
  font-family: var(--mono);
  letter-spacing: .03em;
}

/* ---------------------------------------------------------------------------
   Landing page
--------------------------------------------------------------------------- */
.landing {
  position: relative; z-index: 1;
  padding: var(--s-8) var(--s-6);
  max-width: 1100px;
  margin: 0 auto;
}
.landing-nav {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: var(--s-7);
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--s-8);
}
.landing-hero h1 {
  font-size: clamp(2.4rem, 5vw, 4rem);
  letter-spacing: -0.03em;
  line-height: 1.05;
  max-width: 14ch;
  margin-bottom: var(--s-5);
}
.landing-hero h1 em {
  font-style: italic; color: var(--accent);
}
.landing-hero .lede {
  font-size: 1.15rem;
  color: var(--ink-soft);
  max-width: 48ch;
  margin-bottom: var(--s-6);
}
.landing-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--s-5);
  margin-top: var(--s-8);
  padding-top: var(--s-7);
  border-top: 1px solid var(--rule);
}
.feature {
  padding: var(--s-4) 0;
}
.feature .num {
  font-family: var(--display);
  font-style: italic;
  font-size: 2rem;
  color: var(--accent);
  margin-bottom: var(--s-3);
}
.feature h3 { margin-bottom: var(--s-2); }
.feature p { color: var(--ink-soft); font-size: .92rem; }

/* ---------------------------------------------------------------------------
   Definition list / key-value pairs
--------------------------------------------------------------------------- */
dl.kv {
  display: grid;
  grid-template-columns: minmax(140px, max-content) 1fr;
  gap: var(--s-2) var(--s-5);
  font-size: .92rem;
  margin: 0;
}
dl.kv dt { color: var(--ink-mute); font-weight: 500; }
dl.kv dd { margin: 0; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------------------
   Utility
--------------------------------------------------------------------------- */
.row { display: flex; gap: var(--s-3); align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.stack > * + * { margin-top: var(--s-3); }
.text-mute { color: var(--ink-mute); }
.text-num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.text-display { font-family: var(--display); }
.fs-sm { font-size: .85rem; } .fs-lg { font-size: 1.1rem; }
.divider { height: 1px; background: var(--rule); margin: var(--s-5) 0; }
.hide-sm { } /* placeholder */

@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
  .brand, .rail { display: none; }
  .topbar { padding: 0 var(--s-4); }
  .main { padding: var(--s-4); }
  .page-head { flex-direction: column; align-items: flex-start; }
  .hide-sm { display: none; }
}

/* ---------------------------------------------------------------------------
   Animations (used sparingly, on first load only)
--------------------------------------------------------------------------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.rise { animation: rise .42s cubic-bezier(.22,.61,.36,1) both; }
.rise-1 { animation-delay: .04s; }
.rise-2 { animation-delay: .10s; }
.rise-3 { animation-delay: .16s; }
.rise-4 { animation-delay: .22s; }
.rise-5 { animation-delay: .28s; }

/* Print: clean, no chrome */
@media print {
  .rail, .topbar, .brand, .btn { display: none !important; }
  body, .main { background: #fff; }
}
