:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #edf3f8;
  --text: #13202d;
  --muted: #647386;
  --line: #dbe4ed;
  --primary: #126e82;
  --primary-strong: #0f5969;
  --accent: #f3b23f;
  --danger: #b42318;
  --success: #177245;
  --shadow: 0 18px 40px rgba(28, 45, 64, 0.10);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.auth-page {
  min-height: 100vh;
  padding: 32px;
  background:
    linear-gradient(135deg, rgba(18, 110, 130, 0.94), rgba(19, 32, 45, 0.94)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1200' height='800' viewBox='0 0 1200 800'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.12'%3E%3Cpath d='M0 120h1200M0 280h1200M0 440h1200M0 600h1200M150 0v800M350 0v800M550 0v800M750 0v800M950 0v800'/%3E%3C/g%3E%3C/svg%3E");
  color: #fff;
}

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

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: #fff;
  color: var(--primary);
  font-weight: 800;
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
}

.brand-subtitle,
.sidebar-brand span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) 420px;
  gap: 56px;
  align-items: center;
  width: min(1120px, 100%);
  min-height: calc(100vh - 110px);
  margin: 0 auto;
}

.auth-copy h1 {
  max-width: 740px;
  margin: 12px 0 32px;
  font-size: 56px;
  line-height: 1.02;
  letter-spacing: 0;
}

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

.auth-page .eyebrow {
  color: #9de7ee;
}

.auth-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  max-width: 680px;
}

.auth-metrics div {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.08);
}

.auth-metrics span {
  display: block;
  font-size: 24px;
  font-weight: 800;
}

.auth-metrics small {
  color: rgba(255, 255, 255, 0.72);
}

.auth-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card {
  padding: 24px;
  color: var(--text);
}

.form-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 18px;
  padding: 4px;
  border-radius: 8px;
  background: var(--surface-2);
}

.tab-button {
  border: 0;
  border-radius: 6px;
  padding: 10px 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab-button.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(28, 45, 64, 0.08);
}

.field {
  display: grid;
  gap: 7px;
  min-width: 160px;
}

.field span,
.date-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(18, 110, 130, 0.12);
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  min-height: 40px;
  border-radius: 8px;
  padding: 9px 14px;
  font-weight: 800;
}

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

.primary-button:hover {
  background: var(--primary-strong);
}

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

.ghost-button {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: transparent;
  color: rgba(255, 255, 255, 0.86);
}

.danger-button {
  border: 1px solid rgba(180, 35, 24, 0.2);
  background: #fff7f6;
  color: var(--danger);
}

.full {
  width: 100%;
  margin-top: 10px;
}

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

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

.sidebar .brand-mark {
  background: var(--accent);
  color: #13202d;
}

.sidebar-brand {
  margin-bottom: 26px;
}

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  border: 0;
  border-radius: 8px;
  padding: 12px 14px;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  text-align: left;
  font-weight: 700;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
}

#logoutButton {
  margin-top: auto;
}

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

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

.topbar h2 {
  margin: 4px 0 0;
  font-size: 30px;
  letter-spacing: 0;
}

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

.date-field {
  display: grid;
  gap: 6px;
}

.date-field input {
  width: 150px;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
}

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

.metric-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #fff;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: 0;
}

.metric-card small {
  color: var(--muted);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.8fr);
  gap: 18px;
}

.panel {
  padding: 18px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
}

.panel-header h3 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.panel-header p {
  min-height: 18px;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.chart-panel canvas {
  display: block;
  width: 100%;
  height: 320px;
}

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

.breakdown-item {
  display: grid;
  gap: 6px;
}

.breakdown-item header {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.bar {
  overflow: hidden;
  height: 9px;
  border-radius: 999px;
  background: var(--surface-2);
}

.bar progress {
  display: block;
  width: 100%;
  height: 9px;
  border: 0;
  border-radius: inherit;
  appearance: none;
}

.bar progress::-webkit-progress-bar {
  border-radius: 999px;
  background: var(--surface-2);
}

.bar progress::-webkit-progress-value {
  border-radius: 999px;
  background: var(--primary);
}

.bar progress::-moz-progress-bar {
  border-radius: 999px;
  background: var(--primary);
}

.bar .tone-cogs::-webkit-progress-value {
  background: var(--accent);
}

.bar .tone-cogs::-moz-progress-bar {
  background: var(--accent);
}

.bar .tone-tax::-webkit-progress-value {
  background: #6d5dfc;
}

.bar .tone-tax::-moz-progress-bar {
  background: #6d5dfc;
}

.bar .tone-ops::-webkit-progress-value {
  background: #d95f59;
}

.bar .tone-ops::-moz-progress-bar {
  background: #d95f59;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

td.muted,
.empty-cell {
  color: var(--muted);
}

.profit-positive {
  color: var(--success);
  font-weight: 800;
}

.profit-negative {
  color: var(--danger);
  font-weight: 800;
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

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

.upload-form {
  grid-template-columns: repeat(4, minmax(180px, 1fr)) auto;
}

.settings-form {
  display: grid;
  gap: 14px;
}

.narrow-panel {
  max-width: 680px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 40px));
  border-radius: 8px;
  padding: 14px 16px;
  background: #13202d;
  color: #fff;
  box-shadow: var(--shadow);
}

@media (max-width: 1120px) {
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid,
  .auth-layout {
    grid-template-columns: 1fr;
  }
}

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

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

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

  .workspace,
  .auth-page {
    padding: 18px;
  }

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

  .auth-copy h1 {
    font-size: 40px;
  }

  .topbar-actions,
  .inline-form,
  .upload-form {
    grid-template-columns: 1fr;
  }

  .date-field input,
  .inline-form .wide {
    width: 100%;
    grid-column: auto;
  }
}

@media (max-width: 560px) {
  .metrics-grid,
  .auth-metrics {
    grid-template-columns: 1fr;
  }

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .auth-copy h1 {
    font-size: 32px;
  }
}
