:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --ink: #18212f;
  --muted: #667085;
  --line: #d9e0ea;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #bc6c25;
  --danger: #b42318;
  --success-bg: #e8f6ef;
  --error-bg: #fff0ed;
  --button-text: #ffffff;
  --field-bg: #ffffff;
  --track: #e9eef5;
  --empty-bg: #fafcff;
  --toast-success: #1f2937;
  --toast-error: #991b1b;
  --shadow: 0 12px 32px rgba(24, 33, 47, 0.08);
}

.hidden {
  display: none !important;
}

body[data-theme="dark"] {
  --bg: #0f1726;
  --panel: #182237;
  --ink: #f8fafc;
  --muted: #c4ccda;
  --line: #35435d;
  --primary: #60a5fa;
  --primary-dark: #93c5fd;
  --accent: #fbbf24;
  --danger: #fca5a5;
  --success-bg: #123226;
  --error-bg: #3a1d1b;
  --button-text: #06231f;
  --field-bg: #101827;
  --track: #26344f;
  --empty-bg: #111b2d;
  --toast-success: #eff6ff;
  --toast-error: #fee2e2;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--ink);
  font-family: "DM Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

.app-shell,
.auth-shell {
  opacity: 1;
  transition: opacity 150ms ease;
}

html:not(.page-ready) .app-shell,
html:not(.page-ready) .auth-shell {
  opacity: 0;
}

html.page-leaving .app-shell,
html.page-leaving .auth-shell {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .app-shell,
  .auth-shell {
    transition: none;
  }
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  color: var(--ink);
}

h1 {
  font-size: 2rem;
  line-height: 1.1;
  margin-bottom: 0.45rem;
}

h2 {
  font-size: 1.1rem;
  line-height: 1.25;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 0.8rem 1.5rem;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

body[data-theme="dark"] .app-header {
  background: rgba(23, 32, 51, 0.94);
}

.brand {
  color: var(--ink);
  font-weight: 800;
  font-size: 1.05rem;
}

.main-nav {
  display: flex;
  gap: 0.2rem;
  align-items: center;
  justify-content: center;
}

.main-nav a,
.account-menu a {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  color: var(--muted);
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
  font-weight: 650;
  text-decoration: none;
}

.nav-icon {
  display: none;
  font-size: 1.25rem;
}

.main-nav a.active,
.main-nav a:hover,
.account-menu a:hover {
  color: var(--ink);
  background: #eef3f7;
}

body[data-theme="dark"] .main-nav a.active,
body[data-theme="dark"] .main-nav a:hover,
body[data-theme="dark"] .account-menu a:hover,
body[data-theme="dark"] .nav-toggle {
  color: var(--ink);
  background: #25334f;
}

.account-menu {
  position: relative;
  display: flex;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 0.92rem;
}

.nav-toggle {
  display: none;
}

.account-menu-button {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.55rem;
  padding: 0.35rem 0.55rem 0.35rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 700;
}

.account-avatar {
  display: inline-grid;
  place-items: center;
  overflow: hidden;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  background: #eef3f7;
  color: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 800;
}

.account-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

body[data-theme="dark"] .account-avatar {
  background: #25334f;
  color: #dbeafe;
}

.account-name {
  max-width: 8.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-caret {
  font-size: 1.05rem;
}

.account-menu-panel {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  z-index: 30;
  display: none;
  min-width: 14rem;
  padding: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 40px rgba(15, 23, 38, 0.16);
}

.account-menu.open .account-menu-panel {
  display: grid;
  gap: 0.3rem;
}

.account-menu-panel a,
.account-menu-action {
  width: 100%;
  justify-content: flex-start;
  padding: 0.55rem 0.65rem;
  border-radius: 6px;
}

.account-menu-action.theme-toggle {
  display: flex;
  min-height: 2.45rem;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  text-align: left;
  white-space: nowrap;
}

.account-menu-action {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.account-menu-panel .nav-icon {
  display: inline-block;
}

.account-menu-label {
  margin-left: 0.1rem;
}

.account-menu-panel a:hover,
.account-menu-action:hover {
  background: #eef3f7;
}

body[data-theme="dark"] .account-menu-panel {
  background: var(--panel);
}

body[data-theme="dark"] .account-menu-action {
  background: var(--field-bg);
}

body[data-theme="dark"] .account-menu-panel a:hover,
body[data-theme="dark"] .account-menu-action:hover {
  background: #25334f;
}

.app-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 5rem;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background:
    radial-gradient(circle at 15% 12%, rgba(37, 99, 235, 0.12), transparent 38%),
    radial-gradient(circle at 85% 86%, rgba(14, 165, 233, 0.1), transparent 36%),
    linear-gradient(140deg, rgba(37, 99, 235, 0.06), rgba(15, 23, 42, 0) 58%),
    var(--bg);
}

.auth-card,
.panel,
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

body[data-theme="dark"] .auth-card,
body[data-theme="dark"] .panel,
body[data-theme="dark"] .metric {
  background: var(--panel);
}

.auth-card {
  width: min(430px, 100%);
  padding: 2.1rem;
  display: grid;
  gap: 0.95rem;
}

.panel {
  padding: 1.1rem;
  min-width: 0;
}

.wide {
  min-width: 0;
}

.page-head,
.section-title {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.page-head p {
  margin-bottom: 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}

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

.metric {
  padding: 1rem;
}

.metric-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.metric-toggle-form {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  align-items: center;
}

.metric-toggle {
  min-height: 1.85rem;
  padding: 0.25rem 0.55rem;
  font-size: 0.76rem;
}

.metric-toggle.active {
  background: var(--primary);
  color: var(--button-text);
  border-color: var(--primary);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.metric strong {
  display: block;
  font-size: clamp(1.05rem, 2vw, 1.45rem);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.grid {
  display: grid;
  gap: 1rem;
}

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

.dashboard-focus {
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  align-items: stretch;
  margin-top: 1rem;
}

.readiness-panel,
.dashboard-action-panel {
  display: grid;
  gap: 1rem;
}

.readiness-pill {
  background: #e0f2fe;
  color: #0f4c81;
}

body[data-theme="dark"] .readiness-pill {
  background: #172554;
  color: #bfdbfe;
}

.readiness-summary {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(24, 119, 242, 0.08), rgba(15, 23, 38, 0)),
    var(--empty-bg);
}

.readiness-score {
  display: flex;
  align-items: end;
  gap: 0.65rem;
}

.readiness-score strong {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 0.95;
}

.readiness-score span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.readiness-track {
  height: 0.8rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
}

.readiness-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0f766e, #2563eb);
}

.readiness-list,
.alert-list {
  display: grid;
  gap: 0.75rem;
}

.readiness-step,
.alert-card {
  display: grid;
  gap: 0.35rem;
  padding: 0.95rem 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.readiness-step:hover,
.alert-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(15, 23, 38, 0.08);
  text-decoration: none;
}

.readiness-step strong,
.alert-card strong {
  font-size: 0.96rem;
}

.readiness-step small,
.alert-card small {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.readiness-step.done {
  border-color: #b7e2c8;
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.08), rgba(34, 197, 94, 0.02));
}

body[data-theme="dark"] .readiness-step.done {
  border-color: #285c43;
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.12), rgba(15, 23, 38, 0.12));
}

.readiness-mark {
  display: inline-flex;
  width: fit-content;
  min-height: 1.55rem;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.readiness-step.done .readiness-mark {
  background: #dcfce7;
  color: #166534;
}

body[data-theme="dark"] .readiness-mark {
  background: #1e293b;
  color: #bfdbfe;
}

body[data-theme="dark"] .readiness-step.done .readiness-mark {
  background: #143323;
  color: #bbf7d0;
}

.dashboard-action-panel {
  align-content: start;
}

.dashboard-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.dashboard-actions .button {
  width: 100%;
}

.alert-card.warning {
  border-color: #facc15;
  background: linear-gradient(180deg, rgba(250, 204, 21, 0.14), rgba(250, 204, 21, 0.04));
}

.alert-card.note {
  border-color: #93c5fd;
  background: linear-gradient(180deg, rgba(96, 165, 250, 0.12), rgba(96, 165, 250, 0.03));
}

.alert-card.good {
  border-color: #86efac;
  background: linear-gradient(180deg, rgba(74, 222, 128, 0.14), rgba(74, 222, 128, 0.04));
}

body[data-theme="dark"] .alert-card.warning {
  border-color: #8a6b02;
}

body[data-theme="dark"] .alert-card.note {
  border-color: #295c9f;
}

body[data-theme="dark"] .alert-card.good {
  border-color: #285c43;
}

.form-grid {
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  align-items: start;
}

.stack-form {
  display: grid;
  gap: 0.8rem;
}

.nested-fields {
  display: grid;
  gap: 0.8rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--empty-bg);
}

.settings-section {
  margin-bottom: 1rem;
}

.form-hint {
  margin-bottom: 0;
  font-size: 0.86rem;
}

label {
  display: grid;
  gap: 0.35rem;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 2.55rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0.6rem 0.7rem;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

body[data-theme="dark"] input,
body[data-theme="dark"] select,
body[data-theme="dark"] textarea {
  background: var(--field-bg);
  border-color: var(--line);
  color: var(--ink);
}

body[data-theme="dark"] input::placeholder,
body[data-theme="dark"] textarea::placeholder {
  color: #9aa6ba;
}

textarea {
  min-height: 5.6rem;
  resize: vertical;
}

.check {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.55rem;
  font-weight: 650;
}

.check input {
  width: 1.05rem;
  min-height: 1.05rem;
}

.button,
button {
  display: inline-flex;
  min-height: 2.45rem;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.58rem 0.85rem;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
}

.button:hover {
  text-decoration: none;
}

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

.primary:hover {
  background: var(--primary-dark);
}

.secondary {
  background: #eef7f5;
  color: var(--primary-dark);
  border-color: #cce4df;
}

body[data-theme="dark"] .secondary {
  background: #172554;
  color: #dbeafe;
  border-color: #315aaa;
}

.ghost {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

body[data-theme="dark"] .ghost,
body[data-theme="dark"] .mini-link {
  background: var(--field-bg);
  color: var(--ink);
}

.mini-link {
  display: inline-flex;
  min-height: 2rem;
  align-items: center;
  padding: 0.3rem 0.45rem;
  border-radius: 4px;
  background: #f2f5f8;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 650;
}

.mini-button {
  display: inline-flex;
  width: auto;
  min-height: 1.9rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--field-bg);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 650;
}

.theme-toggle {
  background: #eef3f7;
  color: var(--ink);
  border-color: var(--line);
}

body[data-theme="dark"] .theme-toggle {
  background: var(--field-bg);
  color: var(--ink);
}

.icon-button {
  width: 2.35rem;
  min-height: 2.35rem;
  padding: 0;
}

.material-symbols-outlined {
  font-family: "Material Symbols Outlined";
  font-weight: 600;
  font-style: normal;
  font-size: 1.25rem;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
}

.inline-form {
  display: flex;
  align-items: end;
  gap: 0.5rem;
}

.inline-delete {
  display: inline;
}

.inline-delete button {
  min-height: 2rem;
  padding: 0.3rem 0.45rem;
  background: #fff1f0;
  color: var(--danger);
  border-color: #ffd3cd;
  font-size: 0.82rem;
}

.danger-link {
  background: #fff1f0;
  color: var(--danger);
  border: 1px solid #ffd3cd;
}

.row-actions {
  white-space: nowrap;
  text-align: right;
}

.row-actions form,
.row-actions a {
  margin-left: 0.3rem;
}

.row-action-menu {
  position: relative;
  display: inline-flex;
  justify-content: flex-end;
}

.row-action-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.row-action-toggle .material-symbols-outlined {
  font-size: 1rem;
}

.row-action-panel {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 80;
  display: none;
  min-width: 10.5rem;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 36px rgba(15, 23, 38, 0.16);
}

.row-action-menu.open .row-action-panel {
  display: grid;
  gap: 0.25rem;
}

.row-action-panel a,
.row-action-link {
  display: flex;
  width: 100%;
  justify-content: flex-start;
  align-items: center;
  padding: 0.55rem 0.65rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 550;
  text-decoration: none;
  text-align: left;
}

.row-action-panel form {
  margin: 0;
  width: 100%;
}

.row-action-panel a:hover,
.row-action-link:hover {
  background: #eef3f7;
}

.row-actions > a,
.row-actions > form {
  margin-left: 0.3rem;
}

.row-action-panel a,
.row-action-panel form {
  margin-left: 0;
}

body[data-theme="dark"] .row-action-panel {
  background: var(--panel);
}

body[data-theme="dark"] .row-action-panel a:hover,
body[data-theme="dark"] .row-action-link:hover {
  background: #25334f;
}

.flash {
  border-radius: 6px;
  border: 1px solid var(--line);
  padding: 0.75rem 0.9rem;
  margin-bottom: 1rem;
  font-weight: 650;
}

.flash.success {
  background: var(--success-bg);
  border-color: #b7e2c8;
  color: #14532d;
}

.flash.error {
  background: var(--error-bg);
  border-color: #ffc7bf;
  color: var(--danger);
}

.notyf {
  padding: 0 1.25rem 1.25rem;
}

.notyf__toast {
  border-radius: 6px;
  border: 1px solid var(--line);
  box-shadow: 0 18px 45px rgba(15, 23, 38, 0.18);
  max-width: min(420px, calc(100vw - 2rem));
}

.notyf__toast--success {
  color: #f8fafc;
}

body[data-theme="dark"] .notyf__toast--success {
  color: #0f1726;
}

.notyf__toast--error {
  color: #fff7ed;
}

body[data-theme="dark"] .notyf__toast--error {
  color: #450a0a;
}

.notyf__wrapper {
  padding: 0.9rem 1rem;
}

.notyf__message {
  font-family: "DM Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1.35;
}

.notyf__dismiss {
  opacity: 0.72;
}

.notyf__dismiss:hover {
  opacity: 1;
}

.muted,
.form-footer {
  color: var(--muted);
}

.auth-divider {
  position: relative;
  margin: 0.1rem 0 0.15rem;
  text-align: center;
}

.auth-divider::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 1px solid var(--line);
}

.auth-divider span {
  position: relative;
  padding: 0 0.6rem;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.82rem;
}

.social-google {
  width: 100%;
  font-weight: 600;
  justify-content: center;
}

.social-google-icon {
  width: 1.05rem;
  height: 1.05rem;
  flex: 0 0 auto;
  display: inline-block;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 1.75rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: #f2f5f8;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.tag-list span {
  padding: 0.35rem 0.55rem;
  border-radius: 4px;
  background: #f2f5f8;
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 750;
}

body[data-theme="dark"] .tag-list span,
body[data-theme="dark"] .pill,
body[data-theme="dark"] .empty,
body[data-theme="dark"] .total-row {
  background: var(--empty-bg);
  color: var(--ink);
}

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

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.pagination-status {
  color: var(--muted);
  font-size: 0.9rem;
}

.pagination-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}

