/* =====================================================
   Finance Work App - shared design layer
   Loaded last on every page so it refines the per-page styles.
===================================================== */

:root {
  --bg: #f1f4f9;
  --surface: #ffffff;
  --surface-soft: #f6f8fb;
  --text: #0f172a;
  --text-soft: #334155;
  --muted: #5b6577;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --primary-soft: #e8f0ff;
  --primary-ring: rgba(37, 99, 235, 0.22);

  --income: #047857;
  --income-soft: #e6f6ee;
  --expense: #dc2626;
  --expense-soft: #fdeceb;
  --warn: #b45309;
  --warn-soft: #fff3df;

  --radius: 16px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 28px -14px rgba(15, 23, 42, 0.14);

  --header-h: 64px;
  --bottom-nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- Base ---------- */

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  font-feature-settings: "palt" 0;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 {
  line-height: 1.35;
}

:focus-visible {
  outline: 3px solid var(--primary-ring);
  outline-offset: 2px;
  border-radius: 8px;
}

.amount,
.summary-value,
.money-metric-value,
.dashboard-list-amount,
td,
.calendar-record-time {
  font-variant-numeric: tabular-nums;
}

::selection {
  background: var(--primary-soft);
}

/* ---------- Header ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: none;
}

.app-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  box-shadow: 0 4px 10px -2px rgba(37, 99, 235, 0.45);
  font-weight: 800;
}

.app-name {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.app-subtitle,
.header-user-role {
  color: var(--muted);
}

.header-user-name {
  color: var(--text-soft);
  font-weight: 700;
}

.header-user-avatar {
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-weight: 800;
}

.logout-button {
  min-height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-soft);
  font-weight: 700;
  transition: background 0.15s, border-color 0.15s;
}

.logout-button:hover {
  background: var(--surface-soft);
  border-color: var(--muted);
}

/* ---------- Layout & sidebar ---------- */

.app-layout {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: calc(100vh - var(--header-h));
}

.sidebar {
  position: sticky;
  top: var(--header-h);
  align-self: start;
  height: calc(100vh - var(--header-h));
  height: calc(100dvh - var(--header-h));
  overflow-y: auto;
  padding: 20px 14px 32px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.sidebar-section-title {
  margin: 18px 12px 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.sidebar-section-title:first-child {
  margin-top: 0;
}

.sidebar-nav {
  gap: 2px;
  margin-bottom: 0;
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  color: var(--text-soft);
  font-size: 15px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.nav-link.active {
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-weight: 700;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
}

.nav-icon svg,
.bottom-nav-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.main-content {
  min-width: 0;
  padding: 32px 36px 56px;
  max-width: 1280px;
  width: 100%;
}

/* ---------- Page header ---------- */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px 20px;
  margin-bottom: 24px;
}

.page-title {
  margin: 0 0 4px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--text);
}

.page-description {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

/* ---------- Buttons ---------- */

.primary-button,
.secondary-button,
.save-button,
.login-button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.08s;
}

.primary-button,
.save-button,
.login-button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.3);
}

.primary-button:hover,
.save-button:hover,
.login-button:hover {
  background: var(--primary-strong);
}

.secondary-button {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-soft);
}

.secondary-button:hover {
  background: var(--surface-soft);
  border-color: var(--muted);
}

.danger-button {
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid #fecaca;
  background: var(--expense-soft);
  color: var(--expense);
}

.danger-button:hover {
  background: #fbd5d3;
}

.primary-button:active,
.secondary-button:active,
.danger-button:active,
.save-button:active {
  transform: scale(0.98);
}

.primary-button:disabled,
.secondary-button:disabled,
.danger-button:disabled,
.save-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.action-button,
.month-nav-button,
.month-button,
.today-button,
.year-button {
  min-height: 40px;
  min-width: 40px;
  border-radius: 10px;
  font-weight: 700;
}


.danger-button.show {
  display: inline-flex;
}

