:root {
  --bg: #0f172a;
  --logo-bg: #f2f0ef;
  --panel: #111827;
  --panel-2: #172033;
  --panel-3: #1e293b;
  --line: rgba(148, 163, 184, 0.18);
  --text: #f8fafc;
  --muted: #94a3b8;
  --muted-2: #cbd5e1;
  --gold: #d4af37;
  --gold-2: #f5d46b;
  --green: #22c55e;
  --orange: #f59e0b;
  --red: #ef4444;
  --blue: #38bdf8;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  --radius: 8px;
  --content-max: 1460px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body[data-theme="light"] {
  --bg: #edf1f2;
  --panel: #fbfcfc;
  --panel-2: #f6f8f8;
  --panel-3: #e8edef;
  --line: rgba(57, 78, 96, 0.16);
  --text: #243746;
  --muted: #7d8b96;
  --muted-2: #52606d;
  --gold: #d78643;
  --gold-2: #c87534;
  --shadow: 0 16px 36px rgba(58, 78, 95, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(212, 175, 55, 0.09), transparent 30rem),
    linear-gradient(135deg, #0b1120 0%, var(--bg) 48%, #111827 100%);
  color: var(--text);
  min-height: 100vh;
}

body[data-theme="light"] {
  background:
    radial-gradient(circle at top left, rgba(215, 134, 67, 0.08), transparent 24rem),
    linear-gradient(135deg, #f8fbfb 0%, var(--bg) 44%, #eef2f3 100%);
}

body:not(.is-authenticated) .app-shell,
body:not(.is-authenticated) .overlay,
body.is-authenticated .login-screen {
  display: none;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--logo-bg);
}

.login-card {
  width: min(460px, 100%);
  display: grid;
  gap: 18px;
  border: 1px solid rgba(38, 97, 115, 0.12);
  border-radius: var(--radius);
  padding: 32px 26px 26px;
  background: var(--logo-bg);
  box-shadow: 0 18px 44px rgba(38, 97, 115, 0.12);
}

.login-brand {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 2px 0 22px;
  border-bottom: 1px solid rgba(38, 97, 115, 0.12);
  text-align: center;
}

.login-brand strong {
  color: var(--muted-2);
  font-size: 18px;
  font-weight: 800;
}

.monarch-logo {
  display: block;
  width: 132px;
  height: 132px;
  object-fit: contain;
  margin-bottom: 8px;
}

.login-submit {
  width: 100%;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: #fecaca;
  font-size: 13px;
  font-weight: 700;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(18px);
  z-index: 20;
}

body[data-theme="light"] .sidebar {
  background: rgba(247, 250, 250, 0.96);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px 22px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
}

.brand-logo {
  display: block;
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.brand strong,
.user-pill strong {
  display: block;
}

.brand span,
.user-pill small,
.eyebrow {
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
  margin-top: 22px;
}

.nav-item {
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 12px 14px;
  background: transparent;
  color: var(--muted-2);
  text-align: left;
}

.nav-item:hover,
.nav-item.is-active {
  border-color: rgba(212, 175, 55, 0.24);
  background: rgba(212, 175, 55, 0.1);
  color: var(--text);
}

.sidebar-card {
  margin-top: 24px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(30, 41, 59, 0.66);
}

.sidebar-footer {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(17, 24, 39, 0.78);
}

.sidebar-footer small {
  color: var(--muted);
  line-height: 1.35;
}

.workspace {
  min-width: 0;
  padding-top: 91px;
}

.topbar {
  position: fixed;
  top: 0;
  left: 280px;
  width: calc(100% - 280px);
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(18px);
  box-shadow: 0 12px 28px rgba(7, 12, 24, 0.16);
}

body[data-theme="light"] .topbar {
  background: rgba(248, 251, 251, 0.92);
}

.topbar h1,
.modal h2 {
  margin: 2px 0 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(2rem, 2.6vw, 2.7rem);
  line-height: 1.02;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.link-button {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  color: inherit;
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.link-button:hover {
  color: var(--gold);
  text-decoration: underline;
}

.eyebrow {
  display: block;
  margin-bottom: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 800;
}

.eyebrow[hidden] {
  display: none;
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.82);
  cursor: pointer;
  user-select: none;
}

.theme-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-icon {
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
}

.theme-track {
  position: relative;
  width: 50px;
  height: 28px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.28);
  transition: background 0.25s ease;
}

.theme-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: linear-gradient(135deg, #f3c46f, var(--gold));
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.18);
  transition: transform 0.25s ease, background 0.25s ease;
}

.theme-switch input:checked + .theme-track {
  background: rgba(61, 98, 128, 0.32);
}

.theme-switch input:checked + .theme-track .theme-thumb {
  transform: translateX(22px);
  background: linear-gradient(135deg, #7ea7c7, #c6d9e8);
}

.connection-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(17, 24, 39, 0.82);
}

body[data-theme="light"] .connection-pill,
body[data-theme="light"] .search,
body[data-theme="light"] .theme-switch,
body[data-theme="light"] .user-pill,
body[data-theme="light"] .sidebar-card,
body[data-theme="light"] .field,
body[data-theme="light"] .input,
body[data-theme="light"] .textarea,
body[data-theme="light"] .toggle-chip,
body[data-theme="light"] .month-row,
body[data-theme="light"] .money-box,
body[data-theme="light"] .project-card,
body[data-theme="light"] .category-card,
body[data-theme="light"] .client-card,
body[data-theme="light"] .billing-card,
body[data-theme="light"] .activity-item,
body[data-theme="light"] .btn,
body[data-theme="light"] .modal {
  background: rgba(251, 252, 252, 0.98);
}

body[data-theme="light"] .theme-track {
  background: rgba(215, 134, 67, 0.16);
}

body[data-theme="light"] .theme-switch input:checked + .theme-track {
  background: rgba(86, 126, 157, 0.24);
}

.connection-pill small {
  color: var(--muted);
}

.connection-pill.is-offline .status-dot {
  background: var(--orange);
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.1);
}

.connection-pill.is-online .status-dot {
  background: var(--green);
}

.search {
  display: flex;
  align-items: center;
  min-width: min(34vw, 390px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(17, 24, 39, 0.82);
  overflow: hidden;
}

.search span {
  padding-left: 12px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  padding: 11px 12px;
  background: transparent;
  color: var(--text);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(30, 41, 59, 0.72);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.1);
}

.content {
  padding: 26px;
}

.view-root {
  display: grid;
  width: min(100%, var(--content-max));
  margin: 0 auto;
  gap: 24px;
}

.grid {
  display: grid;
  gap: 16px;
}

.metrics-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr));
  align-items: stretch;
}

