:root {
  --bg: #1a1919;
  --surface: #262525;
  --surface-soft: #2e2d2d;
  --text: #ede9ff;
  --muted: #8a8595;
  --line: #3a3840;
  --accent: #5E3ADB;
  --accent-dark: #4a2cb8;
  --accent-light: #A267FF;
  --danger-bg: #2d1b1b;
  --danger-text: #ff7070;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Poppins', sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 800;
  font-size: 20px;
}

.brand-sta {
  color: #ede9ff;
}

.brand-soft {
  color: var(--accent);
}

.brand-arrow {
  margin-left: 4px;
}

.nav {
  display: flex;
  gap: 8px;
}

.nav a,
.logout-form button,
.text-link {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--muted);
  font-weight: 700;
}

.nav a:hover,
.text-link:hover {
  color: var(--accent-light);
  background: rgba(94, 58, 219, 0.15);
}

.logout-form {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

button {
  font: inherit;
  cursor: pointer;
}

.logout-form button {
  background: transparent;
}

.logout-form button:hover {
  color: var(--danger-text);
  border-color: var(--line);
}

.page {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 36px 0 56px;
}

.auth-shell {
  min-height: calc(100vh - 160px);
  display: grid;
  place-items: center;
}

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

.auth-panel {
  width: min(420px, 100%);
  padding: 32px;
}

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

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: clamp(32px, 4vw, 44px);
}

h2 {
  font-size: 20px;
}

.muted {
  color: var(--muted);
}

.form-stack {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  color: var(--text);
  background: var(--surface-soft);
  font: inherit;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(94, 58, 219, 0.25);
  border-color: var(--accent);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 10px 16px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
}

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

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 14px;
  color: var(--text);
  background: var(--surface);
  font-weight: 800;
}

.secondary-button:hover {
  border-color: var(--accent);
  color: var(--accent-light);
  background: rgba(94, 58, 219, 0.1);
}

.link-button {
  border: 0;
  padding: 0;
  color: var(--accent);
  background: transparent;
  font-weight: 800;
}

.link-button:hover {
  color: var(--accent-light);
  text-decoration: underline;
}

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

.danger-link:hover {
  color: #ff9999;
}

.alert {
  margin-top: 18px;
  border: 1px solid rgba(255, 112, 112, 0.4);
  border-radius: 6px;
  padding: 12px 14px;
  color: var(--danger-text);
  background: var(--danger-bg);
  font-weight: 700;
}

.form-actions,
.row-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.form-actions {
  flex-wrap: wrap;
}

.row-actions {
  justify-content: flex-end;
}

.section-heading {
  margin-bottom: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  padding: 22px;
}

.stat-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 700;
}

.stat-card strong {
  font-size: 34px;
}

.spend-card {
  display: grid;
  align-content: start;
  gap: 10px;
}

.spend-list {
  display: grid;
  gap: 8px;
}

.spend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.spend-row span {
  margin: 0;
  color: var(--text);
}

.spend-row strong {
  font-size: 16px;
  white-space: nowrap;
}

.expense-spend-grid {
  grid-template-columns: minmax(520px, 760px);
}

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

.settlement-table {
  min-width: 560px;
}

.settlement-table th,
.settlement-table td {
  padding: 10px 8px;
}

.settlement-table td strong {
  font-size: 14px;
}

.content-section,
.form-panel {
  padding: 24px;
}

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

.expense-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  align-items: start;
  gap: 20px;
}

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

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

.table-actions {
  display: flex;
  justify-content: flex-end;
}

.bulk-table-form {
  display: grid;
  gap: 16px;
}

.editable-table th,
.editable-table td {
  padding: 9px 8px;
  vertical-align: middle;
}

.editable-table input,
.editable-table select {
  min-height: 36px;
  padding: 7px 8px;
  font-size: 14px;
}

.table-number-input {
  min-width: 110px;
  text-align: right;
}

.table-month-input {
  min-width: 132px;
}

.table-select {
  min-width: 138px;
}

.table-text-input {
  min-width: 180px;
}

