@import url("https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@500;700;800;900&display=swap");

:root {
  --cis-blue: #1264a3;
  --cis-blue-dark: #0d4f82;
  --cis-blue-header: #dceaf5;
  --cis-blue-border: #a9c7dd;
  --cis-blue-border-strong: #6fa2c6;
  --cis-green: #2da44e;
  --cis-green-dark: #116329;
  --cis-green-soft: #eaf7ee;
  --cis-success-text: #205b33;
  --cis-green-heading: #193825;
  --cis-green-header: #dcefe2;
  --cis-green-panel: #f3fbf5;
  --cis-green-panel-alt: #e9f6ee;
  --cis-green-total: #d7eddf;
  --cis-green-border: #b8d5c1;
  --cis-green-border-strong: #78aa87;
  --cis-green-border-muted: #9fb8a8;
  --cis-blue-soft: #e8eef4;
  --cis-bg: #f4f6f8;
  --cis-surface: #ffffff;
  --cis-surface-muted: #f8fafb;
  --cis-border: #d9e0e7;
  --cis-border-soft: #edf1f5;
  --cis-border-strong: #aebdca;
  --cis-border-input: #c9d3dd;
  --cis-text: #17202a;
  --cis-muted: #52616f;
  --cis-muted-dark: #2d3a45;
  --cis-danger: #b42318;
  --cis-danger-dark: #842029;
  --cis-danger-soft: #fdecec;
  --cis-danger-surface: #fff4f4;
  --cis-danger-border: #e8b6b6;
  --cis-shadow: rgba(18, 40, 64, 0.16);
  color-scheme: light;
  font-family: "Nunito Sans", "Segoe UI", Arial, sans-serif;
  background: var(--cis-bg);
  color: var(--cis-text);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(45, 164, 78, 0.10), transparent 34%),
    linear-gradient(315deg, rgba(18, 100, 163, 0.10), transparent 38%),
    var(--cis-bg);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

[hidden] {
  display: none !important;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 18px;
}

.login-box {
  display: grid;
  width: min(420px, 100%);
  gap: 16px;
  border: 1px solid var(--cis-border);
  border-radius: 12px;
  padding: 24px;
  background: var(--cis-surface);
  box-shadow: 0 18px 42px var(--cis-shadow);
}

.login-box h1 {
  margin-bottom: 6px;
}

.login-box p {
  margin: 0;
  color: var(--cis-danger-dark);
  font-size: 14px;
}

.login-box p:empty {
  display: none;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-box .brand-title {
  justify-content: center;
  color: var(--cis-text);
  font-size: 28px;
  font-weight: 900;
}

.brand-title strong {
  color: var(--cis-text);
}

.brand-cis-blue {
  color: var(--cis-blue);
}

.brand-cis-green {
  color: var(--cis-green);
}

.brand-logo {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: 12px;
  object-fit: contain;
}

.brand-logo-small {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.app-header {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) 82px;
  align-items: center;
  gap: 14px;
  margin: 16px 24px;
  padding: 12px;
  border: 1px solid var(--cis-blue-border);
  border-radius: 12px;
  background: var(--cis-blue-header);
  color: var(--cis-text);
  box-shadow: 0 8px 18px rgba(18, 40, 64, 0.08);
}

.header-slot {
  display: flex;
  align-items: center;
}

.header-slot-left {
  justify-content: flex-start;
}

.header-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  object-fit: contain;
}

.header-title {
  display: grid;
  min-width: 0;
  justify-items: center;
  text-align: center;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: end;
  padding: 20px 24px 16px;
  background: var(--cis-surface);
  border-bottom: 1px solid var(--cis-border);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

.app-header h1 {
  font-size: 26px;
  line-height: 1.1;
}

.account-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

#current-user {
  max-width: 96px;
  overflow: hidden;
  color: var(--cis-text);
  font-size: 14px;
  font-weight: 700;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filters {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--cis-muted);
  font-size: 13px;
  font-weight: 700;
}