.two-col {
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
}

.three-col {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card,
.table-panel,
.detail-panel,
.filters,
.empty-state {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.9), rgba(17, 24, 39, 0.94));
  box-shadow: var(--shadow);
}

body[data-theme="light"] .card,
body[data-theme="light"] .table-panel,
body[data-theme="light"] .detail-panel,
body[data-theme="light"] .filters,
body[data-theme="light"] .empty-state,
body[data-theme="light"] .detail-hero,
body[data-theme="light"] .login-card {
  background: linear-gradient(180deg, rgba(252, 253, 253, 0.98), rgba(243, 247, 247, 0.98));
}

.card {
  padding: 18px;
}

.metric {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  min-height: 132px;
  overflow: hidden;
  container-type: inline-size;
}

.metric .label,
.card-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric .value {
  margin: 12px 0 6px;
  max-width: 100%;
  font-size: clamp(22px, 2vw, 32px);
  font-size: clamp(22px, 14cqi, 34px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.05;
  white-space: nowrap;
}

.metric .note,
.subtle {
  color: var(--muted);
  font-size: 13px;
}

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

.panel-head h2,
.section-title {
  margin: 0;
  font-size: 18px;
}

.panel-head h2 {
  letter-spacing: -0.02em;
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tbody tr:hover {
  background: rgba(148, 163, 184, 0.07);
}

body[data-theme="light"] tbody tr:hover {
  background: rgba(215, 134, 67, 0.08);
}

.row-overdue,
.billing-card.is-overdue,
body[data-theme="light"] .row-overdue,
body[data-theme="light"] .billing-card.is-overdue {
  background: transparent;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.badge-active,
.badge-paid,
.badge-completed {
  color: #bbf7d0;
  background: rgba(34, 197, 94, 0.16);
}

.badge-paused,
.badge-unpaid,
.badge-idea,
.badge-pending_pricing {
  color: #fed7aa;
  background: rgba(245, 158, 11, 0.15);
}

.badge-overdue,
.badge-cancelled {
  color: var(--muted);
  background: rgba(148, 163, 184, 0.12);
}

.badge-hidden,
.badge-inactive {
  color: #cbd5e1;
  background: rgba(148, 163, 184, 0.14);
}

.toolbar,
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.filters {
  padding: 14px;
}

.field,
.input,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
  background: rgba(15, 23, 42, 0.82);
  color: var(--text);
  outline: 0;
}

.field:focus,
.input:focus,
.textarea:focus {
  border-color: rgba(212, 175, 55, 0.58);
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

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

.form-field label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted-2);
  font-size: 13px;
  font-weight: 700;
}

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

.btn,
.icon-btn,
.menu-toggle {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(30, 41, 59, 0.9);
  color: var(--text);
  font-weight: 800;
}

.btn {
  padding: 11px 14px;
}

.btn-primary {
  border-color: rgba(212, 175, 55, 0.52);
  background: linear-gradient(135deg, #b98e1f, var(--gold));
  color: #111827;
}

body[data-theme="light"] .btn-primary {
  border-color: rgba(215, 134, 67, 0.54);
  background: linear-gradient(135deg, #d17d39, var(--gold));
  color: #fffdf9;
}

#addEntityButton {
  border-radius: 14px;
  padding: 10px 18px;
}

.btn-danger {
  border-color: rgba(239, 68, 68, 0.42);
  color: #fecaca;
}

.icon-btn,
.menu-toggle {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
}

.menu-toggle {
  display: none;
  flex: 0 0 40px;
  gap: 5px;
  padding: 8px;
  border-radius: 12px;
  background: #243746;
  color: #ffffff;
}

.menu-toggle span {
  display: block;
  width: 21px;
  height: 3px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: none;
}

.project-grid,
.category-grid,
.client-grid,
.billing-list,
.activity-list {
  display: grid;
  gap: 14px;
}

.project-card,
.category-card,
.client-card,
.billing-card,
.activity-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: rgba(17, 24, 39, 0.72);
}

.is-clickable {
  cursor: pointer;
  transition: border-color 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

.is-clickable:hover {
  border-color: rgba(212, 175, 55, 0.45);
  background: rgba(30, 41, 59, 0.92);
  transform: translateY(-1px);
}

body[data-theme="light"] .is-clickable:hover {
  background: rgba(246, 249, 249, 0.98);
}

body[data-theme="light"] .brand-mark {
  background: transparent;
}

body[data-theme="light"] .nav-item:hover,
body[data-theme="light"] .nav-item.is-active {
  border-color: rgba(215, 134, 67, 0.28);
  background: rgba(215, 134, 67, 0.08);
}

.detail-hero {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.92), rgba(17, 24, 39, 0.94));
  box-shadow: var(--shadow);
}

