/* ============================================================
   ODERITH FUERZA DE VENTA — PWA Stylesheet
   Mobile-first · Sistema de diseño verde/blanco/gris
   ============================================================ */

/* ---------- CSS Custom Properties (Tokens) ---------- */
:root {
  --color-primary:       #2E7D32;
  --color-primary-light: #4CAF50;
  --color-primary-dark:  #1B5E20;
  --color-bg:            #FFFFFF;
  --color-bg-alt:        #F5F5F5;
  --color-text:          #424242;
  --color-text-secondary:#9E9E9E;
  --color-border:        #E0E0E0;
  --color-success:       #2E7D32;
  --color-warning:       #F57F17;
  --color-error:         #C62828;
  --color-info:          #1565C0;

  --font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-full:50%;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08);
  --shadow-md:  0 2px 8px rgba(0,0,0,.12);
  --shadow-lg:  0 4px 16px rgba(0,0,0,.16);
  --header-h:   56px;
  --bottomnav-h:60px;
  --touch-min:  44px;
  --transition: .25s cubic-bezier(.4,0,.2,1);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-family);
  color: var(--color-text);
  background: var(--color-bg-alt);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
ul, ol { list-style: none; }

/* ---------- App Shell ---------- */
.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--color-bg);
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
.header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: var(--color-primary);
  color: #fff;
  display: flex; align-items: center;
  padding: 0 16px;
  box-shadow: var(--shadow-md);
}
.header__menu-btn {
  width: 40px; height: 40px;
  background: none; border: none; color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border-radius: var(--radius-full);
  transition: background var(--transition);
  flex-shrink: 0;
}
.header__menu-btn:active { background: rgba(255,255,255,.15); }
.header__logo {
  width: 28px; height: 28px; margin-left: 8px; flex-shrink: 0;
}
.header__title {
  font-size: .95rem; font-weight: 600; margin-left: 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.header__actions { margin-left: auto; display: flex; gap: 4px; }

/* ---------- Sidebar / Drawer ---------- */
.sidebar-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.45);
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.sidebar-overlay.open { opacity: 1; pointer-events: auto; }

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 210;
  width: 280px; max-width: 80vw;
  background: var(--color-bg);
  transform: translateX(-100%);
  transition: transform var(--transition);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.sidebar.open { transform: translateX(0); }

.sidebar__header {
  background: var(--color-primary);
  color: #fff;
  padding: 24px 20px 20px;
}
.sidebar__avatar {
  width: 56px; height: 56px;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 700; margin-bottom: 12px;
  border: 2px solid rgba(255,255,255,.4);
}
.sidebar__user-name { font-size: 1rem; font-weight: 600; }
.sidebar__user-company { font-size: .8rem; opacity: .8; margin-top: 2px; }

.sidebar__nav { flex: 1; padding: 8px 0; overflow-y: auto; }
.sidebar__link {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px;
  font-size: .93rem;
  cursor: pointer;
  transition: background var(--transition);
  min-height: var(--touch-min);
}
.sidebar__link:hover,
.sidebar__link:active { background: var(--color-bg-alt); }
.sidebar__link.active {
  color: var(--color-primary);
  font-weight: 600;
  background: rgba(46,125,50,.08);
}
.sidebar__link svg { width: 22px; height: 22px; flex-shrink: 0; }
.sidebar__divider { height: 1px; background: var(--color-border); margin: 8px 0; }

.sidebar__footer {
  padding: 16px 20px;
  border-top: 1px solid var(--color-border);
}
.sidebar__sub-badge {
  font-size: .78rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; gap: 6px;
}
.sidebar__sub-badge.green  { background: rgba(46,125,50,.1); color: var(--color-success); }
.sidebar__sub-badge.yellow { background: rgba(245,127,23,.1); color: var(--color-warning); }
.sidebar__sub-badge.red    { background: rgba(198,40,40,.1);  color: var(--color-error); }

.sidebar__logout {
  display: flex; align-items: center; gap: 10px;
  margin-top: 12px; padding: 10px 0;
  color: var(--color-error);
  font-size: .9rem; font-weight: 500;
  cursor: pointer; background: none; border: none; width: 100%;
}

/* ---------- Main Content ---------- */
.main-content {
  flex: 1;
  padding-bottom: calc(var(--bottomnav-h) + 16px);
  min-height: calc(100dvh - var(--header-h) - var(--bottomnav-h));
}