.pagination-link.disabled {
  pointer-events: none;
  opacity: 0.45;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 0.7rem 0.65rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

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

.total-row {
  font-weight: 800;
  background: #f7fafc;
}

.empty {
  margin: 0;
  padding: 1rem;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: var(--empty-bg);
  color: var(--ink);
}

.empty-state {
  display: grid;
  gap: 0.6rem;
  align-items: start;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.empty-action {
  width: fit-content;
}

.chart-list,
.compact-list {
  display: grid;
  gap: 0.75rem;
}

.chart-controls {
  display: flex;
  gap: 0.7rem;
  align-items: end;
  margin-bottom: 1rem;
}

.chart-controls label {
  min-width: 10rem;
}

.graph-panel {
  display: grid;
  gap: 0.65rem;
}

.cashflow-chart {
  display: grid;
  gap: 1rem;
}

.cashflow-chart-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--empty-bg);
}

.cashflow-chart-summary span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.cashflow-chart-summary strong {
  font-size: 1.2rem;
}

.cashflow-bars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(42px, 1fr));
  gap: 0.55rem;
  min-height: 18rem;
  align-items: end;
  padding: 0.85rem 0.4rem 0;
  border-bottom: 1px solid var(--line);
}

.cashflow-column {
  display: grid;
  min-width: 0;
  grid-template-rows: 2.2rem 12rem auto;
  gap: 0.45rem;
  align-items: end;
  text-align: center;
}

