/* ==========================================================================
   VISUAL LANGUAGE: "PAPER INVOICE"
   Tactile, editorial financial ledger with rubber-stamped paper aesthetics.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400..800;1,9..144,400..700&family=IBM+Plex+Mono:ital,wght@0,400;0,500;0,600;0,700;1,400;1,600&family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Force light form controls: without this, browsers in dark mode render
     password inputs as black boxes */
  color-scheme: light;
  /* Strict Palette Tokens */
  --paper: #F6F1E7;
  --paper-card: #FDFBF5;
  --paper-hover: #EFE7D6;
  --paper-ruled: #ECE4D3;
  --ink: #1C1710;
  --ink-muted: #6E6455;
  --hairline: #E2D9C4;
  --stamp-red: #B5342A;
  --stamp-green: #2E7D4F;
  --stamp-amber: #A86A12;

  /* Typography */
  --font-serif: "Fraunces", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "IBM Plex Mono", "Courier New", monospace;

  /* Strict Dimensions */
  --radius-card: 3px;
  --radius-btn: 3px;
  --shadow-offset: 3px 3px 0 var(--ink);
  --shadow-offset-sm: 2px 2px 0 var(--ink);
}

/* Base Reset & Grain Overlay */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

/* Subtle Paper Grain Texture (Inline SVG feTurbulence Noise at 3.5% Opacity) */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 99999;
  opacity: 0.038;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='paperNoise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23paperNoise)'/%3E%3C/svg%3E");
}

/* Hairline Scrollbars */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: var(--paper);
}
::-webkit-scrollbar-thumb {
  background: var(--hairline);
  border-radius: 0;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--ink-muted);
}

/* ==========================================================================
   Layout Shell
   ========================================================================== */
#app-root {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: var(--paper);
}

/* ==========================================================================
   Sidebar: Ledger Index Spine
   ========================================================================== */
.sidebar {
  width: 250px;
  min-width: 250px;
  height: 100vh;
  background-color: var(--paper-card);
  border-right: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.5rem 1rem;
  z-index: 40;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.5rem 1.25rem 0.5rem;
  border-bottom: 2px solid var(--ink);
}

.brand-icon {
  width: 34px;
  height: 34px;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 2px 0 var(--ink);
}

.brand-icon svg {
  width: 18px;
  height: 18px;
  color: var(--ink);
  stroke-width: 1.75;
}

.brand-info h1 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.1;
}

.brand-info span {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--ink-muted);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Nav Menu: Ledger Index Tabs */
.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 1.5rem;
}

.nav-item button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.65rem 0.85rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
  color: var(--ink-muted);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.1s ease;
}

.nav-item button svg {
  width: 16px;
  height: 16px;
  stroke: var(--ink-muted);
  stroke-width: 1.5;
  transition: stroke 0.1s ease;
}

.nav-item button:hover {
  background-color: var(--paper-hover);
  color: var(--ink);
  border-color: var(--hairline);
}

.nav-item button:hover svg {
  stroke: var(--ink);
}

.nav-item.active button {
  background-color: var(--paper);
  border: 1px solid var(--ink);
  color: var(--ink);
  font-weight: 700;
  box-shadow: 2px 2px 0 var(--ink);
}

.nav-item.active button svg {
  stroke: var(--ink);
}

.sidebar-footer {
  padding-top: 1rem;
  border-top: 1px solid var(--hairline);
}

.system-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: var(--paper);
  border: 1px solid var(--hairline);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 0;
  background-color: var(--stamp-green);
  border: 1px solid var(--ink);
}

/* ==========================================================================
   Header: Ledger Masthead
   ========================================================================== */
