/* Books (bookkeeping) tab. Built on the dashboard's existing HUD tokens
   (--accent amber, --cyan, --good, --bad) and components (.panel, .btn,
   .sales-stat, .config-form, .calendar-event-modal). */

.books-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.books-period {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.books-select,
.books-input {
  background: var(--track);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  min-height: 36px;
}
.books-select:focus-visible,
.books-input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }
.books-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.books-stats { grid-template-columns: repeat(4, minmax(150px, 1fr)); }
.books-stats .sales-stat-value.neg { color: var(--bad); }
.books-stats .sales-stat-sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Attention strip: the three things that make an accountant chase you. */
.books-attention { display: flex; gap: 10px; flex-wrap: wrap; }
.books-flag {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--track);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.books-flag strong {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  color: var(--accent-bright);
}
.books-flag.clear strong { color: var(--good); }
.books-flag:hover { border-color: var(--accent); }
.books-flag:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* Month bars: income (cyan) against expenses (amber). */
.books-months {
  display: grid;
  grid-template-columns: repeat(12, minmax(36px, 1fr));
  gap: 8px;
  align-items: end;
  height: 190px;
  padding-top: 10px;
  overflow-x: auto;
}
.books-month { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.books-month-bars {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  border-bottom: 1px solid var(--panel-border);
}
.books-month-bar { width: 42%; max-width: 18px; border-radius: 3px 3px 0 0; min-height: 0; }
.books-month-bar.in { background: linear-gradient(180deg, var(--cyan), rgba(52,237,243,0.35)); box-shadow: 0 0 10px rgba(52,237,243,0.35); }
.books-month-bar.out { background: linear-gradient(180deg, var(--accent-bright), var(--accent-dim)); box-shadow: 0 0 10px rgba(255,158,44,0.3); }
.books-month-label { font-size: 11px; color: var(--muted); }
.books-legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.books-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

.books-cats { display: grid; gap: 8px; }
.books-cat-row {
  display: grid;
  grid-template-columns: minmax(140px, 240px) 1fr auto;
  gap: 12px;
  align-items: center;
  font-size: 13px;
}
.books-cat-track { height: 8px; background: var(--track); border-radius: 4px; overflow: hidden; }
.books-cat-fill { height: 100%; background: linear-gradient(90deg, var(--accent-dim), var(--accent)); border-radius: 4px; }
.books-cat-row.in .books-cat-fill { background: linear-gradient(90deg, rgba(52,237,243,0.35), var(--cyan)); }
.books-num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.books-num.in { color: var(--good); }

/* Ledger */
.books-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.books-filters .books-input { flex: 1 1 200px; }
.books-ledger { display: grid; gap: 0; }
.books-row {
  display: grid;
  grid-template-columns: 92px minmax(160px, 1fr) 210px 110px 80px 34px 64px;
  gap: 10px;
  align-items: center;
  padding: 9px 4px;
  border-bottom: 1px solid rgba(52,237,243,0.08);
  font-size: 13px;
}
.books-row.head {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  border-bottom-color: var(--panel-border);
}
.books-row.review { background: linear-gradient(90deg, rgba(255,158,44,0.07), transparent 60%); }
.books-desc { min-width: 0; }
.books-desc .v { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.books-desc .d { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.books-tag {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: 1px;
  border: 1px solid var(--accent-dim);
  color: var(--accent-bright);
  font-weight: 600;
}
.books-tag.cyan { border-color: rgba(52,237,243,0.4); color: var(--cyan); }
.books-row .books-select { width: 100%; padding: 6px 8px; min-height: 32px; font-size: 12px; }
.books-icon-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.books-icon-btn:hover { color: var(--text); border-color: var(--panel-border); }
.books-icon-btn.has { color: var(--cyan); }
.books-icon-btn.missing { color: var(--accent); }
.books-rowactions { display: flex; gap: 2px; justify-content: flex-end; }

.books-rule-offer {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  margin: 6px 0 10px;
  border: 1px solid rgba(52,237,243,0.3);
  border-radius: 8px;
  background: rgba(52,237,243,0.05);
  font-size: 13px;
}

/* Import */
.books-drop {
  border: 1.5px dashed rgba(52,237,243,0.35);
  border-radius: 12px;
  padding: 28px 18px;
  text-align: center;
  background: rgba(52,237,243,0.03);
  cursor: pointer;
}
.config-form label.books-drop {
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  font-size: 13px;
  color: var(--text);
}
.books-drop.drag { border-color: var(--accent); background: rgba(255,158,44,0.06); }
.books-drop strong { display: block; font-size: 16px; margin-bottom: 6px; }
.books-drop input[type="file"] { display: none; }
.books-progress { display: grid; gap: 6px; margin-top: 14px; font-size: 13px; }
.books-progress .line { display: flex; justify-content: space-between; gap: 10px; }
.books-progress .ok { color: var(--good); }
.books-progress .err { color: var(--bad); }

.books-recon {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--track);
  margin-bottom: 14px;
}
.books-recon .k { font-size: 11px; color: var(--muted); }
.books-recon .v { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 3px; }
.books-recon.good { border-color: rgba(53,242,166,0.5); }
.books-recon.bad { border-color: rgba(255,59,48,0.6); }
.books-recon .verdict { grid-column: 1 / -1; font-size: 13px; }
.books-recon.good .verdict { color: var(--good); }
.books-recon.bad .verdict { color: var(--bad); }

.books-review .books-row { grid-template-columns: 28px 138px minmax(160px, 1fr) 200px 110px 90px 130px; }
.books-review .books-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.books-review .books-row .books-input { width: 100%; padding: 6px 8px; min-height: 32px; font-size: 12px; }
.books-status { font-size: 11px; color: var(--muted); }
.books-status.dup { color: var(--muted); }
.books-status.link { color: var(--cyan); }
.books-status.new { color: var(--good); }

/* Export */
.books-export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}
.books-export-card {
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--track);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.books-export-card h3 { margin: 0; font-size: 15px; }
.books-export-card p { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.45; flex: 1; }
.books-export-card.primary {
  border-color: transparent;
  background:
    linear-gradient(155deg, rgba(14,20,32,0.95), rgba(6,9,15,0.9)) padding-box,
    linear-gradient(135deg, var(--cyan), var(--accent) 55%, var(--accent-dim)) border-box;
  border: 1px solid transparent;
}
.books-ready { margin-top: 12px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; font-size: 13px; }
.books-seg { display: inline-flex; border: 1px solid var(--panel-border); border-radius: 8px; overflow: hidden; }
.books-seg button {
  background: var(--track);
  color: var(--muted);
  border: 0;
  padding: 8px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.books-seg button.active { background: rgba(255,158,44,0.14); color: var(--accent-bright); }

.books-pl { width: 100%; border-collapse: collapse; font-size: 13px; }
.books-pl td { padding: 6px 4px; border-bottom: 1px solid rgba(52,237,243,0.08); }
.books-pl tr.total td { font-weight: 700; border-bottom-color: var(--panel-border); }
.books-pl tr.section td { padding-top: 14px; color: var(--muted); font-size: 11px; font-weight: 700; }
.books-pl .code { color: var(--muted); font-size: 11px; width: 54px; }

/* Entry modal */
.books-modal { max-width: 560px !important; }
.books-modal .config-form { max-width: none; gap: 12px; }
.books-modal select,
.books-modal .config-form input[type="text"],
.books-modal .config-form input[type="number"],
.books-modal .config-form input[type="date"] {
  width: 100%;
  background: var(--track);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
.books-modal textarea { min-height: 60px !important; }
.books-two { display: flex; gap: 10px; flex-wrap: wrap; }
.books-two > div { flex: 1; min-width: 140px; }
.books-hst-row { display: flex; gap: 6px; }
.books-hst-row input { flex: 1; }
.books-typeseg { width: 100%; }
.books-typeseg button { flex: 1; }
.books-photo {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px;
  border: 1px dashed rgba(52,237,243,0.35);
  border-radius: 10px;
}
.books-photo img { max-height: 64px; max-width: 90px; border-radius: 6px; object-fit: cover; }
.books-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.books-thumbs a { font-size: 12px; color: var(--cyan); }
.books-match {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(52,237,243,0.35);
  background: rgba(52,237,243,0.05);
  font-size: 13px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.books-match input { margin-top: 3px; accent-color: var(--cyan); }
.config-form label.books-match {
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 0;
}
.books-scan-note { font-size: 12px; color: var(--muted); }

@media (max-width: 900px) {
  .books-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .books-row.head { display: none; }
  .books-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "desc amt"
      "cat cat"
      "date act";
    row-gap: 6px;
    padding: 12px 4px;
  }
  .books-row > .c-date { grid-area: date; color: var(--muted); font-size: 12px; }
  .books-row > .books-desc { grid-area: desc; }
  .books-row > .c-cat { grid-area: cat; }
  .books-row > .c-amt { grid-area: amt; font-size: 15px; }
  .books-row > .c-hst { display: none; }
  .books-row > .c-rec { display: none; }
  .books-row > .books-rowactions { grid-area: act; }
  .books-review .books-row {
    grid-template-columns: 28px 1fr auto;
    grid-template-areas:
      "chk desc amt"
      "chk cat cat"
      "chk date st";
  }
  .books-review .books-row > .c-chk { grid-area: chk; }
  .books-review .books-row > .c-hst { display: none; }
  .books-review .books-row > .c-st { grid-area: st; text-align: right; }
  .books-cat-row { grid-template-columns: 1fr auto; }
  .books-cat-track { grid-column: 1 / -1; grid-row: 2; }
}
