:root {
  --green: #166534;
  --green-dark: #0f2419;
  --green-soft: #ecfdf5;
  --gold: #d9a441;
  --bg: #f7f3e8;
  --ink: #17221d;
  --muted: #647067;
  --card: #fffdf8;
  --line: #e7dcc8;
  --danger: #b91c1c;
  --blue: #1d4ed8;
  --shadow: 0 20px 60px rgba(38, 60, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  line-height: 1.6;
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 20%, rgba(34, 197, 94, 0.17), transparent 32%),
    radial-gradient(circle at 90% 10%, rgba(217, 164, 65, 0.25), transparent 28%),
    linear-gradient(145deg, #fffdf7, #f7f3e8);
}

.login-card {
  width: min(430px, 92vw);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 34px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.12);
}

.brand-mark,
.brand-icon {
  display: grid;
  place-items: center;
  font-weight: 900;
}

.brand-logo {
  object-fit: contain;
  background: #fff;
  padding: 4px;
}

.brand-mark {
  width: 76px;
  height: 76px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--green), #0f3d28);
  color: #fff;
  letter-spacing: 0.08em;
}

.login-card h1 {
  margin: 22px 0 8px;
}

.login-card p,
.login-card small {
  color: var(--muted);
}

label {
  display: block;
  margin: 12px 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: #244135;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  background: white;
  color: var(--ink);
  font-weight: 400;
}

input::placeholder,
textarea::placeholder {
  color: #7a7a7a;
  font-weight: 400;
}

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

.btn-primary,
.btn-secondary,
.btn-danger,
.menu-btn {
  border-radius: 14px;
  padding: 8px 14px;
  border: 1px solid transparent;
  font-weight: 800;
  line-height: 1.2;
}

.btn-primary {
  background: var(--green);
  color: #fff;
}

.btn-secondary,
.menu-btn {
  background: #fff7e6;
  color: #754b08;
  border-color: #f6d58b;
}

.btn-danger {
  background: #fee2e2;
  color: var(--danger);
}

.wide {
  width: 100%;
  margin-top: 18px;
}

.pie-card {
  display: grid;
  gap: 18px;
}

.analytic-card {
  display: grid;
  gap: 16px;
}

.pie-card-compact {
  align-content: start;
  padding: 16px 18px;
  gap: 14px;
}

.pie-wrap {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.pie-card-compact .pie-wrap {
  flex-wrap: nowrap;
  gap: 16px;
  align-items: center;
}

.pie-chart {
  position: relative;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  flex: 0 0 150px;
}

.pie-card-compact .pie-chart {
  width: 112px;
  height: 112px;
  flex: 0 0 112px;
}

.pie-chart::after {
  content: "";
  position: absolute;
  inset: 22px;
  border-radius: 50%;
  background: #fff;
}

.pie-card-compact .pie-chart::after {
  inset: 18px;
}

.pie-chart span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--ink);
}

.pie-card-compact .pie-chart span {
  font-size: 1.15rem;
}

.pie-legend {
  display: grid;
  gap: 10px;
  min-width: 220px;
}

.pie-card-compact .pie-legend {
  min-width: 0;
  flex: 1;
  gap: 8px;
  align-content: start;
}

.pie-legend div {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: center;
  gap: 10px;
}

.pie-card-compact .pie-legend div {
  grid-template-columns: 14px 1fr auto;
  gap: 8px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
}

.swatch.male { background: var(--green); }
.swatch.female { background: #d6b97b; }
.swatch.other { background: #d1d5db; }

.login-card .btn-primary {
  width: 100%;
  margin-top: 18px;
}

.error {
  color: var(--danger);
}

.app-shell {
  display: grid;
  grid-template-columns: 290px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 20px;
  background: var(--green-dark);
  color: #e8ffee;
}

.sidebar-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
}

.brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: #fff;
}