.month-filter {
  display: flex;
  align-items: center;
  gap: 8px;
}

.month-filter input {
  min-width: 150px;
}

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

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

th {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0;
}

tr:last-child td {
  border-bottom: 0;
}

.align-right {
  text-align: right;
}

.cell-subtext {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.expense-complete-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.completed-expense-row {
  color: var(--muted);
  background: #1f1e1e;
  opacity: 0.68;
}

.completed-expense-row strong {
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 8px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 800;
}

.empty-state {
  margin: 0;
  color: var(--muted);
}

.status-pill.status-current {
  color: var(--accent-light);
  border-color: var(--accent-light);
  background: rgba(162, 103, 255, 0.12);
}

.status-pill.status-upcoming {
  color: #60a5fa;
  border-color: #60a5fa;
  background: rgba(96, 165, 250, 0.12);
}

.status-pill.status-fired {
  color: var(--danger-text);
  border-color: var(--danger-text);
  background: var(--danger-bg);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  font-weight: 700;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  accent-color: var(--accent);
}

.org-chart-section {
  margin-top: 32px;
}

.org-tree {
  padding: 24px;
  background: rgba(46, 45, 45, 0.5);
  border-radius: 6px;
  overflow-x: auto;
}

.tree-root,
.tree-children {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tree-root > li {
  margin-left: 0;
}

.tree-children {
  margin-top: 12px;
  margin-left: 24px;
  padding-left: 12px;
  border-left: 2px solid var(--line);
}

.tree-children > li {
  position: relative;
}

.tree-children > li::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 18px;
  width: 12px;
  height: 2px;
  background: var(--line);
}

.tree-node {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: rgba(94, 58, 219, 0.08);
  border: 1px solid rgba(94, 58, 219, 0.3);
  border-radius: 6px;
  width: fit-content;
}

.node-name {
  font-weight: 700;
  color: var(--text);
}

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

.staff-table,
.projects-table {
  padding: 24px;
}

.revenue-summary-table {
  min-width: 760px;
}

.revenue-fill-table {
  min-width: 1120px;
}

.revenue-detail-table {
  min-width: 880px;
}

.revenue-detail-section {
  margin-top: 24px;
}

.selected-row {
  background: rgba(94, 58, 219, 0.12);
}

.table-link {
  display: inline-flex;
  min-height: auto;
  padding: 0;
}

.status-pill.status-slot-pending {
  color: #fbbf24;
  border-color: #fbbf24;
  background: rgba(251, 191, 36, 0.12);
}

.status-pill.status-slot-sent-invoice {
  color: #60a5fa;
  border-color: #60a5fa;
  background: rgba(96, 165, 250, 0.12);
}

.status-pill.status-slot-received {
  color: #34d399;
  border-color: #34d399;
  background: rgba(52, 211, 153, 0.12);
}

.status-pill.status-slot-cash-out {
  color: #f472b6;
  border-color: #f472b6;
  background: rgba(244, 114, 182, 0.12);
}

.search-form {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  align-items: center;
}

.search-form input {
  flex: 1;
  min-width: 200px;
}

.search-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 14px;
  color: var(--text);
  background: var(--surface);
  font-weight: 800;
  cursor: pointer;
}

.search-button:hover {
  border-color: var(--accent);
  color: var(--accent-light);
  background: rgba(94, 58, 219, 0.1);
}

.search-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  color: var(--muted);
  font-weight: 800;
  text-decoration: none;
}

.search-clear:hover {
  color: var(--danger-text);
}

@media (max-width: 820px) {
  .org-tree {
    padding: 16px;
  }

  .tree-children {
    margin-left: 16px;
    padding-left: 8px;
  }

  .tree-children > li::before {
    left: -8px;
    width: 8px;
  }
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
    padding: 18px 20px;
  }

  .logout-form {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }

  .page {
    width: min(100% - 28px, 1180px);
    padding-top: 24px;
  }

  .stats-grid,
  .expense-layout {
    grid-template-columns: 1fr;
  }
}