/* ---------- Bottom Navigation ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  height: var(--bottomnav-h);
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-around;
  z-index: 90;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav__item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 12px;
  font-size: .65rem; color: var(--color-text-secondary);
  cursor: pointer; background: none; border: none;
  min-width: var(--touch-min); min-height: var(--touch-min);
  transition: color var(--transition);
  position: relative;
}
.bottom-nav__item.active { color: var(--color-primary); font-weight: 600; }
.bottom-nav__item.active::before {
  content: '';
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 24px; height: 3px;
  background: var(--color-primary);
  border-radius: 0 0 3px 3px;
}
.bottom-nav__item svg { width: 24px; height: 24px; }
.bottom-nav__badge {
  position: absolute; top: 2px; right: 4px;
  min-width: 16px; height: 16px;
  background: var(--color-error);
  color: #fff; font-size: .6rem; font-weight: 700;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

/* ---------- Pull to Refresh ---------- */
.ptr-indicator {
  text-align: center;
  padding: 12px;
  color: var(--color-primary);
  font-size: .85rem;
  overflow: hidden;
  max-height: 0;
  transition: max-height .3s ease;
}
.ptr-indicator.visible { max-height: 60px; }
.ptr-spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ---------- LOGIN PAGE ---------- */
.login-page {
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 36px 28px 28px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  width: 72px; height: 72px;
  margin: 0 auto 16px;
  background: var(--color-primary);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.8rem; font-weight: 800;
}
.login-title {
  text-align: center; font-size: 1.25rem; font-weight: 700;
  color: var(--color-primary); margin-bottom: 4px;
}
.login-subtitle {
  text-align: center; font-size: .85rem;
  color: var(--color-text-secondary); margin-bottom: 28px;
}
.login-error {
  background: rgba(198,40,40,.08);
  color: var(--color-error);
  font-size: .82rem;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}

/* ---------- Form Elements ---------- */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block; font-size: .82rem; font-weight: 500;
  color: var(--color-text); margin-bottom: 6px;
}
.form-input {
  width: 100%; height: 46px;
  padding: 0 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: .93rem;
  background: var(--color-bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(46,125,50,.12);
}
.form-input.error { border-color: var(--color-error); }
.form-input-wrapper {
  position: relative;
}
.form-input-wrapper .toggle-pw {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--color-text-secondary);
  cursor: pointer; padding: 4px;
}
.form-hint { font-size: .75rem; color: var(--color-error); margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--touch-min); padding: 0 24px;
  border: none; border-radius: var(--radius-md);
  font-size: .93rem; font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform .1s, box-shadow var(--transition);
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: var(--color-primary); color: #fff;
  box-shadow: 0 2px 6px rgba(46,125,50,.3);
}
.btn-primary:hover:not(:disabled) { background: var(--color-primary-dark); }

.btn-secondary {
  background: var(--color-bg-alt); color: var(--color-text);
  border: 1.5px solid var(--color-border);
}

.btn-danger  { background: var(--color-error); color: #fff; }
.btn-warning { background: var(--color-warning); color: #fff; }
.btn-block   { width: 100%; }
.btn-sm      { min-height: 36px; padding: 0 16px; font-size: .82rem; }
.btn-lg      { min-height: 52px; padding: 0 32px; font-size: 1rem; }

.btn-fab {
  position: fixed; bottom: calc(var(--bottomnav-h) + 20px); right: 20px;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--color-primary); color: #fff;
  box-shadow: var(--shadow-lg);
  z-index: 80;
  display: flex; align-items: center; justify-content: center;
  border: none; cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}
.btn-fab:active { transform: scale(.9); }

/* ---------- Search Bar ---------- */
.search-bar {
  position: sticky; top: var(--header-h); z-index: 50;
  background: var(--color-bg);
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
}
.search-input-wrap {
  position: relative;
}
.search-input-wrap svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--color-text-secondary);
}
.search-input {
  width: 100%; height: 42px;
  padding: 0 14px 0 40px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-size: .9rem;
  background: var(--color-bg-alt);
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}
.search-input:focus {
  border-color: var(--color-primary);
  background: var(--color-bg);
}