.main-wrapper {
  flex: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.top-header {
  height: 60px;
  min-height: 60px;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--ink);
  background-color: var(--paper-card);
  z-index: 30;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.breadcrumb-active {
  color: var(--ink);
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Buttons: Hard Offset Printed Style */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  border-radius: var(--radius-btn);
  padding: 0.5rem 1rem;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-offset);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.btn-primary:hover {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 var(--ink);
}

.btn-primary:active {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 var(--ink);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--paper-card);
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: var(--radius-btn);
  padding: 0.5rem 0.9rem;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-offset-sm);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.btn-secondary:hover {
  background-color: var(--paper-hover);
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--ink);
}

.btn-icon {
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: var(--radius-btn);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  font-family: var(--font-mono);
  box-shadow: 1px 1px 0 var(--ink);
}

/* Viewport */
.content-viewport {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2rem;
  position: relative;
}

.view-section {
  display: none;
}

.view-section.active {
  display: block;
}

/* ==========================================================================
   SIGNATURE ELEMENT: RUBBER STAMP BADGES
   ========================================================================== */
.status-pill,
.stamp-badge {
  display: inline-block;
  font-family: var(--font-mono) !important;
  font-size: 0.68rem !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.12em !important;
  padding: 0.15rem 0.5rem !important;
  border-radius: 0 !important;
  border: 2px double currentColor !important;
  line-height: 1.1 !important;
  white-space: nowrap !important;
  user-select: none;
}

.status-pill.paid,
.stamp-badge.paid {
  color: var(--stamp-green) !important;
  border-color: var(--stamp-green) !important;
  background-color: transparent !important;
  transform: rotate(-3deg);
}

.status-pill.unpaid,
.stamp-badge.pending,
.stamp-badge.unpaid {
  color: var(--stamp-amber) !important;
  border-color: var(--stamp-amber) !important;
  background-color: transparent !important;
  transform: rotate(2deg);
}

.status-pill.overdue,
.stamp-badge.overdue,
.stamp-badge.failed {
  color: var(--stamp-red) !important;
  border-color: var(--stamp-red) !important;
  background-color: transparent !important;
  transform: rotate(-2.5deg);
}

/* ==========================================================================
   VIEW 1: DASHBOARD (LEDGER MASTHEAD & ENTRIES)
   ========================================================================== */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1.25rem;
  max-width: 1360px;
  margin: 0 auto;
}

/* Ledger Panel (replacing bubbly cards with hairline ruled panels) */
.bento-card {
  background-color: var(--paper-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  position: relative;
}

.bento-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.6rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--hairline);
}

.bento-card-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.bento-card-title svg {
  width: 14px;
  height: 14px;
  stroke: var(--ink);
  stroke-width: 1.75;
}

/* Hero Spend Block */
.bento-hero-spend {
  grid-column: span 6;
  border-left: 4px solid var(--ink);
}

.hero-spend-value {
  font-family: var(--font-serif);
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0.25rem 0 0.5rem 0;
  line-height: 1;
}

.hero-spend-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--hairline);
}

.trend-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--stamp-green);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid var(--stamp-green);
  padding: 0.15rem 0.4rem;
  border-radius: 0;
}

.kpi-subtext {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--ink-muted);
}

/* KPI Count & Ratio */
.bento-kpi-count {
  grid-column: span 3;
}

.bento-kpi-ratio {
  grid-column: span 3;
}

.kpi-value {
  font-family: var(--font-serif);
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0.2rem 0;
  line-height: 1;
}

/* Charts & Ruled Tables */
.bento-chart-trend {
  grid-column: span 8;
  min-height: 320px;
}

.bento-chart-donut {
  grid-column: span 4;
  min-height: 320px;
}

.chart-container {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 220px;
}

/* Settlement Status Ruled Rows */
.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 0.75rem;
  border-top: 1px solid var(--hairline);
}

.donut-legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px dashed var(--hairline);
  font-size: 0.8rem;
}

.donut-legend-row:last-child {
  border-bottom: none;
}

.donut-legend-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.donut-dot {
  width: 6px;
  height: 6px;
  border-radius: 0;
  border: 1px solid var(--ink);
}

