:root {
  --bg: #F7F4EB;
  --surface: #FFFFFF;
  --panel: #EAE4D3;
  --ink: #111111;
  --muted: #3D3A33;
  --amber: #FFD026;
  --accent: #FF7A59;
  --on-highlight: #111111;
  --border: #111111;
  --shadow-color: #111111;
  --error-bg: #FFE5E0;
  --error-ink: #111111;
  --success-bg: #DFF5E3;
  --success-ink: #111111;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Consolas', 'Courier New', monospace;
}

[data-theme="dark"] {
  --bg: #141413;
  --surface: #1F1E1B;
  --panel: #2B2925;
  --ink: #F7F4EB;
  --muted: #CBC5B5;
  --amber: #FFD026;
  --accent: #FF7A59;
  --on-highlight: #111111;
  --border: #F7F4EB;
  --shadow-color: #000000;
  --error-bg: #4A1C16;
  --error-ink: #F7F4EB;
  --success-bg: #163D22;
  --success-ink: #F7F4EB;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.45;
  overflow-x: hidden;
  min-height: 100dvh;
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  background: var(--amber);
  color: var(--on-highlight);
  padding: 10px 16px;
  border: 2px solid var(--border);
  font-weight: 700;
  z-index: 1000;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

/* Topbar */
.topbar {
  background-color: var(--surface);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-inner {
  max-width: 1360px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stamp-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--amber);
  color: var(--on-highlight);
  border: 2px solid #111111;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.78rem;
  padding: 3px 8px;
  border-radius: 0;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.brand-title {
  font-size: clamp(1rem, 1.5vw, 1.2rem);
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.02em;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  min-width: 44px;
  padding: 8px 14px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
  background-color: var(--surface);
  border: 2px solid var(--border);
  border-radius: 4px;
  box-shadow: 3px 3px 0px var(--shadow-color);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.btn:hover {
  background-color: var(--panel);
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0px var(--shadow-color);
}

.btn-primary {
  background-color: var(--accent);
  color: var(--on-highlight);
  border-color: #111111;
}

.btn-primary:hover {
  background-color: #ff6742;
  color: var(--on-highlight);
}

.btn-amber {
  background-color: var(--amber);
  color: var(--on-highlight);
  border-color: #111111;
}

.btn-amber:hover {
  background-color: #f5c400;
  color: var(--on-highlight);
}

.btn-sm {
  min-height: 44px;
  padding: 6px 12px;
  font-size: 0.82rem;
}

/* Main Layout */
.main-container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 20px 24px 36px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Status Banner */
.status-banner {
  border: 2px solid var(--border);
  padding: 10px 16px;
  border-radius: 4px;
  box-shadow: 3px 3px 0px var(--shadow-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.9rem;
  font-weight: 700;
}

.status-banner[hidden] {
  display: none;
}

.status-banner.is-loading {
  background-color: var(--amber);
  color: var(--on-highlight);
  border-color: #111111;
}

.status-banner.is-error {
  background-color: var(--error-bg);
  color: var(--error-ink);
}

.status-banner.is-success {
  background-color: var(--success-bg);
  color: var(--success-ink);
}

/* Top Summary Strip (4 Clean KPI Cells) */
.focal-ledger-strip {
  background-color: var(--surface);
  border: 2px solid var(--border);
  border-radius: 6px;
  box-shadow: 4px 4px 0px var(--shadow-color);
  display: grid;
  grid-template-columns: repeat(3, 1fr) 1.35fr;
  overflow: hidden;
}

.focal-cell {
  padding: 16px 20px;
  border-right: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.focal-cell:last-child {
  border-right: none;
  background-color: var(--amber);
  color: var(--on-highlight);
}

.focal-label {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.focal-cell:last-child .focal-label,
.focal-cell:last-child .focal-value,
.focal-cell:last-child .focal-sub {
  color: #111111;
}

.focal-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.2rem, 2vw, 1.55rem);
  font-weight: 800;
  color: var(--ink);
  line-height: 1.15;
}

.focal-sub {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

/* 2-Column Workspace Grid */
.workspace-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 20px;
  align-items: stretch;
}

.ledger-card {
  background-color: var(--surface);
  border: 2px solid var(--border);
  border-radius: 6px;
  box-shadow: 4px 4px 0px var(--shadow-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ledger-card-header {
  background-color: var(--panel);
  border-bottom: 2px solid var(--border);
  padding: 10px 16px;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.ledger-card-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ledger-card-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.ledger-card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: space-between;
  gap: 14px;
}

/* Compact 3-Month Upload Rows */
.month-slots-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.month-slot {
  background-color: var(--bg);
  border: 2px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 42px 155px 1fr;
  gap: 10px;
  align-items: center;
}

.slot-number {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.8rem;
  background-color: var(--amber);
  color: var(--on-highlight);
  border: 2px solid #111111;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Form Controls */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-label {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--ink);
}

.input-text,
.input-select,
.input-file,
.input-textarea {
  width: 100%;
  min-height: 44px;
  padding: 7px 11px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  color: var(--ink);
  background-color: var(--surface);
  border: 2px solid var(--border);
  border-radius: 4px;
}

.input-file {
  padding: 6px 8px;
  font-size: 0.82rem;
}

.input-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.input-textarea {
  min-height: 68px;
  resize: vertical;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.card-footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 2px dashed var(--border);
}

/* Artist Table Toolbar & Grid */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 280px;
  max-width: 440px;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.table-scroll-container {
  width: 100%;
  overflow-x: auto;
  border: 2px solid var(--border);
  border-radius: 4px;
  background-color: var(--surface);
}

.royalty-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.royalty-table th,
.royalty-table td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.royalty-table th:last-child,
.royalty-table td:last-child {
  border-right: none;
}

.royalty-table thead th {
  background-color: var(--panel);
  color: var(--ink);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 800;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.royalty-table tbody tr:hover {
  background-color: var(--panel);
}

.royalty-table tfoot td {
  background-color: var(--amber);
  color: var(--on-highlight);
  font-family: var(--font-mono);
  font-weight: 800;
  border-top: 2px solid #111111;
  border-bottom: none;
}

.num-col {
  text-align: right !important;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.net-idr-cell {
  font-weight: 800;
  background-color: rgba(255, 208, 38, 0.16);
}

/* Empty State Box */
.empty-state-box {
  padding: 32px 20px;
  text-align: center;
  border: 2px dashed var(--border);
  border-radius: 4px;
  background-color: var(--bg);
}

.empty-state-title {
  font-size: 1.05rem;
  font-weight: 800;
  margin: 0 0 6px 0;
}

.empty-state-desc {
  color: var(--muted);
  font-size: 0.88rem;
  max-width: 480px;
  margin: 0 auto 14px auto;
}

/* Login Screen */
.login-wrapper {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background-color: var(--surface);
  border: 3px solid var(--border);
  border-radius: 6px;
  box-shadow: 6px 6px 0px var(--shadow-color);
  overflow: hidden;
}

.login-header {
  background-color: var(--amber);
  color: var(--on-highlight);
  border-bottom: 3px solid #111111;
  padding: 18px 22px;
}

.login-body {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(17, 17, 17, 0.78);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-window {
  width: 100%;
  max-width: 860px;
  background-color: var(--surface);
  border: 3px solid var(--border);
  border-radius: 6px;
  box-shadow: 6px 6px 0px var(--shadow-color);
  margin: auto 0;
  overflow: hidden;
}

.modal-header {
  background-color: var(--panel);
  border-bottom: 2px solid var(--border);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.modal-body {
  padding: 20px;
}

/* Printable Invoice Sheet */
.invoice-sheet {
  background-color: #FFFFFF;
  color: #111111;
  border: 3px solid #111111;
  padding: 28px;
  font-family: var(--font-sans);
}

.invoice-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  border-bottom: 3px solid #111111;
  padding-bottom: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.invoice-logo-box {
  display: inline-block;
  background-color: #FFD026;
  color: #111111;
  border: 2px solid #111111;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.85rem;
  padding: 4px 10px;
  margin-bottom: 8px;
}

.invoice-company-name {
  font-size: 1.3rem;
  font-weight: 800;
  margin: 0 0 4px 0;
  color: #111111;
}

.invoice-company-meta {
  font-size: 0.84rem;
  color: #3D3A33;
  margin: 2px 0;
}

.invoice-doc-badge {
  text-align: right;
}

.invoice-doc-title {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 800;
  background-color: #111111;
  color: #FFFFFF;
  padding: 5px 12px;
  display: inline-block;
  margin: 0 0 6px 0;
}

.invoice-artist-banner {
  background-color: #F7F4EB;
  border: 2px solid #111111;
  padding: 14px 18px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.invoice-artist-name {
  font-size: 1.25rem;
  font-weight: 800;
  margin: 2px 0 0 0;
  color: #111111;
}

.invoice-breakdown-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  color: #111111;
}

.invoice-breakdown-table th,
.invoice-breakdown-table td {
  border: 2px solid #111111;
  padding: 9px 12px;
  font-size: 0.88rem;
}

.invoice-breakdown-table thead th {
  background-color: #EAE4D3;
  color: #111111;
  font-weight: 800;
  text-align: left;
}

.invoice-breakdown-table .row-deduction td {
  background-color: #FFF5F2;
  color: #111111;
}

.invoice-breakdown-table .row-subtotal td {
  background-color: #F7F4EB;
  font-weight: 700;
}

.invoice-total-banner {
  background-color: #FFD026;
  color: #111111;
  border: 3px solid #111111;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.invoice-total-label {
  font-size: 0.95rem;
  font-weight: 800;
  text-transform: uppercase;
}

.invoice-total-amount {
  font-family: var(--font-mono);
  font-size: clamp(1.3rem, 2.3vw, 1.75rem);
  font-weight: 800;
  color: #111111;
}

.invoice-footer-grid {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 20px;
  align-items: end;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 2px dashed #111111;
}

.invoice-sign-box {
  text-align: right;
}

.invoice-sign-line {
  display: inline-block;
  min-width: 180px;
  border-bottom: 2px solid #111111;
  height: 44px;
  margin-bottom: 6px;
}

/* Tablet Breakpoint (680px - 1080px) */
@media (max-width: 1080px) {
  .focal-ledger-strip {
    grid-template-columns: 1fr 1fr;
  }
  .focal-cell:nth-child(2) {
    border-right: none;
  }
  .focal-cell:nth-child(1),
  .focal-cell:nth-child(2) {
    border-bottom: 2px solid var(--border);
  }
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

/* Mobile Breakpoint (< 680px) */
@media (max-width: 680px) {
  .topbar-inner {
    padding: 10px 14px;
  }
  .main-container {
    padding: 14px;
    gap: 16px;
  }
  .focal-ledger-strip {
    grid-template-columns: 1fr;
  }
  .focal-cell {
    border-right: none;
    border-bottom: 2px solid var(--border);
    padding: 12px 14px;
  }
  .focal-cell:last-child {
    border-bottom: none;
  }
  .month-slot {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .slot-number {
    width: fit-content;
    padding: 0 10px;
    height: 28px;
  }
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
  .invoice-sheet {
    padding: 16px;
  }
  .invoice-doc-badge,
  .invoice-sign-box {
    text-align: left;
  }
  .invoice-footer-grid {
    grid-template-columns: 1fr;
  }
}

/* Print Rules */
@media print {
  @page {
    size: A4 portrait;
    margin: 12mm;
  }
  body {
    background: #FFFFFF !important;
    color: #111111 !important;
  }
  .no-print,
  .topbar,
  .main-container,
  .modal-header,
  .skip-link {
    display: none !important;
  }
  .modal-backdrop {
    position: static !important;
    background: transparent !important;
    padding: 0 !important;
    display: block !important;
    overflow: visible !important;
  }
  .modal-window {
    max-width: 100% !important;
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
  }
  .modal-body {
    padding: 0 !important;
  }
  .invoice-sheet {
    border: 2px solid #111111 !important;
    box-shadow: none !important;
    padding: 20px !important;
    page-break-inside: avoid;
  }
}