.sidebar-brand span {
  display: block;
  color: #a7f3d0;
  font-size: 12px;
}

.nav h4 {
  margin: 18px 0 8px;
  color: #facc15;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 2px 0;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #d1fae5;
  text-align: left;
  font-weight: 650;
  line-height: 1.2;
}

.nav button:hover,
.nav button.active {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.nav small {
  border-radius: 999px;
  padding: 2px 7px;
  background: rgba(255, 255, 255, 0.12);
  color: #fde68a;
  font-size: 11px;
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 22px 30px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.92);
  backdrop-filter: blur(14px);
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
}

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

.topbar-actions,
.toolbar,
.toolbar-actions,
.actions,
.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-actions,
.toolbar,
.card-head {
  justify-content: space-between;
}

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

.topbar-actions .btn-secondary,
.topbar-actions .btn-primary,
.topbar-actions .btn-danger {
  text-decoration: none;
}

.user-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  background: white;
  font-size: 12px;
  white-space: nowrap;
}

.notice {
  margin: 16px 30px 0;
  border: 1px solid #fde68a;
  border-radius: 12px;
  padding: 10px 12px;
  background: #fffbeb;
  color: #92400e;
  font-size: 13px;
}

.content {
  padding: 28px 30px;
}

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

.grid-2 {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
}