/* Vendors Bar Chart */
.bento-chart-vendors {
  grid-column: span 6;
  min-height: 280px;
}

/* Quick Actions Tray */
.bento-quick-action {
  grid-column: span 6;
  min-height: 280px;
  justify-content: space-between;
}

.quick-prompt-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.quick-prompt-btn {
  padding: 0.75rem;
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-btn);
  color: var(--ink);
  font-size: 0.8rem;
  text-align: left;
  cursor: pointer;
  box-shadow: 1px 1px 0 var(--hairline);
  transition: all 0.08s ease;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.quick-prompt-btn strong {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
}

.quick-prompt-btn span {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-muted);
}

.quick-prompt-btn:hover {
  background: var(--paper-hover);
  border-color: var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
}

/* Ruled Ledger Table */
.bento-recent-invoices {
  grid-column: span 12;
}

.data-table-wrapper {
  overflow-x: auto;
  border-top: 1px solid var(--ink);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  padding: 0.65rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  border-bottom: 2px solid var(--ink);
  background: var(--paper-card);
}

.data-table th:last-child,
.data-table td:last-child {
  text-align: right;
}

.data-table th.th-amount,
.data-table td.mono-amount {
  text-align: right;
}

.data-table td {
  padding: 0.75rem 0.85rem;
  font-size: 0.84rem;
  border-bottom: 1px solid var(--hairline);
  color: var(--ink);
  vertical-align: middle;
}

.data-table tbody tr:hover td {
  background-color: var(--paper-hover);
}

.mono-amount {
  font-family: var(--font-mono);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.btn-delete-row {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 0.3rem 0.4rem;
  border-radius: var(--radius-btn);
  transition: all 0.1s ease;
}

.btn-delete-row:hover {
  color: var(--stamp-red);
  border-color: var(--stamp-red);
  background: rgba(181, 52, 42, 0.06);
}

/* ==========================================================================
   VIEW 2: AI COPILOT (CHAT ON PAPER)
   ========================================================================== */
.chat-workspace {
  display: flex;
  height: calc(100vh - 124px);
  background-color: var(--paper-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-offset-sm);
}

.chat-conversations-sidebar {
  width: 270px;
  min-width: 270px;
  background-color: var(--paper);
  border-right: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
}

.chat-sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid var(--hairline);
}

.chat-conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.chat-conv-item {
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-btn);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.08s ease;
}

.chat-conv-item:hover {
  background-color: var(--paper-hover);
  border-color: var(--hairline);
}

.chat-conv-item.active {
  background-color: var(--paper-card);
  border: 1px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
}

.conv-item-title {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-item-date {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--ink-muted);
  margin-top: 0.15rem;
}

.chat-main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--paper-card);
  position: relative;
}

.chat-messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Chat Messages */
.chat-msg {
  display: flex;
  gap: 0.75rem;
  max-width: 82%;
}

.chat-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg.assistant {
  align-self: flex-start;
}

.chat-avatar {
  width: 30px;
  height: 30px;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-btn);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.chat-msg.user .chat-avatar {
  background: var(--ink);
  color: var(--paper);
}

.chat-msg.assistant .chat-avatar {
  background: var(--paper);
  color: var(--ink);
}

.msg-body {
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-card);
  font-size: 0.88rem;
  line-height: 1.7;
}

/* User Ink-Filled Slip */
.chat-msg.user .msg-body {
  background-color: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: 2px 2px 0 rgba(28, 23, 16, 0.2);
}

/* AI Typed Paper Memo */
.chat-msg.assistant .msg-body {
  background-color: var(--paper-card);
  border: 1px solid var(--hairline);
  color: var(--ink);
  box-shadow: 1px 1px 0 var(--hairline);
}