.cashflow-value {
  align-self: start;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cashflow-bar-shell {
  display: flex;
  height: 12rem;
  align-items: end;
  justify-content: center;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(to top, var(--track), transparent);
  overflow: hidden;
}

.cashflow-bar-shell i {
  display: block;
  width: min(100%, 1.65rem);
  min-height: 0.25rem;
  border-radius: 5px 5px 0 0;
}

.cashflow-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.graph-row {
  display: grid;
  grid-template-columns: 5.5rem minmax(140px, 1fr) 6rem;
  gap: 0.65rem;
  align-items: center;
  font-size: 0.86rem;
}

.graph-track {
  height: 0.95rem;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}

body[data-theme="dark"] .graph-track {
  background: var(--track);
}

.graph-track i {
  display: block;
  height: 100%;
  min-width: 0.25rem;
  border-radius: 999px;
}

.net-bar {
  background: var(--primary);
}

.income-bar {
  background: var(--primary);
}

.deductions-bar,
.deduction-bar {
  background: var(--accent);
}

.negative-bar {
  background: var(--danger);
}

.compact-list div {
  display: grid;
  gap: 0.15rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--line);
}

.compact-list span,
.compact-list small {
  color: var(--muted);
}

.compact-list small {
  display: block;
  font-size: 0.9rem;
}

