:root {
  --bg: #0b1020;
  --panel: #121a33;
  --panel-2: #0f172e;
  --text: #e7ecff;
  --muted: rgba(231, 236, 255, 0.75);
  --border: rgba(231, 236, 255, 0.12);
  --accent: #7c3aed;
  --accent-2: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 14px 30px rgba(0, 0, 0, 0.35);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: radial-gradient(1200px 800px at 20% 10%, rgba(124, 58, 237, 0.25), transparent 60%),
              radial-gradient(900px 600px at 70% 0%, rgba(34, 197, 94, 0.18), transparent 55%),
              var(--bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 16, 32, 0.85);
  backdrop-filter: blur(10px);
}

.topbar__title { display: flex; gap: 10px; align-items: center; }
.topbar__logo { width: 28px; height: 28px; object-fit: contain; flex: 0 0 auto; }
.topbar__status { display: flex; gap: 10px; align-items: center; }

.layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: calc(100vh - 56px);
}

.nav {
  padding: 14px;
  border-right: 1px solid var(--border);
  background: rgba(18, 26, 51, 0.35);
}

.nav__item {
  width: 100%;
  display: block;
  text-align: left;
  border: 1px solid var(--border);
  background: rgba(18, 26, 51, 0.55);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: 140ms ease;
}
.nav__item:hover { transform: translateY(-1px); border-color: rgba(231, 236, 255, 0.22); }
.nav__item.is-active { border-color: rgba(124, 58, 237, 0.55); box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15); }
.nav__sub {
  display: grid;
  gap: 6px;
  margin: 6px 0 12px 14px;
}
.nav__sub[hidden] { display: none; }
.nav__subitem {
  background: rgba(18, 26, 51, 0.45);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(231, 236, 255, 0.12);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: 140ms ease;
}
.nav__subitem:hover { transform: translateY(-1px); border-color: rgba(231, 236, 255, 0.22); }
.nav__subitem.is-active { border-color: rgba(124, 58, 237, 0.55); box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15); }

.content { padding: 18px; }
h1 { margin: 0 0 14px; font-size: 24px; }
h2 { margin: 0 0 12px; font-size: 16px; }

.cards { display: grid; gap: 14px; }
.cards--compact {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 14px;
}
.card {
  background: rgba(18, 26, 51, 0.65);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.card--muted {
  background: rgba(15, 23, 46, 0.45);
  box-shadow: none;
}
.card--subtle {
  background: rgba(15, 23, 46, 0.38);
  box-shadow: none;
  padding: 12px;
}
.card--collapsible { padding: 0; }
.card__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  list-style: none;
}
.card__header::-webkit-details-marker { display: none; }
.card__header h2 { margin: 0; }
.card--collapsible:not([open]) .card__header { border-bottom: none; }
.card__body { padding: 14px; }
.collapse__chevron {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  transition: transform 140ms ease;
}
.card--collapsible[open] .collapse__chevron { transform: rotate(180deg); }

.row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.stack { display: grid; gap: 10px; }
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 14px;
}
.tab {
  border: 1px solid var(--border);
  background: rgba(15, 23, 46, 0.6);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  transition: 140ms ease;
}
.tab:hover { transform: translateY(-1px); border-color: rgba(231, 236, 255, 0.22); }
.tab.is-active {
  border-color: rgba(124, 58, 237, 0.6);
  background: rgba(124, 58, 237, 0.25);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.18);
}
.settings-actions {
  position: sticky;
  top: 70px;
  z-index: 5;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin: 0 -4px 14px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
  background: rgba(18, 26, 51, 0.94);
  backdrop-filter: blur(10px);
}
.tab-panel { display: grid; gap: 14px; }
.settings-section {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: rgba(15, 23, 46, 0.4);
  display: grid;
  gap: 12px;
}
.settings-section h3 { margin: 0; font-size: 13px; }
.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}
.grow { flex: 1; }

