:root {
  /* Colors - Marina Blue Light Theme */
  --c-bg: #F0F4F8;
  --c-surface: #FFFFFF;
  --c-text: #1E293B;
  --c-text-muted: #64748B;
  --c-border: #E2E8F0;
  --c-primary: #0277BD; /* Marina Blue */
  --c-primary-light: #E1F5FE;
  --c-primary-dark: #01579B;
  --c-error: #EF4444;
  --c-success: #10B981;
  --c-warning: #F59E0B;
  
  --c-oscar: #4F7CFF;
  --c-angely: #FF5C8A;
  --c-house: #14B8A6;
  
  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-6: 24px;
  --sp-8: 32px;
  
  /* Radius */
  --rad-sm: 8px;
  --rad-md: 12px;
  --rad-lg: 16px;
  --rad-xl: 24px;
  
  /* Layout */
  --app-max-w: 560px;
  --nav-height: 64px;
  --header-height: 60px;
  
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  /* Forced Light Theme request, but we keep dark mode variables just in case, mapping them to light or maintaining a clean dark marina look */
  :root {
    --c-bg: #F0F4F8;
    --c-surface: #FFFFFF;
    --c-text: #1E293B;
    --c-text-muted: #64748B;
    --c-border: #E2E8F0;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--c-bg);
  color: var(--c-text);
  min-height: 100dvh;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
}

/* Typography */
h1, h2, h3, p { margin: 0; }
.text-error { color: var(--c-error) !important; }
.text-sm { font-size: 0.875rem; }
.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.mt-8 { margin-top: var(--sp-8); }
.pb-safe { padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + var(--sp-4)); }
.justify-center { justify-content: center; }