.renewal-item {
  grid-template-columns: 2.25rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.65rem;
}

.renewal-icon,
.table-icon,
.selected-icon-img,
.item-icon {
  width: 1.35rem;
  height: 1.35rem;
  object-fit: contain;
  filter: none;
}

body[data-theme="dark"] .renewal-icon,
body[data-theme="dark"] .table-icon,
body[data-theme="dark"] .selected-icon-img,
body[data-theme="dark"] .item-icon {
  filter: invert(1) brightness(1.8);
}

.renewal-icon {
  width: 1.8rem;
  height: 1.8rem;
}

.compact-list .renewal-countdown {
  display: inline-grid;
  width: 3rem;
  height: 3rem;
  place-items: center;
  border: 1px solid rgba(37, 99, 235, 0.35);
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 750;
  line-height: 1;
  cursor: help;
}

body[data-theme="dark"] .compact-list .renewal-countdown {
  border-color: rgba(96, 165, 250, 0.45);
  background: rgba(96, 165, 250, 0.13);
  color: #bfdbfe;
}

.empty-icon {
  display: inline-block;
  border: 1px dashed var(--line);
  border-radius: 5px;
  background: var(--empty-bg);
  filter: none !important;
}

.provider-cell {
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
}

.bar-row {
  display: grid;
  grid-template-columns: 5.5rem minmax(140px, 1fr) 5.8rem;
  gap: 0.6rem;
  align-items: center;
  font-size: 0.85rem;
}