.report-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.report-workspace--single {
  grid-template-columns: 1fr;
}
.report-main {
  display: grid;
  gap: 14px;
  min-width: 0;
}
.report-nav-panel {
  position: sticky;
  top: 12px;
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(18, 26, 51, 0.65);
  box-shadow: var(--shadow);
}
.nav .report-nav-panel {
  position: static;
  margin-top: 8px;
  padding: 12px;
  background: rgba(18, 26, 51, 0.58);
  box-shadow: none;
}
.report-nav-panel__header h2 {
  margin: 0;
  font-size: 16px;
}
.report-nav-group {
  border-top: 1px solid rgba(231, 236, 255, 0.08);
  padding-top: 8px;
}
.report-nav-group:first-of-type {
  border-top: 0;
  padding-top: 0;
}
.report-nav-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}
.report-nav-group summary::-webkit-details-marker {
  display: none;
}
.report-nav-group summary::after {
  content: '>';
  color: var(--muted);
  font-size: 13px;
  transition: transform 0.15s ease;
}
.report-nav-group[open] summary {
  border-color: rgba(124, 58, 237, 0.35);
  background: rgba(124, 58, 237, 0.12);
  color: var(--text);
}
.report-nav-group[open] summary::after {
  transform: rotate(90deg);
}
.report-nav-group__items {
  display: grid;
  gap: 6px;
  margin-top: 6px;
  padding-left: 8px;
}
.report-nav-item {
  width: 100%;
  min-height: 32px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.report-nav-item:hover {
  border-color: rgba(231, 236, 255, 0.14);
  background: rgba(231, 236, 255, 0.06);
}
.report-nav-item.active {
  border-color: rgba(124, 58, 237, 0.75);
  background: rgba(124, 58, 237, 0.2);
}
.report-controls {
  display: grid;
  gap: 12px;
}
.report-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(18, 26, 51, 0.65);
  box-shadow: var(--shadow);
}
.report-panel__header,
.report-preview__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.report-panel__header h2,
.report-preview__header h2 {
  margin: 0;
}
.report-scope {
  flex: 0 0 auto;
  padding: 4px 8px;
  border: 1px solid rgba(231, 236, 255, 0.18);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
}
.report-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.report-form--builder {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
}
.report-form--range {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.report-form__wide {
  grid-column: 1 / -1;
}
.report-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  grid-column: 1 / -1;
}
.report-options[hidden] {
  display: none;
}
.report-options .report-form__wide {
  grid-column: 1 / -1;
}
.report-specific-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  grid-column: 1 / -1;
  padding: 10px;
  border: 1px solid rgba(231, 236, 255, 0.1);
  border-radius: 10px;
  background: rgba(15, 23, 46, 0.32);
}
.report-specific-options[hidden] {
  display: none;
}
.report-specific-options .report-form__wide {
  grid-column: 1 / -1;
}
.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  color: var(--text);
  font-size: 13px;
}
.report-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  flex-wrap: wrap;
}
.report-preview {
  min-width: 0;
  overflow: hidden;
}
.report-preview .tablewrap {
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
}
.table-scrollbar {
  position: sticky;
  bottom: 0;
  z-index: 4;
  height: 18px;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 10px 10px;
  background: rgb(15, 23, 46);
}
.table-scrollbar[hidden] {
  display: none;
}
.table-scrollbar__spacer {
  height: 1px;
}
.report-document {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}
.report-document[hidden] {
  display: none;
}
.report-document__bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(231, 236, 255, 0.12);
  border-radius: 8px;
  background: rgba(15, 23, 46, 0.55);
}
.report-document__bar span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}
.report-document__frame {
  width: 100%;
  min-height: 760px;
  border: 0;
  border-radius: 8px;
  background: #eee;
}
.crystal-report {
  width: 1120px;
  min-height: 790px;
  margin: 0 auto;
  padding: 18px 36px 24px;
  border-radius: 2px;
  background: #fff;
  color: #111;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 10px;
  line-height: 1.25;
}
.crystal-report__header {
  margin-bottom: 14px;
  text-align: center;
}
.crystal-report__header h1 {
  margin: 0 0 3px;
  color: #111;
  font-size: 18px;
}
.crystal-report__header p {
  margin: 4px 0 0;
}
.crystal-report__columns,
.crystal-report__line {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 72px 88px 92px 180px;
  gap: 10px;
  align-items: baseline;
}
.crystal-report__columns {
  padding: 0 0 5px 0;
  border-bottom: 1px solid #8a8a8a;
  font-weight: 700;
  text-align: right;
}
.crystal-report__columns span:first-child {
  text-align: left;
}
.crystal-report__line {
  min-height: 20px;
  padding: 2px 0;
}
.crystal-report__branch {
  margin-top: 10px;
}
.crystal-report__summary {
  margin-top: 18px;
  padding-top: 8px;
  border-top: 1px solid #8a8a8a;
}
.crystal-report__branch h3,
.crystal-report__branch h4,
.crystal-report__branch h5 {
  margin: 5px 0 3px;
  color: #111;
  font-size: 10px;
  font-weight: 700;
}
.crystal-report__branch h4 {
  margin-left: 12px;
}
.crystal-report__branch h5 {
  margin-left: 24px;
}
.crystal-report__period {
  margin: 7px 0 2px 44px;
  font-weight: 700;
}
.crystal-report__desc {
  padding-left: 44px;
}
.crystal-report__num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.crystal-report__sign {
  display: inline-block;
  min-width: 10px;
  text-align: center;
}
.payslip-run-report {
  padding: 18px;
  border: 1px solid rgba(231, 236, 255, 0.12);
  border-radius: 8px;
  background: rgba(15, 23, 46, 0.72);
}
.payslip-run-report__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.payslip-run-report__header h1 {
  margin: 0;
  font-size: 18px;
}
.payslip-run-report__header p {
  margin: 4px 0 0;
  color: var(--muted);
}
.payslip-run-report__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.payslip-run-report__stats div {
  padding: 10px 12px;
  border: 1px solid rgba(231, 236, 255, 0.12);
  border-radius: 8px;
  background: rgba(20, 184, 166, 0.08);
}
.payslip-run-report__stats span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}
.payslip-run-report__stats strong {
  display: block;
  margin-top: 3px;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.payslip-run-report__tablewrap {
  max-height: 620px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.payslip-run-report__table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}
.payslip-run-report__table th,
.payslip-run-report__table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(231, 236, 255, 0.1);
  text-align: left;
  white-space: nowrap;
}
.payslip-run-report__table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgb(17, 24, 49);
  color: var(--muted);
  font-size: 11px;
}
.payslip-run-report__table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.payslip-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-start;
  white-space: nowrap;
}
.report-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  margin: 12px 0;
}
.report-meta__item {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid rgba(231, 236, 255, 0.12);
  border-radius: 8px;
  background: rgba(15, 23, 46, 0.38);
}
.report-meta__item strong {
  display: block;
  overflow-wrap: anywhere;
}
.report-meta__item span,
.report-stat span,
.report-field span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}
.report-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin: 0 0 12px;
}
.report-stat {
  padding: 10px 12px;
  border: 1px solid rgba(231, 236, 255, 0.14);
  border-radius: 8px;
  background: rgba(20, 184, 166, 0.08);
}
.report-stat strong {
  display: block;
  margin-top: 3px;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.report-detail {
  display: grid;
  gap: 12px;
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid rgba(231, 236, 255, 0.12);
  border-radius: 10px;
  background: rgba(15, 23, 46, 0.44);
}
.report-detail[hidden] {
  display: none;
}
.report-detail__section {
  display: grid;
  gap: 8px;
}
.report-detail__section h3 {
  margin: 0;
  font-size: 13px;
}
.report-detail__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}
.report-field {
  min-width: 0;
  padding: 8px 9px;
  border-radius: 8px;
  background: rgba(4, 12, 28, 0.35);
}
.report-field strong {
  display: block;
  margin-top: 2px;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.field { display: grid; gap: 6px; font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea {
  height: 36px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 46, 0.75);
  color: var(--text);
  outline: none;
}
.field textarea {
  height: auto;
  min-height: 120px;
  resize: vertical;
}
.field .value {
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 46, 0.55);
  color: var(--text);
  display: flex;
  align-items: center;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: rgba(124, 58, 237, 0.6); }

