:root {
  --bg: #f3f5f8;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-2: #f8fafc;
  --surface-3: #eef3f8;
  --text: #14202b;
  --muted: #64748b;
  --line: #d8e0e8;
  --primary: #0a6fcb;
  --primary-dark: #074d8e;
  --danger: #b42318;
  --pink: #f0529c;
  --gold: #bd8414;
  --green: #14804a;
  --blue: #1177cc;
  --ink: #0f1720;
  --shadow: 0 18px 50px rgba(15, 23, 32, 0.1);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

html {
  background: #e7edf3;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(240, 82, 156, 0.1), transparent 24%),
    radial-gradient(circle at bottom right, rgba(17, 119, 204, 0.12), transparent 28%),
    linear-gradient(180deg, #f8fafc 0%, #edf2f7 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  border: none;
}

input,
select {
  width: 100%;
}

.hidden {
  display: none !important;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 32, 0.6);
  backdrop-filter: blur(14px);
}

.auth-overlay.hidden {
  pointer-events: none;
}

.auth-card {
  width: min(100%, 560px);
  padding: 28px;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 30px 80px rgba(15, 23, 32, 0.25);
}

.auth-hero {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.auth-copy {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.auth-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 6px;
  border-radius: 18px;
  background: #edf3f9;
  margin-bottom: 18px;
}

.auth-tab {
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
}

.auth-tab.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
}

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

.auth-form label,
.form-grid label {
  display: grid;
  gap: 8px;
  font-weight: 600;
  color: #233140;
}

.auth-form input,
.auth-form select,
.form-grid input,
.form-grid select {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 14px;
  background: var(--surface-2);
}

.auth-form input:focus,
.auth-form select:focus,
.form-grid input:focus,
.form-grid select:focus,
.search-row input:focus {
  outline: 2px solid rgba(10, 111, 203, 0.18);
  border-color: var(--primary);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  color: #fff;
  background:
    linear-gradient(200deg, rgba(240, 82, 156, 0.15), transparent 24%),
    linear-gradient(180deg, #0f1720 0%, #121d2a 100%);
}

.brand-block,
.brand-mark,
.topbar-actions,
.user-pill,
.sync-pill,
.search-row,
.split-actions,
.export-actions,
.stack-item,
.report-line,
.section-header,
.header-actions {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 16px;
}

.brand-mark {
  width: 58px;
  height: 58px;
  justify-content: center;
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 14px 34px rgba(240, 82, 156, 0.35);
}

.brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.auth-backup-import {
  justify-content: center;
  margin-top: 10px;
}

.brand-block h1,
.topbar-title {
  margin: 4px 0 0;
}

.brand-block h1 {
  font-size: 1.15rem;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--muted);
}

.sidebar .eyebrow {
  color: rgba(255, 255, 255, 0.65);
}

.nav-tabs {
  display: grid;
  gap: 10px;
}

.nav-tab {
  padding: 14px 16px;
  border-radius: 16px;
  text-align: left;
  cursor: pointer;
  color: #deebf7;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: 0.2s ease;
}

.nav-tab:hover,
.nav-tab.active {
  transform: translateX(3px);
  background: linear-gradient(135deg, rgba(240, 82, 156, 0.24), rgba(17, 119, 204, 0.24));
  border-color: rgba(255, 255, 255, 0.22);
}

.sidebar-note {
  margin-top: auto;
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.55;
  font-size: 0.92rem;
}

.main-content {
  padding: 24px;
}

.topbar {
  margin-bottom: 22px;
  padding: 16px 18px;
  border: 1px solid rgba(216, 224, 232, 0.95);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-title {
  font-size: 1.7rem;
}

.topbar-actions,
.search-row,
.split-actions,
.export-actions,
.section-header,
.header-actions {
  gap: 12px;
  flex-wrap: wrap;
}

.snapshot-filter-wrap {
  position: relative;
}

.snapshot-filter-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 5;
  min-width: 320px;
  padding: 16px;
  border: 1px solid rgba(216, 224, 232, 0.95);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

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

.sync-pill,
.user-pill {
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  background: #f3f7fb;
  border: 1px solid var(--line);
}

.user-pill {
  display: grid;
  gap: 2px;
}

.user-pill span {
  color: var(--muted);
  font-size: 0.85rem;
}

.sync-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #94a3b8;
}

.sync-dot.online {
  background: #22c55e;
}

.sync-dot.warning {
  background: #f59e0b;
}

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

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

.section-header {
  justify-content: space-between;
}

.section-header h2 {
  margin: 4px 0 0;
  font-size: 1.8rem;
}

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

.metric-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.single-left {
  grid-template-columns: minmax(0, 760px);
}

.metric-card,
.card {
  border: 1px solid rgba(216, 224, 232, 0.92);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.metric-card {
  position: relative;
  overflow: hidden;
  padding: 22px;
}

.metric-card::after {
  content: "";
  position: absolute;
  inset: auto -36px -42px auto;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  opacity: 0.1;
  background: currentColor;
}

.metric-card p,
.metric-card span {
  margin: 0;
}

.metric-card h3 {
  margin: 10px 0 8px;
  font-size: 2rem;
}

.metric-card span,
.card-header p,
.list-item-subtitle,
.report-label,
.status-text,
.stack-item-subtitle,
.stack-item-meta {
  color: var(--muted);
}

.accent-pink { color: var(--pink); }
.accent-blue { color: var(--blue); }
.accent-gold { color: var(--gold); }
.accent-green { color: var(--green); }

.card {
  padding: 22px;
}

.card-header {
  margin-bottom: 18px;
}

.card-header h3 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}

.card-header p,
.status-text {
  margin: 0;
  line-height: 1.5;
}

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

.full-width {
  grid-column: 1 / -1;
}

.toggle-field {
  display: flex !important;
  justify-content: space-between;
  align-items: center;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-2);
}

