:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --ink: #101828;
  --muted: #667085;
  --line: #d9e0ea;
  --brand: #0f6fb5;
  --brand-dark: #0b4f86;
  --good: #18794e;
  --warn: #a15c07;
  --bad: #b42318;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

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

button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  padding: 8px 12px;
  cursor: pointer;
}

button.secondary {
  background: #eef4fb;
  color: var(--brand-dark);
}

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

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

input, select, textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 7px 9px;
}

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

label {
  display: grid;
  gap: 5px;
  color: #344054;
  font-size: 13px;
  font-weight: 600;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #0f172a;
  padding: 20px;
}

.login-box {
  width: min(390px, 100%);
  background: #fff;
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 24px 80px rgba(0,0,0,.25);
}

.login-box h1 {
  margin: 0;
  font-size: 22px;
}

.login-box p {
  margin: 4px 0 20px;
  color: var(--muted);
}

.login-box form,
.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid.compact {
  gap: 8px;
  padding-top: 8px;
}

.employee-form {
  gap: 8px;
}

.employee-form input,
.employee-form select {
  min-height: 32px;
}

.form-details {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fbfcfe;
}

.form-details summary {
  min-height: 30px;
  display: flex;
  align-items: center;
  cursor: pointer;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 700;
}

.form-details[open] {
  padding-bottom: 10px;
}

.shell {
  min-height: 100vh;
}

.topbar {
  background: #0f172a;
  color: #fff;
}

.topbar-inner {
  max-width: 1280px;
  min-height: 72px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.brand p,
.userbar span {
  margin: 2px 0 0;
  color: #b7c3d4;
  font-size: 12px;
}

.userbar {
  display: flex;
  align-items: center;
  gap: 14px;
}

.nav-wrap {
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.nav {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nav button {
  background: transparent;
  color: #344054;
  border: 1px solid transparent;
}

.nav button.active {
  background: var(--brand);
  color: #fff;
}

.content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px 20px 32px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.panel {
  grid-column: span 12;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  align-self: start;
}

.half { grid-column: span 6; }
.third { grid-column: span 4; }
.two-third { grid-column: span 8; }

.panel-head {
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  padding: 0 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.panel-head h2,
.panel-head h3 {
  margin: 0;
  font-size: 15px;
}

.panel-body {
  padding: 14px;
}

.metric {
  display: grid;
  gap: 6px;
}

.metric strong {
  font-size: 26px;
}

.metric span,
.muted {
  color: var(--muted);
}

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

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

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

.stat-list span {
  color: var(--muted);
}

.stat-list strong {
  font-size: 20px;
}

.table-wrap {
  overflow: auto;
  max-width: 100%;
}

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

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

th {
  color: #344054;
  font-size: 12px;
  background: #f8fafc;
}

.employee-table {
  min-width: 760px;
  table-layout: fixed;
}

.employee-table th:nth-child(1),
.employee-table td:nth-child(1) {
  width: 56px;
}

.employee-table th:nth-child(2),
.employee-table td:nth-child(2) {
  width: 190px;
}

.employee-table th:nth-child(3),
.employee-table td:nth-child(3) {
  width: 205px;
}

.employee-table th:nth-child(4),
.employee-table td:nth-child(4) {
  width: 110px;
}

.employee-table th:nth-child(5),
.employee-table td:nth-child(5) {
  width: 72px;
}

.employee-table th:nth-child(6),
.employee-table td:nth-child(6) {
  width: 127px;
}

.employee-table td {
  height: 52px;
}

.cell-stack {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.cell-main,
.cell-sub {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-main {
  font-weight: 650;
}

.cell-sub {
  color: var(--muted);
  font-size: 12px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.table-actions {
  gap: 5px;
  flex-wrap: nowrap;
}

.table-actions button {
  min-height: 28px;
  padding: 4px 6px;
  font-size: 11px;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.tabs button {
  background: #eef4fb;
  color: var(--brand-dark);
}

.tabs button.active {
  background: var(--brand);
  color: #fff;
}

.report-filter {
  display: grid;
  grid-template-columns: 1.1fr repeat(2, .9fr) 1.5fr 1.4fr auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.report-filter label {
  min-width: 0;
}

.report-filter button {
  white-space: nowrap;
}

.report-tabs {
  margin-bottom: 0;
}

.report-table {
  min-width: 920px;
  table-layout: fixed;
}

.transaction-table {
  min-width: 1040px;
}

.summary-table {
  min-width: 720px;
}

.report-table th,
.report-table td {
  overflow: hidden;
}

.pill {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  background: #ecfdf3;
  color: var(--good);
  font-size: 12px;
  font-weight: 700;
}

.pill.warn {
  background: #fff7e6;
  color: var(--warn);
}

.pill.bad {
  background: #fef3f2;
  color: var(--bad);
}

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

.setup-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfe;
}

.setup-item code {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  color: var(--brand-dark);
}

.permission-tree {
  display: grid;
  gap: 12px;
  max-height: 460px;
  overflow: auto;
  padding-right: 4px;
}

.module-block {
  border: 1px solid var(--line);
  border-radius: 8px;
}

.module-title {
  padding: 10px 12px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  font-weight: 800;
}

.permission-group {
  padding: 10px 12px;
}

.permission-group h4 {
  margin: 0 0 8px;
  font-size: 13px;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.check-grid.single {
  grid-template-columns: 1fr;
}

.check-grid label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 500;
}

.check-grid input {
  width: 15px;
  min-height: 15px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #101828;
  color: #fff;
  padding: 10px 13px;
  border-radius: 8px;
  opacity: 0;
  transform: translateY(8px);
  transition: .18s ease;
  pointer-events: none;
  z-index: 10;
}

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

.empty {
  padding: 18px;
  color: var(--muted);
}

@media (max-width: 820px) {
  .topbar-inner,
  .userbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .half,
  .third,
  .two-third {
    grid-column: span 12;
  }

  .setup-grid,
  .check-grid {
    grid-template-columns: 1fr;
  }

  .report-filter {
    grid-template-columns: 1fr;
  }
}
