:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  color: #1d1d1f;
  background: #f5f5f7;
  --line: #e5e5ea;
  --muted: #6e6e73;
  --soft: #f7f7f9;
  --blue: #0071e3;
  --green: #16833a;
  --red: #d70015;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  background: #f5f5f7;
}

button,
input {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100vw - 48px));
  margin: 34px auto;
  border-radius: 28px;
  padding: 34px;
  background: #fff;
  box-shadow: 0 28px 70px rgb(0 0 0 / 7%);
}

.viewer-header {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(40px, 5vw, 64px);
  line-height: 1;
  letter-spacing: 0;
}

.lead {
  max-width: 660px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 17px;
  font-weight: 650;
  line-height: 1.42;
}

.primary-button,
.small-button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid #d8d8de;
  border-radius: 999px;
  padding: 0 18px;
  background: #fff;
  color: #1d1d1f;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  flex: 0 0 auto;
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.small-button {
  min-height: 32px;
  padding: 0 13px;
  font-size: 12px;
}

.drop-zone {
  display: grid;
  gap: 6px;
  margin-top: 28px;
  border: 1px dashed #cfd1d8;
  border-radius: 20px;
  padding: 28px;
  background: var(--soft);
  color: var(--muted);
  text-align: center;
}

.drop-zone.drag-over {
  border-color: var(--blue);
  background: #f0f7ff;
}

.drop-zone strong {
  color: #1d1d1f;
  font-size: 17px;
}

.drop-zone small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.book-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 20px;
  background: #fff;
}

.book-summary h2 {
  margin-bottom: 6px;
  font-size: 24px;
}

.book-summary span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.summary-stat {
  display: grid;
  gap: 4px;
  text-align: right;
}

.summary-stat strong {
  color: var(--green);
  font-size: 22px;
}

.viewer-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.entry-list-panel,
.entry-detail-panel {
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
}

.entry-list-panel {
  padding: 16px;
}

.panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 20px;
}

.panel-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

#entry-search {
  width: 100%;
  height: 38px;
  border: 1px solid #d8d8de;
  border-radius: 12px;
  padding: 0 13px;
  outline: none;
}

.entry-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.entry-card {
  display: grid;
  gap: 5px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 12px;
  background: var(--soft);
  text-align: left;
  cursor: pointer;
}

.entry-card:hover,
.entry-card.active {
  border-color: #b7cdf2;
  background: #f4f8ff;
}

.entry-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.entry-detail-panel {
  overflow: hidden;
}

.empty-detail {
  display: grid;
  min-height: 560px;
  place-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-detail strong {
  color: #1d1d1f;
}

.entry-detail {
  padding: 22px;
}

.entry-detail-header {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.entry-detail-header h2 {
  margin-bottom: 8px;
  font-size: 28px;
}

.entry-date {
  color: var(--muted);
  font-weight: 800;
}

.entry-total {
  display: grid;
  gap: 5px;
  text-align: right;
}

.entry-total span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.entry-total strong {
  color: var(--green);
  font-size: 22px;
}

.lines-table {
  overflow: hidden;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.line-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 120px;
  gap: 12px;
  align-items: center;
  min-height: 44px;
  border-bottom: 1px solid var(--line);
  padding: 0 14px;
  font-weight: 750;
}

.line-row:last-child {
  border-bottom: 0;
}

.line-row.header {
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.line-row span:nth-child(2),
.line-row span:nth-child(3) {
  text-align: right;
}

.account-subtitle {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.attachments-section {
  margin-top: 22px;
}

.attachments-section h3 {
  margin-bottom: 12px;
  font-size: 18px;
}

.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.attachment-tile {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: #fff;
}

.file-icon {
  display: inline-grid;
  width: 48px;
  height: 56px;
  place-items: center;
  border: 1px solid #bfe3ce;
  border-radius: 9px;
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
}

.attachment-tile strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-tile span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.preview-box {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--soft);
}

.preview-box img,
.preview-box iframe {
  display: block;
  width: 100%;
  height: 280px;
  border: 0;
  object-fit: contain;
}

.attachment-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.error-message {
  color: var(--red);
}

@media (max-width: 860px) {
  .shell {
    width: min(100vw - 24px, 1180px);
    padding: 22px;
  }

  .viewer-header,
  .book-summary,
  .viewer-layout {
    grid-template-columns: 1fr;
  }

  .viewer-header {
    display: grid;
  }

  .summary-stat {
    text-align: left;
  }

  .line-row {
    grid-template-columns: minmax(0, 1fr) 80px 80px;
  }
}