/* ---------- Cards ---------- */
.card {
  background: var(--color-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin: 0 16px 12px;
  padding: 16px;
  transition: box-shadow var(--transition);
  cursor: pointer;
}
.card:active { box-shadow: var(--shadow-md); }

.card-row {
  display: flex; align-items: center; justify-content: space-between;
}
.card-title {
  font-size: .93rem; font-weight: 600;
  color: var(--color-text);
  margin-bottom: 2px;
}
.card-subtitle {
  font-size: .8rem; color: var(--color-text-secondary);
}
.card-meta {
  font-size: .78rem; color: var(--color-text-secondary);
  margin-top: 6px;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem; font-weight: 600;
  white-space: nowrap;
}
.badge-green  { background: rgba(46,125,50,.1);  color: var(--color-success); }
.badge-yellow { background: rgba(245,127,23,.1); color: var(--color-warning); }
.badge-orange { background: rgba(230,81,0,.1);   color: #E65100; }
.badge-red    { background: rgba(198,40,40,.1);   color: var(--color-error); }
.badge-blue   { background: rgba(21,101,192,.1);  color: var(--color-info); }
.badge-gray   { background: var(--color-bg-alt);  color: var(--color-text-secondary); }

/* ---------- Dashboard ---------- */
.dashboard-section {
  padding: 16px;
}
.dashboard-greeting {
  font-size: 1.15rem; font-weight: 700;
  margin-bottom: 4px;
}
.dashboard-date {
  font-size: .82rem; color: var(--color-text-secondary);
  margin-bottom: 20px;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--color-bg);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.stat-card__icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 10px;
  font-size: 1.1rem;
}
.stat-card__icon.green  { background: rgba(46,125,50,.1);  color: var(--color-success); }
.stat-card__icon.blue   { background: rgba(21,101,192,.1);  color: var(--color-info); }
.stat-card__icon.orange { background: rgba(245,127,23,.1); color: var(--color-warning); }
.stat-card__icon.purple { background: rgba(106,27,154,.1); color: #6A1B9A; }
.stat-card__value {
  font-size: 1.5rem; font-weight: 800;
  color: var(--color-text);
}
.stat-card__label {
  font-size: .75rem; color: var(--color-text-secondary);
  margin-top: 2px;
}

.section-title {
  font-size: .9rem; font-weight: 700;
  color: var(--color-text);
  margin-bottom: 12px;
  padding: 0 16px;
}

/* Subscription Banner */
.sub-banner {
  margin: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; gap: 12px;
  font-size: .85rem; font-weight: 500;
}
.sub-banner.green  { background: rgba(46,125,50,.08);  color: var(--color-success); border: 1px solid rgba(46,125,50,.2); }
.sub-banner.yellow { background: rgba(245,127,23,.08); color: var(--color-warning); border: 1px solid rgba(245,127,23,.2); }
.sub-banner.red    { background: rgba(198,40,40,.08);  color: var(--color-error);   border: 1px solid rgba(198,40,40,.2); }

/* Suspended overlay */
.suspended-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(198,40,40,.97);
  color: #fff;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  padding: 24px;
}
.suspended-overlay__icon { font-size: 4rem; margin-bottom: 16px; }
.suspended-overlay__title { font-size: 1.5rem; font-weight: 800; margin-bottom: 8px; }
.suspended-overlay__msg { font-size: .95rem; opacity: .85; max-width: 280px; }

/* Top Products list */
.top-product-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-bg-alt);
}
.top-product-rank {
  width: 26px; height: 26px;
  border-radius: var(--radius-full);
  background: var(--color-bg-alt);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700;
  color: var(--color-text-secondary);
  flex-shrink: 0;
}
.top-product-rank.gold   { background: #FFF8E1; color: #F57F17; }
.top-product-rank.silver { background: #F5F5F5; color: #757575; }
.top-product-rank.bronze { background: #FBE9E7; color: #E64A19; }
.top-product-info { flex: 1; min-width: 0; }
.top-product-name { font-size: .85rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-product-qty  { font-size: .82rem; font-weight: 700; color: var(--color-primary); white-space: nowrap; }

/* ---------- Product Card ---------- */
.product-card { position: relative; }
.product-card__stock {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .75rem; font-weight: 600;
  margin-top: 8px;
}
.stock-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
}
.stock-green  .stock-dot { background: var(--color-success); }
.stock-yellow .stock-dot { background: var(--color-warning); }
.stock-red    .stock-dot { background: var(--color-error); }
.stock-green  { color: var(--color-success); }
.stock-yellow { color: var(--color-warning); }
.stock-red    { color: var(--color-error); }

.product-price {
  font-size: 1.05rem; font-weight: 800;
  color: var(--color-primary);
}

/* ---------- Product Detail ---------- */
.detail-header {
  background: var(--color-primary);
  color: #fff;
  padding: 20px 16px 24px;
}
.detail-back {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; color: #fff;
  font-size: .85rem; cursor: pointer;
  margin-bottom: 16px; padding: 4px 0;
}
.detail-title { font-size: 1.15rem; font-weight: 700; }
.detail-code  { font-size: .82rem; opacity: .8; margin-top: 4px; }
.detail-body  { padding: 16px; }
.detail-row {
  display: flex; justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-bg-alt);
  font-size: .88rem;
}
.detail-row__label { color: var(--color-text-secondary); }
.detail-row__value { font-weight: 600; }

/* ---------- Client Card ---------- */
.client-card__balance {
  font-size: .95rem; font-weight: 700; text-align: right;
}
.balance-green  { color: var(--color-success); }
.balance-yellow { color: var(--color-warning); }
.balance-red    { color: var(--color-error); }

/* ---------- CxC Table ---------- */
.cxc-summary {
  padding: 16px;
  background: var(--color-bg);
  border-bottom: 2px solid var(--color-border);
}
.cxc-total {
  font-size: 1.3rem; font-weight: 800;
  color: var(--color-primary);
}
.cxc-doc {
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-bg-alt);
}
.cxc-doc__header {
  display: flex; justify-content: space-between; align-items: flex-start;
}
.cxc-doc__type { font-size: .78rem; font-weight: 600; text-transform: uppercase; }
.cxc-doc__amount { font-size: .95rem; font-weight: 700; }
.cxc-doc__detail { font-size: .78rem; color: var(--color-text-secondary); margin-top: 4px; }
.cxc-aging {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px; padding: 16px;
}
.cxc-aging__item {
  text-align: center;
  padding: 10px 4px;
  border-radius: var(--radius-sm);
  font-size: .75rem;
}
.cxc-aging__item .amount { font-size: .88rem; font-weight: 700; display: block; margin-top: 4px; }
.aging-green  { background: rgba(46,125,50,.08);  color: var(--color-success); }
.aging-yellow { background: rgba(245,127,23,.08); color: var(--color-warning); }
.aging-orange { background: rgba(230,81,0,.08);   color: #E65100; }
.aging-red    { background: rgba(198,40,40,.08);   color: var(--color-error); }

/* ---------- Order (Pedido) Screen ---------- */
.order-section { padding: 16px; }
.order-client-box {
  padding: 14px;
  border: 1.5px dashed var(--color-border);
  border-radius: var(--radius-md);
  text-align: center;
  color: var(--color-text-secondary);
  font-size: .88rem;
  cursor: pointer;
  transition: border-color var(--transition);
}
.order-client-box:active { border-color: var(--color-primary); }
.order-client-box.selected {
  border-style: solid;
  border-color: var(--color-primary);
  text-align: left;
  color: var(--color-text);
}

.order-items-list { margin-top: 16px; }
.order-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-bg-alt);
}
.order-item__info { flex: 1; min-width: 0; }
.order-item__name { font-size: .88rem; font-weight: 500; }
.order-item__price { font-size: .78rem; color: var(--color-text-secondary); }
.order-item__qty {
  display: flex; align-items: center; gap: 6px;
}
.order-item__qty button {
  width: 30px; height: 30px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg-alt);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1rem;
}
.order-item__qty span {
  min-width: 28px; text-align: center;
  font-weight: 600; font-size: .93rem;
}
.order-item__subtotal {
  font-weight: 700; font-size: .9rem;
  color: var(--color-primary);
  min-width: 70px; text-align: right;
}
.order-item__remove {
  background: none; border: none; color: var(--color-error);
  cursor: pointer; padding: 4px;
}

