:root {
  --blue-900: #0b2346;
  --blue-800: #103a73;
  --blue-700: #15478c;
  --blue-600: #1f5fab;
  --blue-100: #e8f1ff;
  --ink: #162033;
  --muted: #64748b;
  --canvas: #f4f7fb;
  --surface: #ffffff;
  --surface-blue: #f0f6ff;
  --line: #dbe5f1;
  --teal: #0f9f8f;
  --amber: #d97706;
  --danger: #c24136;
  --success: #138a55;
  --shadow: 0 24px 70px rgb(15 35 75 / 0.14);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(135deg, rgba(21, 71, 140, 0.12), transparent 36%),
    linear-gradient(315deg, rgba(15, 159, 143, 0.1), transparent 34%),
    var(--canvas);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

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

.app-shell.logged-out {
  display: block;
}

.app-shell.logged-out .sidebar {
  display: none;
}

.app-shell.logged-out .workspace {
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
  height: 100vh;
  border-right: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(180deg, var(--blue-900), var(--blue-700));
  color: #ffffff;
  padding: 22px;
}

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

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-weight: 800;
}

.brand h1,
.topbar h2,
.form-card h2,
.login-copy h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 1.35rem;
}

.brand p,
.topbar p,
.login-copy p {
  margin: 4px 0 0;
  color: var(--muted);
}

.brand p,
.sidebar .session-chip {
  color: rgba(255, 255, 255, 0.75);
}

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

.tab-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.76);
  padding: 10px 12px;
  text-align: left;
}

.tab-button.active,
.tab-button:hover {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.session-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 8px 10px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #43e2b5;
}

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

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

.topbar h2 {
  color: var(--blue-900);
  font-size: clamp(1.55rem, 2vw, 2.15rem);
}

.eyebrow,
.panel-kicker {
  color: var(--blue-700);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-actions,
.form-actions,
.row-actions,
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.button,
.primary-button,
.secondary-button,
.danger-button,
.ghost-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 14px;
  color: var(--ink);
  font-weight: 760;
  line-height: 1;
  text-align: center;
  text-decoration: none;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.button:hover,
.primary-button:hover,
.secondary-button:hover,
.danger-button:hover,
.ghost-link:hover {
  transform: translateY(-1px);
}

.button-primary,
.primary-button {
  background: var(--blue-700);
  color: #ffffff;
}

.button-primary:hover,
.primary-button:hover {
  background: var(--blue-600);
}

.button-muted,
.secondary-button,
.ghost-link {
  border-color: var(--line);
  background: #ffffff;
  color: var(--blue-800);
}

.sidebar .button-muted,
.sidebar .secondary-button,
.sidebar .ghost-link {
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.danger-button {
  border-color: rgba(194, 65, 54, 0.32);
  background: #fff4f2;
  color: var(--danger);
}

.surface {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(300px, 400px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.entity-form.hidden + .table-card {
  grid-column: 1 / -1;
}

.login-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 430px);
  gap: 24px;
  min-height: calc(100vh - 52px);
  align-items: center;
  max-width: 1180px;
  margin: 0 auto;
}

.login-copy {
  max-width: 660px;
}

.login-copy h2 {
  margin-top: 8px;
  color: var(--blue-900);
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: 1.02;
}

.login-copy p {
  max-width: 560px;
  font-size: 1.05rem;
}

.form-card {
  display: grid;
  gap: 14px;
  width: min(100%, 460px);
  padding: 18px;
}

.entity-form {
  width: 100%;
}

.form-heading {
  display: grid;
  gap: 4px;
}

.form-card label {
  display: grid;
  gap: 7px;
  color: var(--blue-900);
  font-size: 0.86rem;
  font-weight: 720;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue-700);
  box-shadow: 0 0 0 4px rgba(21, 71, 140, 0.12);
}

textarea {
  min-height: 88px;
  resize: vertical;
}

.dashboard-panel {
  display: grid;
  gap: 16px;
}

.dashboard-loading {
  padding: 20px;
  color: var(--blue-900);
  font-weight: 760;
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 380px);
  gap: 18px;
  padding: 22px;
  background:
    linear-gradient(135deg, rgba(21, 71, 140, 0.1), transparent 46%),
    #ffffff;
}