/* Utilities */
.hidden { display: none !important; }
.house-color { color: var(--c-house); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* App Container */
.app-container {
  max-width: var(--app-max-w);
  margin: 0 auto;
  min-height: 100dvh;
  background-color: var(--c-bg);
  position: relative;
  box-shadow: 0 0 40px rgba(0,0,0,0.05);
}

/* Offline Banner */
.offline-banner {
  background: var(--c-error);
  color: #fff;
  text-align: center;
  padding: var(--sp-2) var(--sp-4);
  font-size: 0.875rem;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 100;
  padding-top: calc(var(--sp-2) + var(--safe-top));
}

/* Header */
.app-header {
  height: calc(var(--header-height) + var(--safe-top));
  padding-top: var(--safe-top);
  display: flex;
  align-items: center;
  justify-content: center;
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10;
  border-bottom: 1px solid var(--c-border);
}

.ledger-tabs {
  display: flex;
  background: var(--c-bg);
  border-radius: var(--rad-xl);
  padding: 4px;
  border: 1px solid var(--c-border);
}
.tab {
  border: none;
  background: transparent;
  padding: 8px 20px;
  border-radius: 20px;
  color: var(--c-text-muted);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}
.tab.active {
  background: var(--c-surface);
  color: var(--c-primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* Search Bar */
.search-bar {
  display: flex;
  align-items: center;
  margin: var(--sp-4);
  background: var(--c-surface);
  border-radius: var(--rad-lg);
  padding: 0 var(--sp-3);
  border: 1px solid var(--c-border);
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
  transition: border-color 0.2s;
}
.search-bar:focus-within {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-primary-light);
}
.search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  padding: var(--sp-3);
  font-size: 16px;
  color: var(--c-text);
  outline: none;
}
.search-bar .icon { color: var(--c-primary); }

/* Expense List */
.expense-list { padding: 0 var(--sp-4); }
.day-group { margin-bottom: var(--sp-6); }
.day-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--sp-2);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--c-text-muted);
  padding: 0 var(--sp-2);
}
.day-items {
  background: var(--c-surface);
  border-radius: var(--rad-lg);
  border: 1px solid var(--c-border);
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}
.expense-item {
  display: flex;
  align-items: center;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--c-border);
  cursor: pointer;
  transition: background 0.2s;
}
.expense-item:last-child { border-bottom: none; }
.expense-item:active { background: var(--c-bg); }
.ex-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--c-primary-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  margin-right: var(--sp-3);
  flex-shrink: 0;
}
.ex-main { flex: 1; overflow: hidden; }
.ex-desc {
  font-weight: 600;
  font-size: 1rem;
  color: var(--c-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ex-meta {
  font-size: 0.8rem;
  color: var(--c-text-muted);
  display: flex; align-items: center; gap: var(--sp-2);
  margin-top: 4px;
}
.badge {
  padding: 3px 8px; border-radius: 6px; font-weight: 700; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-house { background: var(--c-primary-light); color: var(--c-primary-dark); }
.badge-warning { background: #FEF3C7; color: #B45309; }
.badge-success { background: #D1FAE5; color: #065F46; }
.ex-amount { font-weight: 700; font-size: 1.1rem; font-variant-numeric: tabular-nums; margin-left: var(--sp-3); color: var(--c-text); }

.month-switcher-container { margin-bottom: var(--sp-4); }
.month-switcher {
  display: flex; align-items: center; justify-content: center; gap: var(--sp-4);
  padding: var(--sp-2) 0;
}
.month-label {
  display: flex; flex-direction: column; align-items: center;
  background: none; border: none; font-weight: 700; font-size: 1.1rem; color: var(--c-text); cursor: pointer;
}
.month-today { font-size: 0.75rem; color: var(--c-primary); font-weight: 600; margin-top: 2px; text-transform: uppercase; letter-spacing: 0.5px; }

/* Empty state / Error */
.empty-state, .error-msg {
  text-align: center;
  padding: var(--sp-8) var(--sp-4);
  color: var(--c-text-muted);
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-3);
}
.empty-state .icon { font-size: 3rem; opacity: 0.5; color: var(--c-primary); }

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--c-border);
  display: flex; justify-content: space-around; align-items: center;
  z-index: 50;
  max-width: var(--app-max-w);
  margin: 0 auto;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--c-text-muted); text-decoration: none;
  font-size: 0.7rem; font-weight: 600;
  width: 64px; height: 100%;
  transition: color 0.2s;
}
.nav-item.active { color: var(--c-primary); }
.nav-item span { margin-top: 4px; }
.fab {
  width: 60px; height: 60px;
  border-radius: 30px;
  background: var(--c-primary);
  color: #fff;
  border: none;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(2, 119, 189, 0.4);
  transform: translateY(-24px);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
.fab:active { transform: translateY(-20px) scale(0.95); box-shadow: 0 4px 10px rgba(2, 119, 189, 0.4); }

/* Buttons & Inputs */
.btn {
  display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 14px 24px;
  border-radius: var(--rad-xl);
  font-weight: 700; font-size: 16px;
  border: none; cursor: pointer; transition: all 0.2s;
}
.btn-primary { background: var(--c-primary); color: #fff; box-shadow: 0 4px 12px rgba(2, 119, 189, 0.3); }
.btn-outline { background: transparent; border: 2px solid var(--c-border); color: var(--c-text); }
.btn-ghost { background: transparent; color: var(--c-text-muted); }
.btn-danger { background: var(--c-error); color: #fff; }
.btn-danger-soft { background: #FEE2E2; color: #DC2626; }
.btn-block { width: 100%; }
.btn-lg { padding: 16px 24px; font-size: 1.1rem; }
.btn-icon, .icon-btn { background: none; border: none; cursor: pointer; padding: var(--sp-2); border-radius: 50%; color: var(--c-text-muted); display: flex; align-items: center; justify-content: center; }
.btn:active:not(:disabled) { transform: scale(0.98); opacity: 0.9; }
.icon-btn:active { background: var(--c-bg); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; box-shadow: none; transform: none; }

.form-group { margin-bottom: var(--sp-4); }
.form-label { display: block; margin-bottom: var(--sp-2); font-weight: 600; font-size: 0.9rem; color: var(--c-text); }
.form-control, .input {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--rad-md);
  border: 2px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 16px;
  font-family: inherit;
  outline: none; transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.form-control:focus, .input:focus { border-color: var(--c-primary); box-shadow: 0 0 0 4px var(--c-primary-light); }
.form-control[readonly], .input[readonly] { background: var(--c-bg); border-color: var(--c-border); color: var(--c-text-muted); }

/* Custom Forms & Chips */
.field { margin-bottom: var(--sp-6); border: none; padding: 0; }
.field-label { display: block; font-weight: 700; font-size: 0.9rem; margin-bottom: var(--sp-2); color: var(--c-text); }
.field-error { color: var(--c-error); font-size: 0.8rem; font-weight: 500; margin-top: 4px; min-height: 1.2em; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }

.chip-scroller {
  display: flex; gap: var(--sp-2); overflow-x: auto; padding-bottom: 4px; margin-bottom: -4px;
  scrollbar-width: none;
}
.chip-scroller::-webkit-scrollbar { display: none; }
.chip { display: inline-block; cursor: pointer; flex-shrink: 0; }
.chip input { position: absolute; opacity: 0; }
.chip-face {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  border-radius: 20px;
  background: var(--c-surface);
  border: 2px solid var(--c-border);
  font-weight: 600; font-size: 0.95rem;
  color: var(--c-text-muted);
  transition: all 0.2s;
}
.chip input:checked + .chip-face {
  background: var(--c-primary-light);
  border-color: var(--c-primary);
  color: var(--c-primary-dark);
}
.chip input:disabled + .chip-face { opacity: 0.5; cursor: not-allowed; }

.segmented { display: flex; gap: var(--sp-2); }
.seg-option { flex: 1; cursor: pointer; }
.seg-option input { position: absolute; opacity: 0; }
.seg-face {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px;
  border-radius: var(--rad-md);
  background: var(--c-surface);
  border: 2px solid var(--c-border);
  font-weight: 600; font-size: 0.95rem;
  color: var(--c-text-muted);
  transition: all 0.2s;
}
.seg-option input:checked + .seg-face {
  border-color: var(--c-primary);
  background: var(--c-primary-light);
  color: var(--c-primary-dark);
}
.seg-option.seg-user input:checked + .seg-face {
  border-color: var(--c);
  background: var(--c-surface);
  box-shadow: 0 0 0 1px var(--c);
  color: var(--text);
}
.seg-option input:disabled + .seg-face { opacity: 0.5; }

.amount-field {
  position: relative; margin-bottom: var(--sp-4);
  background: var(--c-surface);
  border: 2px solid var(--c-border);
  border-radius: var(--rad-lg);
  display: flex; align-items: center;
  padding: 0 var(--sp-4);
  transition: all 0.2s;
}
.amount-field:focus-within { border-color: var(--c-primary); box-shadow: 0 0 0 4px var(--c-primary-light); }
.amount-currency { font-size: 2.5rem; font-weight: 700; color: var(--c-text-muted); margin-right: 8px; }
.amount-input {
  flex: 1; width: 100%; border: none; background: transparent;
  font-size: 3rem; font-weight: 700; color: var(--c-text);
  padding: var(--sp-4) 0; outline: none;
  font-variant-numeric: tabular-nums;
}
.amount-input.is-long { font-size: 2.2rem; }
.amount-input.is-xlong { font-size: 1.8rem; }
.amount-field.is-readonly { background: var(--c-bg); border-color: transparent; }

.date-row { display: flex; gap: var(--sp-2); align-items: center; }
.pill {
  padding: 10px 16px; border-radius: 20px; font-weight: 600; font-size: 0.9rem;
  background: var(--c-surface); border: 2px solid var(--c-border); color: var(--c-text-muted);
  cursor: pointer; transition: all 0.2s;
}
.pill.is-active { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.pill-date { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; width: 44px; padding: 0; }
.pill-date input[type="date"] { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

details.notes {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--rad-md); padding: var(--sp-3); margin-bottom: var(--sp-6);
}
details.notes summary { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--c-text-muted); cursor: pointer; list-style: none; }
details.notes summary::-webkit-details-marker { display: none; }
details.notes textarea { margin-top: var(--sp-3); resize: vertical; min-height: 80px; }
.xmeta { font-size: 0.8rem; color: var(--c-text-muted); text-align: center; margin-top: var(--sp-4); line-height: 1.5; }
.scope-hint { font-size: 0.85rem; color: var(--c-text-muted); margin-bottom: var(--sp-6); margin-top: -12px; font-style: italic; }

/* Cards & Settings */
.settings-main, .metrics-main { padding: var(--sp-4); }
.settings-section { margin-bottom: var(--sp-8); }
.settings-section h3 { font-size: 0.9rem; color: var(--c-primary); margin-bottom: var(--sp-3); text-transform: uppercase; font-weight: 800; letter-spacing: 1px; }
.card {
  background: var(--c-surface);
  border-radius: var(--rad-lg);
  padding: var(--sp-4);
  border: 1px solid var(--c-border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

.profile-card { display: flex; align-items: center; gap: var(--sp-4); background: var(--c-surface); padding: var(--sp-4); border-radius: var(--rad-lg); border: 1px solid var(--c-border); box-shadow: 0 4px 12px rgba(0,0,0,0.03); }
.avatar { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; color: #fff; font-weight: 700; background: var(--c); }
.avatar-xs { width: 24px; height: 24px; font-size: 10px; }
.profile-info h3 { font-size: 1.25rem; margin-bottom: 4px; font-weight: 800; }
.profile-info p { color: var(--c-text-muted); font-size: 0.9rem; }

.device-list { background: var(--c-surface); border-radius: var(--rad-lg); border: 1px solid var(--c-border); overflow: hidden; box-shadow: 0 4px 12px rgba(0,0,0,0.03); }
.device-item { display: flex; align-items: center; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--c-border); }
.device-item:last-child { border-bottom: none; }
.device-icon { color: var(--c-primary); margin-right: var(--sp-3); background: var(--c-primary-light); padding: 8px; border-radius: 50%; display: flex; }
.device-main { flex: 1; }
.device-name { font-weight: 700; color: var(--c-text); }
.device-meta { font-size: 0.8rem; color: var(--c-text-muted); margin-top: 2px; }
.device-item.current .device-name { color: var(--c-primary); }

/* Metrics */
.metrics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.summary-card { text-align: center; }
.summary-card:first-child { grid-column: span 2; background: var(--c-primary); color: #fff; border: none; }
.summary-card:first-child .summary-label { color: rgba(255,255,255,0.8); }
.summary-label { font-size: 0.85rem; font-weight: 600; color: var(--c-text-muted); margin-bottom: var(--sp-1); text-transform: uppercase; letter-spacing: 0.5px; }
.summary-value { font-size: 1.75rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.summary-card:first-child .summary-value { font-size: 2.5rem; }

.settle-card { grid-column: span 2; display: flex; align-items: center; gap: var(--sp-4); background: var(--c-primary-light); border: none; }
.settle-icon { width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.settle-owe .settle-icon { background: var(--c-warning); }
.settle-receive .settle-icon { background: var(--c-success); }
.settle-even .settle-icon { background: var(--c-primary); }
.settle-text { flex: 1; }
.settle-amount { font-size: 1.4rem; font-weight: 800; color: var(--c-text); margin-top: 4px; }
.settle-text div { font-size: 0.9rem; color: var(--c-text-muted); font-weight: 500; }

.chart-card { grid-column: span 2; }
.chart-card h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: var(--sp-6); text-align: center; color: var(--c-text); }
.chart-container { display: flex; justify-content: center; min-height: 180px; width: 100%; position: relative; }

/* Donut */
.donut { position: relative; width: 180px; height: 180px; margin: 0 auto; display: flex; align-items: center; justify-content: center; }
.donut-svg { transform: rotate(-90deg); width: 100%; height: 100%; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.05)); }
.donut-track { stroke: var(--c-bg); }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.donut-center strong { font-size: 1.75rem; font-weight: 800; line-height: 1.2; color: var(--c-text); }
.donut-center span { font-size: 0.8rem; font-weight: 600; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: 1px; }

/* Trend Bars */
.trend { width: 100%; display: flex; flex-direction: column; gap: var(--sp-6); }
.trend-legend { display: flex; justify-content: center; gap: var(--sp-4); font-size: 0.85rem; font-weight: 600; color: var(--c-text-muted); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-item .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.trend-chart { display: flex; align-items: flex-end; justify-content: space-between; height: 140px; padding-top: var(--sp-4); border-bottom: 2px solid var(--c-border); margin-bottom: var(--sp-2); }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; height: 100%; justify-content: flex-end; }
.trend-bars { display: flex; align-items: flex-end; gap: 4px; width: 100%; justify-content: center; height: 100%; }
.trend-bar { width: 14px; background: var(--c); border-radius: 4px 4px 0 0; min-height: 4px; transition: height 0.5s ease-out; }
.trend-month { font-size: 0.75rem; font-weight: 600; color: var(--c-text-muted); margin-top: 8px; text-transform: uppercase; }
.trend-val { position: absolute; top: -24px; font-size: 0.75rem; font-weight: 700; color: var(--c-text); white-space: nowrap; }

/* Login */
.login-view { display: flex; flex-direction: column; min-height: 100dvh; padding: var(--sp-6); justify-content: center; }
.login-header { text-align: center; margin-bottom: var(--sp-8); }
.login-logo { width: 88px; height: 88px; border-radius: var(--rad-xl); background: var(--c-primary); margin: 0 auto var(--sp-4); display: flex; align-items: center; justify-content: center; color: #fff; box-shadow: 0 12px 24px rgba(2, 119, 189, 0.3); }

.login {
  display: flex; flex-direction: column; justify-content: center;
  width: 100%; max-width: 400px; margin: 0 auto;
}
.login-brand { text-align: center; margin-bottom: var(--sp-8); }
.login-brand h1 { font-size: 2rem; font-weight: 800; color: var(--c-text); }
.login-card {
  padding: var(--sp-6);
  border-radius: var(--rad-xl);
  background: var(--c-surface);
  box-shadow: 0 8px 32px rgba(0,0,0,0.08);
  display: flex; flex-direction: column; gap: var(--sp-6);
}
.who-grid { display: flex; gap: var(--sp-4); margin-top: var(--sp-2); }
.who { flex: 1; cursor: pointer; position: relative; }
.who input { position: absolute; opacity: 0; }
.who-face {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4);
  border: 2px solid var(--c-border);
  border-radius: var(--rad-lg);
  transition: all 0.2s ease;
  background: var(--c-surface);
}
.who input:checked + .who-face {
  border-color: var(--c);
  background: var(--c-surface);
  box-shadow: 0 0 0 4px rgba(0,0,0,0.03);
}
.who-name { font-weight: 700; font-size: 1.1rem; color: var(--c-text); }
.login-foot {
  text-align: center; margin-top: var(--sp-6); font-size: 0.9rem; font-weight: 500;
  display: flex; align-items: center; justify-content: center; gap: var(--sp-2); color: var(--c-text-muted);
}

/* Dialog (Bottom Sheet) & Modals */
.sheet {
  margin: auto 0 0 0;
  width: 100%;
  max-width: var(--app-max-w);
  border: none;
  background: transparent;
  padding: 0;
  color: var(--c-text);
  overflow: visible;
}
.sheet::backdrop { background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); transition: background 0.3s; }
.sheet-inner {
  background: var(--c-surface);
  border-radius: 28px 28px 0 0;
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - var(--safe-top) - 20px - var(--kb, 0px));
  box-shadow: 0 -10px 40px rgba(0,0,0,0.15);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1);
}
.sheet.is-open .sheet-inner { transform: translateY(0); }
.sheet.is-dragging .sheet-inner { transition: none; }

.sheet-header {
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
  text-align: center;
  position: relative;
  touch-action: none;
  flex-shrink: 0;
}
.sheet-handle {
  display: block;
  width: 48px; height: 5px;
  background: var(--c-border);
  border-radius: 3px;
  margin: 0 auto var(--sp-4);
}
.sheet-title { font-size: 1.25rem; font-weight: 800; color: var(--c-text); }
.sheet-close {
  position: absolute; right: var(--sp-4); top: var(--sp-4);
  background: var(--c-bg); color: var(--c-text-muted);
}
.sheet-body { padding: 0 var(--sp-4) var(--sp-4); overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.sheet-footer {
  position: sticky; bottom: 0; background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  padding: var(--sp-4) var(--sp-4) calc(var(--sp-4) + var(--safe-bottom));
  border-top: 1px solid var(--c-border);
  display: flex; gap: var(--sp-3);
}

/* Compact Sheet for Confirmation */
.sheet-compact .sheet-inner { border-radius: var(--rad-xl); margin: auto var(--sp-4); max-height: 80dvh; transform: scale(0.95); opacity: 0; }
.sheet-compact { margin: auto; max-width: 400px; }
.sheet-compact.is-open .sheet-inner { transform: scale(1); opacity: 1; }
.sheet-compact .sheet-header { padding-top: var(--sp-6); }
.sheet-compact .sheet-handle { display: none; }
.confirm-text { text-align: center; font-size: 1.05rem; color: var(--c-text-muted); line-height: 1.5; margin-bottom: var(--sp-2); }
.sheet-compact .sheet-footer { border-top: none; padding-top: 0; justify-content: stretch; }
.sheet-compact .sheet-footer .btn { flex: 1; }

/* Toasts */
.toasts { position: fixed; bottom: calc(var(--nav-height) + var(--safe-bottom) + 24px); left: 16px; right: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--c-text); color: #fff; padding: 14px 20px; border-radius: var(--rad-lg); box-shadow: 0 8px 24px rgba(0,0,0,0.15); display: flex; align-items: center; gap: 12px; max-width: 400px; width: 100%; pointer-events: auto; animation: slideUpToast 0.4s cubic-bezier(0.16, 1, 0.3, 1); overflow: hidden; position: relative; }
.toast-msg { flex: 1; font-size: 0.95rem; font-weight: 600; }
.toast-action { background: none; border: none; color: var(--c-primary-light); font-weight: 800; cursor: pointer; padding: 0; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.5px; }
.toast-timer { position: absolute; bottom: 0; left: 0; height: 4px; background: rgba(255,255,255,0.3); animation: linear shrinkRight forwards; }
.toast-error { background: var(--c-error); }
.toast-success { background: var(--c-success); }
.toast.is-leaving { animation: fadeOutToast 0.3s forwards; }

@keyframes slideUpToast { from { transform: translateY(30px) scale(0.95); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
@keyframes fadeOutToast { to { opacity: 0; transform: translateY(-10px) scale(0.95); } }
@keyframes shrinkRight { from { width: 100%; } to { width: 0; } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* Extra Utilities & Specific Classes */
.checkbox-label {
  display: flex; align-items: center; gap: var(--sp-2); cursor: pointer;
  font-weight: 600; color: var(--c-text); font-size: 0.95rem;
}
.checkbox-label input[type="checkbox"] {
  width: 20px; height: 20px; accent-color: var(--c-primary);
  border: 2px solid var(--c-border); border-radius: 4px; cursor: pointer;
}
.sync-actions {
  display: flex; gap: var(--sp-3); flex-wrap: wrap; justify-content: center;
}
.sync-actions .btn { flex: 1; min-width: 120px; }

/* Login Inputs */
.input-wrap {
  position: relative; display: flex; align-items: center;
}
.input-wrap .input { padding-right: 48px; }
.input-addon {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; color: var(--c-text-muted);
}
.check {
  display: flex; align-items: center; gap: var(--sp-2); cursor: pointer;
  font-weight: 600; color: var(--c-text); font-size: 0.95rem;
  margin-top: var(--sp-4);
}
.check input { position: absolute; opacity: 0; }
.check-box {
  width: 24px; height: 24px; border: 2px solid var(--c-border); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: transparent; transition: all 0.2s;
}
.check input:checked + .check-box {
  background: var(--c-primary); border-color: var(--c-primary); color: #fff;
}
.form-error {
  color: var(--c-error); font-weight: 600; font-size: 0.9rem; text-align: center;
  min-height: 1.2em; margin-top: var(--sp-4);
}
.shake { animation: shake 0.4s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