.order-totals {
  background: var(--color-bg-alt);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 16px;
}
.order-totals__row {
  display: flex; justify-content: space-between;
  padding: 6px 0;
  font-size: .88rem;
}
.order-totals__row.total {
  border-top: 2px solid var(--color-border);
  padding-top: 10px; margin-top: 6px;
  font-size: 1.05rem; font-weight: 800;
  color: var(--color-primary);
}
.order-notes {
  width: 100%; min-height: 70px;
  padding: 12px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: .88rem;
  resize: vertical;
  margin-top: 16px;
  outline: none;
}
.order-notes:focus { border-color: var(--color-primary); }

/* ---------- Pedidos (Orders History) ---------- */
.filter-tabs {
  display: flex; gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
}
.filter-tab {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: .82rem; font-weight: 500;
  background: var(--color-bg-alt);
  color: var(--color-text-secondary);
  border: 1.5px solid transparent;
  cursor: pointer; white-space: nowrap;
  transition: all var(--transition);
  min-height: 34px;
}
.filter-tab.active {
  background: rgba(46,125,50,.1);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.order-status { font-size: .78rem; font-weight: 600; }

/* ---------- Modal / Picker ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  width: 100%; max-width: 480px;
  max-height: 85dvh;
  background: var(--color-bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}
.modal__title { font-size: 1rem; font-weight: 700; }
.modal__close {
  width: 36px; height: 36px;
  border: none; background: var(--color-bg-alt);
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1.1rem;
}
.modal__body {
  flex: 1; overflow-y: auto; padding: 16px;
}
.modal__footer {
  padding: 16px 20px;
  border-top: 1px solid var(--color-border);
}

/* ---------- Success Animation ---------- */
.success-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(46,125,50,.95);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: #fff;
  animation: fadeIn .3s ease;
}
.success-check {
  width: 80px; height: 80px;
  border: 4px solid #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem;
  animation: scaleIn .4s ease .2s both;
  margin-bottom: 20px;
}
.success-title { font-size: 1.3rem; font-weight: 700; animation: fadeInUp .4s ease .4s both; }
.success-msg   { font-size: .9rem; opacity: .85; margin-top: 8px; animation: fadeInUp .4s ease .5s both; }

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--color-text-secondary);
}
.empty-state__icon { font-size: 3rem; margin-bottom: 12px; opacity: .5; }
.empty-state__title { font-size: 1rem; font-weight: 600; margin-bottom: 4px; color: var(--color-text); }
.empty-state__msg { font-size: .85rem; }

