@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;700&family=Lora:ital,wght@0,400..700;1,400..700&family=Outfit:wght@300;400;500;600;700&family=Fira+Mono:wght@400;500&display=swap');

:root {
  /* Color Palette */
  --paper: #FAF8F4;
  --surface: #FFFFFF;
  --ink: #1C2B27;
  --ink-light: #5A6965;
  --ink-muted: #82928E;
  
  --brass: #9E7D42;
  --brass-hover: #866632;
  --brass-light: #FAF3E6;
  --brass-border: #EBDDC2;
  --rule: #DDD7C9;
  --rule-light: #EBE6DC;
  
  --positive: #2E6C4E;
  --positive-bg: #EAF4EE;
  --positive-border: #C8E2D4;
  
  --due: #B83A2A;
  --due-bg: #FCECE9;
  --due-border: #F6D3CD;

  /* Typography */
  --font-logo: 'Cinzel', Georgia, serif;
  --font-display: 'Lora', 'Georgia', serif;
  --font-body: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Fira Mono', 'IBM Plex Mono', 'SF Mono', monospace;

  /* Shadows and Transitions */
  --shadow-sm: 0 1px 3px rgba(28, 43, 39, 0.05);
  --shadow-md: 0 4px 12px rgba(28, 43, 39, 0.06);
  --shadow-lg: 0 8px 24px rgba(28, 43, 39, 0.09);
  
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  margin: 0;
  padding: 0 0 80px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* Header & Top Bar Layout */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--rule-light);
  gap: 20px;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  height: 48px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.06));
}

.brand-meta {
  display: flex;
  flex-direction: column;
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--brass);
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 2px;
}

h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  margin: 0;
  color: var(--ink);
  letter-spacing: -0.01em;
}

h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--ink);
}

h2 { font-size: 22px; }
h3 { font-size: 18px; }

/* Navigation & Action Header */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 16px;
}

.topbar .user {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-light);
}

.topbar .user a {
  color: var(--due);
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition-fast);
}

.topbar .user a:hover {
  text-decoration: underline;
}

/* Tab Navigation */
nav.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 28px;
  flex-wrap: wrap;
}

nav.tabs a {
  padding: 10px 18px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  text-decoration: none;
  color: var(--ink-light);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  border-bottom: none;
  margin-bottom: -1px;
  transition: var(--transition-fast);
  background: transparent;
}

nav.tabs a:hover {
  color: var(--brass);
  background: rgba(158, 125, 66, 0.05);
}

nav.tabs a.active {
  background: var(--surface);
  border-color: var(--rule);
  border-bottom-color: var(--surface);
  color: var(--ink);
  box-shadow: 0 -2px 5px rgba(0,0,0,0.02);
}

/* Cards & Statistics */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--brass);
  opacity: 0.9;
}

.card.no-accent::before {
  display: none;
}

.stats {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  flex: 1;
  min-width: 220px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.stat::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--brass);
}

.stat.stat-collected::before { background: var(--positive); }
.stat.stat-outstanding::before { background: var(--due); }
.stat.stat-combined::before { background: var(--brass); }

.stat .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-light);
  font-weight: 700;
  margin-bottom: 8px;
}

.stat .value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 500;
  line-height: 1.2;
}

.stat .sub {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 6px;
  font-weight: 500;
}

.positive { color: var(--positive); }
.due { color: var(--due); }

/* Tables Design */
.table-container {
  overflow-x: auto;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule-light);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--surface);
}

th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-light);
  padding: 12px 14px;
  border-bottom: 2px solid var(--rule);
  font-weight: 700;
  background: var(--paper);
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--rule-light);
  color: var(--ink);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(158, 125, 66, 0.03);
}

tr.selected-row td {
  background: var(--brass-light) !important;
  border-bottom-color: var(--brass-border);
  border-top-color: var(--brass-border);
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13.5px;
}

.right {
  text-align: right;
}

/* Stamps/Badges */
.stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  border: 1px solid currentColor;
}

.stamp.positive {
  color: var(--positive);
  background: var(--positive-bg);
  border-color: var(--positive-border);
}

.stamp.due {
  color: var(--due);
  background: var(--due-bg);
  border-color: var(--due-border);
}

/* Forms & Input fields */
.form-section-title {
  font-size: 13.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brass);
  font-weight: 700;
  margin-top: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--rule-light);
  padding-bottom: 6px;
}

input, select, textarea {
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--ink);
  width: 100%;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 3px rgba(158, 125, 66, 0.15);
}

label.field {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-light);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 13.5px;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-decoration: none;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.btn:hover {
  background: #2b3d39;
  border-color: #2b3d39;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--rule);
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--brass-light);
  border-color: var(--brass);
  color: var(--brass-hover);
  box-shadow: var(--shadow-sm);
}