.toggle-field input {
  width: auto;
  transform: scale(1.1);
}

.form-actions {
  display: flex;
  justify-content: flex-start;
}

.primary-button,
.ghost-button,
.danger-button,
.import-label {
  padding: 12px 16px;
  border-radius: 14px;
  cursor: pointer;
  transition: 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

.ghost-button,
.import-label {
  color: var(--primary-dark);
  background: #eef5fb;
}

.danger-button {
  color: var(--danger);
  background: #fff1f0;
}

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

.search-card {
  margin-bottom: 2px;
}

.search-row input {
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.stack-list,
.list-block,
.report-output {
  display: grid;
  gap: 12px;
}

.stack-item,
.list-item,
.report-line {
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.stack-item {
  flex-direction: column;
  align-items: flex-start;
}

.stack-item-title,
.list-item-title {
  font-weight: 700;
}

.stack-item-subtitle,
.list-item-subtitle,
.stack-item-meta {
  font-size: 0.93rem;
}

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

.table-card {
  padding-bottom: 14px;
}

.table-wrap {
  overflow: auto;
}

.credit-summary-row {
  background: #f7fbff;
  font-weight: 600;
}

.credit-person-button {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-align: left;
}

.credit-person-button::before {
  color: var(--primary);
  content: "+";
  display: inline-block;
  font-weight: 700;
  margin-right: 0.35rem;
  width: 0.75rem;
}

.credit-person-button[aria-expanded="true"]::before {
  content: "-";
}

.credit-person-button span {
  color: var(--muted);
  font-size: 0.82em;
  font-weight: 500;
}

.credit-detail-row {
  background: #fff;
}

.credit-detail-indent {
  color: var(--muted);
  padding-left: 1.1rem;
}

.credit-payment-detail-row td {
  background: #fff;
  padding: 0 12px 14px;
}

.credit-payment-history {
  background: #f7fbff;
  border-left: 3px solid var(--primary);
  color: var(--ink);
  font-size: 0.92rem;
  padding: 0.8rem 1rem;
}

.credit-payment-history p {
  margin: 0.45rem 0;
}

.credit-payment-history ul {
  margin: 0.45rem 0 0;
  padding-left: 1.2rem;
}

.credit-payment-history li + li {
  margin-top: 0.3rem;
}

.staff-view .staff-restricted {
  display: none !important;
}

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

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

th {
  color: var(--muted);
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

tbody tr:hover {
  background: #fafcfd;
}

.report-output {
  min-height: 280px;
  align-content: start;
}

.report-line {
  justify-content: space-between;
}

.report-value {
  font-weight: 800;
}

.report-details {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  overflow: hidden;
}

.report-details summary {
  list-style: none;
  cursor: pointer;
}

.report-details summary::-webkit-details-marker {
  display: none;
}

.report-details[open] summary {
  border-bottom: 1px solid var(--line);
}

.report-details-body {
  display: grid;
  gap: 8px;
  padding: 12px 16px 14px;
}

.report-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(216, 224, 232, 0.7);
}

.report-detail-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.report-detail-label,
.report-detail-value {
  font-size: 0.93rem;
}

.report-detail-label {
  color: var(--muted);
}

.report-detail-value {
  font-weight: 700;
  text-align: right;
}

.import-label input {
  display: none;
}

@media print {
  body {
    background: #fff;
  }

  .sidebar,
  .topbar,
  .auth-overlay,
  .header-actions,
  .export-actions,
  .form-actions,
  .search-card,
  .content-grid > .card:first-child {
    display: none !important;
  }

  .app-shell {
    display: block;
  }

  .main-content,
  .card {
    padding: 0;
    box-shadow: none;
    border: none;
    background: #fff;
  }

  .tab-panel {
    display: none !important;
  }

  #reports.tab-panel.active {
    display: grid !important;
  }
}

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

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

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

  .dashboard-grid,
  .content-grid,
  .single-left {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .main-content {
    padding: 16px 16px 92px;
  }

  .topbar,
  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar {
    border-radius: 24px;
  }

  .topbar-title {
    font-size: 1.35rem;
  }

  .metric-grid,
  .dashboard-grid,
  .content-grid,
  .single-left,
  .form-grid,
  .auth-form {
    grid-template-columns: 1fr;
  }

  .metric-card h3 {
    font-size: 1.6rem;
  }

  .nav-tabs {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 5;
    padding: 8px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    border-radius: 24px;
    background: rgba(15, 23, 32, 0.95);
    box-shadow: 0 20px 50px rgba(15, 23, 32, 0.28);
  }

  .nav-tab {
    padding: 11px 8px;
    font-size: 0.86rem;
    text-align: center;
    min-height: 44px;
  }

  .nav-tab:hover,
  .nav-tab.active {
    transform: none;
  }

  table {
    min-width: 640px;
  }
}
