:root {
  --ink: #13201d;
  --muted: #64706d;
  --brand: #0f766e;
  --brand-dark: #143c3c;
  --line: #d8dfdc;
  --paper: #f6f8f7;
  --surface: #ffffff;
}

body {
  background: var(--paper);
  color: var(--ink);
}

.app-nav {
  background: var(--brand-dark);
}

.page-heading,
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

h1 {
  font-size: clamp(1.8rem, 2.5vw, 2.6rem);
  font-weight: 750;
}

h2 {
  font-size: 1.2rem;
  font-weight: 720;
}

h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-top: 1rem;
}

.eyebrow {
  color: var(--brand);
  font-size: 0.78rem;
  text-transform: uppercase;
  font-weight: 750;
  letter-spacing: 0;
  margin-bottom: 0.2rem;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
}

.btn-primary:hover {
  background: #115e59;
  border-color: #115e59;
}

.surface,
.empty-state,
.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.25rem;
  box-shadow: 0 10px 30px rgba(19, 32, 29, 0.06);
}

.narrow {
  max-width: 780px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.kpi {
  min-height: 112px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
}

.kpi span {
  color: var(--muted);
  display: block;
  font-size: 0.9rem;
}

.kpi strong {
  display: block;
  font-size: 1.55rem;
  margin-top: 1.2rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 1rem;
}

.signal {
  border-radius: 8px;
  margin-bottom: 0.75rem;
  padding: 0.85rem 1rem;
  font-weight: 700;
}

.signal.green { background: #dcfce7; color: #166534; }
.signal.yellow { background: #fef9c3; color: #854d0e; }
.signal.red { background: #fee2e2; color: #991b1b; }

.recommendation {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  min-height: 110px;
  margin-bottom: 1rem;
}

.news-board .section-head {
  padding-bottom: 0.75rem;
}

.news-board .section-head h2 {
  margin-bottom: 0;
}

.news-list {
  border-top: 1px solid var(--line);
}

.news-item {
  position: relative;
  padding: 1.15rem 0 1.15rem 1rem;
  border-bottom: 1px solid var(--line);
}

.news-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.news-item::before {
  position: absolute;
  inset: 1.15rem auto 1.15rem 0;
  width: 3px;
  content: "";
  background: var(--brand);
}

.news-item.important::before {
  background: #c2413b;
}

.news-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.news-priority {
  color: #991b1b;
  font-weight: 750;
  text-transform: uppercase;
}

.news-item h3 {
  margin: 0.35rem 0 0.45rem;
  font-size: 1.05rem;
}

.news-body {
  max-width: 900px;
  color: var(--ink);
  line-height: 1.55;
}

.news-body p:last-child {
  margin-bottom: 0;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.tool-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 260px;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.month-tile {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 190px;
  padding: 1rem;
}

.month-tile.done {
  border-color: #16a34a;
}

.month-tile.error {
  border-color: #dc2626;
}

.month-tile span {
  color: var(--muted);
  display: block;
  font-size: 0.85rem;
}

.month-tile p {
  color: var(--muted);
  flex: 1;
  font-size: 0.9rem;
  margin: 0;
}

.preline {
  white-space: pre-line;
}

.cash-flow-report {
  overflow: hidden;
  padding: 0;
}

.cash-flow-title {
  background: var(--brand-dark);
  color: white;
  padding: 0.65rem 1rem;
  text-align: center;
}

.cash-flow-title h2 {
  font-size: 1.5rem;
  margin: 0;
  text-transform: uppercase;
}

.cash-flow-source {
  color: var(--muted);
  font-style: italic;
  margin: 0;
  padding: 0.5rem 1rem;
}

.cash-flow-report > .alert,
.cash-flow-report > h3,
.cash-flow-report > .cash-flow-evidence,
.cash-flow-report > .cash-flow-legacy,
.cash-flow-summary {
  margin-left: 1rem;
  margin-right: 1rem;
}

.cash-flow-columns {
  display: grid;
  gap: 2rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 1rem;
}

.cash-flow-block h3,
.cash-flow-quick h3 {
  background: var(--brand-dark);
  color: white;
  font-size: 1.05rem;
  margin: 0;
  padding: 0.35rem 0.5rem;
  text-transform: uppercase;
}

.cash-flow-block table,
.cash-flow-quick table {
  border-collapse: collapse;
  table-layout: fixed;
  width: 100%;
}

.cash-flow-block th,
.cash-flow-block td,
.cash-flow-quick th,
.cash-flow-quick td {
  border: 1px solid var(--line);
  padding: 0.35rem 0.5rem;
}

.cash-flow-block th,
.cash-flow-quick th {
  background: #dbeaf5;
  color: #16395f;
  text-align: center;
}

.cash-flow-block th:last-child,
.cash-flow-block td:last-child {
  width: 40%;
}

.cash-value {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.cash-flow-block tr.total td,
.cash-flow-quick tr.result td {
  font-weight: 700;
}

.cash-flow-block tr.result td,
.cash-flow-quick tr.result td {
  background: #fde6d8;
  font-weight: 700;
}

.cash-flow-block tr.available td {
  background: #e2f0d9;
  font-weight: 700;
}

.cash-value.negative {
  color: #d00000;
}

.cash-flow-quick {
  max-width: 900px;
  padding: 1rem;
}

.cash-flow-note {
  background: #fff3cd;
  color: #795500;
  font-style: italic;
  margin: 1rem 0 0;
  padding: 0.8rem 1rem;
}

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

.executive-summary-header h2 {
  margin: 0;
  font-size: 1.45rem;
}

.executive-summary-header > span {
  color: var(--muted);
  font-weight: 700;
}

.executive-summary-overview {
  max-width: 980px;
  padding: 1.25rem 0;
  font-size: 1.02rem;
  line-height: 1.65;
}

.executive-summary-overview p:last-child {
  margin-bottom: 0;
}

.executive-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.5rem;
}

.executive-summary-section {
  padding-top: 0.9rem;
  border-top: 4px solid var(--line);
}

.executive-summary-section.risks {
  border-color: #c2413b;
}

.executive-summary-section.opportunities {
  border-color: #18835e;
}

.executive-summary-section.recommendations {
  border-color: #2563a5;
}

.executive-summary-section h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.executive-summary-section ol {
  margin: 0;
  padding-left: 1.25rem;
}

.executive-summary-section li {
  margin-bottom: 0.65rem;
  line-height: 1.45;
}

.executive-summary-section p {
  color: var(--muted);
}

.tutorial-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.tutorial-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.tutorial-media {
  aspect-ratio: 16 / 9;
  background: #0f172a;
  border-radius: 8px;
  overflow: hidden;
}

.tutorial-media video,
.tutorial-media iframe {
  border: 0;
  display: block;
  height: 100%;
  width: 100%;
}

.upload-guidance {
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
}

.upload-guidance p {
  color: var(--muted);
}

.guidance-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.guidance-grid ul {
  margin-bottom: 0;
  padding-left: 1.15rem;
}

.guidance-note {
  background: #fef9c3;
  border: 1px solid #fde68a;
  border-radius: 8px;
  color: #854d0e;
  margin: 1rem 0 0;
  padding: 0.85rem 1rem;
}

.chat-context {
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  margin-bottom: 1rem;
  padding-bottom: 1rem;
}

.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 58vh;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.chat-message {
  display: flex;
  flex-direction: column;
  max-width: min(760px, 92%);
}

.chat-message.user {
  align-self: flex-end;
}

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

.chat-meta {
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 0.25rem;
}

.chat-bubble {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem 1rem;
}

.chat-message.user .chat-bubble {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.chat-message.assistant .chat-bubble {
  background: #f8faf9;
}

.chat-form {
  border-top: 1px solid var(--line);
  margin-top: 1.25rem;
  padding-top: 1.25rem;
}

.empty-chat {
  color: var(--muted);
  padding: 1.25rem 0;
}

.login-shell {
  min-height: calc(100vh - 110px);
  display: grid;
  place-items: center;
}

.login-panel {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 2rem;
}

.logo-brand {
  display: inline-flex;
  align-items: center;
  min-height: 64px;
  padding: 0;
}

.logo-brand img {
  display: block;
  height: 78px;
  width: auto;
  max-width: 280px;
  object-fit: contain;
}

.login-logo {
  display: block;
  width: min(360px, 100%);
  height: auto;
  margin: 0.45rem 0 1rem;
}

.auth-wide {
  max-width: 1080px;
  margin: 0 auto;
}

.signup-form {
  display: grid;
  gap: 1.5rem;
}

.form-section {
  border-top: 1px solid var(--line);
  padding-top: 1.25rem;
}

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

.form-grid .span-2 {
  grid-column: span 2;
}

.signup-form .errorlist {
  color: #991b1b;
  font-size: 0.85rem;
  margin: 0.35rem 0 0;
  padding-left: 1rem;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.billing-panel {
  display: grid;
  gap: 1.25rem;
}

.billing-status-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

.status-pill.pending,
.status-pill.past_due {
  background: #fef9c3;
  color: #854d0e;
}

.status-pill.active {
  background: #dcfce7;
  color: #166534;
}

.status-pill.blocked,
.status-pill.canceled {
  background: #fee2e2;
  color: #991b1b;
}

.billing-price {
  min-width: 220px;
  text-align: right;
}

.billing-price span,
.billing-details dt {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
}

.billing-price strong {
  display: block;
  font-size: 1.5rem;
}

.billing-details {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin: 0;
}

.billing-details dd {
  margin: 0.2rem 0 0;
}

.billing-blocked {
  border-top: 1px solid var(--line);
  padding-top: 1.25rem;
}

.report-loading {
  position: fixed;
  inset: 0;
  z-index: 1080;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(19, 32, 29, 0.58);
}

.report-loading[hidden] {
  display: none;
}

.report-loading-panel {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: min(480px, 100%);
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(19, 32, 29, 0.2);
}

.report-loading-panel strong {
  display: block;
  margin-bottom: 0.25rem;
}

.report-loading-panel p {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 900px) {
  .kpi-grid,
  .detail-grid,
  .executive-summary-grid,
  .guidance-grid,
  .form-grid,
  .billing-details,
  .tool-grid,
  .month-grid,
  .tutorial-grid,
  .login-panel {
    grid-template-columns: 1fr;
  }

  .cash-flow-columns {
    grid-template-columns: 1fr;
  }

  .page-heading,
  .section-head,
  .billing-status-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-grid .span-2 {
    grid-column: auto;
  }

  .billing-price {
    text-align: left;
  }
}