.detail-hero h2,
.detail-hero p {
  margin: 0;
}

.detail-hero p {
  color: var(--muted-2);
  line-height: 1.55;
}

.panel-body {
  padding: 18px;
}

.focus-card {
  display: grid;
  gap: 8px;
  text-align: left;
}

.focus-card strong {
  font-size: 19px;
}

.focus-card small {
  color: var(--muted);
  line-height: 1.45;
}

.focus-card:hover {
  border-color: rgba(212, 175, 55, 0.42);
  transform: translateY(-1px);
}

.theme-card {
  text-align: left;
}

.theme-card.is-selected {
  border-color: rgba(212, 175, 55, 0.52);
  box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.24);
}

.settings-users {
  align-items: start;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-access-card {
  gap: 16px;
}

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

.summary-pill {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.42);
}

.summary-pill span {
  color: var(--muted);
  font-size: 13px;
}

.summary-pill strong {
  color: var(--text);
  font-size: 18px;
  text-transform: capitalize;
}

.warning-panel {
  border-color: rgba(245, 158, 11, 0.28);
}

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

.warning-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(245, 158, 11, 0.22);
  border-radius: 16px;
  background: rgba(245, 158, 11, 0.08);
}

.warning-copy {
  color: #fdba74;
  font-size: 14px;
  font-weight: 700;
  text-align: right;
}

