/* Empresas SOL's tab of the workspace (index.html, #tool-compras). The Buzones SOL design system (tokens, Geist, Phosphor), one
   accent: verde azulado. Every rule is scoped to the tab's container .t-compras; the page itself (body, the bar) is app.css's.
   Shape rule: controls 8px; containers 12px; pills fully round. Light by default; dark when <html data-theme="dark">. */

.t-compras {
  --bg: #f5f6f8; --surface: #fcfcfd; --surface-2: #f0f2f5; --border: #e2e5ea; --border-strong: #cfd4dc;
  --text: #14181e; --muted: #5a6371; --accent: #0f766e; --accent-hover: #115e59; --accent-ink: #ffffff; --accent-soft: #e3f4f1;
  --danger: #b42318; --danger-soft: #fdeceb; --ok: #17803d; --ok-soft: #e6f4ea;
  --shadow: 0 1px 2px rgb(20 30 45 / .05), 0 2px 6px rgb(20 30 45 / .04);
  --r-control: 8px; --r-box: 12px; --skeleton: #e9ecf0;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  color-scheme: light;
}
:root[data-theme="dark"] .t-compras {
  --bg: #0e1115; --surface: #151a20; --surface-2: #1c222a; --border: #283039; --border-strong: #36404b;
  --text: #e7eaee; --muted: #98a2af; --accent: #3cc7b4; --accent-hover: #5fd6c6; --accent-ink: #062b27; --accent-soft: #10302c;
  --danger: #f2766b; --danger-soft: #3a1b19; --ok: #4cc97a; --ok-soft: #12301e;
  --shadow: 0 1px 2px rgb(0 0 0 / .35); --skeleton: #222932;
  color-scheme: dark;
}

.t-compras * { box-sizing: border-box; }
.t-compras { background: var(--bg); color: var(--text); font: 14px/1.5 "Geist", system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 1; min-height: calc(100vh - 56px); }
.t-compras h1 { font-size: 24px; line-height: 1.2; font-weight: 650; letter-spacing: -.02em; margin: 0 0 4px; text-wrap: balance; }
.t-compras h2 { font-size: 16px; font-weight: 650; letter-spacing: -.01em; margin: 0; display: flex; align-items: center; gap: 8px; }
.t-compras p { margin: 0 0 8px; }
.t-compras p:last-child { margin-bottom: 0; }
.t-compras a { color: inherit; }
.t-compras .muted { color: var(--muted); }
.t-compras small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.t-compras .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.t-compras .i { width: 18px; height: 18px; fill: currentColor; flex: none; }

.t-compras .btn { appearance: none; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: var(--r-control); padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; text-decoration: none; transition: background-color .15s, border-color .15s, transform .12s cubic-bezier(.23, 1, .32, 1); }
.t-compras .btn:hover { background: var(--surface-2); }
.t-compras .btn:active { transform: scale(.98); }
.t-compras .btn:disabled { opacity: .65; cursor: progress; }
.t-compras .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.t-compras .btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.t-compras .link { appearance: none; border: 0; background: none; padding: 0; font: inherit; color: var(--accent); cursor: pointer; font-weight: 600; }
.t-compras .link:hover { text-decoration: underline; }
.t-compras select { appearance: none; font: inherit; color: var(--text); background: var(--surface) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 256 256"><path fill="%235a6371" d="M213.66 101.66l-80 80a8 8 0 0 1-11.32 0l-80-80a8 8 0 0 1 11.32-11.32L128 164.69l74.34-74.35a8 8 0 0 1 11.32 11.32z"/></svg>') no-repeat right 10px center; border: 1px solid var(--border-strong); border-radius: var(--r-control); padding: 8px 32px 8px 12px; min-width: 0; }
.t-compras :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.t-compras .wrap { max-width: 1080px; margin: 0 auto; padding: 28px 24px 48px; }
.t-compras .cp-head { margin-bottom: 20px; }
/* The company picker and the section tabs are Personas SOL's (renta.css, shared); here only what differs: the tabs line up with
   the content's column, and the picker's search box */
.t-compras .tabs-inner { max-width: 1080px; padding: 0 14px; }
.t-compras .search { position: relative; display: block; }
.t-compras .search .i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.t-compras .search input { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-control); padding: 9px 11px 9px 34px; }
.t-compras .search input::placeholder { color: var(--muted); opacity: 1; }
.t-compras .cp-kicker { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 6px; }
.t-compras .cp-open { color: var(--text); text-align: left; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-compras .cp-boletas, .t-compras .cp-tc { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.t-compras .cp-empty { margin: 10px 0 0; }
.t-compras .cp-head p { max-width: 62ch; }
.t-compras .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-box); box-shadow: var(--shadow); padding: 20px; }
.t-compras .panel + .panel { margin-top: 16px; }
.t-compras .panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.t-compras .panel-head p { margin: 4px 0 0; max-width: 60ch; }
.t-compras .count { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 0 8px; line-height: 20px; }
.t-compras .pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 9px; border-radius: 999px; white-space: nowrap; line-height: 20px; background: var(--surface-2); color: var(--muted); }
.t-compras .pill[data-tone="ok"] { background: var(--ok-soft); color: var(--ok); }
.t-compras .pill[data-tone="danger"] { background: var(--danger-soft); color: var(--danger); }
.t-compras .pill[data-tone="accent"] { background: var(--accent-soft); color: var(--accent); }
.t-compras .pill[data-tone="warn"] { background: var(--warn-soft); color: var(--warn); }
.t-compras .note { display: flex; gap: 8px; align-items: center; }
.t-compras .note[data-tone="danger"] { color: var(--danger); }

