:root {
  --bg: #f5f8fb;
  --panel: #ffffff;
  --line: #d8e2ee;
  --line-strong: #111827;
  --text: #17233a;
  --muted: #60708a;
  --blue: #2563eb;
  --blue-soft: #e9f0ff;
  --purple: #5b42ff;
  --navy: #17365d;
  --teal: #0f8b8d;
  --green: #1f7a4d;
  --amber: #b45309;
  --red: #b42318;
}

.finance-login-page {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #f5f7fa;
  color: #172033;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.finance-login-card {
  width: min(100%, 360px);
  box-sizing: border-box;
  padding: 40px;
  border: 1px solid #e3e8ef;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 18px 50px rgb(15 23 42 / 10%);
  text-align: center;
}

.finance-login-brand {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .3em;
}

.finance-login-card h1 {
  margin: 0;
  font-size: 20px;
}

.finance-login-subtitle {
  margin: 10px 0 28px;
  color: #667085;
  font-size: 14px;
  line-height: 1.5;
}

.finance-login-button {
  display: block;
  width: 100%;
  box-sizing: border-box;
  border: 0;
  border-radius: 10px;
  padding: 11px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.finance-login-button-primary {
  background: #2563eb;
  color: #fff;
}

.finance-login-button-secondary {
  margin-top: 12px;
  border: 1px solid #d9e0e9;
  background: #f8fafc;
  color: #172033;
}

.finance-login-error {
  margin: 16px 0 0;
  color: #b42318;
  font-size: 13px;
}

.report-auth {
  margin-top: auto;
  padding: 20px 18px 4px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.report-auth form {
  margin-top: 8px;
}

.report-auth button {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

* {
  box-sizing: border-box;
}

body.finance-report {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
}

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

.report-sidebar {
  display: flex;
  flex-direction: column;
  padding: 24px 12px;
  border-right: 1px solid var(--line);
  background: #fbfdff;
}

.report-nav-title {
  margin: 0 0 14px;
  padding: 0 2px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

.report-nav {
  display: grid;
  gap: 12px;
}

.report-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}

.report-nav a.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
  color: #111f4d;
}

.report-nav i {
  width: 20px;
  height: 20px;
  color: #38546f;
}

.nav-badge {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 6px;
  background: #efeaff;
  color: var(--purple);
  font-size: 12px;
  font-weight: 700;
}

.report-main {
  padding: 22px 36px;
  overflow: auto;
}

.close-workspace {
  max-width: 1460px;
  margin: 0 auto;
}

.close-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: 28px 30px;
  border-radius: 14px;
  background: linear-gradient(135deg, #17365d 0%, #234f77 70%, #0f7b82 140%);
  color: #fff;
  box-shadow: 0 16px 34px rgba(23, 54, 93, 0.2);
}

.close-hero h1 {
  margin: 3px 0 8px;
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1;
}

.close-hero p:not(.eyebrow) {
  max-width: 760px;
  margin: 0;
  color: #d8e8f4;
  line-height: 1.5;
}

.eyebrow {
  margin: 0;
  color: var(--teal);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.close-hero .eyebrow {
  color: #7de1de;
}

.period-picker {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px 8px;
  min-width: 300px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
}

.period-picker label {
  grid-column: 1 / -1;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.primary-button,
.secondary-button {
  min-height: 36px;
  padding: 7px 13px;
  border: 0;
  border-radius: 7px;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  background: #1a73e8;
  color: #fff;
}

.period-picker .primary-button {
  background: #fff;
  color: var(--navy);
}

.secondary-button {
  border: 1px solid #bac9d9;
  background: #fff;
  color: var(--navy);
}

.message-stack {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.message {
  padding: 11px 14px;
  border: 1px solid #bfd3ea;
  border-radius: 8px;
  background: #edf6ff;
  color: #25466e;
  font-size: 13px;
  font-weight: 700;
}

.message-error { border-color: #f4b7b2; background: #fff0ef; color: #8f2118; }
.message-success { border-color: #add9c0; background: #edf9f2; color: #17603a; }

.close-summary-grid {
  display: grid;
  grid-template-columns: minmax(300px, 2fr) repeat(3, minmax(150px, 1fr));
  gap: 14px;
  margin: 18px 0 14px;
}

.metric-card {
  min-height: 132px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
  box-shadow: 0 7px 22px rgba(23, 54, 93, 0.07);
}

.metric-card > span,
.metric-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.metric-card > strong {
  display: block;
  margin: 8px 0 3px;
  color: var(--navy);
  font-size: 36px;
  line-height: 1;
}

.metric-card small,
.metric-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.metric-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.metric-heading strong {
  color: var(--navy);
  font-size: 26px;
}

.progress-track {
  height: 9px;
  margin: 21px 0 13px;
  overflow: hidden;
  border-radius: 99px;
  background: #e6edf4;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), #5bc0a8);
}

.metric-alert { border-color: #f2cb8f; background: #fffaf0; }
.metric-danger { border-color: #efb4af; background: #fff5f4; }
.metric-danger > strong { color: var(--red); }

.critical-path-banner {
  display: flex;
  gap: 13px;
  padding: 16px 18px;
  border: 1px solid #edc474;
  border-radius: 10px;
  background: #fff8e3;
  color: #593b09;
}

.critical-path-banner i {
  flex: 0 0 auto;
  width: 22px;
  color: #b66b00;
}

.critical-path-banner p {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.45;
}

.workspace-section {
  margin-top: 22px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(23, 54, 93, 0.055);
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.section-heading h2 {
  margin: 3px 0 0;
  color: var(--navy);
  font-size: 21px;
}

.section-note {
  color: var(--muted);
  font-size: 12px;
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 13px;
}

.source-card {
  padding: 17px;
  border: 1px solid #dce5ee;
  border-radius: 9px;
  background: #fbfdff;
}

.source-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.source-card h3 {
  margin: 0;
  color: var(--navy);
  font-size: 16px;
}

.source-card p {
  min-height: 38px;
  margin: 12px 0 6px;
  font-size: 13px;
  line-height: 1.4;
}

.source-card small {
  display: block;
  min-height: 34px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.connection-badge,
.status-badge,
.readiness-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.connection-badge { padding: 4px 8px; }
.connection-badge.connected { background: #e5f6ed; color: var(--green); }
.connection-badge.not-connected { background: #eef1f5; color: #687386; }

.source-latest {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #e2e9f1;
  font-size: 11px;
}

.source-latest span { color: var(--muted); }
.source-latest strong { text-align: right; }

.task-heading {
  align-items: flex-start;
}

.task-filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.task-list {
  display: grid;
  gap: 8px;
}

.task-row {
  overflow: hidden;
  border: 1px solid #dbe4ed;
  border-radius: 9px;
  background: #fff;
}

.task-row.critical {
  border-left: 4px solid #e4a11b;
}

.task-row summary {
  display: grid;
  grid-template-columns: 62px minmax(230px, 1fr) 92px 82px 108px 70px 16px;
  align-items: center;
  gap: 10px;
  min-height: 68px;
  padding: 10px 12px;
  background: #fbfdff;
  cursor: pointer;
  list-style: none;
}

.task-row summary::-webkit-details-marker { display: none; }
.task-row[open] summary { border-bottom: 1px solid #dbe4ed; background: #f6faff; }

.task-code {
  color: var(--navy);
  font-size: 12px;
  font-weight: 900;
}

.task-main {
  display: grid;
  gap: 4px;
}

.task-main strong {
  font-size: 13px;
  line-height: 1.3;
}

.task-main small,
.task-owner,
.task-date {
  color: var(--muted);
  font-size: 11px;
}

.task-date.overdue { color: var(--red); font-weight: 900; }

.status-badge { padding: 5px 9px; background: #eef1f5; color: #586477; }
.status-in_progress { background: #e8f0ff; color: #2458a6; }
.status-blocked { background: #feeceb; color: var(--red); }
.status-ready_for_review { background: #fff2d4; color: #8b5700; }
.status-complete { background: #e5f6ed; color: var(--green); }
.status-not_applicable { background: #eeeaf8; color: #63527f; }

.readiness-badge { padding: 4px 8px; }
.readiness-badge.ready { color: var(--green); border: 1px solid #a9d6bd; }
.readiness-badge.waiting { color: #80601b; border: 1px solid #e8cc8a; }
.readiness-badge.resolved { color: #647083; border: 1px solid #cdd5de; }

.task-chevron { width: 16px; color: #79879a; transition: transform 0.15s ease; }
.task-row[open] .task-chevron { transform: rotate(180deg); }

.task-editor {
  padding: 16px;
}

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

.task-context div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: 7px;
  background: #f6f8fb;
}

.task-context span,
.task-editor label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.task-context strong {
  font-size: 12px;
  line-height: 1.35;
}

.dependency-warning {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 14px;
  color: #8a5600;
  font-size: 12px;
  font-weight: 700;
}

.dependency-warning i { width: 15px; }

.task-editor-grid {
  display: grid;
  grid-template-columns: 200px minmax(260px, 1fr) 2fr auto;
  align-items: end;
  gap: 12px;
}

.task-editor label {
  display: grid;
  gap: 5px;
}

.task-editor .field-control {
  width: 100%;
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
}

.task-editor textarea { resize: vertical; }
.task-save { padding-bottom: 1px; }

.activity-list {
  display: grid;
  gap: 0;
}

.activity-list > div:not(.empty-state) {
  display: grid;
  grid-template-columns: 76px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid #e7edf3;
  font-size: 12px;
}

.activity-list p { margin: 0; }
.activity-list time { color: var(--muted); font-size: 11px; }
.empty-state { padding: 28px; color: var(--muted); text-align: center; }

@media (max-width: 1180px) {
  .report-shell { grid-template-columns: 250px minmax(0, 1fr); }
  .report-sidebar { padding: 18px 10px; }
  .report-nav { gap: 7px; }
  .report-nav a { min-height: 46px; }
  .close-summary-grid { grid-template-columns: repeat(3, 1fr); }
  .metric-card-wide { grid-column: 1 / -1; }
  .task-row summary { grid-template-columns: 58px minmax(220px, 1fr) 78px 106px 66px 16px; }
  .task-owner { display: none; }
  .task-editor-grid { grid-template-columns: 180px 1fr; }
  .task-note-label { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  .report-shell { display: block; }
  .report-sidebar { position: static; border-right: 0; border-bottom: 1px solid var(--line); }
  .report-nav { display: flex; overflow-x: auto; }
  .report-nav a { flex: 0 0 auto; }
  .report-main { padding: 16px; }
  .close-hero { display: grid; padding: 22px; }
  .period-picker { min-width: 0; }
  .close-summary-grid, .source-grid { grid-template-columns: 1fr; }
  .metric-card-wide { grid-column: auto; }
  .section-heading { display: grid; }
  .task-filters { justify-content: flex-start; }
  .task-row summary { grid-template-columns: 48px minmax(0, 1fr) 16px; }
  .task-date, .readiness-badge, .status-badge { display: none; }
  .task-context { grid-template-columns: 1fr 1fr; }
  .task-editor-grid { grid-template-columns: 1fr; }
  .task-note-label { grid-column: auto; }
}

.report-note {
  max-width: 980px;
  margin: 0 0 28px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  color: #3f4a5f;
  font-size: 14px;
  line-height: 1.45;
}

.report-paper {
  max-width: 980px;
  min-height: 680px;
  padding: 30px 24px 54px;
  border-top: 4px solid #4b5563;
  background: var(--panel);
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.12);
}

.product-sales-paper {
  max-width: 1320px;
}

.report-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.report-title {
  margin: 0;
  font-size: 26px;
  line-height: 1.15;
  font-weight: 800;
  color: #3b4150;
}

.report-updated {
  margin-left: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.report-actions,
.report-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.report-filters {
  padding-bottom: 16px;
  border-bottom: 1px solid #e5ebf3;
}

.custom-period-fields {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.custom-period-fields[hidden] {
  display: none;
}

.pill,
.icon-button,
.field-control {
  min-height: 28px;
  border: 1px solid #cbd8e6;
  border-radius: 999px;
  background: #ffffff;
  color: #17233a;
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-weight: 700;
}

.field-control {
  padding: 4px 10px;
  border-radius: 7px;
}

.period-select {
  min-width: 148px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-radius: 7px;
  text-decoration: none;
  font-weight: 700;
}

.icon-button i {
  width: 16px;
  height: 16px;
}

.summary-table,
.group-table,
.detail-table,
.product-sales-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.summary-table {
  table-layout: fixed;
  margin-top: 8px;
}

.group-table {
  table-layout: fixed;
}

.item-col {
  width: 54%;
}

.orders-col {
  width: 16%;
}

.amount-col {
  width: 30%;
}

.summary-table th,
.group-table th,
.detail-table th,
.product-sales-table th {
  padding: 9px 0;
  border-bottom: 1px solid #e5ebf3;
  color: #1e2d46;
  font-size: 12px;
  font-weight: 800;
  text-align: left;
}

.summary-table td,
.group-table td,
.detail-table td,
.product-sales-table td {
  padding: 8px 0;
  border-bottom: 1px solid rgba(216, 226, 238, 0.55);
  vertical-align: top;
}

.summary-table th + th,
.summary-table td + td,
.group-table th + th,
.group-table td + td {
  padding-left: 18px;
}

.summary-table .section td {
  padding-top: 18px;
  border-bottom: 0;
  font-weight: 800;
  color: #1e2d46;
}

.summary-table tbody tr:last-child td,
.group-table tbody tr:last-child td,
.detail-table tbody tr:last-child td,
.product-sales-table tbody tr:last-child td {
  border-bottom: 0;
}

.summary-table .indent .item-label {
  padding-left: 32px;
  font-weight: 500;
}

.summary-table .strong td {
  padding-top: 14px;
  font-weight: 800;
}

.product-sales-table {
  min-width: 1120px;
  table-layout: fixed;
}

.product-sales-table th:first-child,
.product-sales-table td:first-child {
  width: 28%;
  padding-right: 16px;
}

.product-sales-table .strong td {
  padding-top: 14px;
  font-weight: 800;
}

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

.amount-cell,
.count-cell {
  text-align: right;
  white-space: nowrap;
}

.summary-table th.amount-cell,
.summary-table th.count-cell,
.group-table th.amount-cell,
.group-table th.count-cell,
.detail-table th.amount-cell,
.product-sales-table th.amount-cell,
.product-sales-table th.count-cell {
  text-align: right;
}

.amount-link {
  border-bottom: 1px solid currentColor;
  text-decoration: none;
}

.stripe-summary-table .item-col {
  width: 68%;
}

.stripe-summary-table .amount-col {
  width: 32%;
}

.count-cell {
  color: var(--muted);
  font-size: 12px;
}

.group-table {
  margin-top: 18px;
}

.detail-wrap {
  margin-top: 34px;
}

.detail-title {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 800;
  color: #2d3b53;
}

.detail-table td {
  border-bottom: 1px solid #edf1f6;
}

.muted {
  color: var(--muted);
}

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

.filter-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

  .report-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .report-main {
    padding: 18px;
  }

  .report-paper {
    min-height: 0;
    padding: 24px 16px 40px;
  }
}

@media (max-width: 560px) {
  .report-nav {
    grid-template-columns: 1fr;
  }

  .report-head {
    display: block;
  }

  .report-actions {
    margin-top: 14px;
  }

  .summary-table,
  .group-table,
  .detail-table,
  .product-sales-table {
    font-size: 13px;
  }
}

.forecast-table-wrap {
  overflow-x: auto;
}

.forecast-table {
  table-layout: auto;
  min-width: 100%;
}

.forecast-table th:first-child,
.forecast-table .item-label {
  min-width: 260px;
}

.forecast-table .amount-cell {
  min-width: 96px;
  white-space: nowrap;
}