body[data-theme="light"] .warning-item {
  background: rgba(215, 134, 67, 0.08);
  border-color: rgba(215, 134, 67, 0.18);
}

body[data-theme="light"] .warning-copy {
  color: #b7662b;
}

.access-group {
  display: grid;
  gap: 10px;
}

.access-group strong {
  font-size: 14px;
}

.toggle-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.62);
  color: var(--muted-2);
}

.multi-field {
  min-height: 148px;
  padding: 10px;
}

.multi-field option {
  padding: 8px 10px;
  border-radius: 10px;
}

.multi-field option:checked {
  background: rgba(212, 175, 55, 0.22);
  color: var(--text);
}

body[data-theme="light"] .summary-pill {
  background: rgba(255, 255, 255, 0.9);
}

body[data-theme="light"] .multi-field option:checked {
  background: rgba(215, 134, 67, 0.18);
}

@media (max-width: 900px) {
  .user-access-summary {
    grid-template-columns: 1fr;
  }

  .panel-actions,
  .warning-item {
    flex-direction: column;
    align-items: stretch;
  }

  .warning-copy {
    text-align: left;
  }
}

.project-card {
  display: grid;
  gap: 14px;
}

.card-row,
.split-row,
.billing-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.money-box {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(15, 23, 42, 0.68);
}

.money-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.money-box strong {
  display: block;
  margin-top: 4px;
}

.progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--green));
}

.color-chip {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
}

.summary {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  color: var(--muted-2);
}

.summary-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.summary-row strong {
  color: var(--text);
}

.archive-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.client-payment-group {
  display: grid;
  gap: 12px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.client-payment-group:first-child {
  padding-top: 0;
  border-top: 0;
}

.client-payment-group h3 {
  margin: 0;
  font-size: 1rem;
}

.billing-months {
  display: none;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.billing-card.is-open .billing-months {
  display: grid;
  gap: 8px;
}

.offer-download {
  position: relative;
}

.invoice-create {
  position: relative;
}

.offer-download::before {
  content: "↓";
  margin-right: 6px;
  font-weight: 900;
}

.invoice-create::before {
  content: "+";
  margin-right: 6px;
  font-weight: 900;
}

.offer-download.is-due {
  border-color: rgba(34, 197, 94, 0.78);
  background: rgba(34, 197, 94, 0.18);
  color: #dcfce7;
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.32), 0 0 22px rgba(34, 197, 94, 0.34);
}

body[data-theme="light"] .offer-download.is-due {
  background: rgba(22, 163, 74, 0.12);
  color: #14532d;
}

.month-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(15, 23, 42, 0.6);
}

.permission-grid {
  min-width: 980px;
}

.permission-toggle {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
}

.empty-state {
  padding: 32px;
  text-align: center;
  color: var(--muted);
}