.bars {
  display: grid;
  gap: 0.25rem;
}

.bars i {
  display: block;
  height: 0.48rem;
  min-width: 0.25rem;
  border-radius: 999px;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.subnav a {
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 650;
  text-decoration: none;
}

.subnav a.active,
.subnav a:hover {
  color: var(--ink);
  background: var(--empty-bg);
}

.wide-modal {
  width: min(900px, 100%);
  overflow-x: hidden;
}

#template-modal .wide-modal {
  width: min(1080px, calc(100vw - 2rem));
}

#invoice-modal .wide-modal {
  width: min(1140px, calc(100vw - 2rem));
}

.invoice-items {
  display: grid;
  gap: 0.7rem;
}

.invoice-items--support {
  gap: 0.9rem;
}

.support-group {
  display: grid;
  gap: 0.7rem;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--empty-bg);
}

.support-group__head {
  display: grid;
  gap: 0.8rem;
}

.support-group__head-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.support-group__head-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.support-group__heading {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--muted);
}

.support-group__name {
  flex: 1;
}

.support-group__body {
  display: grid;
  gap: 0.7rem;
}

.support-group.is-collapsed .support-group__body {
  display: none;
}

.support-group__collapse {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.support-group__collapse .material-symbols-outlined,
.support-group__drag-handle .material-symbols-outlined,
.invoice-item-row__drag-handle .material-symbols-outlined {
  font-size: 1.05rem;
}

.support-group__drag-handle,
.invoice-item-row__drag-handle {
  cursor: grab;
}

.support-group__drag-handle:active,
.invoice-item-row__drag-handle:active {
  cursor: grabbing;
}

.support-group-list-actions,
.support-group__actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
}

.support-group__items {
  display: grid;
  gap: 0.6rem;
}

.invoice-item-row {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 0.9fr) minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 0.6rem;
  align-items: end;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--empty-bg);
}

.invoice-item-row > label {
  min-width: 0;
}

.invoice-item-row--support {
  grid-template-columns: 1fr;
}

.invoice-item-row__description--support input {
  min-height: 2.75rem;
}

.invoice-item-row__support-top,
.invoice-item-row__support-bottom {
  display: grid;
  gap: 0.6rem;
  align-items: end;
}

.invoice-item-row__support-top {
  grid-template-columns: auto minmax(0, 0.95fr) minmax(0, 0.95fr) minmax(0, 2.2fr);
}

.invoice-item-row__support-bottom {
  grid-template-columns: auto minmax(0, 0.8fr) minmax(0, 0.8fr) minmax(0, 1fr) minmax(0, 1.1fr) auto;
}

.invoice-item-row__drag-handle {
  align-self: stretch;
  min-height: 100%;
}

.invoice-item-row__support-bottom::before {
  content: "";
}

.support-group.sortable-ghost,
.invoice-item-row.sortable-ghost {
  opacity: 0.45;
}

.support-group.sortable-chosen,
.invoice-item-row.sortable-chosen {
  box-shadow: 0 12px 28px rgba(15, 23, 38, 0.12);
}

.template-designer {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(320px, 1.15fr);
  gap: 1rem;
  align-items: start;
}

.template-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem 0.7rem;
}

.template-preview-shell {
  display: grid;
  gap: 0.4rem;
}

.template-preview {
  display: grid;
  gap: 0.7rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #18212f;
  font-size: 0.76rem;
}

.template-preview .preview-default,
.template-preview .preview-meta,
.template-preview .preview-table,
.template-preview .preview-notes,
.template-preview .support-preview {
  display: none;
}

.template-preview.is-type-default .preview-default,
.template-preview.is-type-default .preview-meta,
.template-preview.is-type-default .preview-table,
.template-preview.is-type-default .preview-notes,
.template-preview.is-type-support .support-preview {
  display: grid;
}

.template-preview small,
.template-preview span,
.template-preview strong,
.template-preview b {
  color: inherit;
}

.preview-accent {
  height: 0.3rem;
  border-radius: 999px;
  background: var(--primary);
}

.preview-head,
.preview-meta,
.preview-table > div {
  display: grid;
  gap: 0.6rem;
}

.preview-head {
  grid-template-columns: 1fr 1fr;
}

.preview-head > div,
.preview-meta span {
  display: grid;
  gap: 0.2rem;
}

.preview-logo {
  width: 2.5rem;
  height: 1.4rem;
  border-radius: 4px;
  background: #dbeafe;
}