.btn {
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(124, 58, 237, 0.65);
  background: rgba(124, 58, 237, 0.25);
  color: var(--text);
  cursor: pointer;
  transition: 140ms ease;
}
.btn:hover { transform: translateY(-1px); background: rgba(124, 58, 237, 0.35); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn--secondary {
  border-color: rgba(231, 236, 255, 0.22);
  background: rgba(231, 236, 255, 0.06);
}
.btn--tiny {
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
}
.btn--danger {
  border-color: rgba(239, 68, 68, 0.7);
  background: rgba(239, 68, 68, 0.22);
}
.btn--locked {
  border-color: rgba(124, 58, 237, 0.9);
  background: rgba(124, 58, 237, 0.55);
  color: #fff;
}
.btn--locked:disabled {
  opacity: 1;
  cursor: default;
}

.muted { color: var(--muted); }
.link { color: var(--text); text-decoration: none; border-bottom: 1px dashed rgba(231, 236, 255, 0.3); }
.link:hover { border-bottom-color: rgba(231, 236, 255, 0.6); }

.pill {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(231, 236, 255, 0.06);
}
.pill--ok { border-color: rgba(34, 197, 94, 0.55); background: rgba(34, 197, 94, 0.12); }
.pill--warn { border-color: rgba(245, 158, 11, 0.55); background: rgba(245, 158, 11, 0.12); }
.pill--bad { border-color: rgba(239, 68, 68, 0.6); background: rgba(239, 68, 68, 0.14); }

.tablewrap { overflow: auto; border-radius: 12px; border: 1px solid var(--border); max-height: 540px; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th, .table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(231, 236, 255, 0.08);
  text-align: left;
  white-space: nowrap;
}
.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  font-weight: 600;
  background: rgb(15, 23, 46);
}
.table th.num,
.table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.table tr:hover td { background: rgba(124, 58, 237, 0.06); }
.table tr.report-row--employee-start td {
  border-top: 8px solid rgba(15, 23, 46, 0.95);
  font-weight: 600;
}

