:root {
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --paper: #ffffff;
  --soft: #f7f8fb;
  --dark: #15151a;
  --mint: #c9f7e5;
  --coral: #ffd2c8;
  --lemon: #fff1a8;
  --sky: #cae8ff;
  --hot: #ff4f8b;
  --green: #21c58e;
  --blue: #2563eb;
  --radius: 8px;
  --shadow: 0 18px 50px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(249, 250, 251, 0.88), rgba(249, 250, 251, 0.72)),
    url("chicken-bg.png") center / cover fixed,
    linear-gradient(135deg, #f9fafb 0%, #eef7f5 45%, #fff9dc 100%);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  background: rgba(255, 255, 255, 0.78);
  border-right: 1px solid rgba(17, 24, 39, 0.08);
  backdrop-filter: blur(22px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  color: #fff;
  background: var(--dark);
  border: 3px solid #9cffcb;
  border-radius: var(--radius);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  margin-top: 3px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-link {
  width: 100%;
  padding: 13px 14px;
  color: #2f3440;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
}

.nav-link:hover,
.nav-link.active {
  color: var(--ink);
  background: #fff;
  border-color: rgba(17, 24, 39, 0.10);
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.06);
}

.sidebar-note {
  position: absolute;
  right: 24px;
  bottom: 24px;
  left: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  color: #374151;
  background: #f4fff9;
  border: 1px solid #b9f4d7;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.4;
}

.pulse {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  background: var(--green);
  border-radius: 999px;
  box-shadow: 0 0 0 6px rgba(33, 197, 142, 0.15);
}

.main {
  padding: 30px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1;
}

h2 {
  font-size: 18px;
}

.top-actions,
.filter-panel,
.line-builder,
.payment-row {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

.primary-btn,
.dark-btn,
.ghost-btn,
.danger-btn {
  min-height: 42px;
  padding: 0 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-weight: 800;
}

.print-btn {
  min-height: 32px;
  padding: 0 10px;
  color: #111827;
  background: #eafff4;
  border: 1px solid #9cffcb;
  border-radius: var(--radius);
  font-weight: 800;
}

.primary-btn {
  color: #101014;
  background: #9cffcb;
  border-color: #6de5aa;
  box-shadow: 0 10px 22px rgba(33, 197, 142, 0.20);
}

.dark-btn {
  color: #fff;
  background: var(--dark);
}

.ghost-btn {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
}

.danger-btn {
  min-height: 32px;
  padding: 0 10px;
  color: #b91c1c;
  background: #fff1f2;
  border-color: #fecdd3;
}

.wide {
  width: 100%;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.filter-panel,
.panel {
  background: rgba(255, 255, 255, 0.90);
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.metric-card {
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.filter-panel {
  padding: 16px;
  margin-bottom: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card {
  min-height: 152px;
  padding: 18px;
  overflow: hidden;
}

.metric-card span,
.metric-card small {
  display: block;
}

.metric-card span {
  color: #374151;
  font-size: 13px;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin: 16px 0 8px;
  font-size: clamp(24px, 2.6vw, 34px);
  line-height: 1;
}

.metric-card small {
  color: #4b5563;
}

.mint {
  background: linear-gradient(145deg, var(--mint), #fff);
}

.coral {
  background: linear-gradient(145deg, var(--coral), #fff);
}

.lemon {
  background: linear-gradient(145deg, var(--lemon), #fff);
}

.sky {
  background: linear-gradient(145deg, var(--sky), #fff);
}

.dashboard-grid,
.work-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(330px, 0.8fr);
  gap: 18px;
}

.work-grid {
  grid-template-columns: minmax(340px, 0.85fr) minmax(0, 1.15fr);
}

.panel {
  padding: 18px;
}

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

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

label {
  display: grid;
  gap: 7px;
  color: #374151;
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #111827;
  box-shadow: 0 0 0 3px rgba(156, 255, 203, 0.45);
}

.form-panel {
  display: grid;
  gap: 14px;
  align-content: start;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.line-builder {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(90px, 0.5fr) auto;
}

.payment-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.invoice-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px;
  background: #15151a;
  color: #fff;
  border-radius: var(--radius);
}

.invoice-total strong {
  font-size: 24px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.table-wrap.compact {
  max-height: 250px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  min-width: 650px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 13px;
}

th {
  color: #6b7280;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

tbody tr:hover {
  background: rgba(156, 255, 203, 0.14);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status.paid {
  color: #065f46;
  background: #d1fae5;
}

.status.partial {
  color: #92400e;
  background: #fef3c7;
}

.status.unpaid {
  color: #991b1b;
  background: #fee2e2;
}

.cash-bars {
  display: grid;
  gap: 22px;
}

.cash-bars span,
.cash-bars strong {
  display: block;
}

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

.cash-bars strong {
  margin: 4px 0 10px;
}

.bar {
  height: 12px;
  overflow: hidden;
  background: #eef2f7;
  border-radius: 999px;
}

.bar i {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #9cffcb, #ff4f8b);
  border-radius: inherit;
  transition: width 220ms ease;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  max-width: 360px;
  padding: 14px 16px;
  color: #fff;
  background: #111827;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.print-sheet {
  display: none;
}

.print-header,
.print-meta,
.print-summary,
.print-signatures {
  display: grid;
  gap: 12px;
}

.print-header {
  grid-template-columns: 1fr auto;
  align-items: start;
  border-bottom: 2px solid #111827;
  padding-bottom: 18px;
  margin-bottom: 18px;
}

.print-header h2 {
  font-size: 26px;
}

.print-header p,
.print-meta p,
.print-summary p {
  margin: 3px 0;
}

.print-badge {
  padding: 9px 12px;
  border: 1px solid #111827;
  border-radius: 6px;
  font-weight: 800;
}

.print-meta {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 18px;
}

.print-summary {
  width: min(360px, 100%);
  margin-left: auto;
  margin-top: 16px;
}

.print-summary p {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.print-summary strong {
  font-size: 18px;
}

.print-signatures {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 42px;
  text-align: center;
}

.signature-line {
  margin-top: 58px;
  border-top: 1px solid #111827;
  padding-top: 8px;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .sidebar-note {
    position: static;
    margin-top: 16px;
  }

  .nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric-grid,
  .dashboard-grid,
  .work-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .main,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .nav,
  .metric-grid,
  .dashboard-grid,
  .work-grid,
  .form-grid.two,
  .line-builder,
  .payment-row {
    grid-template-columns: 1fr;
  }

  .primary-btn,
  .dark-btn,
  .ghost-btn {
    width: 100%;
  }

  table {
    min-width: 560px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .app-shell,
  .toast {
    display: none !important;
  }

  .print-sheet {
    display: block;
    padding: 28px;
    color: #111827;
    background: #fff;
  }

  table {
    min-width: 0;
  }

  th,
  td {
    padding: 10px 8px;
    font-size: 12px;
  }
}