/* ---------- Loading Skeleton ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--color-bg-alt) 25%, #eee 50%, var(--color-bg-alt) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-title { height: 18px; width: 60%; margin-bottom: 12px; }
.skeleton-card {
  height: 80px;
  margin: 0 16px 12px;
  border-radius: var(--radius-md);
}

/* ---------- Toast Notification ---------- */
.toast {
  position: fixed;
  top: calc(var(--header-h) + 12px);
  left: 50%; transform: translateX(-50%) translateY(-100px);
  max-width: 420px; width: calc(100% - 32px);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: .88rem; font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 500;
  display: flex; align-items: center; gap: 10px;
  transition: transform .35s cubic-bezier(.4,0,.2,1);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast-success { background: var(--color-success); color: #fff; }
.toast-error   { background: var(--color-error);   color: #fff; }
.toast-warning { background: var(--color-warning); color: #fff; }
.toast-info    { background: var(--color-info);     color: #fff; }

/* ---------- Spinner ---------- */
.spinner-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(255,255,255,.7);
  display: flex; align-items: center; justify-content: center;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ---------- Animations ---------- */
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}
@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
  from { transform: scale(0); } to { transform: scale(1); }
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.fade-in    { animation: fadeIn .3s ease; }
.fade-in-up { animation: fadeInUp .35s ease; }

/* ---------- Utilities ---------- */
.text-center   { text-align: center; }
.text-right    { text-align: right; }
.text-sm       { font-size: .82rem; }
.text-xs       { font-size: .75rem; }
.text-muted    { color: var(--color-text-secondary); }
.text-primary  { color: var(--color-primary); }
.text-error    { color: var(--color-error); }
.text-success  { color: var(--color-success); }
.text-warning  { color: var(--color-warning); }
.fw-600        { font-weight: 600; }
.fw-700        { font-weight: 700; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.p-16  { padding: 16px; }
.gap-8 { gap: 8px; }
.flex  { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Desktop max-width constraint ---------- */
@media (min-width: 481px) {
  body {
    background: #E8F5E9;
  }
  .app-shell {
    box-shadow: 0 0 30px rgba(0,0,0,.1);
  }
  .bottom-nav {
    border-radius: 0;
  }
}

/* ---------- Safe area for notched devices ---------- */
@supports (padding: env(safe-area-inset-bottom)) {
  .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  }
  .main-content {
    padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + 16px);
  }
}