.status-message {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(231, 236, 255, 0.04);
  line-height: 1.45;
  white-space: pre-line;
}

.status-message:empty { display: none; }
.table tr.report-row--summary td {
  font-weight: 700;
  background: rgba(20, 184, 166, 0.08);
}
.table tfoot td {
  background: rgba(15, 23, 46, 0.5);
  font-weight: 600;
  border-top: 1px solid rgba(231, 236, 255, 0.12);
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(18, 26, 51, 0.9);
  box-shadow: var(--shadow);
  color: var(--text);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(10px);
}
.modal__card {
  width: min(720px, 100%);
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .nav { position: sticky; top: 56px; display: flex; gap: 10px; overflow: auto; }
  .nav__item { margin: 0; width: auto; white-space: nowrap; }
  .grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
  .report-workspace { grid-template-columns: 1fr; }
  .report-nav-panel { position: static; }
  .nav .report-nav-panel { flex: 0 0 280px; max-height: 70vh; overflow: auto; }
  .report-form--builder { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  .report-form--range { grid-template-columns: 1fr; }
  .report-form--builder { grid-template-columns: 1fr; }
  .report-options { grid-template-columns: 1fr; }
  .report-specific-options { grid-template-columns: 1fr; }
  .report-actions { justify-content: stretch; }
  .report-actions .btn { flex: 1 1 auto; }
}
