/* ==========================================================================
   Coordina CAE — sistema de disseny
   CSS propi amb variables. Sense dependències de build (ni Vite ni npm).
   ========================================================================== */

:root {
    --brand-400: #34d399;
    --brand-500: #10b981;
    --brand-600: #059669;
    --brand-700: #047857;

    --success:  #10b981;
    --success-bg: #ecfdf5;
    --danger:   #ef4444;
    --danger-bg: #fef2f2;

    --bg:       #f6f7fb;
    --surface:  #ffffff;
    --surface-2:#f9fafb;
    --text:     #0f172a;
    --muted:    #64748b;
    --border:   #e7e9f0;

    --radius-sm: 8px;
    --radius:    14px;

    --shadow-sm: 0 1px 2px rgba(15,23,42,.05);
    --shadow:    0 4px 16px rgba(15,23,42,.06);
    --shadow-lg: 0 12px 40px rgba(15,23,42,.12);

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
.muted { color: var(--muted); }

/* --- Marca ---------------------------------------------------------------- */
.brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 9px;
    background: var(--brand-600); color: #fff;
    font-weight: 800; font-size: .78rem; letter-spacing: .03em;
}
.brand-mark-lg { width: 52px; height: 52px; font-size: 1.05rem; border-radius: 13px; }

/* --- Botons --------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    padding: .62rem 1.05rem; border-radius: var(--radius-sm);
    font-size: .92rem; font-weight: 600; cursor: pointer;
    border: 1px solid transparent; transition: all .15s ease;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand-600); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-700); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-block { width: 100%; }
.btn-lg { padding: .8rem 1.2rem; font-size: 1rem; }
.btn-sm { padding: .4rem .75rem; font-size: .85rem; }

/* --- Formularis ----------------------------------------------------------- */
.field { margin-bottom: 1rem; }
.label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .35rem; }
.input {
    width: 100%; padding: .65rem .8rem;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: .95rem; font-family: inherit; background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus {
    outline: none; border-color: var(--brand-400);
    box-shadow: 0 0 0 3px rgba(16,185,129,.15);
}
.checkbox-row {
    display: flex; align-items: center; gap: .5rem;
    font-size: .9rem; color: var(--muted); cursor: pointer;
}

/* --- Alertes -------------------------------------------------------------- */
.alert {
    padding: .7rem .9rem; border-radius: var(--radius-sm);
    font-size: .9rem; margin-bottom: 1rem; border: 1px solid transparent;
}
.alert-danger { background: var(--danger-bg); color: #b91c1c; border-color: #fecaca; }
.alert-success { background: var(--success-bg); color: #047857; border-color: #a7f3d0; }

/* --- Login ---------------------------------------------------------------- */
.auth-body {
    min-height: 100vh;
    background: linear-gradient(135deg, #ecfdf5 0%, #f6f7fb 55%, #eef2ff 100%);
}
.auth-wrap {
    min-height: 100vh;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 1.5rem;
}
.auth-card {
    width: 100%; max-width: 400px;
    background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); padding: 2rem 1.75rem;
}
.auth-head { text-align: center; margin-bottom: 1.5rem; }
.auth-head h1 { font-size: 1.35rem; margin: .8rem 0 .2rem; }
.auth-head p { color: var(--muted); font-size: .9rem; margin: 0; }
.auth-foot { color: var(--muted); font-size: .8rem; margin-top: 1.25rem; }

/* --- App shell ------------------------------------------------------------ */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: .75rem;
    padding: .75rem 1.25rem; background: var(--surface);
    border-bottom: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.topbar .brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; }
.spacer { flex: 1; }
.user-box { display: flex; align-items: center; gap: .75rem; }
.user-name { font-size: .9rem; font-weight: 600; }

.content { width: 100%; max-width: 960px; margin: 0 auto; padding: 1.5rem 1.25rem; }
.page-head { margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.5rem; }

.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1.5rem;
}
.card h2 { font-size: 1.1rem; margin-bottom: .5rem; }

.meta-list { margin: 1.25rem 0 0; display: grid; gap: .6rem; }
.meta-list > div { display: flex; justify-content: space-between; gap: 1rem;
    padding: .5rem 0; border-top: 1px solid var(--border); }
.meta-list dt { color: var(--muted); font-size: .88rem; }
.meta-list dd { margin: 0; font-weight: 600; font-size: .9rem; }

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 640px) {
    .user-name { display: none; }
    .content { padding: 1rem; }
}