.msg-body h1, .msg-body h2, .msg-body h3 {
  font-family: var(--font-serif);
  margin: 0.5rem 0 0.25rem 0;
  color: var(--ink);
}
.msg-body code {
  font-family: var(--font-mono);
  background: rgba(28, 23, 16, 0.06);
  padding: 0.15rem 0.35rem;
  border: 1px solid var(--hairline);
  font-size: 0.82rem;
}
.msg-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-family: var(--font-mono);
}
.msg-body th, .msg-body td {
  border: 1px solid var(--hairline);
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
}
.msg-body th {
  background: var(--paper);
}

/* Excel Report Tear-off Voucher inside Chat */
.report-download-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--paper);
  border: 2px dashed var(--ink);
  border-radius: 0;
  padding: 0.85rem 1.15rem;
  margin-top: 0.75rem;
  gap: 1rem;
}

.report-file-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.report-file-icon {
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: var(--paper-card);
}

.report-file-info strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 0.9rem;
  color: var(--ink);
}

.report-file-info span {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
}

/* Chat Input Tray */
.chat-input-bar {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--hairline);
  background: var(--paper-card);
}

.chat-input-wrapper {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: var(--radius-btn);
  padding: 0.5rem 0.75rem;
  box-shadow: 2px 2px 0 var(--hairline);
}

.chat-input-wrapper:focus-within {
  box-shadow: 3px 3px 0 var(--ink);
}

.chat-attachment-preview {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--paper-card);
  border: 1px dashed var(--ink);
  padding: 0.25rem 0.5rem;
  margin-bottom: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink);
  width: fit-content;
}

.btn-remove-attachment {
  background: transparent;
  border: none;
  color: var(--stamp-red);
  cursor: pointer;
  font-weight: 700;
  margin-left: 0.25rem;
}

.chat-input-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.chat-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  resize: none;
  max-height: 120px;
}

.btn-chat-attach {
  background: transparent;
  border: none;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 0.35rem;
  transition: color 0.1s ease;
}

.btn-chat-attach:hover {
  color: var(--ink);
}

.btn-chat-send {
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: var(--radius-btn);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--paper);
  cursor: pointer;
  box-shadow: 1px 1px 0 var(--ink);
}

.btn-chat-send:active {
  transform: translate(1px, 1px);
  box-shadow: none;
}

/* ==========================================================================
   VIEW 3: UPLOAD CENTER (INCOMING DOCKET & PROGRESS DOCKET)
   ========================================================================== */
.upload-center-container {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Incoming Tray Dropzone */
.dropzone-card {
  background: var(--paper-card);
  border: 2px dashed var(--ink);
  border-radius: var(--radius-card);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.1s ease;
  position: relative;
}

.dropzone-card:hover, .dropzone-card.dragover {
  background-color: var(--paper-hover);
  box-shadow: 4px 4px 0 var(--ink);
}

.incoming-stamp {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--ink);
  border: 2px double var(--ink);
  padding: 0.2rem 0.6rem;
  margin-bottom: 1rem;
  transform: rotate(-2deg);
}

.dropzone-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.35rem;
}

.dropzone-subtitle {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-muted);
  margin-bottom: 1.5rem;
}

/* Processing Docket (Receipt-Style Stage Checklist) */
.processing-docket {
  background: var(--paper-card);
  border: 1px solid var(--hairline);
  border-top: 4px solid var(--ink);
  padding: 1.5rem;
  box-shadow: var(--shadow-offset-sm);
  display: none;
}

.docket-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.75rem;
  border-bottom: 1px dashed var(--hairline);
  margin-bottom: 1rem;
}

.docket-title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
}

.docket-timer {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--ink-muted);
}

/* Thin Ink Progress Bar */
.ink-progress-bar-bg {
  height: 4px;
  background-color: var(--hairline);
  width: 100%;
  margin-bottom: 1.25rem;
  border-radius: 0;
  overflow: hidden;
}

.ink-progress-bar-fill {
  height: 100%;
  background-color: var(--ink);
  width: 0%;
  transition: width 0.3s ease;
}