.preview-meta {
  grid-template-columns: 1.4fr 1fr 1fr;
  padding: 0.65rem;
  border-radius: 6px;
  background: #f1f5f9;
}

.preview-table {
  display: grid;
  gap: 0;
  border-top: 1px solid #cbd5e1;
}

.preview-table > div {
  grid-template-columns: 1.5fr 0.7fr 0.7fr 0.7fr 0.8fr;
  padding: 0.38rem 0;
  border-bottom: 1px solid #e2e8f0;
}

.preview-table > div:nth-last-child(-n + 3) {
  grid-template-columns: 1fr auto;
  font-weight: 700;
}

.preview-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.preview-notes small {
  padding: 0.25rem 0.4rem;
  border-radius: 999px;
  background: #eef2ff;
}

.support-preview {
  gap: 0.75rem;
}

.support-title-block {
  display: grid;
  gap: 0.2rem;
}

.support-title-block strong {
  font-size: 1.5rem;
  line-height: 1.1;
}

.support-preview-block {
  display: grid;
  gap: 0.2rem;
}

.support-preview-table {
  display: grid;
  gap: 0;
  border: 1px solid #cbd5e1;
}

.support-preview-table > div {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) 0.45fr 0.7fr 0.7fr 0.8fr;
}

.support-preview-table > div > * {
  padding: 0.42rem 0.38rem;
  border-right: 1px solid #cbd5e1;
  border-bottom: 1px solid #cbd5e1;
}

.support-preview-table > div > *:last-child {
  border-right: 0;
}

.support-preview-table > div:last-child > * {
  border-bottom: 0;
}

.support-preview-client {
  grid-template-columns: 1fr !important;
  background: #e5e7eb;
  font-weight: 700;
}

.support-preview-client > span {
  border-right: 0;
}

.support-preview-total > span:nth-child(4) {
  background: #f6d7d8;
  font-weight: 700;
}

.support-preview-total > span:nth-child(5) {
  background: #fbe5e5;
  font-weight: 700;
}

.template-preview.is-compact {
  gap: 0.45rem;
  padding: 0.65rem;
  font-size: 0.7rem;
}

.template-preview.is-compact .preview-head {
  grid-template-columns: 1fr;
}

.template-preview.is-compact .preview-meta {
  padding: 0.45rem;
}

.invoice-layout-compact {
  padding: 1.25rem;
}

.invoice-layout-compact .invoice-print-head,
.invoice-layout-compact .invoice-print-meta {
  gap: 1rem;
  margin-bottom: 1rem;
}

.invoice-layout-compact th,
.invoice-layout-compact td {
  padding: 0.55rem 0.45rem;
}

.status-pill {
  display: inline-flex;
  min-height: 1.6rem;
  align-items: center;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  background: var(--empty-bg);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 750;
}

.status-paid {
  background: #dcfce7;
  color: #166534;
}

.status-overdue,
.status-cancelled {
  background: #fee2e2;
  color: #991b1b;
}

.status-sent {
  background: #dbeafe;
  color: #1e40af;
}

body[data-theme="dark"] .status-paid {
  background: #123226;
  color: #bbf7d0;
}

body[data-theme="dark"] .status-overdue,
body[data-theme="dark"] .status-cancelled {
  background: #3a1d1b;
  color: #fecaca;
}

body[data-theme="dark"] .status-sent {
  background: #172554;
  color: #bfdbfe;
}

.detail-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.9rem 1rem;
}

.invoice-view-top {
  align-items: stretch;
  margin-bottom: 1rem;
}

.invoice-view-top .panel {
  height: 100%;
}

.invoice-client-panel p {
  margin-bottom: 0.55rem;
}

.invoice-client-panel p:last-child {
  margin-bottom: 0;
}

.detail-grid span {
  color: var(--muted);
  font-weight: 700;
}

.invoice-paper {
  width: min(900px, 100%);
  margin: 0 auto;
  padding: 2rem;
  border: 1px solid #d9e0ea;
  background: #fff;
  color: #18212f;
}

.invoice-paper h1,
.invoice-paper h2,
.invoice-paper p,
.invoice-paper td,
.invoice-paper th {
  color: #18212f;
}

.invoice-print-head,
.invoice-print-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.invoice-print-head {
  border-top: 0.35rem solid var(--invoice-accent);
  padding-top: 1rem;
}

.invoice-print-meta {
  grid-template-columns: 1.5fr 1fr 1fr;
  padding: 1rem;
  background: #f7f8fb;
}

.invoice-print-meta span {
  display: block;
  color: #667085;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.support-invoice-paper {
  display: grid;
  gap: 1.4rem;
  font-size: 1.12rem;
}

