/* DocControl — estils base. --accent i --on-accent els defineix cada empresa (_Brand.cshtml). */
:root {
  --ink: #17202A; --muted: #5B6673; --line: #E3E7EC; --line-soft: #EEF1F4; --bg: #F6F8FA;
  --field: #C9D1D9; --soft: #E6F2F5; --ok-bg: #E5F3E8; --ok: #1E6B2F; --warn-bg: #FDF0DD; --warn: #8A4B00;
  --danger: #A3361B; --danger-bg: #FBE9E4; --radius: 12px;
  --font: "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.45; }
a { color: var(--accent); }
h1 { font-size: 26px; margin: 0; }
h2 { font-size: 18px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { background: var(--line-soft); padding: 1px 5px; border-radius: 4px; }

/* Botons i camps */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px;
  border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { filter: brightness(0.92); }
.btn-outline { background: #fff; color: var(--ink); border-color: var(--field); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--field); }
.btn-danger { background: #fff; color: var(--danger); border-color: #E7B7AA; }
.btn-sm { min-height: 34px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; min-height: 48px; font-size: 16px; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }
.link-btn.danger { color: var(--danger); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: 14px; font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], input:not([type]), select, textarea {
  min-height: 44px; padding: 0 12px; border: 1px solid var(--field); border-radius: 8px; font: inherit; font-size: 15px; background: #fff; color: var(--ink); width: 100%; }
textarea { padding: 10px 12px; min-height: 90px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: 10px; }
.check input { width: 20px; height: 20px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.row > .field { flex: 1 1 200px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.validation, .field-validation-error, .validation-summary-errors { color: var(--danger); font-size: 14px; }
.validation-summary-errors ul { margin: 0; padding-left: 18px; }

/* Avisos i etiquetes */
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.err { background: var(--danger-bg); color: var(--danger); }
.alert.info { background: #fff; border: 1px solid var(--line); color: var(--muted); }
.badge { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 9px; background: var(--line-soft); color: #4B5563; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.new { background: var(--soft); color: var(--ink); }
.badge.accent { background: var(--accent); color: var(--on-accent); }

/* Targetes i taules */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.grid td { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid td.right, table.grid th.right { text-align: right; }
table.grid tr.highlight td { background: var(--soft); }
.actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.actions form { display: inline; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* Logo */
.logo { display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; object-fit: contain; background: #fff; flex: none; }
.logo-mono { background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 13px; }
.logo.sm { width: 40px; height: 40px; }
.logo.lg { width: 64px; height: 64px; font-size: 18px; }
.logo.inv.logo-mono { background: #fff; color: var(--accent); }

/* Pantalles d'accés */
.auth { min-height: 100vh; display: flex; flex-wrap: wrap; }
.auth-hero { flex: 1 1 420px; background: var(--accent); color: var(--on-accent); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.auth-hero .brand { display: flex; align-items: center; gap: 14px; font-weight: 600; font-size: 18px; }
.auth-hero h1 { font-size: 38px; line-height: 1.15; }
.auth-hero p { font-size: 18px; max-width: 460px; margin: 12px 0 0; }
.auth-panel { flex: 1 1 420px; display: flex; flex-direction: column; padding: 28px 48px; }
.auth-panel .top { display: flex; justify-content: flex-end; }
.auth-panel .center { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px 0; }
.auth-form { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 18px; }
.auth-form h2 { font-size: 26px; }
.auth-foot { text-align: center; font-size: 13px; color: var(--muted); }
.app-foot { margin-top: 40px; text-align: center; font-size: 12px; color: var(--muted); }
.auth-simple { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 48px 16px; gap: 28px; }
.auth-simple .card { width: 100%; max-width: 480px; }
.qr { display: block; width: 200px; height: 200px; margin: 0 auto; image-rendering: pixelated; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; font-family: ui-monospace, Consolas, monospace; font-size: 16px; }

/* Selector d'idioma */
.lang { display: inline-flex; }
.lang a { min-height: 34px; display: inline-flex; align-items: center; padding: 0 11px; border: 1px solid var(--field); color: var(--muted); text-decoration: none; font-size: 13px; background: transparent; }
.lang a:first-child { border-radius: 8px 0 0 8px; }
.lang a:last-child { border-radius: 0 8px 8px 0; border-left: 0; }
.lang a.on { background: #fff; color: var(--ink); font-weight: 700; }

/* Portal del client */
.topbar { background: #fff; border-bottom: 1px solid var(--line); padding: 10px 28px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.topbar .brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topbar-right form { margin: 0; }
.page { max-width: 1280px; margin: 0 auto; padding: 28px; }
.split { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.split > .side { flex: 1 1 260px; max-width: 320px; }
.split > .content { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.tree { display: flex; flex-direction: column; gap: 2px; padding: 14px; }
.tree .title { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 4px 10px 10px; }
.tree a, .tree .item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 14px; }
.tree a:hover { background: var(--bg); }
.tree a.on, .tree .item.on { background: var(--soft); font-weight: 600; }
.tree .count { color: var(--muted); font-weight: 400; font-size: 13px; }
.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; }
.crumb { font-size: 14px; color: var(--muted); }
.doc-name { display: flex; align-items: center; gap: 10px; }
.doc-name .ext { font-size: 11px; font-weight: 700; color: #fff; background: #8A96A3; border-radius: 4px; padding: 2px 5px; text-transform: uppercase; min-width: 34px; text-align: center; }
.doc-name .ext.pdf { background: #B4472B; }
.doc-name .ext.xls, .doc-name .ext.xlsx { background: #2E7D32; }
.doc-name .ext.doc, .doc-name .ext.docx { background: #1F4E9C; }

/* Backoffice */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.sidebar { flex: 1 1 240px; max-width: 260px; background: #fff; border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 6px; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.sidebar .brand div { display: flex; flex-direction: column; font-size: 14px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a { padding: 11px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 15px; }
.side-nav a:hover { background: var(--bg); }
.side-nav a.on { background: var(--soft); font-weight: 600; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 16px 8px 0; align-items: flex-start; }
.main { flex: 999 1 560px; min-width: 0; padding: 28px 32px; display: flex; flex-direction: column; gap: 20px; }
.tabs { display: inline-flex; gap: 4px; background: var(--line-soft); border-radius: 10px; padding: 4px; flex-wrap: wrap; }
.tabs a { min-height: 36px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: 7px; color: #4B5563; text-decoration: none; font-size: 14px; }
.tabs a.on { background: #fff; color: var(--ink); font-weight: 600; }
.dropzone { border: 2px dashed #9FB3C2; border-radius: 12px; padding: 26px; display: flex; flex-direction: column; align-items: center; gap: 6px; background: #F8FBFC; text-align: center; cursor: pointer; }
.dropzone.drag { background: var(--soft); border-color: var(--accent); }
.dropzone input[type=file] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.file-list { border: 1px solid var(--line); border-radius: 10px; }
.file-list div { padding: 9px 14px; border-bottom: 1px solid var(--line-soft); display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.file-list div:last-child { border-bottom: 0; }
.file-list:empty { display: none; }
details.inline { display: inline-block; position: relative; }
details.inline summary { list-style: none; cursor: pointer; color: var(--accent); text-decoration: underline; font-size: 13px; }
details.inline summary::-webkit-details-marker { display: none; }
details.inline[open] .pop { position: absolute; right: 0; top: 26px; z-index: 5; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.12); display: flex; gap: 8px; min-width: 300px; }
.preview { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.preview .hero { background: var(--accent); color: var(--on-accent); padding: 24px; display: flex; flex-direction: column; gap: 12px; font-size: 20px; font-weight: 700; }
.preview .body { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.preview .ph { height: 38px; border: 1px solid var(--field); border-radius: 8px; }
.swatch { width: 44px; height: 44px; border-radius: 8px; border: 1px solid var(--field); padding: 2px; }

@media (max-width: 640px) {
  .hide-sm { display: none; }
  .page, .main { padding: 16px; }
  .auth-hero, .auth-panel { padding: 28px 16px; }
  .auth-hero h1 { font-size: 30px; }
  .sidebar { max-width: none; border-right: 0; border-bottom: 1px solid var(--line); }
  .split > .side { max-width: none; }
  .topbar { padding: 10px 16px; }
}