.ink-progress-bar-fill.is-indeterminate {
  width: 35% !important;
  animation: inkIndeterminate 1.8s ease-in-out infinite;
}

@keyframes inkIndeterminate {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(180%); }
  100% { transform: translateX(350%); }
}

.docket-inline-spinner {
  display: inline-block;
  width: 8px;
  height: 8px;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: docketSpin 0.75s linear infinite;
  margin-right: 4px;
  vertical-align: middle;
}

@keyframes docketSpin {
  to { transform: rotate(360deg); }
}

/* Checklist Stage Rows */
.docket-stage-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.docket-stage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px dashed var(--hairline);
  font-size: 0.84rem;
}

.docket-stage-name {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-sans);
  color: var(--ink);
}

.docket-stage-status {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.docket-stage-time {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--ink-muted);
}

/* Extraction Result Card */
.extraction-result-card {
  background: var(--paper-card);
  border: 1px solid var(--hairline);
  border-top: 3px solid var(--stamp-green);
  padding: 1.75rem;
  box-shadow: var(--shadow-offset-sm);
  display: none;
}

.extraction-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 1.25rem;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.field-item {
  background: var(--paper);
  border: 1px solid var(--hairline);
  padding: 0.75rem;
}

.field-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--ink-muted);
  letter-spacing: 0.08em;
  margin-bottom: 0.2rem;
}

.field-value {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
}

/* ==========================================================================
   VIEW 4: INVOICES LEDGER (THE HERO SCREEN)
   ========================================================================== */
.ledger-container {
  max-width: 1360px;
  margin: 0 auto;
  background: var(--paper-card);
  border: 1px solid var(--hairline);
  border-top: 3px solid var(--ink);
  padding: 1.5rem;
  box-shadow: var(--shadow-offset-sm);
}

.ledger-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.search-input-wrapper {
  position: relative;
  width: 320px;
}

.search-input-wrapper input {
  width: 100%;
  padding: 0.55rem 0.85rem 0.55rem 2.2rem;
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-btn);
  color: var(--ink);
  outline: none;
  font-family: var(--font-sans);
  font-size: 0.84rem;
}

.search-input-wrapper input:focus {
  border-color: var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
}

.search-icon-pos {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-muted);
}

/* Folder / Binder Index Tabs */
.filter-pills {
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 2px solid var(--ink);
}

.filter-pill {
  padding: 0.45rem 1rem;
  border-radius: 0;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-bottom: none;
  color: var(--ink-muted);
  cursor: pointer;
  margin-right: -1px;
}

.filter-pill:hover {
  background: var(--paper-hover);
  color: var(--ink);
}

.filter-pill.active {
  background: var(--paper-card);
  border: 1px solid var(--ink);
  border-bottom: 2px solid var(--paper-card);
  color: var(--ink);
  font-weight: 700;
  margin-bottom: -2px;
}

/* ==========================================================================
   LOADING & EMPTY STATES
   ========================================================================== */
/* Animated Hairline Shimmer (Never spinners on stat blocks) */
.skeleton-shimmer {
  display: inline-block;
  height: 1.2em;
  background: linear-gradient(90deg, var(--hairline) 25%, var(--paper-card) 50%, var(--hairline) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 0;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Empty State Stamp */
.empty-ledger-state {
  text-align: center;
  padding: 3.5rem 1rem;
}

.empty-stamp {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
  border: 2px double var(--hairline);
  padding: 0.5rem 1.5rem;
  margin-bottom: 0.5rem;
  transform: rotate(-2deg);
}

.empty-caption {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-muted);
}

/* ==========================================================================
   Modal Dialog
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(28, 23, 16, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  background: var(--paper-card);
  border: 2px solid var(--ink);
  border-radius: var(--radius-card);
  padding: 2rem;
  width: 440px;
  max-width: 90vw;
  box-shadow: 6px 6px 0 var(--ink);
}

.modal-box h3 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: var(--ink);
  margin-bottom: 0.5rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Toast Container */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 9999;
}

