:root {
  --bg: #070707;
  --panel: #111111;
  --panel-2: #171717;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f7f2ea;
  --muted: #a8a09a;
  --orange: #ff7a18;
  --orange-2: #ffae42;
  --green: #3ddc97;
  --red: #ff5c5c;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 122, 24, 0.22), transparent 28rem),
    linear-gradient(135deg, #050505 0%, #0d0d0d 48%, #140b06 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 7, 7, 0.82);
  backdrop-filter: blur(18px);
}

.header-inner,
.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.header-inner {
  display: grid;
  grid-template-columns: auto minmax(280px, 520px) auto;
  align-items: center;
  min-height: 74px;
  gap: 14px;
  padding: 10px 0;
}

.brand {
  grid-column: 1;
  grid-row: 1;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(255, 122, 24, 0.55);
  border-radius: var(--radius);
  color: #121212;
  font-size: 0.82rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--orange), var(--orange-2));
  box-shadow: 0 10px 28px rgba(255, 122, 24, 0.2);
}

.brand strong {
  display: block;
  letter-spacing: 0;
}

.brand small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

.export-button,
.filter-button,
.monthly-filter-button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: #181818;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.export-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 800;
}

.logout-button {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: #181818;
  font-weight: 850;
}

.logout-button:hover {
  border-color: rgba(255, 122, 24, 0.65);
}

.export-button:not(:disabled):hover,
.filter-button:hover,
.monthly-filter-button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 122, 24, 0.65);
}

.export-button:not(:disabled) {
  color: #15100c;
  border-color: transparent;
  background: linear-gradient(135deg, var(--orange), var(--orange-2));
}

.export-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-shell {
  display: grid;
  gap: 22px;
  padding: 18px 0 44px;
}

.app-tabs {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(17, 17, 17, 0.82);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
}

.tab-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
  background: transparent;
  font-size: 0.95rem;
  font-weight: 950;
  white-space: nowrap;
}

.tab-button.active {
  color: #15100c;
  background: var(--orange);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: grid;
  gap: 22px;
}

.auth-shell {
  width: min(540px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0;
}

.auth-card {
  display: grid;
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(17, 17, 17, 0.9);
  box-shadow: var(--shadow);
}

.auth-card h1 {
  font-size: clamp(2rem, 8vw, 3rem);
}

.auth-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.auth-card label {
  display: grid;
  gap: 7px;
}

.auth-card label span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-card input {
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: 0;
  color: var(--text);
  background: #0b0b0b;
}

.auth-card input:focus {
  border-color: rgba(255, 122, 24, 0.72);
  box-shadow: 0 0 0 3px rgba(255, 122, 24, 0.12);
}

.remember-login {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 9px !important;
  min-height: 42px;
  padding: 0 2px;
  color: var(--text);
  font-weight: 850;
}

.remember-login input {
  width: 18px;
  height: 18px;
  min-height: 0;
  padding: 0;
  accent-color: var(--orange);
}

.remember-login span {
  color: var(--text) !important;
  font-size: 0.9rem !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
}

.auth-button {
  min-height: 48px;
  border: 0;
  border-radius: var(--radius);
  color: #15100c;
  background: var(--orange);
  font-weight: 950;
}

.auth-message {
  min-height: 1.4em;
  color: var(--orange-2) !important;
  font-weight: 800;
}

.upload-panel,
.workspace-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(17, 17, 17, 0.82);
  box-shadow: var(--shadow);
}

.upload-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.85fr);
  align-items: center;
  gap: 22px;
  padding: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--orange-2);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  max-width: 700px;
  margin: 0;
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.upload-copy p:last-child {
  max-width: 590px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.drop-zone {
  position: relative;
  display: grid;
  min-height: 230px;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 24px;
  border: 1px dashed rgba(255, 122, 24, 0.55);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 122, 24, 0.12), rgba(255, 255, 255, 0.03));
  text-align: center;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
  overflow: hidden;
  cursor: pointer;
}