.dashboard-hero strong {
  display: block;
  margin-top: 8px;
  color: var(--blue-900);
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.02;
  overflow-wrap: anywhere;
}

.dashboard-hero p {
  max-width: 620px;
  margin: 8px 0 0;
  color: var(--muted);
}

.dashboard-split {
  display: grid;
  gap: 10px;
}

.dashboard-split span,
.movement-grid span {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  padding: 12px;
  font-size: 0.84rem;
}

.dashboard-split strong,
.movement-grid strong {
  color: var(--blue-900);
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

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

.summary-card {
  min-width: 0;
  padding: 18px;
}

.wide-card {
  grid-row: span 2;
}

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

.card-heading > strong {
  color: var(--blue-900);
  font-size: 1.4rem;
}

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

.movement-grid.compact {
  grid-template-columns: 1fr;
}

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

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.list-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.list-row div,
.progress-row div {
  min-width: 0;
}

.list-row strong,
.progress-row strong {
  display: block;
  color: var(--blue-900);
  line-height: 1.25;
}

.list-row span,
.progress-row span,
.empty-state {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.84rem;
}

.list-row b {
  flex: 0 0 auto;
  color: var(--blue-900);
  text-align: right;
  overflow-wrap: anywhere;
}

.transaction-list .list-row b {
  min-width: 128px;
}

.progress-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(90px, 120px) auto;
  gap: 10px;
  align-items: center;
}

.progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--blue-100);
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue-700);
}

.success-text {
  color: var(--success) !important;
}

.danger-text {
  color: var(--danger) !important;
}

.table-card {
  min-width: 0;
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  border-bottom: 1px solid var(--line);
  background: var(--surface-blue);
  padding: 16px;
}

.table-toolbar input {
  width: min(100%, 360px);
  max-width: none;
}

.table-scroll {
  overflow: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #fbfdff;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

td {
  color: #27364c;
}

tbody tr:hover {
  background: #f7fbff;
}

.badge {
  display: inline-flex;
  border-radius: 999px;
  background: #e8f1ff;
  color: var(--blue-800);
  padding: 5px 9px;
  font-size: 0.78rem;
  font-weight: 760;
}

.app-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.app-alert::before {
  display: grid;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  background: var(--blue-100);
  color: var(--blue-700);
  content: "i";
  font-size: 0.78rem;
  font-weight: 900;
}

.app-alert-success {
  border-color: rgba(19, 138, 85, 0.26);
}

.app-alert-success::before {
  background: rgba(19, 138, 85, 0.12);
  color: var(--success);
  content: "✓";
}

.app-alert-error {
  border-color: rgba(194, 65, 54, 0.28);
}

.app-alert-error::before {
  background: rgba(194, 65, 54, 0.12);
  color: var(--danger);
  content: "!";
}

.app-alert-warning {
  border-color: rgba(217, 119, 6, 0.28);
}

.app-alert-warning::before {
  background: rgba(217, 119, 6, 0.13);
  color: var(--amber);
  content: "!";
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  width: min(430px, calc(100vw - 36px));
}

.hidden {
  display: none !important;
}

@media (max-width: 1040px) {
  .app-shell,
  .login-panel,
  .content-grid,
  .dashboard-hero,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

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

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

  .login-copy h2 {
    font-size: clamp(2rem, 8vw, 3.4rem);
  }
}

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

  .topbar,
  .table-toolbar,
  .header-actions,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .module-tabs,
  .movement-grid,
  .progress-row {
    grid-template-columns: 1fr;
  }

  .list-row,
  .card-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .table-toolbar input {
    max-width: none;
  }
}