.support-invoice-paper .support-title-block h1 {
  margin: 0;
  font-size: 2.9rem;
  line-height: 1.02;
  font-weight: 900;
}

.support-invoice-paper .support-title-block {
  border-top: 0.35rem solid var(--invoice-accent);
  padding-top: 1.9rem;
  margin-bottom: 0.8rem;
}

.support-header-block,
.support-footer-block {
  display: grid;
  gap: 0.35rem;
}

.support-header-block p,
.support-footer-block p {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.3;
}

.support-notes-block {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.35rem;
}

.support-notes-block p {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.35;
}

b.support-label,
.support-label {
  font-weight: 800;
}

.support-invoice-table th {
  font-weight: 900;
}

.support-invoice-table td,
.support-invoice-table th {
  font-size: 1.05rem;
}

.support-table-wrap {
  border: 0;
  padding: 0;
}

.support-invoice-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.support-invoice-table th,
.support-invoice-table td {
  padding: 0.6rem 0.55rem;
  border: 1px solid #2c3440;
  text-align: left;
  vertical-align: top;
}

.support-invoice-table th {
  font-weight: 700;
}

.support-invoice-table th:nth-child(1),
.support-invoice-table td:nth-child(1) {
  width: 52%;
}

.support-client-row td {
  background: #eceff3;
  font-weight: 700;
}

.support-total-row td:nth-child(4) {
  background: #f6d7d8;
  font-weight: 700;
}

.support-total-row td:nth-child(5) {
  background: #fbe5e5;
  font-weight: 700;
}

.invoice-logo {
  max-width: 5.5rem;
  max-height: 2.75rem;
  object-fit: contain;
  margin-bottom: 1rem;
}

.invoice-notes {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #d9e0ea;
}

.icon-picker {
  display: grid;
  gap: 0.7rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--empty-bg);
}

.selected-icon {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.icon-results {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
  max-height: calc((4.7rem * 2) + 0.45rem);
  overflow-y: auto;
  padding-right: 0.2rem;
}

.icon-search-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0.7rem;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: var(--field-bg);
}

.icon-choice {
  display: grid;
  gap: 0.25rem;
  min-height: 4.7rem;
  justify-items: center;
  padding: 0.5rem 0.3rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field-bg);
  color: var(--ink);
  font-size: 0.68rem;
  font-weight: 700;
  overflow: hidden;
}

.icon-choice img {
  width: 1.5rem;
  height: 1.5rem;
  object-fit: contain;
}

body[data-theme="dark"] .icon-choice img {
  filter: invert(1) brightness(1.8);
}

.icon-choice span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-choice:hover,
.icon-choice.selected {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.12);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

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

.danger-outline {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}

.danger-outline:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: start;
  justify-content: center;
  overflow-y: auto;
  padding: 4.5rem 1rem 1rem;
  background: rgba(12, 18, 28, 0.58);
}

.modal.open {
  display: flex;
}

.modal-card {
  width: min(620px, 100%);
  max-height: calc(100dvh - 6rem);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.confirm-card {
  width: min(520px, 100%);
}

.delete-choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  margin: 1rem 0;
}

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

.confirm-action {
  display: grid;
  align-content: start;
  gap: 0.55rem;
}

.delete-choice-grid .button {
  width: 100%;
}

.modal-close {
  display: inline-flex;
  width: 2rem;
  height: 2rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-size: 1.25rem;
  line-height: 1;
  text-decoration: none;
}

.date-popover {
  position: absolute;
  z-index: 80;
  width: 300px;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.date-title {
  display: grid;
  grid-template-columns: 2.1rem 1fr 2.1rem;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.6rem;
  text-align: center;
}

.date-title button,
.date-grid button {
  min-height: 2.1rem;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink);
}

.date-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.25rem;
}

.date-day-label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-align: center;
}

.date-grid button:hover,
.date-grid button.selected {
  background: var(--primary);
  color: var(--button-text);
}

.mapping-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
  margin-bottom: 0.9rem;
}

.preview-table {
  margin-top: 1rem;
  max-height: 22rem;
}

.print-report {
  background: #fff;
}

.report-title {
  margin-bottom: 1rem;
}

.print-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.print-panel {
  margin-bottom: 1rem;
}