.drop-zone:hover,
.drop-zone.drag-over {
  transform: translateY(-2px);
  border-color: var(--orange-2);
  background: linear-gradient(180deg, rgba(255, 122, 24, 0.22), rgba(255, 255, 255, 0.05));
}

.drop-zone input {
  position: absolute;
  inset: 0;
  z-index: 2;
  inline-size: 100%;
  block-size: 100%;
  opacity: 0;
  cursor: pointer;
}

.drop-icon {
  pointer-events: none;
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 999px;
  color: #121212;
  font-size: 2rem;
  font-weight: 300;
  background: var(--orange);
}

.drop-title {
  pointer-events: none;
  font-size: 1.05rem;
  font-weight: 850;
}

.drop-subtitle {
  pointer-events: none;
  color: var(--muted);
  font-size: 0.9rem;
}

.file-status {
  pointer-events: none;
  max-width: 100%;
  margin-top: 8px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--radius);
  color: #d8d0c8;
  background: rgba(0, 0, 0, 0.22);
  font-size: 0.82rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-status.success {
  color: var(--green);
}

.file-status.error {
  color: var(--red);
}

.workspace-card {
  overflow: hidden;
}

.date-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 122, 24, 0.06);
}

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

.date-field span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.date-field input,
.date-field select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: 0;
  color: var(--text);
  background: #0b0b0b;
}

.date-field input:focus,
.date-field select:focus,
.search-wrap:focus-within {
  border-color: rgba(255, 122, 24, 0.72);
  box-shadow: 0 0 0 3px rgba(255, 122, 24, 0.12);
}

.load-button,
.delete-button {
  align-self: end;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: #15100c;
  background: var(--orange);
  font-weight: 900;
  transition: transform 160ms ease, opacity 160ms ease;
}

.delete-button {
  color: var(--text);
  border-color: rgba(255, 92, 92, 0.45);
  background: rgba(255, 92, 92, 0.16);
}

.load-button:not(:disabled):hover,
.delete-button:not(:disabled):hover {
  transform: translateY(-1px);
}

.load-button:disabled,
.delete-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.house-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.house-field {
  display: grid;
  gap: 7px;
}

.house-field span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.house-field textarea {
  width: 100%;
  min-height: 86px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: 0;
  color: var(--text);
  background: #0b0b0b;
}

.house-field textarea:focus {
  border-color: rgba(255, 122, 24, 0.72);
  box-shadow: 0 0 0 3px rgba(255, 122, 24, 0.12);
}

.house-actions {
  display: grid;
  align-content: end;
  gap: 8px;
}

.house-actions span {
  color: var(--orange-2);
  font-size: 0.84rem;
  font-weight: 900;
  text-align: center;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0b0b0b;
}

.search-wrap span {
  color: var(--orange-2);
  font-size: 1.2rem;
}

.search-wrap input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.search-wrap input::placeholder {
  color: #77706b;
}

.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.exclude-house-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: #181818;
  font-weight: 850;
}

.exclude-house-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--orange);
}

.copy-visible-button {
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid rgba(255, 122, 24, 0.5);
  border-radius: var(--radius);
  color: #15100c;
  background: var(--orange);
  font-weight: 950;
  transition: transform 160ms ease, opacity 160ms ease;
}

.copy-visible-button:hover {
  transform: translateY(-1px);
}

.filter-button,
.monthly-filter-button {
  min-height: 46px;
  padding: 0 14px;
  font-weight: 800;
}

.filter-button.active,
.monthly-filter-button.active {
  color: #15100c;
  border-color: transparent;
  background: var(--orange);
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
}

.stats-strip div {
  padding: 16px 18px;
  border-right: 1px solid var(--line);
}

.stats-strip div:last-child {
  border-right: 0;
}

.stats-strip span {
  display: block;
  font-size: 1.45rem;
  font-weight: 900;
}

.stats-strip small {
  color: var(--muted);
  font-weight: 750;
}

.table-shell {
  position: relative;
  min-height: 280px;
  overflow: hidden;
}

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

thead {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #121212;
}

th:nth-child(1),
td:nth-child(1) {
  width: 18%;
}