.room-filter {
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

.room-filter legend {
  margin-bottom: 6px;
  color: var(--cis-muted);
  font-size: 13px;
  font-weight: 700;
}

.room-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.room-option {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--cis-border-strong);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--cis-surface);
  color: var(--cis-text);
  cursor: pointer;
}

.room-option input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--cis-blue);
}

select,
input {
  min-height: 40px;
  width: 100%;
  border: 1px solid var(--cis-border-input);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--cis-surface);
  color: var(--cis-text);
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: var(--cis-blue);
  color: var(--cis-surface);
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.query-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 18px;
}

.status-band {
  color: var(--cis-muted-dark);
  font-size: 13px;
}

.status-band.error {
  color: var(--cis-danger-dark);
}

.status-band.success {
  color: var(--cis-success-text);
}

.result-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 24px;
  padding: 24px;
}

.result-layout-single {
  grid-template-columns: minmax(0, 720px);
}

.summary-panel,
.report-panel {
  background: var(--cis-surface);
  border: 1px solid var(--cis-border);
  border-radius: 8px;
}

.summary-panel {
  align-self: start;
  padding: 18px;
}

.summary-panel h2,
.panel-title h2 {
  font-size: 18px;
}

dl {
  margin: 16px 0 0;
}

dl div {
  padding: 12px 0;
  border-top: 1px solid var(--cis-border-soft);
}

dt {
  color: var(--cis-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

dd {
  margin: 4px 0 0;
  font-weight: 700;
}

.result-value {
  color: var(--cis-green-dark);
  font-size: 20px;
}

.report-panel {
  min-width: 0;
}

#logout-button {
  display: grid;
  width: 44px;
  min-height: 32px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--cis-blue-border-strong);
  border-radius: 8px;
  padding: 0;
  background: rgba(255, 255, 255, 0.92);
  color: var(--cis-text);
}

#logout-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

#updated-at {
  flex-shrink: 0;
  color: var(--cis-muted);
  font-size: 13px;
  text-align: right;
}

#updated-at:empty {
  display: none;
}

#report-output {
  padding: 18px;
}

.empty-state {
  color: var(--cis-muted);
}

.gross-card {
  display: grid;
  gap: 0;
}

.gross-card + .gross-card {
  margin-top: 18px;
}

.gross-card header,
.gross-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.gross-card header {
  padding: 14px 16px;
  border: 1px solid var(--cis-green-border);
  border-radius: 8px 8px 0 0;
  background: var(--cis-green-header);
  color: var(--cis-green-heading);
}

.gross-card.is-collapsed header {
  border-radius: 8px;
}

.collapsible-header {
  flex-wrap: wrap;
}

.card-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.collapse-toggle {
  min-height: 30px;
  border: 1px solid var(--cis-green-border-strong);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--cis-surface);
  color: var(--cis-green-heading);
  font-size: 12px;
}

.gross-card header span,
.gross-row span {
  font-weight: 700;
}

.gross-list {
  border-left: 1px solid var(--cis-green-border);
  border-right: 1px solid var(--cis-green-border);
  border-bottom: 1px solid var(--cis-green-border);
  border-radius: 0 0 8px 8px;
  overflow: hidden;
}

.room-metric-list {
  display: grid;
  gap: 0;
}

.room-metric-group {
  display: grid;
  gap: 0;
  background: var(--cis-green-panel);
}

.room-metric-group + .room-metric-group {
  border-top: 2px solid var(--cis-green-border-strong);
}

.room-metric-group h3 {
  margin: 0;
  padding: 14px 16px;
  background: var(--cis-green-soft);
  color: var(--cis-green-heading);
  font-size: 17px;
}

.gross-row {
  padding: 16px;
  border-bottom: 1px solid var(--cis-green-border);
  background: var(--cis-green-panel);
  font-size: 18px;
}

.gross-row.compact-row {
  padding: 12px 16px;
  font-size: 16px;
}

.gross-row:nth-child(even) {
  background: var(--cis-green-panel-alt);
}

.gross-row.gross-total-row {
  border-top: 2px solid var(--cis-green-border-strong);
  background: var(--cis-green-total);
}

.gross-row strong {
  color: var(--cis-green-dark);
  font-size: 22px;
}

