:root {
  --green: #2e7d32;
  --green-dark: #1b5e20;
  --green-soft: #e8f5e9;
  --bg: #f4f6f4;
  --panel: #ffffff;
  --section: #f7f8f7;
  --text: #1f2a24;
  --muted: #6b7a70;
  --border: #e3e7e4;
  --danger: #c62828;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

a { color: var(--green); }

/* ---------- Barra superior ---------- */
.appbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}
.appbar .back {
  width: 36px; height: 36px; border-radius: 8px;
  display: grid; place-items: center;
  color: var(--text); text-decoration: none; font-size: 20px;
}
.appbar .back:hover { background: var(--section); }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand strong { display: block; font-size: 17px; font-weight: 800; }
.brand small { display: block; color: var(--muted); font-size: 12.5px; }
.appbar .spacer { flex: 1; }

.segmented {
  display: inline-flex;
  background: var(--section);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
}
.segmented a, .segmented button {
  border: 0; background: none; font: inherit; font-weight: 700;
  color: var(--muted); padding: 7px 16px; border-radius: 8px;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.segmented .active { background: #fff; color: var(--green); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* ---------- Botones ---------- */
.btn {
  font: inherit; font-weight: 700; font-size: 14.5px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; gap: 7px;
  white-space: nowrap;
}
.btn:hover { border-color: #c9d1cb; background: #fbfcfb; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-dark); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn[disabled] { opacity: .6; cursor: default; }
.btn .dot { width: 7px; height: 7px; border-radius: 50%; background: #f9a825; display: none; }
.btn.dirty .dot { display: inline-block; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.icon { font-size: 14px; width: 16px; text-align: center; flex: none; }

/* ---------- Formularios ---------- */
label, .label {
  display: block;
  font-size: 12px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase;
  color: #3d4a42; margin-bottom: 6px;
}
input, select, textarea {
  font: inherit; font-size: 15px; color: var(--text);
  padding: 10px 13px;
  border: 1px solid var(--border); border-radius: 8px;
  background: #fff; width: 100%;
}
input::placeholder, textarea::placeholder { color: #a3aea7; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--green-soft); border-color: var(--green); }
textarea { min-height: 64px; resize: vertical; }
.field { margin-bottom: 14px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: #3d4a42; font-weight: 600; text-transform: none; letter-spacing: 0; margin: 0; cursor: pointer; }
.check input { width: 15px; height: 15px; accent-color: var(--green); margin: 0; }

/* ---------- Páginas normales (lista, ajustes, login) ---------- */
main.page { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 22px; margin: 0; font-weight: 800; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 18px; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; background: var(--section); border-bottom: 1px solid var(--border); font-weight: 800; }
.card-head .title { display: flex; align-items: center; gap: 8px; }
.card-head .title svg { color: var(--green); }
.card-body { padding: 18px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat span { color: var(--muted); font-size: 13px; }
.stat strong { display: block; font-size: 24px; margin-top: 6px; }

.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.list th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 800; }
table.list tr:last-child td { border-bottom: none; }
table.list .num { text-align: right; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 30px; }
.tag { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 800; background: var(--green-soft); color: var(--green); }
.tag.albaran { background: #fff4e0; color: #a35c00; }
.tag.informe { background: #e8eefc; color: #1f4fd1; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.filters input { max-width: 300px; }
.inline { display: inline; margin: 0; }
.pagination { display: flex; gap: 6px; justify-content: center; padding: 14px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; text-decoration: none; color: var(--text); }

.flash { background: var(--green-soft); color: var(--green-dark); padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-weight: 600; }
.errors { background: #fdecea; color: var(--danger); padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.errors ul { margin: 0; padding-left: 18px; }

.login { max-width: 400px; margin: 70px auto; }
.login .brand { justify-content: center; margin-bottom: 4px; }

/* ---------- Admin del sitio web ---------- */
.thumb-empty { width: 52px; height: 52px; border-radius: 8px; background: var(--green-soft); color: var(--green); display: grid; place-items: center; }
.count { background: var(--green); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; margin-left: 4px; }
.photo-admin { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.photo-admin-item { border: 1px solid var(--border); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.photo-admin-item img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; }
.photo-admin-title { display: flex; gap: 6px; }
.photo-admin-title input { padding: 6px 8px; font-size: 13px; }

/* ---------- Logo ---------- */
.logo-img { width: auto; max-width: 140px; object-fit: contain; display: block; }
.logo-setting { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.logo-preview { width: 120px; height: 100px; border: 1px dashed var(--border); border-radius: 8px; display: grid; place-items: center; background: var(--section); }
.logo-preview .logo-img { max-width: 100px; max-height: 80px; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 10px; }

/* ---------- Editor ---------- */
.back-btn { display: inline-flex; align-items: center; gap: 8px; flex: none; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--section); color: var(--text); text-decoration: none; font-weight: 700; font-size: 14px; transition: background .15s, border-color .15s, color .15s; }
.back-btn:hover { background: var(--green-soft); border-color: #cfe3d0; color: var(--green-dark); }
.back-btn .icon { color: var(--green); }
@media (max-width: 1150px) { .back-btn span { display: none; } .back-btn { padding: 9px 11px; } }
.editor-form hr.sep { border: 0; border-top: 1px solid var(--border); margin: 6px 0 14px; }
.editor-page .appbar { flex-wrap: nowrap; gap: 12px; padding: 10px 16px; }
.editor-page .appbar .btn { padding: 7px 12px; font-size: 14px; }
.editor-page .segmented button { padding: 6px 12px; font-size: 14px; }
.editor-page .brand { min-width: 0; }
.editor-page .brand small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.editor-page .segmented, .editor-page .tools { flex: none; flex-wrap: nowrap; }
@media (max-width: 1440px) {
  .editor-page .tools .btn:not(.primary) .label-text { display: none; }
}
@media (max-width: 1150px) {
  .editor-page .segmented button { padding: 6px 9px; }
  .editor-page .brand small { display: none; }
}
body.editor-page { height: 100vh; overflow: clip; display: flex; flex-direction: column; }
.editor { flex: 1; display: grid; grid-template-columns: 460px 1fr; grid-template-rows: minmax(0, 1fr); min-height: 0; }
.editor-form { overflow-y: auto; padding: 0 14px 40px 20px; border-right: 1px solid var(--border); background: var(--bg); }
.editor-form .card { margin: 14px 0 0; }
.editor-form .card-body { padding: 16px 18px; }
.editor-form .field:last-child { margin-bottom: 0; }

.line-item { border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 10px; background: #fff; }
.line-item .line-top { display: flex; gap: 8px; align-items: flex-start; }
.line-item .line-top textarea { min-height: 42px; }
.line-item .line-nums { display: grid; grid-template-columns: 1fr 1fr .9fr 1fr; gap: 8px; margin-top: 8px; align-items: end; }
.line-item .line-nums label { font-size: 10.5px; margin-bottom: 4px; }
.line-item .line-nums input, .line-item .line-nums select { padding: 8px 8px; }
.line-item .importe { text-align: right; font-weight: 800; padding-bottom: 9px; }
.line-del { border: 0; background: none; color: #9aa79e; font-size: 18px; cursor: pointer; padding: 6px; line-height: 1; border-radius: 6px; }
.line-del:hover { color: var(--danger); background: #fdecea; }
.lines-empty { color: var(--muted); text-align: center; font-size: 14px; padding: 6px 0; }
.summary div { display: flex; justify-content: space-between; padding: 4px 0; }
.summary .grand { border-top: 2px solid var(--text); margin-top: 6px; padding-top: 8px; font-weight: 800; font-size: 17px; }

.preview { display: flex; flex-direction: column; min-width: 0; background: #ececec; }
.preview-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 20px; background: #fff; border-bottom: 1px solid var(--border); font-weight: 700; }
.preview-bar .title { display: flex; align-items: center; gap: 8px; }
.preview-bar .title svg { color: var(--green); }
.zoom { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.zoom button { width: 32px; height: 32px; border: 1px solid var(--border); background: #fff; border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.zoom span { min-width: 44px; text-align: center; }
.preview-scroll { flex: 1; overflow: auto; padding: 28px; }
.sheet { width: 794px; min-height: 1123px; margin: 0 auto; background: #fff; box-shadow: 0 4px 24px rgba(0,0,0,.10); padding: 56px 60px 40px; display: flex; flex-direction: column; }
.sheet.doc > .doc-footer { margin-top: auto; padding-top: 26px; }

/* Modal «Cargar» */
.modal { position: fixed; inset: 0; background: rgba(20,30,24,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal[hidden] { display: none; }
.modal-box { background: #fff; border-radius: 12px; width: 100%; max-width: 640px; max-height: 80vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 800; }
.modal-search { padding: 12px 18px; border-bottom: 1px solid var(--border); }
.modal-list { overflow-y: auto; }
.modal-list a { display: grid; grid-template-columns: 90px 90px 1fr auto; gap: 10px; align-items: center; padding: 11px 18px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.modal-list a:hover { background: var(--section); }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 60; font-weight: 600; }
.toast.error { background: var(--danger); }

/* Pestañas Formulario / Vista Previa: solo en móvil, como el original (≤ 860px) */
.mobile-tabs { display: none; background: #fff; border-bottom: 1px solid var(--border); }
.mobile-tabs button { flex: 1; border: 0; background: none; font: inherit; font-weight: 700; color: var(--muted); padding: 12px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-bottom: 3px solid transparent; cursor: pointer; }
.mobile-tabs button.active { color: var(--green); border-bottom-color: var(--green); }

@media (max-width: 1000px) {
  .editor { grid-template-columns: 380px 1fr; }
}
@media (max-width: 860px) {
  body.editor-page { height: auto; overflow: visible; }
  .editor-page .appbar { flex-wrap: wrap; position: static; }
  .appbar .tools { width: 100%; }
  .mobile-tabs { display: flex; position: sticky; top: 0; z-index: 15; }
  .editor { grid-template-columns: 1fr; grid-template-rows: auto; }
  .editor[data-tab="form"] .preview, .editor[data-tab="preview"] .editor-form { display: none; }
  .editor-form { overflow: visible; border-right: 0; padding: 0 16px 20px; }
  .preview-scroll { padding: 16px; }
}
@media (max-width: 640px) {
  .appbar { padding: 10px 16px; }
  .row { grid-template-columns: 1fr; }
  .btn .label-text { display: none; }
}

@media print {
  @page { size: A4; margin: 0; }
  body.editor-page { height: auto; overflow: visible; background: #fff; display: block; }
  .appbar, .mobile-tabs, .editor-form, .preview-bar, .toast, .modal { display: none !important; }
  .editor .preview { display: flex !important; }
  .editor { display: block; }
  .preview, .preview-scroll { background: #fff; padding: 0; overflow: visible; }
  .sheet { box-shadow: none; margin: 0; width: 210mm; min-height: auto; zoom: 1 !important; }
}

/* ---------- Acceso con PIN ---------- */
.pin-login { max-width: 360px; }
.pin-login .brand { justify-content: center; }
.pin-login form { display: flex; flex-direction: column; align-items: center; }
.pin-title { text-align: center; margin-bottom: 14px; }
.pin-input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.pin-dots { display: flex; gap: 14px; margin: 4px 0 12px; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--green); transition: background .15s, transform .15s; }
.pin-dots span.on { background: var(--green); transform: scale(1.1); }
.pin-input:focus-visible + .pin-dots span { box-shadow: 0 0 0 3px var(--green-soft); }
.pin-help { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.pin-error { color: var(--danger); font-size: 14px; font-weight: 700; margin: 0 0 16px; text-align: center; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 72px); gap: 12px; margin-bottom: 18px; }
.pin-pad button { height: 64px; border-radius: 50%; border: 1px solid var(--border); background: var(--section); font: inherit; font-size: 24px; font-weight: 700; color: var(--text); cursor: pointer; transition: background .15s, transform .1s; }
.pin-pad button:hover { background: var(--green-soft); }
.pin-pad button:active { transform: scale(.94); background: #d7ecd8; }
.pin-pad button[data-clear], .pin-pad button[data-back] { font-size: 18px; color: var(--muted); background: transparent; border-color: transparent; }
.pin-remember { margin-bottom: 14px; }
.pin-submit { width: 100%; justify-content: center; }
.pin-back { text-align: center; margin: 18px 0 0; font-size: 14px; }

/* ---------- Panel: barra lateral ---------- */
body.has-sidebar { padding-left: 260px; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; background: linear-gradient(180deg, #1b4d1e 0%, #12321a 100%); color: rgba(255,255,255,.82); display: flex; flex-direction: column; padding: 20px 14px; overflow-y: auto; }
.sidebar-brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: inherit; padding: 4px 8px 18px; }
.sidebar-brand .logo-img { height: 38px; width: auto; background: #fff; border-radius: 10px; padding: 4px; }
.sidebar-brand strong { display: block; color: #fff; font-size: 15.5px; font-weight: 800; line-height: 1.2; }
.sidebar-brand small { display: block; font-size: 12px; opacity: .7; }
.sidebar-label { margin: 14px 10px 6px; font-size: 10.5px; font-weight: 800; letter-spacing: 1.4px; text-transform: uppercase; color: rgba(255,255,255,.45); }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a, .sidebar-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: rgba(255,255,255,.82); text-decoration: none; font-weight: 600; font-size: 14.5px; background: none; border: 0; font-family: inherit; width: 100%; cursor: pointer; text-align: left; transition: background .15s, color .15s; }
.sidebar-nav a i, .sidebar-link i { width: 18px; text-align: center; font-size: 15px; opacity: .9; }
.sidebar-nav a:hover, .sidebar-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav a.active { background: #fff; color: var(--green-dark); box-shadow: 0 6px 16px rgba(0,0,0,.18); }
.sidebar-nav a.active i { color: var(--green); }
.sidebar-badge { margin-left: auto; font-style: normal; background: #c5e1a5; color: #12321a; border-radius: 99px; font-size: 11.5px; font-weight: 800; padding: 1px 8px; }
.sidebar-create a { font-weight: 500; font-size: 14px; padding: 8px 12px; }
.sidebar-create a i { font-size: 12px; }
.sidebar-bottom { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.1); display: flex; flex-direction: column; gap: 2px; }
.sidebar-bottom form { margin: 0; }
.mobilebar { display: none; }
.sidebar-overlay { display: none; }

.has-sidebar main.page { max-width: 1240px; padding: 32px 36px 60px; }
.flash { display: flex; align-items: center; gap: 10px; }

@media (max-width: 960px) {
  body.has-sidebar { padding-left: 0; }
  .sidebar { transform: translateX(-100%); transition: transform .25s; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-overlay { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(10,25,13,.45); }
  .mobilebar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30; background: #fff; border-bottom: 1px solid var(--border); padding: 10px 16px; }
  .mobilebar .sidebar-brand { padding: 0; color: var(--text); }
  .mobilebar .sidebar-brand strong { color: var(--green-dark); }
  .mobilebar-toggle { border: 1px solid var(--border); background: #fff; width: 40px; height: 40px; border-radius: 10px; font-size: 17px; cursor: pointer; color: var(--text); }
  .has-sidebar main.page { padding: 20px 16px 50px; }
}

/* ---------- Panel: inicio / documentos ---------- */
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.dash-head h1 { margin: 0; font-size: 26px; font-weight: 800; }
.dash-head p { margin: 4px 0 0; color: var(--muted); }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 22px; }
.quick a { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: 14px; text-decoration: none; color: var(--text); background: #fff; border: 1px solid var(--border); transition: transform .15s, box-shadow .15s, border-color .15s; }
.quick a:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(18,50,26,.08); border-color: #cfe3d0; }
.quick-ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 18px; flex: none; }
.quick strong { display: block; font-size: 15px; }
.quick small { color: var(--muted); font-size: 12.5px; }
.quick .plus { margin-left: auto; color: var(--muted); }
.ic-factura { background: var(--green-soft); color: var(--green); }
.ic-albaran { background: #fff4e0; color: #b26a00; }
.ic-informe { background: #e8eefc; color: #2a56c6; }
.ic-money { background: #e9f7ef; color: #1e8a4c; }
.ic-docs { background: #f2ecfb; color: #7a43c6; }
.ic-alert { background: #fdeceb; color: #c62828; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.kpi { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; display: flex; gap: 14px; align-items: center; }
.kpi > div > span { display: block; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kpi .quick-ic { display: grid; }
.kpi strong { display: block; font-size: 21px; font-weight: 800; margin-top: 2px; white-space: nowrap; }
.kpi a { color: inherit; text-decoration: none; }

.doc-table-card { background: #fff; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.doc-table-tools { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.doc-table-tools .search { position: relative; flex: 1; min-width: 220px; max-width: 380px; }
.doc-table-tools .search i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; }
.doc-table-tools .search input { padding-left: 36px; border-radius: 10px; }
.doc-table-tools .count-label { margin-left: auto; color: var(--muted); font-size: 13px; }
table.docs { width: 100%; border-collapse: collapse; }
table.docs th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 800; padding: 12px 18px; background: #fafbfa; border-bottom: 1px solid var(--border); }
table.docs td { padding: 13px 18px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.docs tr:last-child td { border-bottom: 0; }
table.docs tbody tr { transition: background .12s; }
table.docs tbody tr:hover { background: #f8fbf7; }
table.docs .num { text-align: right; white-space: nowrap; }
.doc-type { display: inline-flex; align-items: center; gap: 10px; }
.doc-type .quick-ic { width: 36px; height: 36px; border-radius: 10px; font-size: 14px; }
.doc-type strong { display: block; font-size: 14.5px; }
.doc-type small { color: var(--muted); font-size: 12px; }
.doc-client { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; font-weight: 800; color: #fff; background: var(--green); flex: none; text-transform: uppercase; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border); background: #fff; color: var(--text); display: inline-grid; place-items: center; cursor: pointer; text-decoration: none; font-size: 13.5px; transition: background .12s, color .12s, border-color .12s; }
.icon-btn:hover { background: var(--green-soft); color: var(--green); border-color: #cfe3d0; }
.icon-btn.danger:hover { background: #fdecea; color: var(--danger); border-color: #f5c6c3; }
.empty-state { text-align: center; padding: 56px 20px; }
.empty-state > i { font-size: 38px; color: #b7d3b9; margin-bottom: 10px; }
.empty-state h3 { margin: 6px 0 4px; }
.empty-state p { color: var(--muted); margin: 0 0 16px; }

@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px) {
  .quick, .kpis { grid-template-columns: 1fr; }
  table.docs thead { display: none; }
  table.docs, table.docs tbody, table.docs tr, table.docs td { display: block; width: 100%; }
  table.docs tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
  table.docs td { border: 0; padding: 4px 0; }
  table.docs td.num { text-align: left; }
  .row-actions { justify-content: flex-start; margin-top: 6px; }
}
.segmented a small { font-size: 11px; font-weight: 800; color: var(--muted); background: rgba(0,0,0,.05); border-radius: 99px; padding: 0 7px; }
.segmented a.active small { background: var(--green-soft); color: var(--green); }

/* ---------- Formulario de producto ---------- */
.pf { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.pf .card { border-radius: 16px; }
.pf-side { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 18px; }
.pf-side .card { margin: 0; }
.pf-hint { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--muted); }
.pf-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pf-chip { border: 1px solid var(--border); background: var(--section); border-radius: 99px; padding: 4px 12px; font: inherit; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; }
.pf-chip:hover { background: var(--green-soft); border-color: #cfe3d0; color: var(--green-dark); }
.pf-money { position: relative; }
.pf-money input { padding-right: 34px; }
.pf-money span { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; }
.pf-note { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--section); color: var(--muted); font-size: 13px; }
.pf-note i { color: var(--green); margin-top: 2px; }
.pf-flags { display: flex; flex-direction: column; gap: 10px; }
.pf-flag { display: flex; align-items: center; gap: 14px; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; cursor: pointer; text-transform: none; letter-spacing: 0; margin: 0; color: var(--text); transition: border-color .15s, background .15s; }
.pf-flag:has(.switch:checked) { border-color: #cfe3d0; background: #f7fbf6; }
.pf-flag-ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--section); color: var(--muted); flex: none; }
.pf-flag:has(.switch:checked) .pf-flag-ic { background: var(--green-soft); color: var(--green); }
.pf-flag-text { flex: 1; }
.pf-flag-text strong { display: block; font-size: 14.5px; }
.pf-flag-text small { display: block; font-size: 12.5px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.switch { appearance: none; -webkit-appearance: none; width: 44px !important; height: 25px; border-radius: 99px; background: #d5dbd6; position: relative; cursor: pointer; flex: none; padding: 0 !important; border: 0 !important; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(19px); }
.switch:focus-visible { outline: 3px solid var(--green-soft); }

.pf-drop { position: relative; display: grid; place-items: center; aspect-ratio: 1 / 1; border: 2px dashed #c9d6cb; border-radius: 14px; background: var(--section); cursor: pointer; overflow: hidden; text-transform: none; letter-spacing: 0; margin: 0; transition: border-color .15s, background .15s; }
.pf-drop:hover, .pf-drop.dragging { border-color: var(--green); background: var(--green-soft); }
.pf-drop.has-img { border-style: solid; border-color: var(--border); }
.pf-drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pf-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.pf-drop-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 20px; color: var(--muted); }
.pf-drop-empty i { font-size: 34px; color: var(--green); }
.pf-drop-empty strong { color: var(--text); font-size: 14.5px; }
.pf-drop-empty small { font-size: 12.5px; font-weight: 500; }
.pf-drop-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }

.pf-preview { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: #fff; transition: opacity .2s; }
.pf-preview.is-hidden { opacity: .45; }
.pf-preview-img { position: relative; aspect-ratio: 4 / 3; background: var(--section); }
.pf-preview-img img { width: 100%; height: 100%; object-fit: cover; }
.pf-preview-noimg { position: absolute; inset: 0; display: grid; place-items: center; font-size: 40px; color: #a9caab; background: linear-gradient(135deg, var(--green-soft), #f6faf5); }
.pf-badge { position: absolute; top: 10px; left: 10px; background: var(--green); color: #fff; font-size: 11.5px; font-weight: 800; padding: 3px 10px; border-radius: 99px; }
.pf-badge.out { background: #6b7a70; }
.pf-preview-body { padding: 12px 14px 14px; }
.pf-preview-body small { color: var(--green); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; }
.pf-preview-body strong { display: block; font-size: 15px; margin: 2px 0 4px; }
.pf-preview-body p { margin: 0 0 10px; color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pf-preview-btns { display: flex; gap: 6px; }
.pf-wa, .pf-add { flex: 1; text-align: center; border-radius: 99px; padding: 6px 8px; font-size: 12.5px; font-weight: 700; color: #fff; background: #25d366; white-space: nowrap; }
.pf-add { background: var(--green); }
.pf-add[hidden] { display: none; }

.pf-savebar { display: none; }
@media (max-width: 1000px) {
  .pf { grid-template-columns: 1fr; }
  .pf-side { position: static; }
  .pf-savebar { display: flex; gap: 10px; justify-content: flex-end; position: sticky; bottom: 0; margin: 18px -16px -50px; padding: 12px 16px; background: rgba(255,255,255,.96); border-top: 1px solid var(--border); }
  .pf-savebar .btn { flex: 1; justify-content: center; }
}

/* Elementos ocultos con el atributo hidden, aunque tengan display propio */
[hidden] { display: none !important; }

/* ---------- Sitio web (galería y mensajes) ---------- */
.kpis-3 { grid-template-columns: repeat(3, 1fr); }
.wa-card { border-radius: 16px; }
.wa-card .card-head .muted { color: var(--muted); font-weight: 500; font-size: 13px; }
.wa-card .count { margin-left: 6px; }
.up { margin-bottom: 18px; }
.up-drop { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 30px 20px; border: 2px dashed #c9d6cb; border-radius: 14px; background: var(--section); text-align: center; cursor: pointer; text-transform: none; letter-spacing: 0; margin: 0; color: var(--muted); transition: border-color .15s, background .15s, padding .2s; }
.up-drop:hover, .up-drop.dragging { border-color: var(--green); background: var(--green-soft); }
.up-drop.compact { padding: 14px 20px; }
.up-drop.compact small { display: none; }
.up-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.up-drop i { font-size: 32px; color: var(--green); }
.up-drop strong { color: var(--text); font-size: 15px; }
.up-drop small { font-size: 12.5px; font-weight: 500; }
.up-queue { margin-top: 12px; }
.up-thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.up-thumbs img { width: 76px; height: 76px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }
.up-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.up-bar input { flex: 1; min-width: 220px; }

.gal { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.gal-item { position: relative; margin: 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: #fff; }
.gal-item img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.gal-del { position: absolute; top: 8px; right: 8px; margin: 0; opacity: 0; transition: opacity .15s; }
.gal-item:hover .gal-del, .gal-item:focus-within .gal-del { opacity: 1; }
.gal-del .icon-btn { background: rgba(255,255,255,.95); }
.gal-title { margin: 0; }
.gal-title input { border: 0; border-top: 1px solid var(--border); border-radius: 0; padding: 9px 12px; font-size: 13.5px; background: #fff; }
.gal-title input:focus { outline: 0; background: var(--green-soft); }

.inbox { display: flex; flex-direction: column; }
.msg { display: flex; gap: 14px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.msg:last-child { border-bottom: 0; }
.msg.unread { background: #f7fbf6; }
.msg .avatar { width: 40px; height: 40px; font-size: 15px; }
.msg-body { flex: 1; min-width: 0; }
.msg-top { display: flex; align-items: center; gap: 8px; }
.msg-top strong { font-size: 15px; }
.msg-top time { margin-left: auto; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.msg-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.msg-text { margin: 6px 0 10px; color: #2b3a2f; white-space: pre-wrap; line-height: 1.55; }
.msg.unread .msg-text { color: var(--text); font-weight: 500; }
.msg-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.msg-actions .spacer { flex: 1; }
.msg-wa { background: #25d366; border-color: #25d366; color: #fff; }
.msg-wa:hover { background: #1ebe5b; border-color: #1ebe5b; }

@media (hover: none) { .gal-del { opacity: 1; } }
@media (max-width: 760px) { .kpis-3 { grid-template-columns: 1fr; } .msg-top time { margin-left: 0; } .msg-top { flex-wrap: wrap; } }

/* ---------- Ajustes ---------- */
.row.row-3 { grid-template-columns: 1fr 1.4fr 1.4fr; }
.st-score { color: var(--green); font-size: 14px; }
.st-progress { height: 8px; border-radius: 99px; background: var(--section); overflow: hidden; margin-bottom: 14px; }
.st-progress span { display: block; height: 100%; background: linear-gradient(90deg, #4caf50, var(--green)); border-radius: 99px; transition: width .3s; }
.st-checks { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.st-checks li { display: flex; gap: 10px; align-items: flex-start; }
.st-checks li > i { margin-top: 3px; font-size: 15px; }
.st-checks .st-ok { display: none; color: var(--green); }
.st-checks .st-no { color: #c3ccc5; }
.st-checks li.ok .st-ok { display: inline-block; }
.st-checks li.ok .st-no { display: none; }
.st-checks strong { display: block; font-size: 14px; }
.st-checks small { display: block; color: var(--muted); font-size: 12.5px; }
.st-checks li.ok small { display: none; }
.st-checks li.ok strong { color: var(--muted); font-weight: 600; }
.st-logo { position: relative; display: grid; place-items: center; height: 150px; border: 2px dashed #c9d6cb; border-radius: 14px; background: var(--section); cursor: pointer; margin: 0; overflow: hidden; text-transform: none; letter-spacing: 0; }
.st-logo:hover { border-color: var(--green); background: var(--green-soft); }
.st-logo img { max-height: 96px; max-width: 80%; object-fit: contain; }
.st-logo input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.st-logo span { position: absolute; bottom: 8px; font-size: 12.5px; font-weight: 700; color: var(--green-dark); background: rgba(255,255,255,.9); padding: 3px 10px; border-radius: 99px; }
.st-pin { margin-top: 20px; }
.st-pin .card { border-radius: 16px; }
.st-pin-input { letter-spacing: 6px; font-size: 18px; font-weight: 700; }
@media (max-width: 760px) { .row.row-3 { grid-template-columns: 1fr; } }