/* ==========================================================================
   Coordina — components de l'aplicació (M1-M8)
   ========================================================================== */

/* --- Layout amb barra lateral --------------------------------------------- */
.app { display: flex; min-height: 100vh; }
.side {
    width: 234px; flex-shrink: 0; background: #0b2e26; color: #d1fae5;
    display: flex; flex-direction: column; padding: 1rem .75rem;
}
.side .brand { display: flex; align-items: center; gap: .55rem; color: #fff;
    font-weight: 700; padding: .4rem .5rem 1rem; }
.side .brand .brand-mark { background: var(--brand-500); }
.side nav { display: flex; flex-direction: column; gap: .15rem; }
.side nav a {
    display: flex; align-items: center; gap: .6rem; padding: .6rem .7rem;
    border-radius: var(--radius-sm); color: #a7d7c8; font-size: .92rem; font-weight: 500;
}
.side nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side nav a.active { background: var(--brand-600); color: #fff; }
.side .side-foot { margin-top: auto; font-size: .8rem; color: #7fb8a7; padding: .5rem; }
.side .side-foot form { margin-top: .4rem; }
.side .side-foot .btn-ghost { color: #d1fae5; border-color: rgba(255,255,255,.2); width: 100%; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
    display: flex; align-items: center; gap: .75rem; padding: .8rem 1.5rem;
    background: var(--surface); border-bottom: 1px solid var(--border);
}
.app-topbar h1 { font-size: 1.15rem; }
.app-body { padding: 1.5rem; max-width: 1100px; width: 100%; }

/* --- Semàfor -------------------------------------------------------------- */
.light { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; font-size: .85rem; }
.light .dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.light.green .dot { background: var(--success); box-shadow: 0 0 0 3px #d1fae5; }
.light.amber .dot { background: var(--warning); box-shadow: 0 0 0 3px #fef3c7; }
.light.red .dot   { background: var(--danger);  box-shadow: 0 0 0 3px #fee2e2; }
.light.green { color: #047857; } .light.amber { color: #b45309; } .light.red { color: #b91c1c; }

/* --- Badges d'estat ------------------------------------------------------- */
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 999px;
    font-size: .74rem; font-weight: 700; letter-spacing: .01em; }
.badge.st-valid   { background: #d1fae5; color: #047857; }
.badge.st-amber   { background: #fef3c7; color: #b45309; }
.badge.st-red     { background: #fee2e2; color: #b91c1c; }
.badge.st-neutral { background: #eef0f5; color: #475569; }

/* --- KPIs ----------------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.1rem; box-shadow: var(--shadow-sm); }
.kpi .v { font-size: 1.8rem; font-weight: 750; letter-spacing: -.02em; }
.kpi .l { color: var(--muted); font-size: .82rem; margin-top: .2rem; }

/* --- Taules --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm); }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { text-align: left; padding: .7rem .9rem; color: var(--muted);
    font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--border); }
table.data td { padding: .7rem .9rem; border-bottom: 1px solid var(--border-2, #eef0f5); }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--surface-2); }

/* --- Seccions i llistes de slots ------------------------------------------ */
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted); margin: 1.5rem 0 .6rem; font-weight: 700; }
.slot { display: flex; align-items: center; gap: .8rem; padding: .8rem 1rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    margin-bottom: .5rem; }
.slot .slot-main { flex: 1; min-width: 0; }
.slot .slot-name { font-weight: 600; font-size: .92rem; }
.slot .slot-sub { color: var(--muted); font-size: .8rem; }
.slot form { margin: 0; }
.file-mini { font-size: .82rem; }

/* --- Grid de targetes ----------------------------------------------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill,minmax(260px,1fr)); gap: 1rem; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.1rem; box-shadow: var(--shadow-sm); display: block; }
.tile:hover { box-shadow: var(--shadow); }
.tile h3 { font-size: 1rem; margin-bottom: .3rem; }
.tile .meta { color: var(--muted); font-size: .84rem; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.stack > * + * { margin-top: 1rem; }
.hint { color: var(--muted); font-size: .82rem; }
.progress { height: 7px; background: #eef0f5; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand-500); }

/* --- Portal del sub (mobile-first) ---------------------------------------- */
.portal-top { background: var(--brand-600); color: #fff; padding: 1rem 1.1rem;
    display: flex; align-items: center; gap: .6rem; position: sticky; top: 0; z-index: 5; }
.portal-top .brand-mark { background: rgba(255,255,255,.2); }
.portal-top .spacer { flex: 1; }
.portal-top a, .portal-top button { color: #fff; }
.portal-body { max-width: 640px; margin: 0 auto; padding: 1.1rem; }
.portal-nav { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.portal-nav a { padding: .45rem .8rem; border-radius: 999px; background: var(--surface);
    border: 1px solid var(--border); font-size: .85rem; font-weight: 600; }
.portal-nav a.active { background: var(--brand-600); color: #fff; border-color: var(--brand-600); }

@media (max-width: 820px) {
    .side { position: fixed; left: -260px; top: 0; bottom: 0; transition: left .2s; z-index: 20; }
    body.nav-open .side { left: 0; }
    .grid-2 { grid-template-columns: 1fr; }
}

/* --- Selector d'idioma ---------------------------------------------------- */
.locale-switch { display: inline-flex; gap: .25rem; font-size: .8rem; }
.locale-switch a { padding: .15rem .45rem; border-radius: 6px; color: var(--muted); font-weight: 600; }
.locale-switch a.active { background: var(--brand-600); color: #fff; }

/* --- Landing -------------------------------------------------------------- */
.lp-nav { display: flex; align-items: center; gap: 1rem; max-width: 1080px; margin: 0 auto; padding: 1.1rem 1.25rem; }
.lp-nav .brand { display: flex; align-items: center; gap: .55rem; font-weight: 800; }
.lp-nav .spacer { flex: 1; }
.lp-hero { max-width: 820px; margin: 0 auto; padding: 3rem 1.25rem 2rem; text-align: center; }
.lp-tag { display: inline-block; background: #d1fae5; color: #047857; font-weight: 700;
    font-size: .78rem; padding: .3rem .8rem; border-radius: 999px; margin-bottom: 1rem; }
.lp-hero h1 { font-size: 2.3rem; line-height: 1.1; letter-spacing: -.03em; margin-bottom: 1rem; }
.lp-hero p { font-size: 1.1rem; color: var(--muted); max-width: 640px; margin: 0 auto 1.5rem; }
.lp-cta { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }
.lp-section { max-width: 1080px; margin: 0 auto; padding: 2.5rem 1.25rem; }
.lp-section h2 { font-size: 1.5rem; text-align: center; margin-bottom: 1.75rem; }
.lp-steps { display: grid; grid-template-columns: repeat(auto-fit,minmax(240px,1fr)); gap: 1.25rem; }
.lp-step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }
.lp-step .n { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-600); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700; margin-bottom: .8rem; }
.lp-step h3 { font-size: 1.05rem; margin-bottom: .4rem; }
.lp-step p { color: var(--muted); font-size: .92rem; }
.lp-plans { display: grid; grid-template-columns: repeat(auto-fit,minmax(240px,1fr)); gap: 1.25rem; align-items: stretch; }
.lp-plan { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.75rem; display: flex; flex-direction: column; }
.lp-plan.feat { border-color: var(--brand-500); box-shadow: 0 0 0 3px #d1fae5; }
.lp-plan .price { font-size: 2.2rem; font-weight: 800; letter-spacing: -.02em; }
.lp-plan .price small { font-size: .95rem; color: var(--muted); font-weight: 500; }
.lp-plan ul { list-style: none; padding: 0; margin: 1rem 0; }
.lp-plan li { padding: .35rem 0; color: var(--muted); font-size: .92rem; }
.lp-plan .btn { margin-top: auto; }
.lp-why { display: flex; gap: 1.5rem; justify-content: center; flex-wrap: wrap; }
.lp-why div { font-weight: 600; }
.lp-foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 2rem 1.25rem 3rem; }
@media (max-width: 640px) { .lp-hero h1 { font-size: 1.7rem; } }