.toast {
  padding: 0.75rem 1.15rem;
  border-radius: var(--radius-btn);
  background: var(--paper-card);
  border: 1px solid var(--ink);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: var(--shadow-offset-sm);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 260px;
}

.toast.success { border-left: 4px solid var(--stamp-green); }
.toast.error { border-left: 4px solid var(--stamp-red); }
.toast.info { border-left: 4px solid var(--ink); }

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 1200px) {
  .bento-hero-spend { grid-column: span 12; }
  .bento-kpi-count { grid-column: span 6; }
  .bento-kpi-ratio { grid-column: span 6; }
  .bento-chart-trend { grid-column: span 12; }
  .bento-chart-donut { grid-column: span 12; }
  .bento-chart-vendors { grid-column: span 12; }
  .bento-quick-action { grid-column: span 12; }
  .field-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  #app-root { flex-direction: column; }
  .sidebar { width: 100%; height: auto; border-right: none; border-bottom: 2px solid var(--ink); padding: 0.75rem; }
  .nav-menu { flex-direction: row; overflow-x: auto; margin-top: 0.5rem; }
  .chat-workspace { flex-direction: column; height: auto; }
  .chat-conversations-sidebar { width: 100%; height: 160px; }
  .field-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   AUTHENTICATION FOLIO (PAPER INVOICE DESIGN SYSTEM)
   ========================================================================== */
#auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: var(--paper);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow-y: auto;
}

#auth-overlay.hidden {
  display: none !important;
}

.auth-card {
  width: 100%;
  max-width: 480px;
  background: var(--paper-card);
  border: 1px solid var(--ink);
  box-shadow: var(--shadow-offset);
  border-radius: var(--radius-card);
  padding: 2.25rem;
  position: relative;
}

.auth-stamp-seal {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--stamp-amber);
  border: 1.5px dashed var(--stamp-amber);
  padding: 0.25rem 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transform: rotate(-3deg);
  pointer-events: none;
}

.auth-header {
  border-bottom: 1.5px solid var(--hairline);
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
}

.auth-header .brand-tagline {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}

.auth-header h2 {
  font-family: var(--font-serif);
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}

.auth-header p {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--ink-muted);
  margin-top: 0.25rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.auth-form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.auth-form-group label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink);
}

.auth-input {
  box-sizing: border-box;
  width: 100%;
  padding: 0.75rem 0.85rem;
  background: #FAF7EE;
  border: 1px solid var(--hairline);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  border-radius: var(--radius-btn);
  outline: none;
  transition: border-color 0.15s ease;
}

.auth-input:focus {
  border-color: var(--ink);
  background: #FFFFFF;
}

/* Keep autofill consistent with the paper theme */
.auth-input:-webkit-autofill,
.auth-input:-webkit-autofill:hover,
.auth-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px #FAF7EE inset;
  caret-color: var(--ink);
}

.password-input-wrapper {
  box-sizing: border-box;
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.password-input-wrapper .auth-input {
  box-sizing: border-box;
  width: 100%;
  padding-right: 2.75rem;
}

.password-toggle-btn {
  box-sizing: border-box;
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.35rem;
  color: var(--ink-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-btn);
  transition: color 0.15s ease, background-color 0.15s ease;
  z-index: 2;
}

.password-toggle-btn:hover {
  color: var(--ink);
  background-color: rgba(0, 0, 0, 0.06);
}

.password-toggle-btn:focus-visible {
  outline: 1.5px solid var(--ink);
  outline-offset: 1px;
}

.password-toggle-btn svg,
.password-toggle-btn path,
.password-toggle-btn circle,
.password-toggle-btn line {
  pointer-events: none;
}

.auth-stamp-notice {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-btn);
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.auth-stamp-notice.warning {
  background: #FBF4E6;
  border: 1.5px dashed var(--stamp-amber);
  color: var(--stamp-amber);
}

.auth-stamp-notice.error {
  background: #FDF0EE;
  border: 1.5px dashed var(--stamp-red);
  color: var(--stamp-red);
}

.auth-stamp-notice.success {
  background: #EEF8F1;
  border: 1.5px dashed var(--stamp-green);
  color: var(--stamp-green);
}

.stamp-tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stamp-desc {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--ink);
}