th:nth-child(2),
td:nth-child(2),
th:nth-child(3),
td:nth-child(3) {
  width: 29%;
}

th:nth-child(4),
td:nth-child(4) {
  width: 24%;
}

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

tbody tr {
  transition: background 140ms ease, box-shadow 140ms ease;
}

tbody tr.selected-row {
  background: rgba(255, 122, 24, 0.16);
  box-shadow: inset 4px 0 0 var(--orange);
}

tbody tr.selected-row td {
  border-bottom-color: rgba(255, 122, 24, 0.35);
}

th button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 52px;
  padding: 0 18px;
  border: 0;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 900;
  background: transparent;
  overflow-wrap: anywhere;
}

th button:hover {
  color: var(--orange-2);
}

th button span {
  width: 1rem;
  color: var(--orange);
}

td {
  padding: 16px 18px;
  color: #f3ede6;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
  word-break: break-word;
  transition: background 130ms ease, color 130ms ease;
}

td.copyable {
  cursor: copy;
}

td.copyable:hover {
  color: #15100c;
  background: var(--orange);
}

tr.selected-row td.copyable:hover {
  color: var(--text);
  background: rgba(255, 122, 24, 0.28);
}

.total-positive {
  color: var(--green);
  font-weight: 850;
}

.total-negative {
  color: var(--red);
  font-weight: 850;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  min-height: 280px;
  padding: 32px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--text);
  font-size: 1.3rem;
}

.empty-state.hidden {
  display: none;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.66);
  backdrop-filter: blur(10px);
}

.loading-overlay.active {
  display: grid;
}

.loader-card {
  display: grid;
  place-items: center;
  gap: 10px;
  width: min(320px, 100%);
  padding: 28px;
  border: 1px solid rgba(255, 122, 24, 0.35);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid rgba(255, 255, 255, 0.16);
  border-top-color: var(--orange);
  border-radius: 999px;
  animation: spin 800ms linear infinite;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  padding: 10px 14px;
  border: 1px solid rgba(255, 122, 24, 0.45);
  border-radius: var(--radius);
  color: #15100c;
  font-weight: 900;
  background: var(--orange);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 820px) {
  .header-inner,
  .app-shell {
    width: min(100% - 20px, 1180px);
  }

  .header-inner {
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 0;
    gap: 10px;
    padding: 9px 0;
  }

  .brand small {
    display: none;
  }

  .brand {
    grid-column: 1;
  }

  .export-button {
    padding: 0 12px;
  }

  .logout-button {
    grid-column: 2;
    padding: 0 10px;
  }

  .upload-panel,
  .toolbar,
  .date-panel,
  .house-panel {
    grid-template-columns: 1fr;
  }

  .upload-panel {
    padding: 18px;
  }

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

  .load-button,
  .delete-button,
  .copy-visible-button {
    width: 100%;
  }

  .app-tabs {
    grid-column: 1 / -1;
    grid-row: 2;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    padding: 4px;
  }

  .tab-button {
    min-height: 38px;
    padding: 0 4px;
    font-size: 0.78rem;
  }

  .app-shell {
    padding-top: 12px;
  }
}

@media (max-width: 560px) {
  .brand strong {
    max-width: 128px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .export-button {
    min-width: 44px;
    padding: 0 10px;
  }

  .export-button {
    font-size: 0.86rem;
  }

  .stats-strip span {
    font-size: 1.15rem;
  }

  .stats-strip div {
    padding: 12px;
  }

  th button {
    min-height: 46px;
    padding: 0 6px;
    font-size: 0.7rem;
    line-height: 1.12;
  }

  th button span {
    width: 0.7rem;
  }

  td {
    padding: 10px 6px;
    font-size: 0.72rem;
    line-height: 1.2;
  }

  th:nth-child(1),
  td:nth-child(1) {
    width: 20%;
  }

  th:nth-child(2),
  td:nth-child(2),
  th:nth-child(3),
  td:nth-child(3) {
    width: 28%;
  }

  th:nth-child(4),
  td:nth-child(4) {
    width: 24%;
  }
}
