/* =============================================================================
   Nutriuna — full d'estils de l'aplicació (CSS propi, sense framework)
   Paleta i tipografia: identitat Nutriuna (recursos/index.html)
   ========================================================================== */

:root {
  --forest: #164F43;
  --deep: #103D35;
  --dark: #203C37;
  --green: #6AAF81;
  --green-soft: #8CC69A;
  --peach: #F6A57A;
  --paper: #FBFAF7;
  --cream: #F8F5EF;
  --white: #FFFFFF;
  --muted: #60716D;
  --line: #E9E9E3;
  --mint: #EDF6ED;
  --danger: #B3402F;
  --danger-bg: #FDECEC;
  --warning: #8A5A12;
  --warning-bg: #FFF4E0;
  --success: #1F6B45;
  --success-bg: #E6F4EA;
  --info: #1F4F6B;
  --info-bg: #E8F1F7;

  --shadow: 0 24px 80px rgba(21, 62, 52, .10);
  --shadow-sm: 0 6px 20px rgba(21, 62, 52, .08);
  --radius: 20px;
  --radius-sm: 12px;
  --sidebar: 268px;
  --font: Inter, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--dark);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--forest); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; background: var(--mint); color: var(--forest); padding: .1rem .4rem; border-radius: 6px; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.015em; color: var(--deep); }
p { margin: 0 0 1rem; }
.text-muted { color: var(--muted); }