.otp-boxes-container {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 1.25rem 0;
}

.otp-digit {
  width: 52px;
  height: 60px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 1.85rem;
  font-weight: 700;
  background: #FAF7EE;
  border: 1.5px solid var(--hairline);
  color: var(--ink);
  border-radius: var(--radius-btn);
  outline: none;
  transition: all 0.15s ease;
}

.otp-digit:focus {
  border-color: var(--ink);
  background: #FFFFFF;
  box-shadow: 2px 2px 0 var(--ink);
}

.otp-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
  margin-bottom: 1.25rem;
  border-top: 1px dashed var(--hairline);
  padding-top: 0.75rem;
}

.auth-footer-nav {
  margin-top: 1.5rem;
  border-top: 1px solid var(--hairline);
  padding-top: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.auth-link {
  color: var(--ink);
  text-decoration: underline;
  cursor: pointer;
  font-weight: 600;
  background: none;
  border: none;
  font-size: inherit;
  font-family: inherit;
  padding: 0;
}

.auth-link:hover {
  color: var(--stamp-amber);
}

.user-badge-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Custom Pinned Charts & Modal Folio
   ───────────────────────────────────────────────────────────────────────────── */

.bento-custom-charts-card {
  grid-column: span 12;
  min-height: 220px;
}

.custom-charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(460px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.custom-chart-card {
  background: var(--paper-card);
  border: 1px solid var(--hairline);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.custom-chart-card:hover {
  border-color: var(--ink-muted);
  box-shadow: 2px 2px 0 var(--hairline);
}

.custom-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px dashed var(--hairline);
  padding-bottom: 0.6rem;
  margin-bottom: 0.65rem;
}

.custom-chart-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
}

.custom-chart-prompt {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-muted);
  margin-top: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

.custom-chart-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.custom-chart-frame-wrapper {
  width: 100%;
  height: 340px;
  background: #FDFBF5;
  border: 1px solid var(--hairline);
  overflow: hidden;
}

.custom-chart-frame-wrapper iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.custom-charts-empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2.5rem 1.5rem;
  border: 1px dashed var(--hairline);
  background: var(--paper);
}

.chart-template-chip {
  padding: 0.3rem 0.65rem;
  background: var(--paper);
  border: 1px solid var(--hairline);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  cursor: pointer;
  border-radius: var(--radius-btn);
  transition: all 0.15s ease;
}

.chart-template-chip:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

/* Modal Backdrop & Paper Modal */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(28, 23, 16, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.paper-modal {
  background: var(--paper);
  border: 1.5px solid var(--ink);
  box-shadow: 6px 6px 0 var(--ink);
  padding: 1.5rem;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  .custom-charts-grid {
    grid-template-columns: 1fr;
  }
}

/* ─────────────────────────────────────────────────────────────────────────────
   Live AI Dispatch Thinking & Stage Indicators
   ───────────────────────────────────────────────────────────────────────────── */

.chat-thinking-container {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.4rem 0.2rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.thinking-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--stamp-amber);
  animation: inkPulse 1.4s infinite ease-in-out;
}

@keyframes inkPulse {
  0%, 100% {
    transform: scale(0.85);
    opacity: 0.4;
  }
  50% {
    transform: scale(1.25);
    opacity: 1;
  }
}

.thinking-stage-text {
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  color: var(--ink);
  transition: opacity 0.2s ease;
}