/* ---------- Cards & panels ---------- */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

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

.summary-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.summary-value {
  margin: 0 0 4px;
  color: var(--text);
  font-size: 26px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.summary-value.income {
  color: var(--income);
}

.summary-value.expense {
  color: var(--expense);
}

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

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.panel-title {
  margin: 0;
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
}

.panel-body {
  padding: 16px 20px 20px;
}

.panel-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 4px;
  color: var(--primary-strong);
  font-size: 14px;
  font-weight: 700;
}

.panel-link:hover {
  text-decoration: underline;
}

.record-count {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.loading-state,
.dashboard-empty,
.empty-state {
  color: var(--muted);
  font-size: 14px;
}

.info-box {
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid #bfd3fb;
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.75;
}

/* ---------- Dashboard ---------- */

.money-overview {
  gap: 16px;
}

.money-period {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.money-period-title {
  color: var(--text);
  font-size: 17px;
  font-weight: 800;
}

.money-period-label {
  color: var(--muted);
  font-size: 13px;
}

.money-metric {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.money-metric-label {
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 700;
}

.money-metric-note {
  color: var(--muted);
  font-size: 12.5px;
}

.money-metric-value {
  font-weight: 800;
}

.quick-link {
  min-height: 64px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.quick-link:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: var(--shadow-sm);
}

.quick-link-title {
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
}

.quick-link-description {
  color: var(--muted);
  font-size: 13px;
}

.dashboard-list-item {
  padding: 14px 0;
}

.dashboard-list-title {
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}

/* ---------- Toolbar & form controls ---------- */

.toolbar,
.calendar-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.search-wrap {
  position: relative;
  flex: 1 1 260px;
  min-width: 0;
}

.search-wrap .search-input {
  width: 100%;
}

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

input,
select,
textarea {
  color: var(--text);
}

.form-input,
.form-select,
.form-textarea,
.filter-input,
.filter-select,
.search-input,
.month-input,
input[type="text"],
input[type="search"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="month"],
input[type="time"],
select,
textarea {
  min-height: 46px;
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  background-color: var(--surface);
  color: var(--text);
  font-size: 15px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea {
  min-height: 96px;
  line-height: 1.6;
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover,
.filter-select:hover,
.search-input:hover {
  border-color: var(--muted);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus,
.filter-input:focus,
.filter-select:focus,
.search-input:focus,
.month-input:focus,
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-ring);
}

::placeholder {
  color: #8591a5;
  opacity: 1;
}

input[readonly],
input:disabled,
select:disabled,
textarea:disabled {
  background: var(--surface-soft);
  color: var(--muted);
}

input[type="checkbox"],
input[type="radio"] {
  width: 20px;
  height: 20px;
  min-height: 0;
  accent-color: var(--primary);
}

select {
  cursor: pointer;
}

/* ---------- Form layout ---------- */

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

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

.form-label {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.form-label .required,
.form-label span[style*="dc2626"],
.required {
  color: var(--expense);
}

.form-help {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.form-error {
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
}

/* ---------- Modal ---------- */

.modal-backdrop {
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  background: rgba(15, 23, 42, 0.5);
}

.modal {
  display: flex;
  flex-direction: column;
  overflow: hidden !important;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 24px 60px -12px rgba(15, 23, 42, 0.35);
}

.modal > form {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.modal-header {
  flex: 0 0 auto;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  color: var(--text);
  font-size: 19px;
  font-weight: 800;
}

.modal-description {
  color: var(--muted);
  font-size: 14px;
}

.modal-close {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: var(--text-soft);
}

.modal-close:hover {
  background: var(--surface-soft);
}

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 20px 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-footer {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ---------- Badges ---------- */

.badge,
.type-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
}

.type-income {
  background: var(--income-soft);
  color: var(--income);
}

.type-expense {
  background: var(--expense-soft);
  color: var(--expense);
}

.amount-income {
  color: var(--income);
}

.amount-expense {
  color: var(--expense);
}

/* ---------- Tables ---------- */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  border-collapse: collapse;
}

th {
  color: var(--text-soft);
  font-weight: 700;
}

tbody tr {
  transition: background 0.12s;
}

tbody tr:hover {
  background: var(--surface-soft);
}

/* ---------- Calendar (work records) ---------- */

.calendar-day {
  transition: background 0.12s;
}

.calendar-day:hover {
  background: var(--primary-soft);
}

.calendar-day.today {
  box-shadow: inset 0 0 0 2px var(--primary);
}

.calendar-record-chip {
  font-weight: 700;
}

/* ---------- Login ---------- */

.login-password-field {
  position: relative;
}

.login-password-field input {
  width: 100%;
  padding-right: 64px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--primary-strong);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.password-toggle:hover {
  background: var(--primary-soft);
}

/* ---------- Bottom navigation (mobile only) ---------- */

.bottom-nav,
.mobile-menu-button,
.mobile-menu-backdrop {
  display: none;
}

.sidebar-footer {
  display: none;
}

/* =====================================================
   Tablet / mobile
===================================================== */

@media (max-width: 900px) {
  :root {
    --header-h: 56px;
  }

  .app-layout {
    display: block !important;
    min-height: 0;
  }

  .main-content {
    max-width: none;
    padding: 20px 16px calc(var(--bottom-nav-h) + var(--safe-bottom) + 28px);
  }

  .app-header {
    padding: 0 14px;
  }

  .app-subtitle,
  .header-user-info {
    display: none;
  }

  .app-logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }

  .logout-button {
    width: 40px;
    padding: 0;
  }

  .logout-button-text {
    display: none;
  }

  /* Drawer: full menu opened from the bottom bar */
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1001;
    display: flex !important;
    flex-direction: column;
    width: min(86vw, 320px);
    height: 100vh;
    height: 100dvh;
    align-self: auto;
    padding: 20px 14px calc(24px + var(--safe-bottom));
    overflow-y: auto;
    border-right: 0;
    border-radius: 0 20px 20px 0;
    box-shadow: none;
    transform: translateX(-102%);
    visibility: hidden;
    transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s linear 0.25s;
  }

  .sidebar.mobile-menu-open {
    transform: translateX(0);
    visibility: visible;
    box-shadow: 16px 0 40px rgba(15, 23, 42, 0.25);
    transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s;
  }

  .sidebar-footer {
    display: block;
    margin-top: auto;
    padding-top: 20px;
  }

  .sidebar-footer .secondary-button {
    width: 100%;
  }

  .mobile-menu-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
  }

  .mobile-menu-backdrop.show {
    opacity: 1;
    pointer-events: auto;
  }

  .bottom-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 900;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    height: calc(var(--bottom-nav-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.96);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    backdrop-filter: saturate(160%) blur(14px);
  }

  body.mobile-menu-open .bottom-nav {
    z-index: 900;
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    padding: 6px 2px 4px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
  }

  .bottom-nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 30px;
    border-radius: 999px;
    transition: background 0.15s, color 0.15s;
  }

  .bottom-nav-icon svg {
    width: 22px;
    height: 22px;
  }

  .bottom-nav-item.active {
    color: var(--primary-strong);
  }

  .bottom-nav-item.active .bottom-nav-icon {
    background: var(--primary-soft);
  }

  /* Floating "add" button */
  .fab-add {
    position: fixed !important;
    right: 16px;
    bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 14px);
    z-index: 800;
    min-height: 52px;
    padding: 0 22px !important;
    border-radius: 999px !important;
    font-size: 15px !important;
    box-shadow: 0 10px 24px -6px rgba(37, 99, 235, 0.55), 0 2px 4px rgba(15, 23, 42, 0.12) !important;
  }

  body.modal-open .fab-add,
  body.modal-open .bottom-nav,
  body.mobile-menu-open .fab-add {
    display: none !important;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 15px;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 18px;
  }

  .page-header > div[style*="flex"] {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px !important;
  }

  .page-header > div[style*="flex"] > * {
    width: 100%;
  }

  .page-title {
    font-size: 23px;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px;
    margin-bottom: 18px;
  }

  .summary-card {
    padding: 14px;
  }

  .summary-label {
    font-size: 12.5px;
  }

  .summary-value {
    font-size: 20px;
  }

  .summary-note {
    font-size: 12px;
  }

  .panel-header {
    padding: 14px 16px;
  }

  .panel-body {
    padding: 14px 16px 16px;
  }

  /* Dashboard: compact label / value rows */
  .money-overview {
    grid-template-columns: 1fr !important;
  }

  .money-period {
    padding: 16px !important;
  }

  .money-metrics,
  .money-period.next .money-metrics {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .money-metric {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    gap: 2px 12px;
    padding: 12px 14px !important;
  }

  .money-metric-label {
    grid-column: 1;
    margin: 0 !important;
  }

  .money-metric-value {
    grid-column: 2;
    grid-row: 1;
    margin: 0 !important;
    font-size: 22px !important;
    text-align: right;
  }

  .money-metric-note {
    grid-column: 1 / -1;
    margin: 0 !important;
  }

  .quick-menu {
    grid-template-columns: 1fr 1fr !important;
  }

  .toolbar,
  .calendar-toolbar {
    gap: 8px;
  }

  .calendar-toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .calendar-month-controls {
    display: grid !important;
    grid-template-columns: 48px minmax(0, 1fr) 48px auto;
    align-items: center;
    gap: 8px !important;
    width: 100%;
  }

  .calendar-month-controls .month-input {
    width: 100%;
    min-width: 0;
  }

  .calendar-month-controls .month-nav-button {
    width: 48px;
    min-height: 50px;
  }

  .calendar-month-controls .today-button {
    min-height: 50px;
    padding: 0 16px;
  }

  .calendar-filters {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    width: 100%;
  }

  .calendar-filters > * {
    width: 100%;
    min-width: 0;
  }

  .toolbar > select,
  .toolbar > .filter-select,
  .toolbar > .filter-input {
    flex: 1 1 100%;
    width: 100%;
  }

  /* iOS zooms into inputs below 16px */
  .form-input,
  .form-select,
  .form-textarea,
  .filter-input,
  .filter-select,
  .search-input,
  .month-input,
  input[type="text"],
  input[type="search"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  input[type="month"],
  input[type="time"],
  input[type="tel"],
  select,
  textarea {
    min-height: 50px;
    font-size: 16px;
  }

  .form-grid {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }

  .form-label {
    font-size: 14px;
  }

  /* Modals become bottom sheets */
  .modal-backdrop {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  .modal {
    width: 100% !important;
    max-width: none !important;
    max-height: 94vh !important;
    max-height: 94dvh !important;
    border-radius: 22px 22px 0 0 !important;
    animation: sheet-up 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  }

  .modal-header {
    position: relative;
    padding: 22px 16px 14px;
  }

  .modal-header::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: var(--border-strong);
    transform: translateX(-50%);
  }

  .modal-body {
    padding: 16px;
  }

  .modal-footer {
    padding: 12px 16px calc(12px + var(--safe-bottom));
    flex-direction: column-reverse;
    gap: 8px;
  }

  .modal-footer > button,
  .modal-footer > a {
    width: 100%;
    min-height: 50px;
    font-size: 16px;
  }

  .table-wrap {
    border-radius: 0;
  }

  .calendar-day {
    min-height: 64px;
  }
}

@keyframes sheet-up {
  from {
    transform: translateY(40px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (min-width: 901px) and (max-width: 1100px) {
  .main-content {
    padding: 26px 24px 48px;
  }

  .app-layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
body.modal-open{overflow:hidden}

.panel-header:has(> .panel-description) {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
