:root {
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  color: #221f31;
  background: #f6f6fa;
  font-synthesis: none;
  --ink: #221f31;
  --muted: #625e72;
  --border: #e6e4ec;
  --surface: #fff;
  --eyebrow: #514471;
  --accent: #5238b2;
  --accent-strong: #432999;
  --accent-wash: #f0ebfe;
  --sidebar: #181727;
  --sidebar-border: #373349;
  --radius: 16px;
  --shadow: 0 2px 4px #24174706;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 0; line-height: 1.5; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: wait; opacity: .7; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex="0"]:focus-visible {
  outline: 3px solid #8d6bf0;
  outline-offset: 3px;
}
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.muted { color: var(--muted); }
svg { flex: none; display: inline-block; vertical-align: middle; }
button svg, .nav-link svg, .stat-icon svg { width: 1.25rem; height: 1.25rem; }

.skip-link {
  position: fixed; z-index: 5; top: .5rem; left: .5rem;
  transform: translateY(-160%); padding: .75rem 1rem;
  border-radius: 8px; color: white; background: var(--accent-strong);
}
.skip-link:focus { transform: none; }
.app-shell { display: grid; grid-template-columns: 234px minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column;
  background: var(--sidebar); padding: 24px 16px 18px; color: #f7f4ff; overflow: auto;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 6px; margin-bottom: 38px; }
.brand-mark {
  display: grid; place-items: center; flex: none; width: 38px; height: 38px;
  border-radius: 11px; color: white; background: linear-gradient(145deg, #9274fb, #6548d7);
  font-size: 1.14rem; font-weight: 850; box-shadow: inset 0 1px #ffffff38;
}
.brand-name { font-size: 1.05rem; font-weight: 750; letter-spacing: -.035em; }
.brand-name span { color: #ded4ff; }
.sidebar-nav { display: grid; gap: 5px; align-content: start; }
.nav-link {
  border: 1px solid transparent; text-decoration: none; color: #cfcbdf; background: transparent;
  display: flex; align-items: center; gap: 11px; text-align: start;
  padding: 10px 12px; border-radius: 10px; min-height: 46px; font-size: .92rem; font-weight: 570;
}
.nav-link:hover { color: white; background: #28263c; }
.nav-link.active, .nav-link.is-active, .nav-link[aria-current="page"], .nav-link[aria-pressed="true"] {
  border-color: #494060; background: #332a4d; color: #f4ecff; font-weight: 700;
}
.nav-link[aria-current="page"] svg, .nav-link.active svg, .nav-link.is-active svg { color: #cbb8ff; }
.mode-card {
  margin-top: auto; margin-inline: 1px; padding: 13px 12px 12px;
  background: #222034; border: 1px solid var(--sidebar-border); border-radius: 12px;
  color: #ddd7ee; font-size: .82rem;
}
.mode-card :is(h2, h3, strong, label) { color: #f4eeff; font-weight: 700; }
.mode-card p { color: #c6bfd8; margin: .24rem 0 .65rem; }
.mode-card label { display: block; }
.mode-title { display: flex; align-items: center; gap: 7px; font-weight: 700; }
.mode-dot { width: 7px; height: 7px; border-radius: 50%; background: #ae93fd; }
.mode-card select {
  display: block; width: 100%; color: #f7f3ff; background: #302c43;
  border: 1px solid #57516b; padding: 7px 9px; margin-top: 8px; border-radius: 8px; min-height: 44px;
}
.mode-card select option { background: #302c43; }
.mode-card button {
  color: #f7f3ff; background: #302c43; border-color: #57516b; margin-top: 6px;
}
.workspace { min-width: 0; }
.topbar { background: #fff; border-bottom: 1px solid var(--border); }
.topbar-inner {
  max-width: 1460px; margin: 0 auto; min-height: 66px; padding: 8px 32px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.workspace-title { color: var(--muted); font-weight: 630; font-size: .86rem; }
.current-user, .user-profile { display: flex; align-items: center; gap: 9px; min-width: 0; }
.current-user strong { display: block; line-height: 1.25; font-size: .86rem; overflow-wrap: anywhere; }
.current-user small { color: var(--muted); display: block; font-size: .76rem; }
.user-meta > span { color: var(--muted); display: block; font-size: .76rem; }
.page { max-width: 1460px; margin: 0 auto; padding: 30px 32px 45px; }
.page-header {
  display: flex; justify-content: space-between; align-items: end; gap: 14px;
  margin-bottom: 21px;
}
.page-header h1 { font-size: clamp(1.64rem, 2.7vw, 2.22rem); letter-spacing: -.047em; font-weight: 760; line-height: 1.17; }
.page-caption { margin-top: 6px; font-size: .91rem; color: var(--muted); max-width: 68ch; }
.page-caption:empty { display: none; }
.page-actions { display: flex; flex-wrap: wrap; flex: 0 1 auto; align-items: center; gap: 8px; }
.page-actions > :empty { display: none; }
.button, .icon-button {
  display: inline-flex; justify-content: center; align-items: center; text-decoration: none;
  gap: 8px; min-height: 44px; padding: 8px 14px;
  border: 1px solid transparent; border-radius: 9px; font-weight: 690; line-height: 1.25;
  color: var(--ink); background: transparent; font-size: .89rem;
}
.button-primary { color: #fff; background: var(--accent); box-shadow: 0 2px 3px #371c7b25; }
.button-primary:hover { background: var(--accent-strong); }
.button-secondary, .icon-button { border-color: #dcd9e6; background: #fff; }
.button-secondary:hover, .icon-button:hover { background: #f6f3ff; }
.button-quiet, .panel-link, .section-link { color: var(--accent-strong); }
.button-quiet:hover, .panel-link:hover, .section-link:hover { background: #f3efff; }
.button-danger { color: #8a283a; background: #ffeef0; border-color: #f3cbd1; }
.icon-button { width: 44px; padding: 0; }
.toolbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 16px;
}
.month-control, .filter-field {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .84rem; font-weight: 640; color: var(--muted); min-width: 0;
}
.month-control input, .month-control select, .filter-field input, .filter-field select {
  padding: 8px 10px; min-height: 44px; border: 1px solid #dcd9e6; border-radius: 9px;
  color: var(--ink); background: #fff;
}
.month-control svg { color: var(--accent); }
.month-control .icon-button { width: 36px; min-height: 40px; }
.month-previous svg { transform: rotate(180deg); }
.month-label {
  display: flex; align-items: center; gap: 8px; padding: 0 12px;
  min-height: 40px; border: 1px solid #dcd9e6; background: white; border-radius: 9px; color: var(--ink);
}
.month-input-label { position: relative; display: inline-grid; align-items: center; min-height: 38px; cursor: pointer; }
.month-input-label:focus-within { outline: 2px solid #8d6bf0; outline-offset: 2px; }
.month-input-label .month-picker { position: absolute; inset: 0; opacity: 0; min-height: 0; width: 100%; cursor: pointer; }
.month-picker::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: auto; height: auto; cursor: pointer; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 19px; }
.stat-card {
  display: flex; flex-direction: column; align-items: flex-start; min-width: 0; gap: 4px;
  border: 1px solid var(--border); background: white; border-radius: var(--radius); padding: 16px 17px 15px;
  box-shadow: var(--shadow);
}
.stat-icon {
  display: inline-grid; place-items: center; width: 37px; height: 37px; border-radius: 10px;
  color: #5835b6; background: var(--accent-wash); margin-bottom: 5px;
}
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; margin-bottom: 4px; }
.stat-top .stat-icon { flex: none; margin: 0; }
.stat-label { color: var(--muted); font-size: .82rem; font-weight: 660; }
.stat-value { font-size: clamp(1.13rem, 2.2vw, 1.73rem); font-weight: 760; letter-spacing: -.042em; line-height: 1.23; overflow-wrap: anywhere; }
.stat-note { color: var(--muted); font-size: .77rem; }
.stat-feature {
  background: linear-gradient(122deg, #453192, #5a3bb5);
  border-color: #5742a4; color: #fff;
}
.stat-feature .stat-icon { color: #fff; background: #ffffff24; }
.stat-feature .stat-label, .stat-feature .stat-note { color: #efe8ff; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 2.42fr) minmax(235px, 1fr); align-items: start; gap: 16px; margin-bottom: 16px; }
.page-grid { display: grid; gap: 16px; }
.panel {
  min-width: 0; background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel-header { padding: 16px 19px; display: flex; justify-content: space-between; align-items: center; gap: 8px; border-bottom: 1px solid #efedf4; }
.panel-title, .panel-header h2 { font-size: 1.06rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.28; }
.panel-subtitle { color: var(--muted); font-size: .81rem; margin-top: 3px; }
.panel-body { padding: 14px 19px; }
.list-filters { margin: 0; padding: 11px 18px; border-bottom: 1px solid var(--border); }
.totals-line { display: flex; align-items: center; flex-wrap: wrap; gap: 14px 24px; font-size: .84rem; }
.totals-line span { display: grid; color: var(--muted); }
.totals-line strong { color: var(--ink); font-size: 1.04rem; }
.panel-link, .section-link {
  display: inline-flex; align-items: center; gap: 4px;
  border: 0; border-radius: 8px; background: transparent; padding: 8px 7px;
  text-decoration: none; min-height: 44px; font-size: .8rem; font-weight: 700; white-space: nowrap;
}
.panel-link svg, .section-link svg { width: 1rem; height: 1rem; }
.table-wrap { width: 100%; overflow-x: auto; container-type: inline-size; border-radius: 0 0 var(--radius) var(--radius); }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
caption { text-align: left; padding: 12px 15px; }
:is(thead, tbody) :is(th, td) { padding: 12px 13px; text-align: start; vertical-align: middle; }
:is(thead, tbody) tr > :first-child { padding-inline-start: 18px; }
:is(thead, tbody) tr > :last-child { padding-inline-end: 18px; }
thead th {
  position: sticky; inset-block-start: 0; z-index: 1;
  background: #faf9fd; color: #615c73; font-size: .74rem; font-weight: 700; white-space: nowrap;
}
tbody tr:not(:last-child) :is(td, th) { border-bottom: 1px solid #efedf4; }
tbody td, tbody th { font-size: .83rem; }
tbody tr:hover { background: #fcfbff; }
.service-cell { min-width: 108px; overflow-wrap: anywhere; }
.service-title { display: block; color: var(--ink); font-weight: 710; line-height: 1.3; }
button.service-title { text-align: start; padding: 0; background: none; border: 0; font-size: inherit; }
button.service-title:hover { color: var(--accent); text-decoration: underline; }
.service-meta { display: block; color: var(--muted); margin-top: 3px; font-size: .75rem; }
.row-action { width: 1%; }
.row-action .icon-button { width: 35px; min-height: 35px; color: var(--accent); border-color: #eeeaf7; }
.person-cell { display: flex; align-items: center; gap: 7px; min-width: 0; }
.avatar {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none; aspect-ratio: 1;
  border-radius: 50%; background: #efe7ff; color: #5836aa; font-size: .81rem; font-weight: 800;
}
.avatar-small { width: 27px; height: 27px; font-size: .64rem; }
.avatar-cyan, .crew-item:nth-child(3n+2) .avatar { color: #0b6467; background: #dcf5f3; }
.avatar-peach, .crew-item:nth-child(3n) .avatar { color: #9b4a2a; background: #fff0e6; }
.amount, .tabular, .stat-value { font-variant-numeric: tabular-nums; }
.amount { white-space: nowrap; font-weight: 700; }
.status-badge {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  padding: 3px 8px; border-radius: 999px; color: #4a4160; background: #f0edf5;
  font-size: .72rem; font-weight: 740; line-height: 1.5;
}
.status-badge svg { width: 13px; height: 13px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-pending { color: #744b14; background: #fff1d4; }
.status-approved { color: #4e329e; background: #eee8ff; }
.status-paid { color: #186047; background: #dff6ec; }
.crew-list, .team-list { display: grid; padding: 0; margin: 0; list-style: none; }
.crew-list { padding: 15px 19px 8px; }
.panel-footer { display: flex; justify-content: flex-end; padding: 0 12px 6px; }
.crew-item, .team-item { display: grid; gap: 7px; padding: 13px 0; }
.crew-item:first-child, .team-item:first-child { padding-top: 1px; }
.crew-item:not(:last-child), .team-item:not(:last-child) { border-bottom: 1px solid #efedf4; }
.crew-meta { display: grid; gap: 0; min-width: 0; }
.crew-meta strong { font-size: .84rem; }
.crew-summary, .team-summary { color: var(--muted); font-size: .77rem; }
.crew-summary { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.crew-summary strong { color: var(--ink); }
.crew-paid { color: var(--muted); font-size: .74rem; text-align: end; }
.payout-list .crew-summary { grid-template-columns: minmax(0, 1fr) auto; }
.crew-progress, .crew-list progress {
  display: block; width: 100%; height: 5px; appearance: none; color: #7858d3; border: 0;
  border-radius: 99px; background: #eae5f6;
}
.crew-progress::-webkit-progress-bar { border-radius: 99px; background: #eae5f6; }
.crew-progress::-webkit-progress-value { border-radius: 99px; background: #7858d3; }
.crew-progress::-moz-progress-bar { background: #7858d3; border-radius: 99px; }
.empty-state, .loading { color: var(--muted); padding: 22px 18px; font-size: .92rem; }

dialog {
  width: min(560px, calc(100% - 22px)); max-height: calc(100dvh - 22px); padding: 0;
  border: 1px solid var(--border); border-radius: 17px; color: var(--ink); background: white;
  box-shadow: 0 22px 90px #21177138;
}
dialog::backdrop { background: #1c152c80; }
.dialog-header {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.dialog-header h2, #dialog-title { font-size: 1.27rem; line-height: 1.25; letter-spacing: -.024em; }
.dialog-body { padding: 17px 20px; }
.dialog-body .dialog-footer { margin: 16px -20px -17px; }
.dialog-body .form-error:not(:empty) { margin-top: 12px; }
.form-grid, .dialog-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.input-field { display: grid; align-content: start; gap: 5px; min-width: 0; font-size: .87rem; font-weight: 630; }
.input-field.full, .field-wide, .input-field.wide, .input-field.span-2 { grid-column: 1 / -1; }
.input-field :is(input, select, textarea), .auth-form :is(input, textarea, select) {
  width: 100%; min-width: 0; min-height: 48px; padding: 8px 10px;
  color: var(--ink); background: #fff; border: 1px solid #9c96ad; border-radius: 8px;
  font-size: 1rem; font-weight: 450;
}
.input-field textarea { min-height: 90px; resize: vertical; }
.input-field :user-invalid, .input-field [aria-invalid="true"] { border-color: #b44259; }
.input-help { color: var(--muted); font-size: .78rem; font-weight: 450; }
.dialog-footer { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
.dialog-message { margin-bottom: 12px; color: var(--muted); font-size: .88rem; }
.form-error, [role="alert"] { color: #942e42; font-size: .85rem; }
.dialog-message:empty, .form-error:empty { display: none; }
.auth-form { display: grid; gap: 14px; max-width: 420px; }
.sign-in-panel { max-width: 500px; }
.sign-in-panel .form-grid { grid-template-columns: minmax(0, 1fr); padding: 20px; }
.detail-header { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: .86rem; }
.detail-description { margin-top: 12px; white-space: pre-wrap; }
.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; margin: 14px 0; }
.detail-list dt { color: var(--muted); font-size: .8rem; }
.detail-list dd { margin: 0; font-size: .92rem; overflow-wrap: anywhere; }
.detail-payments { display: grid; gap: 7px; padding-left: 0; margin: 8px 0 4px; list-style: none; }
.detail-payments li { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.toast {
  position: fixed; z-index: 4; right: 18px; bottom: 18px; max-width: min(460px, calc(100% - 36px));
  color: #fff; background: var(--sidebar); border-radius: 11px; padding: 11px 15px; box-shadow: 0 6px 25px #2117712a;
  overflow-wrap: anywhere;
}
.toast:empty { display: none; }
.toast.is-error { background: #85283d; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 198px minmax(0, 1fr); }
  .page, .topbar-inner { padding-inline: 22px; }
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 740px) {
  .app-shell { display: block; min-height: 100svh; }
  .sidebar { position: static; display: grid; height: auto; padding: 12px 14px; overflow: visible; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; align-items: start; }
  .brand { margin: 0; padding: 0; min-height: 39px; }
  .sidebar-nav { display: flex; flex-wrap: nowrap; overflow-x: auto; grid-column: 1 / -1; grid-row: 2; }
  .nav-link { flex: 0 0 auto; gap: 6px; padding-inline: 9px; min-height: 44px; font-size: .81rem; }
  .nav-link svg { width: 1rem; height: 1rem; }
  .mode-card { padding: 0; margin: 0; border: 0; background: transparent; max-width: 150px; }
  .mode-card select { margin-top: 1px; font-size: .82rem; padding-inline: 6px; min-height: 40px; }
  .mode-card p { display: none; }
  .topbar-inner { min-height: 54px; padding: 5px 14px; }
  .page { padding: 20px 14px 30px; }
  .page-header { flex-wrap: wrap; align-items: start; margin-bottom: 15px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-bottom: 13px; }
  .stat-card { padding: 11px 12px; gap: 3px; }
  .stat-icon { width: 32px; height: 32px; }
  .stat-icon svg { width: 1rem; height: 1rem; }
  .stat-label { font-size: .79rem; }
  .panel-header { padding: 10px 12px; }
  .panel-body { padding: 11px 12px; }
  .toolbar { margin-bottom: 12px; }
  .dialog-header, .dialog-body, .dialog-footer { padding-inline: 14px; }
  .dialog-body .dialog-footer { margin-inline: -14px; }
}
@media (max-width: 390px) {
  .form-grid, .dialog-grid { grid-template-columns: minmax(0, 1fr); }
  .workspace-title { font-size: .75rem; }
}

@container (max-width: 500px) {
  .work-table, .work-table tbody { display: block; }
  .work-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .work-table tbody tr {
    position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px 12px; padding: 13px 14px;
  }
  .work-table tbody tr:not(:last-child) { border-bottom: 1px solid var(--border); }
  .work-table tbody tr > :is(th, td) { padding: 0; border: 0; min-width: 0; }
  .work-table tbody th { grid-column: 1 / -1; padding-right: 39px; }
  .work-table td[data-label]::before { content: attr(data-label) " " / ""; display: block; font-weight: 500; font-size: .72rem; color: var(--muted); }
  .work-table .row-action { position: absolute; top: 8px; right: 9px; width: auto; }
  .work-table .row-action .icon-button { width: 42px; min-height: 42px; }
}
