:root {
  color-scheme: light;
  --ink: #1f2633;
  --muted: #687284;
  --line: #e7ebf2;
  --panel: #ffffff;
  --paper: #f7f6f1;
  --rose: #ff7e8a;
  --mint: #46c6a8;
  --lemon: #f5bf42;
  --sky: #5aa9e6;
  --plum: #8b6bd6;
  --navy: #25364f;
  --shadow: 0 18px 50px rgba(38, 49, 68, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(145deg, rgba(255, 126, 138, 0.12), transparent 34%),
    linear-gradient(45deg, rgba(70, 198, 168, 0.16), transparent 38%),
    var(--paper);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
  border-radius: 8px;
  backdrop-filter: blur(18px);
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--rose), var(--lemon));
  color: #231b12;
  font-weight: 900;
  letter-spacing: 0;
}

.eyebrow {
  margin: 18px 0 6px;
  color: var(--plum);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2,
p {
  margin-top: 0;
}

.login-panel h1 {
  margin-bottom: 22px;
  font-size: clamp(2rem, 7vw, 3.1rem);
  line-height: 1;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

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

input:focus,
select:focus {
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(90, 169, 230, 0.18);
}

.primary-button,
.secondary-button,
.ghost-button,
.file-button {
  min-height: 42px;
  padding: 0 15px;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
  letter-spacing: 0;
}

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

.secondary-button,
.file-button {
  color: var(--navy);
  background: #eef5ff;
  border: 1px solid #d8e7fb;
}

.ghost-button {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: #c43e4c;
  font-weight: 700;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px;
  color: #fff;
  background: #243248;
}

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

.sidebar-brand span {
  display: block;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.82rem;
}

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

.tab {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.72);
  background: transparent;
  text-align: left;
  font-weight: 800;
}

.tab.active,
.tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.13);
}

.sidebar .ghost-button {
  margin-top: auto;
}

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

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

.topbar h1 {
  max-width: 760px;
  margin-bottom: 0;
  font-size: clamp(1.7rem, 3.4vw, 3.4rem);
  line-height: 1.03;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: end;
}

.date-picker {
  min-width: 150px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

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

.kpi-grid.compact {
  grid-template-columns: repeat(3, minmax(160px, 1fr));
}

.kpi-card,
.chart-card,
.data-card,
.integration-card {
  border: 1px solid rgba(255, 255, 255, 0.82);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 34px rgba(38, 49, 68, 0.08);
  border-radius: 8px;
}

.kpi-card {
  min-height: 132px;
  padding: 18px;
  overflow: hidden;
  position: relative;
}

.kpi-card::after {
  content: "";
  position: absolute;
  right: -24px;
  bottom: -34px;
  width: 108px;
  height: 108px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.42);
}

.kpi-card span,
.kpi-card small {
  position: relative;
  z-index: 1;
  display: block;
  color: rgba(31, 38, 51, 0.72);
  font-weight: 800;
}

.kpi-card strong {
  position: relative;
  z-index: 1;
  display: block;
  margin: 12px 0 6px;
  font-size: clamp(1.8rem, 4vw, 2.55rem);
  line-height: 1;
}

.directory-callout {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(90, 169, 230, 0.14);
  font-size: 0.92rem;
}

.directory-callout a {
  color: var(--ink);
  font-weight: 800;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}

.status-strip.single {
  grid-template-columns: 1fr;
}

.source-pill {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.86rem;
  font-weight: 800;
}

.source-pill::before {
  content: "";
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #cbd3df;
}

.source-pill.ok::before {
  background: var(--mint);
}

.source-pill.warn::before {
  background: var(--lemon);
}

.mint {
  background: linear-gradient(135deg, rgba(70, 198, 168, 0.36), rgba(255, 255, 255, 0.88));
}

.coral {
  background: linear-gradient(135deg, rgba(255, 126, 138, 0.36), rgba(255, 255, 255, 0.88));
}