.skip-link { position: absolute; left: -999px; top: 0; background: var(--forest); color: #fff; padding: .5rem 1rem; z-index: 100; }
.skip-link:focus { left: 1rem; top: 1rem; }

.icon { flex: none; }

/* --- Shell ---------------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--deep);
  color: #DCEBE2;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar__brand { padding: 1.4rem 1.4rem 1rem; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.brand { display: inline-flex; align-items: center; }
.brand__logo { height: 34px; width: auto; display: block; filter: brightness(0) invert(1); opacity: .95; }
.sidebar__org { margin-top: .9rem; display: flex; flex-direction: column; gap: .1rem; }
.sidebar__org-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .14em; color: rgba(220, 235, 226, .6); }
.sidebar__org-name { font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { padding: .9rem .8rem; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav__section { font-size: .7rem; text-transform: uppercase; letter-spacing: .14em; color: rgba(220, 235, 226, .5); padding: 1rem .7rem .4rem; }
.nav__link {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem .75rem; border-radius: 10px;
  color: #DCEBE2; font-weight: 500; text-decoration: none;
  transition: background .15s, color .15s;
  width: 100%; border: 0; background: transparent; font: inherit; cursor: pointer; text-align: left;
}
.nav__link:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav__link.is-active { background: var(--green); color: var(--deep); }
.nav__link.is-active .icon { color: var(--deep); }
.nav__soon { margin-left: auto; font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; background: rgba(255, 255, 255, .1); padding: .15rem .45rem; border-radius: 999px; color: rgba(220, 235, 226, .75); }
.nav__link.is-active .nav__soon { background: rgba(16, 61, 53, .15); color: var(--deep); }
.sidebar__footer { padding: .8rem; border-top: 1px solid rgba(255, 255, 255, .08); }

.app__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .9rem 1.75rem;
  background: rgba(251, 250, 247, .85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar__menu { display: none; border: 1px solid var(--line); background: #fff; border-radius: 10px; width: 40px; height: 40px; place-items: center; color: var(--forest); cursor: pointer; }
.topbar__title { font-size: 1.15rem; font-weight: 600; flex: 1; }
.topbar__user { display: flex; align-items: center; gap: .65rem; color: inherit; }
.topbar__user:hover { text-decoration: none; }
.topbar__user-text { display: flex; flex-direction: column; line-height: 1.2; }
.topbar__user-name { font-weight: 600; font-size: .9rem; }
.topbar__user-role { font-size: .75rem; color: var(--muted); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--mint); color: var(--forest); display: grid; place-items: center; font-weight: 700; }

.content { padding: 1.75rem; flex: 1; max-width: 1240px; width: 100%; }
.content > * + * { margin-top: 1.5rem; }

.footer { display: flex; justify-content: space-between; padding: 1rem 1.75rem; font-size: .78rem; color: var(--muted); border-top: 1px solid var(--line); }
.footer__host { font-family: ui-monospace, Menlo, monospace; }

.app__backdrop { position: fixed; inset: 0; background: rgba(16, 61, 53, .45); z-index: 19; }
.app__backdrop[hidden] { display: none; }

/* --- Cards & grids -------------------------------------------------------- */
.grid { display: grid; gap: 1.25rem; }
.grid--metrics { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid--2-1 { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.card--mint { background: var(--mint); border-color: transparent; }
.card__title { font-size: 1.02rem; margin-bottom: 1rem; display: flex; align-items: center; gap: .5rem; }
.card--metric { display: flex; flex-direction: column; gap: .3rem; color: inherit; transition: transform .15s, box-shadow .15s; }
.card--metric:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow); }
.card__label { font-size: .82rem; color: var(--muted); font-weight: 500; }
.card__value { font-size: 2rem; font-weight: 700; color: var(--forest); letter-spacing: -.03em; }
.card__value--empty { color: var(--green-soft); }
.card__hint { font-size: .8rem; color: var(--muted); }

.hero {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 1.5rem; flex-wrap: wrap;
  padding: 2rem;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--forest), var(--deep));
  color: #fff;
  position: relative; overflow: hidden;
}
.hero::after { content: ""; position: absolute; right: -8rem; top: -8rem; width: 22rem; height: 22rem; border-radius: 50%; background: radial-gradient(circle, rgba(140, 198, 154, .35), transparent 65%); }
.hero > * { position: relative; }
.hero__kicker { font-size: .78rem; text-transform: uppercase; letter-spacing: .14em; color: var(--green-soft); margin-bottom: .4rem; }
.hero__title { color: #fff; font-size: 1.8rem; margin-bottom: .5rem; }
.hero__text { color: rgba(255, 255, 255, .8); max-width: 44rem; margin: 0; }
.hero__actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.hero .btn--primary { background: var(--peach); color: var(--deep); }
.hero .btn--primary:hover { background: #F7B48F; }
.hero .btn--ghost { border-color: rgba(255, 255, 255, .35); color: #fff; }
.hero .btn--ghost:hover { background: rgba(255, 255, 255, .1); }

.steps { margin: 0; padding: 0 0 0 1.4rem; display: flex; flex-direction: column; gap: .8rem; }
.steps li strong { display: block; }
.steps li span { color: var(--muted); font-size: .9rem; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1rem; margin: 0; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.kv--inline { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.kv--inline dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; }
.kv--inline dd { font-weight: 600; margin-bottom: .6rem; }

.empty { color: var(--muted); font-style: italic; }

/* --- Forms ---------------------------------------------------------------- */
.form { display: flex; flex-direction: column; gap: 1rem; }
.form__subtitle { font-size: .9rem; color: var(--muted); font-weight: 600; margin-top: .5rem; text-transform: uppercase; letter-spacing: .08em; }
.field { display: flex; flex-direction: column; gap: .4rem; }
.field--2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.field--2 > div { display: flex; flex-direction: column; gap: .4rem; }
.field label, .field--2 label { font-weight: 600; font-size: .88rem; color: var(--dark); }
.field__row { display: flex; justify-content: space-between; align-items: baseline; }
.field__help { font-size: .78rem; color: var(--muted); }
.field__static { margin: 0; padding: .7rem 0; color: var(--muted); }
.link-muted { font-size: .82rem; color: var(--muted); }

input[type="text"], input[type="email"], input[type="password"], select, textarea {
  width: 100%;
  padding: .75rem .95rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--cream);
  color: var(--dark);
  font: inherit;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green); background: #fff; box-shadow: 0 0 0 3px rgba(106, 175, 129, .25); }
input:disabled, select:disabled { opacity: .7; cursor: not-allowed; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .75rem 1.2rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit; font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--forest); color: #fff; }
.btn--primary:hover { background: var(--deep); }
.btn--secondary { background: var(--mint); color: var(--forest); }
.btn--secondary:hover { background: #DFF0E2; }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--forest); }
.btn--ghost:hover { background: var(--mint); }
.btn--block { width: 100%; }

/* --- Alerts & badges ------------------------------------------------------ */
.alert { padding: .8rem 1rem; border-radius: var(--radius-sm); font-size: .92rem; margin-bottom: 1rem; border: 1px solid transparent; }
.alert__list { margin: 0; padding-left: 1.1rem; }
.alert--success { background: var(--success-bg); color: var(--success); }
.alert--danger  { background: var(--danger-bg);  color: var(--danger); }
.alert--warning { background: var(--warning-bg); color: var(--warning); }
.alert--info    { background: var(--info-bg);    color: var(--info); }

.badge { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--mint); color: var(--forest); }
.badge--ok { background: var(--success-bg); color: var(--success); }
.badge--off { background: var(--line); color: var(--muted); }

/* --- Tables --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: .6rem .75rem; border-bottom: 1px solid var(--line); }
.table td { padding: .75rem; border-bottom: 1px solid var(--line); }
.table tbody tr:hover { background: var(--paper); }

/* --- Placeholders & errors ------------------------------------------------- */
.placeholder {
  text-align: center;
  padding: 3.5rem 1.5rem;
  background: var(--white);
  border: 1px dashed var(--green-soft);
  border-radius: var(--radius);
  max-width: 640px;
  margin: 2rem auto;
}
.placeholder--error { border-style: solid; border-color: var(--line); }
.placeholder__icon { width: 64px; height: 64px; margin: 0 auto 1rem; border-radius: 18px; background: var(--mint); color: var(--forest); display: grid; place-items: center; }
.placeholder__icon .icon { width: 30px; height: 30px; }
.placeholder__icon--warn { background: var(--warning-bg); color: var(--warning); }
.placeholder__kicker { font-size: .75rem; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); margin-bottom: .3rem; }
.placeholder__title { font-size: 1.6rem; margin-bottom: .6rem; }
.placeholder__text { color: var(--muted); max-width: 32rem; margin: 0 auto 1.25rem; }
.placeholder__meta { display: flex; gap: .8rem; justify-content: center; align-items: center; margin-bottom: 1.5rem; font-size: .85rem; }

/* --- Auth layout ---------------------------------------------------------- */
.auth { background: var(--paper); }
.auth__wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth__aside {
  position: relative; overflow: hidden;
  background: linear-gradient(160deg, var(--forest) 0%, var(--deep) 100%);
  color: #fff;
  display: flex; align-items: center; padding: 4rem;
}
.auth__aside-inner { position: relative; z-index: 1; max-width: 30rem; }
.auth__kicker { font-size: .78rem; text-transform: uppercase; letter-spacing: .14em; color: var(--green-soft); }
.auth__claim { font-size: 2.4rem; line-height: 1.12; color: #fff; margin: .6rem 0 1.5rem; }
.auth__points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; color: rgba(255, 255, 255, .85); }
.auth__points li::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--peach); margin-right: .7rem; vertical-align: middle; }
.auth__blob { position: absolute; border-radius: 50%; filter: blur(10px); opacity: .55; }
.auth__blob--a { width: 28rem; height: 28rem; right: -10rem; top: -8rem; background: radial-gradient(circle, var(--green), transparent 65%); }
.auth__blob--b { width: 22rem; height: 22rem; left: -8rem; bottom: -8rem; background: radial-gradient(circle, var(--peach), transparent 65%); opacity: .4; }

.auth__panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 3rem 1.5rem; }
.auth__card { width: 100%; max-width: 26rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 2.25rem; box-shadow: var(--shadow); }
.auth__brand { margin-bottom: 1.5rem; }
.auth__logo { height: 40px; width: auto; display: block; }
.auth__org { margin: .8rem 0 0; font-size: .85rem; color: var(--muted); font-weight: 600; }
.auth__title { font-size: 1.5rem; margin-bottom: .3rem; }
.auth__lead { color: var(--muted); margin-bottom: 1.25rem; }
.auth__alt { text-align: center; margin: 1.25rem 0 0; font-size: .9rem; }
.auth__foot { margin-top: 1.5rem; font-size: .78rem; color: var(--muted); }

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 960px) {
  .auth__wrap { grid-template-columns: 1fr; }
  .auth__aside { display: none; }
  .grid--2-1 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 20; transform: translateX(-100%); transition: transform .2s ease; box-shadow: none; }
  .sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow); }
  .topbar__menu { display: grid; }
  .topbar__user-text { display: none; }
  .content { padding: 1.1rem; }
  .hero { padding: 1.5rem; }
  .field--2 { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