.modal {
  width: min(720px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  background: #111827;
  color: var(--text);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.64);
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.modal-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.modal-body {
  padding: 18px;
}

.overlay {
  display: none;
}

.text-green {
  color: var(--green);
}

.text-red {
  color: var(--red);
}

.text-gold {
  color: var(--gold-2);
}

@media (max-width: 1200px) {
  .metrics-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .two-col,
  .three-col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  body.is-authenticated {
    background:
      linear-gradient(180deg, #f4efe9 0%, #eef2f2 26%, #e6ecee 100%);
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(82vw, 310px);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }

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

  body.sidebar-open .overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 18;
    background: rgba(0, 0, 0, 0.5);
  }

  .menu-toggle {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  .topbar {
    left: 0;
    width: 100%;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    align-items: center;
    gap: 10px 12px;
    padding: max(10px, env(safe-area-inset-top)) 12px 12px;
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 18px;
  }

  .workspace {
    padding-top: 176px;
  }

  .topbar > div:first-of-type {
    min-width: 0;
  }

  .topbar h1 {
    margin: 0;
    font-size: 1.6rem;
    line-height: 1;
  }

  .topbar-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(96px, 1fr) auto auto auto auto;
    width: 100%;
    gap: 8px;
    align-items: center;
  }

  .search {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
    min-height: 40px;
  }

  .search span {
    padding-left: 10px;
    font-size: 11px;
  }

  .search input {
    padding: 9px 10px;
    font-size: 14px;
  }

  .topbar-actions > .btn,
  .theme-switch,
  .user-pill {
    width: auto;
    min-height: 40px;
    padding: 8px 10px;
    font-size: 14px;
    line-height: 1.1;
    white-space: nowrap;
  }

  .user-pill {
    justify-content: center;
    gap: 7px;
  }

  .user-pill small {
    display: none;
  }

  .theme-switch {
    justify-self: stretch;
    gap: 6px;
    border-radius: 14px;
  }

  .theme-track {
    width: 42px;
    height: 24px;
  }

  .theme-thumb {
    width: 18px;
    height: 18px;
  }

  .theme-switch input:checked + .theme-track .theme-thumb {
    transform: translateX(18px);
  }

  #addEntityButton {
    border-radius: 12px;
    padding: 8px 12px;
  }

  .content {
    padding: 14px 14px calc(28px + env(safe-area-inset-bottom));
  }

  .view-root {
    gap: 18px;
  }

  .card,
  .table-panel,
  .detail-panel,
  .filters,
  .empty-state,
  .detail-hero {
    border-radius: 20px;
  }

  .metric,
  .project-card,
  .category-card,
  .client-card,
  .billing-card,
  .activity-item {
    border-radius: 18px;
  }

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

  .money-grid,
  .form-grid,
  .user-access-summary {
    grid-template-columns: 1fr;
  }

  .metric {
    min-height: 116px;
  }

  .metric .value {
    font-size: clamp(22px, 8vw, 30px);
  }

  .detail-hero,
  .panel-body,
  .panel-head,
  .summary,
  .modal-head,
  .modal-actions,
  .modal-body {
    padding-left: 14px;
    padding-right: 14px;
  }

  .panel-head,
  .split-row,
  .card-row,
  .billing-head,
  .panel-actions,
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-actions .btn,
  .toolbar .btn {
    width: 100%;
  }

  .table-wrap {
    margin: 0 -14px;
    padding: 0 14px 2px;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 640px;
  }

  th,
  td {
    padding: 12px 10px;
  }

  .sidebar-footer {
    position: static;
    margin-top: 18px;
  }
}

@media (max-width: 560px) {
  .workspace {
    padding-top: 286px;
  }

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

  .topbar-actions > .btn,
  .theme-switch,
  .user-pill {
    width: 100%;
  }

  #logoutButton {
    grid-column: 1 / -1;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .search span {
    padding-left: 10px;
    font-size: 11px;
  }

  .search input {
    padding: 10px;
    font-size: 16px;
  }

  .topbar h1 {
    font-size: 1.45rem;
    line-height: 1;
  }

  .detail-hero h2,
  .panel-head h2,
  .section-title {
    font-size: 1.35rem;
  }

  .content {
    padding: 12px 12px calc(24px + env(safe-area-inset-bottom));
  }

  .table-wrap {
    margin: 0 -12px;
    padding: 0 12px 2px;
  }

  table {
    min-width: 580px;
  }

  .detail-hero,
  .panel-body,
  .panel-head,
  .summary,
  .modal-head,
  .modal-actions,
  .modal-body {
    padding-left: 12px;
    padding-right: 12px;
  }
}