.lemon {
  background: linear-gradient(135deg, rgba(245, 191, 66, 0.42), rgba(255, 255, 255, 0.88));
}

.sky {
  background: linear-gradient(135deg, rgba(90, 169, 230, 0.34), rgba(255, 255, 255, 0.88));
}

.chart-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 14px;
}

.chart-card,
.data-card,
.integration-card {
  padding: 18px;
}

.chart-card.wide {
  grid-column: span 2;
}

.card-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}

.card-title h2 {
  margin: 0;
  font-size: 1rem;
}

.card-title span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

canvas {
  width: 100%;
  height: 220px;
  max-height: 220px;
  display: block;
}

.chart-card.wide canvas {
  height: 240px;
  max-height: 240px;
}

.split-layout .chart-card canvas {
  height: 240px;
  max-height: 240px;
}

.split-layout,
.integration-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(330px, 0.9fr);
  gap: 14px;
}

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

.section-title h2 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(1.35rem, 2.4vw, 2.2rem);
  line-height: 1.08;
}

.profit-simulator {
  display: grid;
  gap: 14px;
}

.simulator-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 14px;
}

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

.input-grid label {
  min-width: 0;
}

.simulator-table table,
#simPlanTable {
  min-width: 980px;
}

.simulator-table input {
  min-width: 86px;
  min-height: 38px;
  padding: 0 9px;
}

.simulator-results {
  align-items: start;
}

.breakdown-list {
  display: grid;
  gap: 10px;
}

.breakdown-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 42px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.breakdown-list div:last-child {
  border-bottom: 0;
}

.breakdown-list span {
  color: var(--muted);
  font-weight: 800;
}

.breakdown-list strong {
  font-size: 1rem;
  white-space: nowrap;
}

.positive {
  color: #1d8b72;
}

.negative {
  color: #be3445;
}

.sim-microstats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.sim-microstats span {
  padding: 8px 10px;
  border: 1px solid #d8e7fb;
  border-radius: 8px;
  color: var(--navy);
  background: #eef5ff;
  font-size: 0.8rem;
  font-weight: 900;
}

.sim-note {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
  font-weight: 650;
}

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

.compact-form input[name="description"],
.compact-form .other-category,
.compact-form .primary-button {
  grid-column: span 2;
}

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

.data-card.full {
  width: 100%;
}

.table-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.file-button {
  display: inline-grid;
  place-items: center;
}

.file-button input {
  display: none;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: #fff;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.9rem;
}

th {
  color: var(--muted);
  background: #fbfcfe;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

td.amount {
  font-weight: 900;
}

.delete-row {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid #ffd5da;
  border-radius: 8px;
  color: #ad3041;
  background: #fff0f2;
  font-weight: 800;
}

.integration-grid {
  grid-template-columns: repeat(2, minmax(260px, 1fr));
}

.integration-card {
  position: relative;
  min-height: 280px;
}

.integration-card h2 {
  margin-bottom: 8px;
}

.integration-card p {
  color: var(--muted);
  line-height: 1.5;
}

.status-dot {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #cbd3df;
}

.integration-card.configured .status-dot {
  background: var(--mint);
}

pre {
  max-height: 128px;
  overflow: auto;
  padding: 10px;
  border-radius: 8px;
  color: #364154;
  background: #f4f7fb;
  font-size: 0.78rem;
  white-space: pre-wrap;
}

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

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

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

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

  .kpi-grid,
  .kpi-grid.compact,
  .status-strip,
  .chart-grid,
  .split-layout,
  .integration-grid,
  .simulator-grid {
    grid-template-columns: 1fr;
  }

  .chart-card.wide {
    grid-column: auto;
  }

  .section-title {
    align-items: stretch;
    flex-direction: column;
  }
}

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

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

  .compact-form,
  .metrics-form,
  .input-grid {
    grid-template-columns: 1fr;
  }

  .compact-form input[name="description"],
  .compact-form .other-category,
  .compact-form .primary-button {
    grid-column: auto;
  }
}