.btn-danger {
  color: var(--due);
  font-weight: 600;
  text-decoration: none;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.btn-danger:hover {
  background: var(--due-bg);
  color: var(--due);
  text-decoration: none;
}

.btn-primary-action {
  background: var(--brass);
  border-color: var(--brass);
  color: var(--surface);
}

.btn-primary-action:hover {
  background: var(--brass-hover);
  border-color: var(--brass-hover);
}

/* Grid Layouts */
.form-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }

@media (max-width: 900px) {
  .grid-4, .grid-5, .grid-6 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4, .grid-5, .grid-6 {
    grid-template-columns: 1fr;
  }
  .app-header {
    flex-direction: column;
    text-align: center;
    align-items: center;
  }
}

/* Empty State / Errors */
.empty {
  color: var(--ink-muted);
  font-size: 14px;
  padding: 24px 0;
  text-align: center;
  font-style: italic;
}

.error {
  background: var(--due-bg);
  border: 1px solid var(--due-border);
  color: var(--due);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  margin-bottom: 24px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Search Bar */
.search-box-container {
  margin-bottom: 16px;
  position: relative;
}

.search-box-container input {
  padding-left: 36px;
  border-radius: var(--radius-md);
}

.search-box-container::before {
  content: "🔍";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13.5px;
  opacity: 0.6;
}

/* CSS Category Chart styling */
.category-chart {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chart-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chart-label-group {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  font-weight: 500;
}

.chart-cat-name {
  color: var(--ink);
}

.chart-cat-amount {
  font-family: var(--font-mono);
  font-weight: 600;
}

.chart-track {
  height: 10px;
  background: var(--rule-light);
  border-radius: 5px;
  overflow: hidden;
  position: relative;
}

.chart-bar {
  height: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--brass-border) 0%, var(--brass) 100%);
  transition: width 0.8s ease-out;
}

/* Dashboards layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  margin-top: 16px;
}

.dashboard-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.dashboard-card p {
  color: var(--ink-light);
  font-size: 14.5px;
  margin-bottom: 24px;
  line-height: 1.6;
}

.dashboard-card .btn {
  align-self: flex-start;
}

.logo-container-large {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 40px;
  text-align: center;
}

.logo-large {
  max-height: 120px;
  width: auto;
  margin-bottom: 16px;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.06));
}

.login-box {
  max-width: 400px;
  margin: 80px auto;
}

/* Filter controls bar styling */
.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.filter-bar > div {
  flex: 1 1 150px;
}

.filter-bar .btn, .filter-bar a.btn {
  margin-top: 0;
  height: 38px;
}

/* Printing Optimization Stylesheet */
@media print {
  body {
    background: #FFFFFF !important;
    color: #000000 !important;
    font-size: 12px;
    padding: 0;
  }
  
  .wrap {
    max-width: 100% !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  
  /* Hide non-printable UI elements */
  nav.tabs, 
  .topbar .user,
  .user,
  form,
  .btn,
  .btn-ghost,
  .btn-danger,
  .search-box-container,
  input,
  select,
  th:last-child,
  td:last-child {
    display: none !important;
  }
  
  /* Ensure logo print size is optimal */
  .brand-logo, .logo-large {
    max-height: 48px !important;
  }
  
  /* Make cards look clean and flat for print */
  .card {
    border: 1px solid #000000 !important;
    box-shadow: none !important;
    background: #FFFFFF !important;
    padding: 12px !important;
    margin-bottom: 20px !important;
    page-break-inside: avoid;
  }
  
  .card::before {
    display: none !important;
  }
  
  /* Align stat cards in a simple horizontal row on print */
  .stats {
    display: flex !important;
    flex-direction: row !important;
    gap: 10px !important;
    margin-bottom: 20px !important;
    page-break-inside: avoid;
  }
  
  .stat {
    border: 1px solid #000000 !important;
    background: #FFFFFF !important;
    padding: 10px !important;
    flex: 1 !important;
    min-width: 0 !important;
    box-shadow: none !important;
  }
  
  .stat::before {
    display: none !important;
  }
  
  .stat .value {
    font-size: 18px !important;
    color: #000000 !important;
  }
  
  /* High contrast table styles */
  table {
    border-collapse: collapse !important;
    width: 100% !important;
  }
  
  th, td {
    border: 1px solid #000000 !important;
    padding: 6px 8px !important;
    color: #000000 !important;
    font-size: 11px !important;
    background: #FFFFFF !important;
  }
  
  th {
    text-transform: uppercase !important;
    font-weight: bold !important;
  }
  
  tr:hover td {
    background: none !important;
  }
  
  /* Ensure page breaks are handled nicely */
  h1, h2, h3, h4 {
    page-break-after: avoid;
  }
  
  table, tr {
    page-break-inside: avoid;
  }
  
  .category-chart {
    gap: 8px !important;
  }
  
  .chart-track {
    border: 1px solid #000000 !important;
    background: #FFFFFF !important;
    height: 8px !important;
  }
  
  .chart-bar {
    background: #666666 !important;
  }
}
