/* Panell d'administració AFA */
:root {
    --green: #078838; --green-dark: #056a2b; --green-soft: #e6f4eb; --sun: #fbdc08; --red: #d9151c; --yellow: #fbdc08;
    --ink: #1d1d1b; --muted: #6b7775; --line: #e3e6e5; --bg: #f5f6f4; --white: #fff; --danger: #c62828;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.5; }
a { color: var(--green); }
img { max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.num { text-align: right; white-space: nowrap; }
.icon { width: 22px; height: 22px; flex-shrink: 0; }
.icon-sm { width: 18px; height: 18px; }
code { background: #eef1f0; padding: .1rem .35rem; border-radius: 4px; font-size: .88em; }

/* Layout */
.admin { display: flex; min-height: 100vh; }
.sidebar { width: 250px; flex-shrink: 0; background: #1d1d1b; color: #d6d7d7; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sb-brand { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.2rem; color: #fff; text-decoration: none; font-weight: 800; font-size: 1.1rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.sb-brand { flex-direction: column; align-items: stretch; gap: .5rem; }
.sb-brand img { background: #fff; border-radius: 10px; padding: 8px 10px; width: 100%; height: auto; }
.sb-brand span { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: #a9abab; font-weight: 700; text-align: center; }
.sidebar::before { content: ""; display: block; height: 5px; flex-shrink: 0; background: linear-gradient(90deg, var(--red) 0 33.33%, var(--green) 33.33% 66.66%, var(--yellow) 66.66% 100%); }
.sidebar nav { padding: .6rem 0; flex: 1; }
.sidebar nav a { display: flex; align-items: center; gap: .6rem; padding: .55rem 1.2rem; color: #d6d7d7; text-decoration: none; font-size: .93rem; border-left: 3px solid transparent; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.active { background: rgba(7,136,56,.35); color: #fff; border-left-color: var(--yellow); }
.sb-head { text-transform: uppercase; font-size: .7rem; letter-spacing: .1em; padding: 1rem 1.2rem .3rem; color: #8d8f8f; font-weight: 700; }
.sb-foot { padding: 1rem 1.2rem; border-top: 1px solid rgba(255,255,255,.08); display: flex; justify-content: space-between; font-size: .85rem; }
.sb-foot a { color: #fff; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 1rem; padding: .8rem 1.6rem; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar h1 { font-size: 1.25rem; margin: 0; flex: 1; }
.topbar .user { display: flex; align-items: center; gap: .8rem; font-size: .9rem; }
.topbar .user form { margin: 0; }
.sb-toggle { display: none; background: none; border: 0; font-size: 1.5rem; cursor: pointer; }
.content { padding: 1.6rem; max-width: 1300px; width: 100%; }
@media (max-width: 900px) {
    .sidebar { position: fixed; left: -260px; z-index: 30; transition: left .2s; }
    .sb-open .sidebar { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.3); }
    .sb-toggle { display: block; }
    .topbar .user span { display: none; }
    .content { padding: 1rem; }
}

/* Components */
.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1.3rem 1.4rem; margin-bottom: 1.3rem; }
.panel.flush { padding: 0; overflow-x: auto; }
.panel h2 { font-size: 1.05rem; margin: 0 0 .9rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #c8cfcd; background: #fafbfa; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); border-color: var(--green-dark); }
.btn-danger { background: #fff; border-color: #f2c4c4; color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-light { background: transparent; }
.btn-small { padding: .3rem .65rem; font-size: .83rem; }
.btn-block { width: 100%; margin-top: .5rem; }
.alert { padding: .8rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.alert-success { background: #e3f4ea; color: #155c34; }
.alert-error { background: #fdecea; color: #8a1c1c; }
.alert-info { background: #e8f2f9; color: #1d4f6e; }
.alert-warn { background: #fff4d6; color: #7a5300; }
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .76rem; font-weight: 700; }
.badge-ok { background: #e3f4ea; color: #155c34; }
.badge-warn { background: #fff4d6; color: #7a5300; }
.badge-bad { background: #fdecea; color: #8a1c1c; }
.badge-muted { background: #eceeed; color: #555; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.3rem; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1.1rem 1.2rem; display: flex; flex-direction: column; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat strong { font-size: 1.7rem; margin: .2rem 0; }
.stat strong.sm { font-size: 1.05rem; }
.stat small { color: var(--muted); }
.quick { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.3rem; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.3rem; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .7rem .9rem; border-bottom: 1px solid var(--line); background: #fafbfa; }
.table td { padding: .7rem .9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table a { text-decoration: none; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn { margin-left: .2rem; }
.thumb { width: 54px; height: 40px; object-fit: cover; border-radius: 6px; display: block; }
form.inline { display: inline; }
@media (max-width: 700px) {
    .table.list thead { display: none; }
    .table.list tr { display: block; border-bottom: 1px solid var(--line); padding: .5rem 0; }
    .table.list td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .3rem .9rem; text-align: right; }
    .table.list td::before { content: attr(data-label); font-weight: 600; color: var(--muted); text-align: left; }
    .table.list td.actions { justify-content: flex-end; flex-wrap: wrap; }
}

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1rem; }
.toolbar .search { flex: 1; min-width: 200px; }
.toolbar .search input { max-width: 320px; }
.tabs { display: flex; flex-wrap: wrap; gap: .2rem; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .2rem; }
.tabs a { padding: .35rem .75rem; border-radius: 6px; text-decoration: none; color: var(--muted); font-size: .88rem; font-weight: 600; }
.tabs a.active { background: var(--green-soft); color: var(--green-dark); }

/* Forms */
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.3rem; align-items: start; }
.form-grid .side { position: sticky; top: 76px; }
@media (max-width: 1000px) { .form-grid { grid-template-columns: 1fr; } .form-grid .side { position: static; } }
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .3rem; }
.field .help, .field small { display: block; color: var(--muted); font-size: .8rem; margin-top: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=date], input[type=datetime-local], input:not([type]), select, textarea {
    width: 100%; padding: .55rem .7rem; border: 1px solid #cfd6d4; border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31,111,92,.25); border-color: var(--green); }
.check { display: flex; gap: .5rem; align-items: center; margin: .4rem 0 1rem; font-weight: 600; font-size: .9rem; cursor: pointer; }
.check input { accent-color: var(--green); width: 17px; height: 17px; }
.check.small { font-size: .82rem; font-weight: 400; margin: .3rem 0; }
.input-suffix { display: flex; align-items: center; }
.input-suffix input { border-radius: 8px 0 0 8px; }
.input-suffix span { padding: .55rem .7rem; background: #eef1f0; border: 1px solid #cfd6d4; border-left: 0; border-radius: 0 8px 8px 0; }
.img-preview { margin-bottom: .5rem; }
.img-preview img { max-height: 140px; border-radius: 8px; border: 1px solid var(--line); }
.icon-picker { display: flex; flex-wrap: wrap; gap: .3rem; }
.icon-picker input { position: absolute; opacity: 0; }
.icon-picker span { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; color: var(--muted); }
.icon-picker input:checked + span { border-color: var(--green); background: var(--green-soft); color: var(--green); }
.form-heading { font-size: 1.05rem; margin: 1.6rem 0 .8rem; padding-bottom: .4rem; border-bottom: 1px solid var(--line); }
.form-heading:first-child { margin-top: 0; }
.help-box { background: #f1f8f3; border-radius: 8px; padding: .7rem .9rem; font-size: .86rem; color: #3c4a48; }
.settings-form { max-width: 820px; }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.grid-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1rem; }
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 200px; }
.danger-zone { margin-top: 1rem; }

/* Quill */
.editor { background: #fff; }
.editor .ql-editor { min-height: 260px; font-size: 15px; line-height: 1.6; }
.editor.small .ql-editor { min-height: 110px; }
.ql-toolbar.ql-snow { border-radius: 8px 8px 0 0; border-color: #cfd6d4; background: #fafbfa; }
.ql-container.ql-snow { border-radius: 0 0 8px 8px; border-color: #cfd6d4; }

/* Gallery admin */
.gallery-admin { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.gitem { border: 1px solid var(--line); border-radius: 10px; padding: .6rem; }
.gitem img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 6px; margin-bottom: .4rem; }
.gitem .row { display: flex; justify-content: space-between; align-items: center; margin-top: .4rem; gap: .4rem; }
.gitem .row input { width: 60px; }

/* Updates */
pre.commit { background: #f5f6f4; padding: .7rem; border-radius: 8px; white-space: pre-wrap; font-size: .85rem; max-height: 160px; overflow: auto; }
ol.log li { margin-bottom: .3rem; }

/* Check-in */
.checkin { max-width: 640px; }
.reader { width: 100%; border-radius: 10px; overflow: hidden; background: #111; margin-bottom: .8rem; min-height: 0; }
.reader:empty { display: none; }
.row-gap { display: flex; gap: .5rem; margin-bottom: 1rem; }
.ci-result { border-radius: 12px; padding: 1.4rem; margin-bottom: 1.3rem; font-size: 1.1rem; text-align: center; color: #fff; }
.ci-result strong { display: block; font-size: 1.5rem; }
.ci-result.ok { background: #1a7f37; }
.ci-result.warn { background: #b7791f; }
.ci-result.bad { background: #c62828; }
.ci-history { list-style: none; padding: 0; margin: 0; max-height: 300px; overflow: auto; font-size: .9rem; }
.ci-history li { padding: .4rem 0; border-bottom: 1px solid var(--line); }

/* Progress (reutilitzat) */
.progress { height: 12px; background: #eef1f0; border-radius: 999px; overflow: hidden; margin: .4rem 0 .8rem; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--green), #6fbf3f 60%, var(--yellow)); }
.progress-meta { display: flex; flex-wrap: wrap; gap: 1.5rem; }
.progress-meta div { display: flex; flex-direction: column; }
.progress-meta strong { font-size: 1.2rem; }
.progress-meta span { color: var(--muted); font-size: .82rem; }

/* Login */
.login-page { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(160deg, #e6f4eb, #fff9cc); padding: 1rem; }
.login-card { position: relative; overflow: hidden; }
.login-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 6px; background: linear-gradient(90deg, var(--red) 0 33.33%, var(--green) 33.33% 66.66%, var(--yellow) 66.66% 100%); }
.login-logo { width: 240px; height: auto; }
.login-card { background: #fff; padding: 2.2rem; border-radius: 16px; width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,.08); text-align: center; }
.login-card h1 { margin: .6rem 0 0; font-size: 1.4rem; }
.login-card label { display: block; text-align: left; font-weight: 600; font-size: .88rem; margin: .9rem 0; }
.login-card label input { margin-top: .3rem; }
.login-card img { margin: 0 auto; }
.login-card .btn { margin: .6rem 0 1rem; padding: .75rem; }

@media print {
    .sidebar, .topbar, .toolbar, .actions, #manual, .stats { display: none !important; }
    .content { padding: 0; }
    .panel { border: 0; }
}

/* Missatges */
.table tr.unread td { background: #fbfdf9; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--red); margin-right: .45rem; vertical-align: middle; }
.dl { display: grid; grid-template-columns: 160px 1fr; gap: .45rem 1rem; margin: 0 0 1.2rem; }
.dl dt { color: var(--muted); font-size: .88rem; }
.dl dd { margin: 0; }
.message-body { background: #f7f8f7; border-left: 4px solid var(--yellow); padding: 1rem 1.2rem; border-radius: 0 8px 8px 0; line-height: 1.65; white-space: normal; }
.nav-count { margin-left: auto; background: var(--red); color: #fff; font-size: .72rem; font-weight: 700; border-radius: 999px; padding: .05rem .45rem; }
@media (max-width: 600px) { .dl { grid-template-columns: 1fr; } }