/* The clients that keep the RCE: who, the month and its actions, then what the last download left */
.t-compras .cp-list { list-style: none; margin: 0; padding: 0; }
.t-compras .cp-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; align-items: center; padding: 14px 0; border-top: 1px solid var(--border); }
.t-compras .cp-row:first-child { border-top: 0; padding-top: 4px; }
.t-compras .cp-who { min-width: 0; }
.t-compras .cp-who strong { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-compras .cp-do { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.t-compras .cp-line { grid-column: 1 / -1; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.t-compras .cp-line:empty { display: none; }
.t-compras .cp-fresh { font-size: 12px; }
.t-compras .cp-fresh .pill { margin: 0 2px; }
.t-compras .cp-fresh .link { font-size: 12px; }
.t-compras .cp-status { display: inline-flex; gap: 6px; align-items: center; font-weight: 500; }
.t-compras .cp-status .i { width: 16px; height: 16px; }
.t-compras .cp-status[data-tone="ok"] .i { color: var(--ok); }
.t-compras .cp-status[data-tone="danger"] { color: var(--danger); }
.t-compras .cp-status[data-tone="accent"] { color: var(--accent); }
.t-compras .cp-status[data-tone="warn"] { color: var(--warn); }
.t-compras .cp-tc[data-tone="warn"] { color: var(--warn); }
.t-compras .cp-tc[data-tone="ok"] .i { color: var(--ok); }

/* The comprobantes of the chosen month */
.t-compras .table-wrap { grid-column: 1 / -1; overflow-x: auto; margin-top: 4px; border: 1px solid var(--border); border-radius: var(--r-control); }
.t-compras .cp-docs { width: 100%; border-collapse: collapse; font-size: 13px; }
.t-compras .cp-docs th, .t-compras .cp-docs td { padding: 8px 12px; text-align: left; border-top: 1px solid var(--border); vertical-align: top; }
.t-compras .cp-docs thead th { border-top: 0; background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--muted); }
.t-compras .cp-docs .num { text-align: right; white-space: nowrap; }
.t-compras .cp-docs .cp-desc { min-width: 220px; max-width: 420px; }
.t-compras .cp-docs td[data-label="Comprobante"] { white-space: nowrap; }
.t-compras .cp-docs .cp-clamp { display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Not checked yet, not in SIRE, clave refused: names only */
.t-compras .cp-names { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 24px; }
.t-compras .cp-names li { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; min-width: 0; }
.t-compras .cp-names small { display: inline; }
.t-compras .cp-fold summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; }
.t-compras .cp-fold summary::-webkit-details-marker { display: none; }
.t-compras .cp-fold summary .i { color: var(--muted); transition: transform .2s cubic-bezier(.23, 1, .32, 1); }
.t-compras .cp-fold[open] summary .i { transform: rotate(180deg); }
.t-compras .cp-fold[open] summary { margin-bottom: 8px; }
.t-compras .cp-fold p { font-size: 13px; }

.t-compras .skeleton { display: grid; gap: 16px; }
.t-compras .skeleton span { display: block; height: 140px; border-radius: var(--r-box); background: var(--skeleton); }
@media (prefers-reduced-motion: no-preference) {
  .t-compras .cp-status[data-tone="accent"] .i, .t-compras .btn:disabled .i { animation: cp-spin .9s linear infinite; }
  @keyframes cp-spin { to { transform: rotate(360deg); } }
}

/* Phones: each client is a card, the month and its button take the width, the table becomes rows of label and value */
@media (min-width: 768px) {
  .t-compras .cp-docs td[data-label="Documento"] { white-space: nowrap; }
  .t-compras .cp-docs td[data-label="Emisor"] { min-width: 170px; }
}
@media (max-width: 767px) {
  .t-compras .wrap { padding: 20px 16px 40px; }
  .t-compras .panel { padding: 16px; }
  .t-compras .panel-head { flex-direction: column; }
  .t-compras .panel-head .btn { width: 100%; }
  .t-compras .cp-row { grid-template-columns: 1fr; }
  .t-compras .cp-do { flex-wrap: wrap; justify-content: stretch; }
  .t-compras .cp-do select { flex: 1 1 100%; }
  .t-compras .cp-do .btn { flex: 1; }
  .t-compras .cp-docs thead { display: none; }
  .t-compras .cp-docs tr { display: block; padding: 8px 12px; border-top: 1px solid var(--border); }
  .t-compras .cp-docs tr:first-child { border-top: 0; }
  .t-compras .cp-docs td { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border: 0; text-align: right; }
  .t-compras .cp-docs td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; }
  .t-compras .cp-docs td small { text-align: right; }
  .t-compras .cp-docs .num { text-align: right; }
  .t-compras .cp-docs .cp-desc { min-width: 0; max-width: none; }
}

/* Ajustes (ajustes.js): the non-sanction window, each client's risk, and its generated months against SUNAT */
.t-compras .aj-window { display: flex; gap: 10px; align-items: flex-start; background: var(--accent-soft); color: var(--text); border-radius: var(--r-box); padding: 12px 16px; margin: 0 0 16px; font-size: 13px; }
.t-compras .aj-window .i { color: var(--accent); margin-top: 1px; }
.t-compras .aj-row .cp-do .pill { white-space: normal; text-align: center; }
.t-compras .aj-when { display: inline; }
.t-compras .aj-meses td small { display: block; }
.t-compras .aj-meses .aj-gap td { background: var(--danger-soft); }
.t-compras .aj-meses .aj-check td { background: var(--warn-soft); }
.t-compras .aj-meses .aj-dj td { border-top: 0; padding-top: 0; font-size: 12px; color: var(--muted); }
.t-compras .aj-meses .aj-dj.aj-check td { color: var(--text); }
.t-compras .aj-meses .aj-dj p { margin: 0 0 2px; max-width: 90ch; }
.t-compras .aj-meses .aj-dj p.aj-fresh { color: var(--muted); margin-top: 4px; }
.t-compras .aj-fresh .pill { margin: 0 2px; }
.t-compras .aj-fresh .link { font-size: 12px; }
.t-compras .aj-meses .aj-tipo td { border-top: 0; padding-top: 2px; color: var(--muted); }
.t-compras .aj-meses .aj-tipo td:first-child { padding-left: 28px; }
.t-compras .aj-foot { grid-column: 1 / -1; font-size: 12px; margin: 6px 0 0; }
.t-compras .aj-armar { display: block; margin-top: 4px; font-size: 12px; }
.t-compras .aj-form { grid-column: 1 / -1; margin-top: 8px; padding: 16px; border: 1px solid var(--border-strong); border-radius: var(--r-box); background: var(--surface-2); }
.t-compras .aj-form h3 { font-size: 15px; font-weight: 650; margin: 0 0 8px; }
.t-compras .aj-form p { font-size: 13px; max-width: 80ch; }
.t-compras .aj-form textarea { display: block; width: 100%; margin: 8px 0 12px; font: 13px/1.5 ui-monospace, "Geist Mono", Consolas, monospace; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-control); padding: 10px 12px; resize: vertical; }
.t-compras .aj-form input { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-control); padding: 7px 10px; width: 72px; margin-left: 8px; }
.t-compras .aj-form-do { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.t-compras .aj-form-do label { margin-right: auto; font-size: 13px; font-weight: 500; }
@media (max-width: 767px) {
  .t-compras .tabs-inner { padding: 0 6px; }
  .t-compras .aj-row .cp-do { justify-content: flex-start; }
  .t-compras .aj-meses .aj-tipo td:first-child { padding-left: 0; }
  .t-compras .aj-meses .aj-tipo { padding-left: 16px; }
  .t-compras .aj-meses td.aj-blank { display: none; }
  .t-compras .aj-meses .aj-dj td { display: block; text-align: left; }
  .t-compras .aj-form-do .btn { flex: 1; }
  .t-compras .aj-form-do label { flex: 1 1 100%; }
}

/* Declaraciones y pagos (declaraciones.js): the year, Leer de SUNAT, then each month's declarations beside its payments */
.t-compras .dj-bar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 12px; }
.t-compras .seg { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-control); padding: 3px; }
.t-compras .seg button { appearance: none; border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); padding: 6px 16px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.t-compras .seg button:hover { color: var(--text); }
.t-compras .seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.t-compras .dj-when, .t-compras .dj-empty { font-size: 13px; }
.t-compras p.cp-status { display: flex; margin: 0 0 12px; font-size: 13px; }
.t-compras .dj-meses, .t-compras .dj-decl, .t-compras .dj-pagos { list-style: none; margin: 0; padding: 0; }
.t-compras .dj-mes { padding: 16px 0; border-top: 1px solid var(--border); }
.t-compras .dj-mes h3 { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 15px; font-weight: 650; margin: 0 0 10px; }
.t-compras .dj-total { font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.t-compras .dj-cols { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 12px 32px; }
.t-compras .dj-cols h4 { font-size: 12px; font-weight: 600; color: var(--muted); margin: 0 0 6px; }
.t-compras .dj-none { font-size: 13px; margin: 0; }
.t-compras .dj-do { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.t-compras .dj-fresh { font-size: 12px; margin: -4px 0 10px; }
.t-compras .dj-fresh .pill { margin: 0 2px; }
.t-compras .dj-sin621 { font-size: 13px; margin: -4px 0 10px; }
.t-compras .dj-sin621 .pill { margin-right: 4px; white-space: normal; }
.t-compras .dj-decl > li + li { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.t-compras .dj-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.t-compras .dj-form strong { font-weight: 600; }
.t-compras .dj-montos { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 6px 0 0; font-size: 13px; }
.t-compras .dj-montos dt { color: var(--muted); font-size: 12px; }
.t-compras .dj-montos dd { margin: 0; font-weight: 600; white-space: nowrap; }
.t-compras .dj-pagos li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 4px 0; font-size: 13px; }
.t-compras .dj-pagos li + li { border-top: 1px dashed var(--border); }
.t-compras .dj-pagos strong { white-space: nowrap; font-weight: 600; }
.t-compras .dj-what { min-width: 0; }
/* Detracciones: each month's two sides, its deposits and its PDF */
.t-compras .dt-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px 24px; align-items: center; }
.t-compras .dt-side { display: grid; gap: 2px; font-size: 13px; }
.t-compras .dt-side .muted { font-size: 12px; }
.t-compras .dt-side strong { font-weight: 600; }
.t-compras .dt-do { display: flex; gap: 16px; align-items: center; justify-content: flex-end; }
.t-compras .dt-mes .table-wrap { margin-top: 12px; }
.t-compras .dt-rango { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: end; margin-top: 10px; }
.t-compras .dt-fecha { display: grid; gap: 2px; font-size: 12px; }
.t-compras .dt-fecha input { font: inherit; font-size: 13px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: inherit; }
.t-compras .dt-docs td[data-label="Comprobante"], .t-compras .dt-docs td[data-label="Fecha de pago"] { white-space: nowrap; }
@media (max-width: 767px) {
  .t-compras .dj-cols { grid-template-columns: 1fr; }
  .t-compras .dt-row { grid-template-columns: 1fr 1fr; }
  .t-compras .dt-do { grid-column: 1 / -1; justify-content: space-between; }
  .t-compras .dt-do .btn { margin-left: auto; }
  .t-compras .dt-fecha { flex: 1 1 9rem; }
  .t-compras .dj-bar .seg, .t-compras .dj-bar .btn, .t-compras .dj-do { width: 100%; }
}