@media (max-width: 1020px) {
  .dashboard-focus {
    grid-template-columns: 1fr;
  }

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

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

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

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

@media (max-width: 760px) {
  body {
    min-height: 100dvh;
  }

  .app-header {
    position: static;
    grid-template-columns: 1fr auto;
    align-items: center;
    min-height: 3.8rem;
    padding: 0.65rem 0.85rem;
    box-shadow: 0 8px 24px rgba(15, 23, 38, 0.08);
    backdrop-filter: none;
  }

  .nav-toggle {
    display: none;
  }

  .main-nav {
    position: fixed !important;
    top: auto !important;
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(0.75rem + env(safe-area-inset-bottom)) !important;
    z-index: 40;
    transform: translateZ(0);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: 0.2rem;
    padding: 0.4rem;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 18px 40px rgba(15, 23, 38, 0.18);
    backdrop-filter: blur(16px);
  }

  body[data-theme="dark"] .main-nav {
    background: rgba(24, 34, 55, 0.94);
  }

  .main-nav a {
    display: grid;
    gap: 0.15rem;
    justify-items: center;
    place-items: center;
    min-width: 0;
    min-height: 3.15rem;
    padding: 0.45rem 0;
    border-radius: 12px;
    font-size: 0.66rem;
    line-height: 1.1;
  }

  .main-nav a span:last-child {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav-icon {
    display: inline-block;
    font-size: 1.35rem;
  }

  .account-menu {
    grid-column: auto;
    justify-content: end;
    border-top: 0;
    padding-top: 0;
    font-size: 0.82rem;
  }

  .account-menu > span {
    max-width: 8.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .account-menu a {
    padding: 0.45rem 0.35rem;
  }

  .app-shell {
    width: 100%;
    padding: 1rem 0.75rem calc(25rem + env(safe-area-inset-bottom));
  }

  .auth-card {
    padding: 1.25rem;
  }

  .page-head,
  .section-title {
    display: grid;
    gap: 0.65rem;
  }

  .page-head {
    margin-bottom: 0.85rem;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }

  .dashboard-actions {
    grid-template-columns: 1fr;
  }

  .metric,
  .panel {
    border-radius: 12px;
    box-shadow: none;
  }

  .metric-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .panel {
    padding: 0.9rem;
  }

  input,
  select,
  textarea {
    min-height: 3rem;
    border-radius: 10px;
    font-size: 1rem;
  }

  .bar-row {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .graph-row {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .cashflow-chart-summary {
    border-radius: 10px;
  }

  .cashflow-bars {
    grid-auto-flow: column;
    grid-auto-columns: minmax(42px, 1fr);
    grid-template-columns: none;
    min-height: auto;
    gap: 0.6rem;
    overflow-x: auto;
    padding-bottom: 0.6rem;
  }

  .cashflow-column {
    grid-template-rows: 1.6rem 8rem auto;
  }

  .cashflow-bar-shell {
    height: 8rem;
  }

  .chart-controls {
    display: grid;
  }

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

  .invoice-item-row {
    grid-template-columns: 1fr;
    border-radius: 10px;
  }

  .invoice-item-row__support-top,
  .invoice-item-row__support-bottom,
  .invoice-item-row--support {
    grid-template-columns: 1fr;
  }

  .support-group__head,
  .support-group-list-actions,
  .support-group__actions {
    display: grid;
  }

  .template-designer,
  .template-field-grid {
    grid-template-columns: 1fr;
  }

  .preview-head,
  .preview-meta {
    grid-template-columns: 1fr;
  }

  .invoice-print-head,
  .invoice-print-meta {
    grid-template-columns: 1fr;
  }

  .invoice-paper {
    padding: 1rem;
  }

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

  table {
    min-width: 680px;
  }

  .button,
  button {
    width: 100%;
    min-height: 3rem;
    border-radius: 10px;
  }

  .theme-toggle,
  .icon-button,
  .date-title button,
  .date-grid button {
    width: auto;
  }

  .row-actions .mini-link,
  .row-actions button {
    width: auto;
  }

  .delete-choice-grid {
    grid-template-columns: 1fr;
  }

  .modal {
    align-items: end;
    padding: 0;
  }

  .modal-card {
    width: 100%;
    max-height: min(88dvh, 760px);
    overflow-y: auto;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 18px 18px 0 0;
    padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
  }

  .modal-card::before {
    content: "";
    display: block;
    width: 2.75rem;
    height: 0.28rem;
    margin: 0 auto 0.85rem;
    border-radius: 999px;
    background: var(--line);
  }

  .modal-card .modal-close {
    display: none;
  }

  .date-popover {
    position: fixed !important;
    left: 0.75rem !important;
    right: 0.75rem;
    top: auto !important;
    bottom: calc(5.8rem + env(safe-area-inset-bottom));
    width: auto;
    border-radius: 14px;
  }
}

@media (max-width: 460px) {
  h1 {
    font-size: 1.55rem;
  }

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

@media print {
  body {
    background: #fff;
  }

  .app-header,
  .subnav,
  .print-toolbar,
  .modal,
  .date-popover,
  .flash {
    display: none !important;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .panel,
  .metric {
    box-shadow: none;
    border-color: #d0d0d0;
  }

  .metric-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  table {
    font-size: 0.78rem;
  }

  .invoice-paper {
    border: 0;
    padding: 0;
    width: 100%;
  }
}
