:root {
  color-scheme: light;
  --ink: #20242c;
  --muted: #647084;
  --line: #d7dce5;
  --grid-line: #aeb8c8;
  --panel: #ffffff;
  --page: #f5f7fb;
  --accent: #0c8f8f;
  --accent-dark: #096f70;
  --warn: #f29d38;
  --soft-warn: #fff3df;
  --soft-good: #e8f6ee;
  --blue: #2f65d8;
  --pink: #ffd5dc;
  --yellow: #eef714;
  --shadow: 0 16px 42px rgba(26, 37, 60, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button,
.file-action {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  padding: 9px 12px;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

button:hover,
.file-action:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

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

.sidebar {
  background: #13202d;
  color: #fff;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--accent);
  font-weight: 800;
}

.brand h1,
.brand p,
.toolbar h3,
.toolbar p {
  margin: 0;
}

.brand h1 {
  font-size: 19px;
}

.brand p {
  color: #b9c4d2;
  font-size: 13px;
  line-height: 1.35;
}

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

.tab {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #d9e2ee;
  border-color: rgba(255, 255, 255, 0.12);
}

.tab.is-active {
  background: #fff;
  color: var(--ink);
  border-color: #fff;
}

.panel {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 14px;
}

.provider-panel {
  margin-top: 2px;
}

.compact label,
.month-picker label,
.compare-controls label {
  display: grid;
  gap: 7px;
  color: inherit;
  font-size: 13px;
  font-weight: 700;
}

.sidebar select,
.sidebar input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
}

#awsRoleArnInput {
  font-size: 12px;
}

.inline-control {
  display: grid;
  grid-template-columns: 1fr 40px;
  gap: 8px;
  margin-top: 7px;
}

.stacked-field {
  margin-top: 12px;
}

.provider-note {
  margin: 12px 0 0;
  color: #c8d4e3;
  font-size: 13px;
  line-height: 1.4;
}

.icon-btn {
  padding: 0;
  font-size: 20px;
  font-weight: 800;
}

.money-input {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 6px;
  background: #fff;
}

.money-input span {
  color: var(--muted);
  text-align: center;
}

.money-input input {
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
}

.workspace {
  padding: 24px;
  min-width: 0;
}

.topbar,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 18px;
}

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

.topbar h2 {
  margin: 0;
  font-size: 28px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.export-range {
  display: flex;
  align-items: end;
  gap: 8px;
}

.export-range label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.export-range select {
  min-width: 118px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

.actions button:first-child,
#importAwsBtn,
#autoReasonsBtn,
#addVendorBtn,
#addVendorAccountBtn,
#dialogSaveBtn {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

#importAwsBtn:disabled {
  cursor: wait;
  opacity: 0.75;
  transform: none;
}

.danger-btn,
.mini-danger {
  border-color: #d26b6b;
  color: #9f2020;
}

.danger-btn:hover,
.mini-danger:hover {
  border-color: #b91c1c;
  background: #fff1f1;
}

.danger-btn:disabled,
#addVendorAccountBtn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.file-action input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
}

.metric strong {
  font-size: 24px;
}

.view {
  display: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.view.is-active {
  display: block;
}

.toolbar {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.toolbar h3 {
  font-size: 18px;
}

.toolbar p {
  color: var(--muted);
  margin-top: 4px;
  font-size: 14px;
}

.month-picker select,
.compare-controls select,
.vendor-controls select {
  min-width: 145px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
}

.compare-controls {
  display: flex;
  gap: 10px;
}

.vendor-controls {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.vendor-controls label {
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 270px);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 980px;
}

th,
td {
  border-right: 1px solid var(--grid-line);
  border-bottom: 1px solid var(--grid-line);
  padding: 0;
  background: #fff;
  min-width: 105px;
}

tbody tr:nth-child(even) td {
  background: #f7f9fd;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--pink);
  color: #111827;
  font-weight: 800;
  padding: 11px 10px;
  text-align: right;
}

th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  min-width: 250px;
  text-align: left;
}

th:first-child {
  background: var(--blue);
  color: #fff;
}

td:first-child {
  background: #f9fbff;
  font-weight: 700;
  padding: 0 10px;
}

.row-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 39px;
}

.row-actions {
  display: inline-flex;
  flex-shrink: 0;
  gap: 6px;
}

.child-row-title {
  padding-left: 18px;
}

.year-banner-row th {
  padding: 0;
}

.year-banner {
  background: var(--accent);
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: center;
  padding: 6px 12px;
}

.year-nav-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: #ffffff;
  border-radius: 4px;
  padding: 2px 10px;
  font-size: 14px;
  cursor: pointer;
  margin: 0 10px;
  line-height: 1.4;
}

.year-nav-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.account-group-row td {
  background: #fff9cb;
  font-weight: 800;
}

.account-group-row td:first-child {
  background: #fff200;
  color: #111827;
}

.mini-danger {
  padding: 5px 8px;
  font-size: 12px;
  line-height: 1;
}

.mini-action {
  padding: 5px 8px;
  font-size: 12px;
  line-height: 1;
  color: var(--accent-dark);
  border-color: var(--accent);
}

tbody tr:nth-child(even) td:first-child {
  background: #eef3fb;
}

tfoot td {
  background: #eef8f8;
  font-weight: 800;
  padding: 12px 10px;
  text-align: right;
  border-top: 2px solid #8795a8;
}

tfoot td:first-child {
  background: #dff3f3;
}

.cell-input,
.note-input,
.period-input,
.status-select {
  width: 100%;
  border: 1px solid transparent;
  min-height: 39px;
  padding: 9px 10px;
  text-align: right;
  background: transparent;
}

.cell-input:hover,
.cell-input:focus,
.note-input:focus,
.period-input:focus,
.status-select:focus {
  border-color: var(--accent);
  background: #fff;
  outline: none;
}

.cell-input::placeholder {
  color: #9aa5b5;
}

.note-input {
  text-align: left;
  resize: vertical;
  min-width: 220px;
}

.period-input,
.status-select {
  min-width: 135px;
  text-align: left;
}

.third-period-cell {
  border-right: 2px solid #8795a8;
}

.is-warning,
.is-warning input,
.is-warning textarea {
  background: var(--soft-warn);
}

.is-positive {
  color: #127347;
}

.is-negative {
  color: #a53c00;
}

.center-cell {
  text-align: center;
}

.amount-cell {
  padding: 10px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.empty-row {
  position: static;
  padding: 18px;
  color: var(--muted);
  text-align: left;
  font-weight: 700;
}

.checkbox-cell {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

dialog {
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(13, 23, 34, 0.48);
}

.dialog-card {
  display: grid;
  gap: 16px;
  width: min(420px, calc(100vw - 32px));
  padding: 20px;
}

.dialog-card h3,
.dialog-card menu {
  margin: 0;
}

.dialog-card label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

.dialog-card input {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.dialog-card menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0;
}

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

  .sidebar {
    position: static;
  }

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

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

  .actions {
    justify-content: flex-start;
  }

  .table-wrap {
    max-height: none;
  }
}

@media (max-width: 560px) {
  .workspace {
    padding: 14px;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .compare-controls {
    flex-direction: column;
  }
}