.dashboard-pie-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.spaced {
  margin-top: 16px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.card h2,
.card h3,
.modal-card h2 {
  margin: 0 0 6px;
}

.metric {
  margin-top: 8px;
  font-size: 30px;
  font-weight: 900;
}

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

.toolbar {
  margin-bottom: 14px;
}

.dashboard-metric-row {
  display: grid;
  grid-template-columns: 1fr;
  max-width: none;
}

.compact-head {
  align-items: center;
  gap: 12px;
}

.dashboard-pie-row .pie-card-compact {
  min-width: 0;
  min-height: 224px;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 12px 14px;
}

.dashboard-pie-row .pie-card-compact > div:first-child {
  min-height: 58px;
  display: grid;
  align-content: start;
}

.dashboard-pie-row .pie-card-compact h3 {
  font-size: 1.05rem;
  margin-bottom: 4px;
  line-height: 1.25;
}

.dashboard-pie-row .pie-card-compact .muted {
  font-size: 0.92rem;
  line-height: 1.45;
  margin: 0;
}

.dashboard-pie-row .pie-card-compact .pie-wrap {
  gap: 12px;
  margin-top: 0;
  min-height: 108px;
  align-items: center;
}

.dashboard-pie-row .pie-card-compact .pie-chart {
  width: 100px;
  height: 100px;
  flex: 0 0 100px;
}

.dashboard-pie-row .pie-card-compact .pie-chart::after {
  inset: 16px;
}

.dashboard-pie-row .pie-card-compact .pie-chart span {
  font-size: 1rem;
}

.dashboard-pie-row .pie-card-compact .pie-legend {
  gap: 4px;
  align-self: center;
}

.dashboard-pie-row .pie-card-compact .pie-legend div {
  font-size: 0.95rem;
  line-height: 1.35;
}

.dashboard-pie-row .pie-card-compact .pie-legend b {
  font-size: 0.95rem;
}

.toolbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar-actions .btn-primary,
.toolbar-actions .btn-secondary,
.topbar-actions .btn-primary,
.topbar-actions .btn-secondary,
.actions .btn-primary,
.actions .btn-secondary,
.actions .btn-danger {
  min-height: 36px;
}

.search-input {
  width: min(260px, 100%);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
}

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

th,
td {
  padding: 12px;
  border-bottom: 1px solid #f0e8da;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
  line-height: 1.45;
}

th {
  background: #fff7e6;
  color: #4b5563;
  font-size: 14px;
  font-weight: 600;
}

td {
  font-weight: 400;
}

.sort-head {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.sort-mark {
  min-width: 10px;
  color: #8b7355;
  font-size: 11px;
  line-height: 1;
}

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

.actions {
  white-space: nowrap;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 14px;
  font-weight: 500;
}

.badge.gray {
  background: #f3f4f6;
  color: #4b5563;
}

.badge.gold {
  background: #fef3c7;
  color: #92400e;
}

.table-wrap .actions .btn-primary,
.table-wrap .actions .btn-secondary,
.table-wrap .actions .btn-danger {
  font-size: 14px;
  font-weight: 500;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.chart {
  display: flex;
  height: 190px;
  align-items: end;
  gap: 10px;
  padding: 16px 14px 34px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.hbar-list {
  display: grid;
  gap: 12px;
}

.hbar-row {
  display: grid;
  gap: 7px;
}

.hbar-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.hbar-meta span {
  font-weight: 600;
}

.hbar-track {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: #eef2ec;
}

.hbar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2f6a3f, #66bb6a);
}

.dual-chart {
  display: flex;
  align-items: end;
  gap: 14px;
  min-height: 240px;
  padding: 16px 14px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.dual-group {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 10px;
  justify-items: center;
}

.dual-bars {
  width: 100%;
  min-height: 180px;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 8px;
}

.dual-bar {
  position: relative;
  width: min(38px, 42%);
  min-height: 8px;
  border-radius: 10px 10px 0 0;
}

.dual-bar.incoming {
  background: linear-gradient(#22c55e, #166534);
}

.dual-bar.outgoing {
  background: linear-gradient(#f87171, #dc2626);
}

.dual-bar b {
  position: absolute;
  top: -23px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--ink);
  font-size: 10px;
  white-space: nowrap;
}

.dual-group > span {
  color: var(--muted);
  font-size: 12px;
}

.mini-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.mini-legend div {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.bar {
  position: relative;
  flex: 1;
  min-height: 16px;
  border-radius: 10px 10px 0 0;
  background: linear-gradient(#22c55e, #166534);
}

.bar b {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--green);
  font-size: 11px;
}

.bar span {
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 11px;
}

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

.stat-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.55);
}

.modal-card {
  width: min(860px, 100%);
  max-height: 92vh;
  overflow: auto;
  border-radius: 18px;
  padding: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
}

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

.form-section {
  display: grid;
  gap: 12px;
  padding-top: 4px;
}

.form-section h3 {
  margin: 0;
  font-size: 16px;
}

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

.readonly-field {
  display: grid;
  gap: 6px;
}

.readonly-value {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
}

.readonly-value .badge {
  display: inline-flex;
}

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

.coming {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 18px;
  align-items: start;
}

.coming .icon {
  display: grid;
  width: 70px;
  height: 70px;
  place-items: center;
  border-radius: 16px;
  background: #fef3c7;
  color: #78350f;
  font-weight: 900;
}

.feature-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.feature-list div {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}

@media (min-width: 921px) {
  .menu-btn {
    display: none;
  }
}

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

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 5;
    width: min(320px, 86vw);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 20px 0 60px rgba(0, 0, 0, 0.22);
  }

  .app-shell.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .topbar {
    grid-template-columns: auto 1fr;
    align-items: start;
    padding: 18px;
  }

  .topbar-actions {
    grid-column: 1 / -1;
    width: 100%;
    justify-content: space-between;
  }

  .content {
    padding: 18px;
  }

  .notice {
    margin: 12px 18px 0;
  }

  .grid,
  .grid-2,
  .dashboard-pie-row,
  .feature-list,
  .form-grid,
  .coming {
    grid-template-columns: 1fr;
  }

  .dual-chart {
    overflow-x: auto;
  }

  .dual-group {
    min-width: 68px;
  }

  .pie-card-compact .pie-wrap {
    flex-wrap: wrap;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-actions {
    justify-content: stretch;
  }

  .toolbar-actions > * {
    flex: 1 1 160px;
  }

  .detail-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }
}