.gross-row strong.money-negative {
  color: var(--cis-danger);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--cis-green-border-muted);
  border-radius: 8px;
}

.table-wrap + .table-wrap {
  margin-top: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

td,
th {
  border: 1px solid var(--cis-green-border);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: var(--cis-green-header);
  color: var(--cis-green-heading);
  font-size: 12px;
  text-transform: uppercase;
}

td:last-child,
th:last-child {
  text-align: right;
  font-weight: 700;
}

.gross-table {
  min-width: 0;
  table-layout: fixed;
  font-size: 13px;
}

.gross-table th {
  position: static;
  padding: 8px 4px;
  text-align: center;
  font-size: 12px;
}

.gross-table th,
.gross-table td {
  white-space: nowrap;
  word-break: normal;
}

.gross-table th:not(:first-child),
.gross-table td:not(:first-child) {
  text-align: center;
}

.gross-table td:not(:first-child) {
  font-family: "Arial Narrow", Arial, Helvetica, sans-serif;
}

.gross-table td:first-child {
  color: var(--cis-green-heading);
  font-weight: 800;
  width: 18%;
}

.gross-table td {
  padding: 10px 4px;
  font-weight: 700;
  text-align: center;
}

.gross-table .money-negative {
  color: var(--cis-danger);
}

.metric-table {
  font-size: 12px;
}

.metric-table td:first-child {
  width: auto;
  color: inherit;
  font-weight: 700;
}

tbody tr:nth-child(odd):not(.heading-row):not(.summary-row) {
  background: var(--cis-green-panel);
}

tbody tr:nth-child(even):not(.heading-row):not(.summary-row) {
  background: var(--cis-green-panel-alt);
}

.summary-row {
  background: var(--cis-green-total);
}

.summary-row td {
  border-top: 2px solid var(--cis-green-border-strong);
  font-weight: 800;
  text-align: left;
  white-space: nowrap;
}

.summary-label {
  margin-right: 10px;
}

.summary-value {
  color: var(--cis-green-dark);
}

.room-report + .room-report {
  margin-top: 24px;
}

.room-report header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 12px;
}

.room-report h3 {
  font-size: 20px;
}

.room-report header dl {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
}

.room-report header dl div {
  min-width: 130px;
  border: 1px solid var(--cis-border);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--cis-surface-muted);
}

.partial-errors {
  margin-top: 18px;
  border: 1px solid var(--cis-danger-border);
  border-radius: 8px;
  padding: 12px;
  background: var(--cis-danger-surface);
  color: var(--cis-danger-dark);
}

.raw-text {
  white-space: pre-wrap;
  line-height: 1.5;
  color: var(--cis-muted-dark);
}

@media (max-width: 920px) {
  .toolbar,
  .result-layout,
  .filters {
    grid-template-columns: 1fr;
  }

  .app-header {
    align-items: center;
    padding: 14px 16px;
  }

  .app-header h1 {
    font-size: 20px;
  }

  .account-actions {
    justify-content: flex-end;
  }
}

@media (max-width: 640px) {
  .result-layout {
    padding: 12px 0;
  }

  .report-panel {
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  #report-output {
    padding: 8px 4px;
  }

  .gross-card header {
    padding: 12px 14px;
  }

  .gross-table {
    font-size: 11px;
  }

  .gross-table th {
    padding: 9px 2px;
    font-size: 10px;
  }

  .gross-table:not(.metric-table) th:first-child,
  .gross-table:not(.metric-table) td:first-child {
    width: 14%;
  }

  .gross-table td {
    padding: 11px 1px;
    font-size: 11px;
  }

  .gross-table:not(.metric-table) td:not(:first-child) {
    font-size: 10.75px;
  }

  .gross-table td.money-negative {
    font-size: 10px;
  }

  .gross-table:not(.metric-table) td.money-negative {
    font-size: 10px;
  }

  .gross-table td:first-child {
    font-size: 9px;
  }

  .metric-table {
    font-size: 10px;
  }

  .metric-table td:first-child {
    font-size: 11px;
  }
}
