/* =========================================================================
   MySegretaria — Design System
   Mobile-first, light/dark via [data-theme], keeps the brand blue (#3a416f).
   ========================================================================= */

/* ---------- Tokens ---------- */
:root {
  --brand-50:  #eef0f7;
  --brand-100: #d6daea;
  --brand-200: #aab2d2;
  --brand-300: #7a85b5;
  --brand-400: #535f95;
  --brand-500: #3a416f;
  --brand-600: #303763;
  --brand-700: #262c52;
  --brand-800: #1d2240;

  --accent:    #36b9cc;
  --success:   #1cc88a;
  --warning:   #f6b73c;
  --danger:    #e83e8c;
  --info:      #36b9cc;
  --pink:      #e83e8c;

  --bg:            #f5f6fb;
  --surface:       #ffffff;
  --surface-2:     #fafbff;
  --elevated:      #ffffff;
  --border:        #e6e8f1;
  --border-strong: #d2d6e6;

  --text:       #1d2240;
  --text-muted: #5a6483;
  --text-soft:  #8a91a8;
  --on-brand:   #ffffff;

  --shadow-sm:    0 1px 2px rgba(29,34,64,.06), 0 1px 3px rgba(29,34,64,.04);
  --shadow:       0 4px 12px rgba(29,34,64,.08), 0 2px 4px rgba(29,34,64,.04);
  --shadow-lg:    0 12px 32px rgba(29,34,64,.14), 0 4px 12px rgba(29,34,64,.06);
  --shadow-brand: 0 8px 22px rgba(58,65,111,.25);

  --radius-xs: 8px;
  --radius-sm: 10px;
  --radius:    14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;

  --font: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, 'Heebo', system-ui, sans-serif;

  --header-h:     56px;
  --bottom-nav-h: 68px;
  --transition:   180ms cubic-bezier(.2,.8,.2,1);
}

[data-theme="dark"] {
  --brand-50:  #1d2240;
  --brand-100: #262c52;

  --bg:            #0f1226;
  --surface:       #181c36;
  --surface-2:     #1f2440;
  --elevated:      #20254a;
  --border:        #2c3157;
  --border-strong: #3a4070;

  --text:       #eef0f7;
  --text-muted: #a8b0cc;
  --text-soft:  #7a83a3;

  --shadow-sm:    0 1px 2px rgba(0,0,0,.4);
  --shadow:       0 4px 12px rgba(0,0,0,.45);
  --shadow-lg:    0 12px 32px rgba(0,0,0,.55);
  --shadow-brand: 0 8px 22px rgba(0,0,0,.55);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh; min-height: 100dvh;
}
body { padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom)); }
body.no-bottom-nav { padding-bottom: 0; }

img, svg { max-width: 100%; display: block; }
a { color: var(--brand-500); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--brand-600); }
input, select, textarea, button { font-family: inherit; font-size: inherit; color: inherit; }

h1, h2, h3, h4, h5, h6 { margin: 0 0 var(--space-3); font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 var(--space-3); }
::selection { background: var(--brand-500); color: #fff; }

/* ---------- Layout ---------- */
.app { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }

.app-header {
  position: sticky; top: 0; z-index: 40;
  height: calc(var(--header-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  display: flex; align-items: center; justify-content: space-between;
  padding-left: var(--space-4); padding-right: var(--space-4);
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
[data-theme="dark"] .app-header { background: rgba(24,28,54,.85); }

.app-header__title {
  display: flex; align-items: center; gap: var(--space-2);
  font-weight: 700; font-size: 1.05rem; color: var(--text);
}
.logo-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-300));
  color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: .85rem;
  box-shadow: var(--shadow-brand);
}
.app-header__actions { display: flex; align-items: center; gap: var(--space-2); }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: var(--radius-pill);
  border: 0; background: transparent;
  color: var(--text);
  display: grid; place-items: center;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: var(--brand-50); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 22px; height: 22px; }

.container {
  width: 100%; max-width: 1100px;
  margin: 0 auto;
  padding: var(--space-4);
}
@media (min-width: 768px) { .container { padding: var(--space-6); } }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}
.card.is-elevated { box-shadow: var(--shadow); }
.card.is-interactive { cursor: pointer; }
.card.is-interactive:hover { box-shadow: var(--shadow); transform: translateY(-1px); border-color: var(--border-strong); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-3);
}
.card-title {
  font-size: .78rem;
  font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); margin: 0;
}

/* ---------- Stats grid ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}
@media (min-width: 768px) {
  .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
}
.stat {
  display: flex; align-items: center; gap: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px; background: var(--brand-500);
}
.stat.is-success::before { background: var(--success); }
.stat.is-warning::before { background: var(--warning); }
.stat.is-info::before    { background: var(--info); }
.stat.is-pink::before    { background: var(--pink); }
.stat__icon {
  flex: 0 0 44px;
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--brand-50);
  color: var(--brand-500);
  display: grid; place-items: center;
}
.stat.is-success .stat__icon { background: rgba(28,200,138,.14); color: var(--success); }
.stat.is-warning .stat__icon { background: rgba(246,183,60,.14); color: var(--warning); }
.stat.is-info .stat__icon    { background: rgba(54,185,204,.14); color: var(--info); }
.stat.is-pink .stat__icon    { background: rgba(232,62,140,.12); color: var(--pink); }
.stat__icon svg { width: 22px; height: 22px; }
.stat__body { min-width: 0; flex: 1; }
.stat__label {
  font-size: .72rem; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.stat__value {
  margin-top: 2px;
  font-size: 1.2rem; font-weight: 800;
  color: var(--text);
  letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stat__hint { margin-top: 2px; font-size: .72rem; color: var(--text-soft); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  padding: .7rem 1.25rem;
  font-size: .95rem; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: background var(--transition), color var(--transition),
              transform var(--transition), box-shadow var(--transition),
              border-color var(--transition), filter var(--transition);
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-400));
  color: #fff;
  box-shadow: var(--shadow-brand);
}
.btn-primary:hover { color: #fff; filter: brightness(1.06); }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--brand-50); border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--brand-500); padding: .55rem .9rem; }
.btn-ghost:hover { background: var(--brand-50); }
.btn-block { width: 100%; }
.btn-lg { padding: .9rem 1.4rem; font-size: 1rem; min-height: 52px; }

/* ---------- Forms ---------- */
.field { position: relative; margin-bottom: var(--space-4); }
.field > label {
  display: block;
  font-size: .82rem; font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.input, .textarea, .select {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .8rem .95rem;
  font-size: 1rem;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  appearance: none; -webkit-appearance: none;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--brand-400);
  background: var(--surface);
  box-shadow: 0 0 0 4px rgba(58,65,111,.12);
}
.textarea { min-height: 130px; resize: vertical; }
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235a6483' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .9rem center;
  padding-right: 2.4rem;
}

/* Native option list — Chromium / Firefox honor these (Safari mostly ignores) */
option {
  background-color: var(--surface);
  color: var(--text);
}
[data-theme="dark"] select { color-scheme: dark; }

/* Floating-label input */
.field.is-floating .input {
  height: 56px;
  padding: 1.4rem .95rem .55rem;
}
.field.is-floating > label {
  position: absolute;
  top: 50%; left: .95rem;
  transform: translateY(-50%);
  pointer-events: none;
  margin: 0;
  background: transparent;
  color: var(--text-soft);
  font-weight: 500;
  font-size: 1rem;
  transition: top var(--transition), font-size var(--transition), color var(--transition), transform var(--transition);
}
.field.is-floating .input:focus + label,
.field.is-floating .input:not(:placeholder-shown) + label {
  top: 12px; transform: none;
  font-size: .72rem; font-weight: 700;
  color: var(--brand-500);
  text-transform: uppercase; letter-spacing: .04em;
}
.field.has-icon .input { padding-left: 2.6rem; }
.field.has-icon .field-icon {
  position: absolute; left: .9rem; top: 50%;
  transform: translateY(-50%);
  color: var(--text-soft);
  pointer-events: none;
  width: 20px; height: 20px;
}
.field.is-floating.has-icon > label { left: 2.6rem; }

.password-toggle {
  position: absolute; right: 6px; top: 50%;
  transform: translateY(-50%);
  width: 36px; height: 36px;
  border-radius: var(--radius-pill);
  border: 0; background: transparent;
  color: var(--text-muted); cursor: pointer;
  display: grid; place-items: center;
}
.password-toggle:hover { background: var(--brand-50); color: var(--brand-500); }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 50;
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  box-shadow: 0 -6px 18px rgba(29,34,64,.06);
}
[data-theme="dark"] .bottom-nav { background: rgba(24,28,54,.96); backdrop-filter: blur(10px); }
.bottom-nav__item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: .68rem; font-weight: 600;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: color var(--transition);
  position: relative;
}
.bottom-nav__item svg { width: 22px; height: 22px; }
.bottom-nav__item.is-active { color: var(--brand-500); }
.bottom-nav__item.is-active::before {
  content: ""; position: absolute; top: 6px;
  width: 28px; height: 4px;
  border-radius: var(--radius-pill);
  background: var(--brand-500); opacity: .9;
}
.bottom-nav__item:hover { color: var(--brand-500); }

/* ---------- Drawer ---------- */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,18,38,.55);
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
  z-index: 60;
}
.drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(86vw, 360px);
  background: var(--surface);
  z-index: 70;
  transform: translateX(100%);
  transition: transform var(--transition);
  display: flex; flex-direction: column;
  box-shadow: -12px 0 30px rgba(0,0,0,.18);
  padding-top: env(safe-area-inset-top);
}
.drawer.is-open { transform: translateX(0); }
.drawer__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.drawer__user { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.drawer__user-info { min-width: 0; }
.drawer__user-name {
  font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 200px;
}
.drawer__user-mail {
  font-size: .8rem; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 200px;
}
.avatar {
  width: 44px; height: 44px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--brand-500), var(--brand-300));
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; text-transform: uppercase;
  flex-shrink: 0;
}
.drawer__nav {
  list-style: none;
  margin: 0; padding: var(--space-3);
  display: flex; flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  flex: 1;
}
.drawer__nav a {
  display: flex; align-items: center; gap: var(--space-3);
  padding: .8rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
}
.drawer__nav a svg { width: 20px; height: 20px; color: var(--text-muted); flex-shrink: 0; }
.drawer__nav a:hover, .drawer__nav a.is-active { background: var(--brand-50); color: var(--brand-600); }
.drawer__nav a.is-active svg { color: var(--brand-500); }
.drawer__nav .danger { color: var(--danger); }
.drawer__nav .danger svg { color: var(--danger); }
.drawer__footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3);
}

/* Theme toggle */
.theme-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  background: var(--brand-50);
  color: var(--text-muted);
  border: 0; cursor: pointer;
  font-size: .8rem; font-weight: 600;
}
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle:hover { background: var(--brand-100); color: var(--brand-600); }

/* ---------- Badges / status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: .75rem; font-weight: 700;
  background: var(--brand-50); color: var(--brand-600);
}
.badge-success { background: rgba(28,200,138,.14); color: #0e8e5c; }
.badge-warning { background: rgba(246,183,60,.18); color: #8b6500; }
.badge-danger  { background: rgba(232,62,140,.14); color: #b3286a; }

.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: var(--space-6) 0 var(--space-3);
}
.section-title h2 { font-size: 1.05rem; margin: 0; letter-spacing: -.01em; }
.section-title .muted { font-size: .8rem; color: var(--text-muted); }

/* ---------- Progress ring ---------- */
.ring {
  --size: 150px;
  --p: 0;
  --track: var(--brand-50);
  --fill: var(--brand-500);
  width: var(--size); height: var(--size);
  border-radius: 50%;
  background: conic-gradient(var(--fill) calc(var(--p) * 1%), var(--track) 0);
  display: grid; place-items: center;
  position: relative;
  margin: 0 auto;
  transition: background 600ms ease;
}
.ring::before {
  content: ""; position: absolute; inset: 10px;
  background: var(--surface);
  border-radius: 50%;
}
.ring__label { position: relative; z-index: 1; text-align: center; }
.ring__value {
  font-size: 1.8rem; font-weight: 800;
  color: var(--text); letter-spacing: -.02em;
}
.ring__caption {
  margin-top: 2px;
  font-size: .68rem;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); font-weight: 700;
}

/* ---------- Status select ---------- */
.status-select-wrap { display: flex; gap: var(--space-3); align-items: center; }
.status-select {
  width: 100%;
  border-radius: var(--radius-pill);
  border: 2px solid var(--border);
  padding: .85rem 1rem;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
  text-align: center;
  text-align-last: center;
  appearance: none;
  -webkit-appearance: none;
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.6rem;
  transition: border-color var(--transition), color var(--transition), box-shadow var(--transition);
}
.status-select:focus { outline: none; box-shadow: 0 0 0 4px rgba(58,65,111,.12); }
.status-select option { background: var(--surface); color: var(--text); font-weight: 600; }

/* ---------- Apply bar (in-flow, never sticky) ---------- */
.apply-bar {
  display: flex; justify-content: center;
  margin-top: var(--space-6);
  padding-bottom: var(--space-3);
}
.apply-bar .btn {
  box-shadow: var(--shadow);
  padding-left: 2rem; padding-right: 2rem;
}

/* ---------- Notes grid ---------- */
.notes-grid { display: grid; gap: var(--space-3); grid-template-columns: 1fr; }
@media (min-width: 768px) { .notes-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); } }

/* ---------- Tenant switch ---------- */
/* ---------- Tenant switcher (admin) ---------- */
.tenant-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .tenant-switch { background: var(--surface-2); }

.tenant-switch select,
.tenant-switch__search {
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: .92rem;
  padding: 0 .8rem;
  outline: none;
  min-width: 0;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.tenant-switch select:hover,
.tenant-switch__search:hover { border-color: var(--border-strong); }
.tenant-switch select:focus,
.tenant-switch__search:focus {
  border-color: var(--brand-400);
  box-shadow: 0 0 0 3px rgba(58,65,111,.18);
  background: var(--surface);
}

.tenant-switch select {
  flex: 2 1 0;          /* take ~2/3 of the row → wide popup */
  appearance: none;
  -webkit-appearance: none;
  font-weight: 600;
  cursor: pointer;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235a6483' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
[data-theme="dark"] .tenant-switch select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23a8b0cc' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}
.tenant-switch select option {
  background: var(--surface);
  color: var(--text);
  padding: 6px 8px;
}

.tenant-switch__search {
  flex: 1 1 0;          /* search takes the remaining ~1/3 */
}
.tenant-switch__search::placeholder { color: var(--text-soft); }
.tenant-switch__search.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(232,62,140,.15);
  color: var(--danger);
}

.tenant-switch button {
  border: 0;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-400));
  color: #fff;
  height: 42px;
  padding: 0 18px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  font-size: .92rem;
  flex: 0 0 auto;
  white-space: nowrap;
  box-shadow: var(--shadow-brand);
  transition: filter var(--transition), transform var(--transition);
}
.tenant-switch button:hover { filter: brightness(1.06); }
.tenant-switch button:active { transform: translateY(1px); }

@media (max-width: 720px) {
  .tenant-switch {
    flex-wrap: wrap;
    padding: 10px;
  }
  .tenant-switch select,
  .tenant-switch__search { flex: 1 1 100%; }
  .tenant-switch button   { flex: 1 1 100%; }
}

/* ---------- Login / auth ---------- */
.auth-page {
  min-height: 100vh; min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
  background: var(--bg);
}
@media (min-width: 992px) { .auth-page { grid-template-columns: 1fr 1fr; } }

.auth-hero {
  display: none;
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, var(--brand-600), var(--brand-400) 55%, #5a6299);
  color: #fff;
  padding: var(--space-8);
}
@media (min-width: 992px) { .auth-hero { display: flex; flex-direction: column; justify-content: center; } }
.auth-hero__inner { position: relative; z-index: 2; max-width: 460px; }
.auth-hero__brand {
  display: flex; align-items: center; gap: var(--space-3);
  margin-bottom: var(--space-7);
  font-weight: 700; font-size: 1.1rem;
}
.auth-hero__brand .logo-mark { width: 36px; height: 36px; font-size: 1rem; }
.auth-hero h1 {
  font-size: 2.4rem; line-height: 1.1; letter-spacing: -.02em;
  margin-bottom: var(--space-4);
}
.auth-hero p { color: rgba(255,255,255,.85); font-size: 1.05rem; }
.auth-hero__bubbles span {
  position: absolute; border-radius: 50%;
  background: rgba(255,255,255,.08);
  filter: blur(2px);
}
.auth-hero__bubbles span:nth-child(1) { width: 320px; height: 320px; top: -100px; right: -120px; }
.auth-hero__bubbles span:nth-child(2) { width: 180px; height: 180px; bottom: 40px; left: 20px; background: rgba(255,255,255,.06); }
.auth-hero__bubbles span:nth-child(3) { width: 90px;  height: 90px;  top: 30%; right: 25%; background: rgba(255,255,255,.10); }
.auth-hero__bubbles span:nth-child(4) { width: 140px; height: 140px; bottom: -40px; right: 30%; background: rgba(255,255,255,.05); }

.auth-form {
  display: flex; flex-direction: column; justify-content: center;
  padding: var(--space-7) var(--space-5);
  background: var(--surface);
}
@media (min-width: 992px) { .auth-form { padding: var(--space-8); } }
.auth-form__inner { width: 100%; max-width: 380px; margin: 0 auto; }
.auth-form__brand {
  display: flex; align-items: center; gap: var(--space-2);
  margin-bottom: var(--space-6);
  font-weight: 700;
}
@media (min-width: 992px) { .auth-form__brand { display: none; } }
.auth-form__brand .logo-mark { width: 36px; height: 36px; }
.auth-form h2 { font-size: 1.6rem; letter-spacing: -.02em; margin-bottom: 6px; }
.auth-form .lead { color: var(--text-muted); margin-bottom: var(--space-6); }
.auth-form .help { margin-top: var(--space-5); font-size: .85rem; color: var(--text-muted); text-align: center; }

.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  font-size: .9rem;
  margin-bottom: var(--space-4);
  border: 1px solid transparent;
  display: flex; gap: var(--space-2); align-items: flex-start;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-danger  { background: rgba(232,62,140,.10); color: #b3286a; border-color: rgba(232,62,140,.25); }
.alert-warning { background: rgba(246,183,60,.12); color: #8b6500; border-color: rgba(246,183,60,.3); }
.alert-success { background: rgba(28,200,138,.12); color: #0e8e5c; border-color: rgba(28,200,138,.25); }

/* ---------- Offline ---------- */
.offline-page {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center;
  padding: var(--space-5);
}
.offline-wrap { width: 100%; max-width: 420px; }
.offline-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-7) var(--space-5);
  text-align: center;
  box-shadow: var(--shadow);
}
.offline-icon {
  width: 88px; height: 88px;
  margin: 0 auto var(--space-4);
  border-radius: 50%;
  background: var(--brand-50); color: var(--brand-500);
  display: grid; place-items: center;
}

/* ---------- Profile hero ---------- */
.profile-hero {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-5);
  background: linear-gradient(135deg, var(--brand-500), var(--brand-300));
  color: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-brand);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}
.profile-hero__avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  border: 2px solid rgba(255,255,255,.3);
  display: grid; place-items: center;
  font-size: 1.8rem; font-weight: 800;
  text-transform: uppercase;
  flex-shrink: 0;
}
.profile-hero__body { min-width: 0; flex: 1; }
.profile-hero__name {
  font-size: 1.35rem; font-weight: 700;
  letter-spacing: -.01em;
  word-break: break-word;
  line-height: 1.2;
}
.profile-hero__chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 8px;
}
.chip-on-brand {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.18);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip-on-brand svg { width: 14px; height: 14px; flex-shrink: 0; }

@media (max-width: 480px) {
  .profile-hero {
    padding: var(--space-4);
    gap: var(--space-3);
    flex-wrap: nowrap;
  }
  .profile-hero__avatar {
    width: 56px; height: 56px; font-size: 1.3rem;
    border-width: 1.5px;
  }
  .profile-hero__name { font-size: 1.05rem; }
  .chip-on-brand { font-size: .72rem; padding: 3px 8px; }
}

/* ---------- WhatsApp brand color hint ---------- */
.brand-whatsapp { color: #25d366; }
.option-row.is-whatsapp .option-row__icon { background: rgba(37,211,102,.14); color: #25d366; }
.switch.is-whatsapp input:checked + .switch__slider { background: #25d366; }

/* Conditional reveal */
.reveal {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 280ms ease, opacity 220ms ease, margin-top 220ms ease;
  margin-top: 0;
}
.reveal.is-open {
  max-height: 800px;
  opacity: 1;
  margin-top: var(--space-3);
}

/* ---------- Segmented links (month switcher) ---------- */
.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px;
  gap: 2px;
}
.segmented a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}
.segmented a:hover { color: var(--brand-500); }
.segmented a.is-active {
  background: var(--surface);
  color: var(--brand-500);
  box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .segmented a.is-active { background: var(--elevated); }
.segmented svg { width: 14px; height: 14px; }

/* PDF capture: when this class is present we force a clean light look
   on the snapshot area only (no shadow, light background) */
.pdf-capturing {
  background: #ffffff !important;
  padding: 16px !important;
  color: #1d2240 !important;
  border-radius: 0 !important;
}
.pdf-capturing * { box-shadow: none !important; }

/* ---------- Credit card visual ---------- */
.credit-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  aspect-ratio: 1.586 / 1;
  border-radius: 18px;
  padding: var(--space-5);
  color: #fff;
  background:
    radial-gradient(1200px circle at -10% -10%, rgba(255,255,255,.12), transparent 40%),
    radial-gradient(800px circle at 110% 110%, rgba(255,255,255,.08), transparent 35%),
    linear-gradient(135deg, var(--brand-700), var(--brand-500) 60%, #5a6299);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.credit-card::before {
  content: "";
  position: absolute;
  top: -60px; right: -60px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,.06);
}
.credit-card__head {
  display: flex; align-items: center; justify-content: space-between;
}
.credit-card__chip {
  width: 38px; height: 28px;
  border-radius: 6px;
  background: linear-gradient(135deg, #d8b864, #b89540);
  position: relative;
  flex-shrink: 0;
}
.credit-card__chip::before {
  content: ""; position: absolute; inset: 6px;
  border: 1px solid rgba(0,0,0,.25);
  border-radius: 3px;
}
.credit-card__brand {
  font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase;
  font-size: .9rem;
  opacity: .9;
  text-align: right;
}
.credit-card__number {
  font-variant-numeric: tabular-nums;
  font-size: 1.3rem;
  letter-spacing: .12em;
  font-weight: 600;
  margin-top: var(--space-3);
}
.credit-card__foot {
  display: flex; justify-content: space-between; align-items: end;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  opacity: .85;
}
.credit-card__foot strong { font-size: .9rem; opacity: 1; letter-spacing: .04em; }

@media (max-width: 480px) {
  .credit-card { padding: var(--space-4); border-radius: 16px; }
  .credit-card__number { font-size: 1.15rem; letter-spacing: .1em; }
  .credit-card__chip { width: 32px; height: 24px; }
}

/* ---------- Priority picker (segmented radio) ---------- */
.priority-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px;
}
.priority-picker label {
  display: flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 8px 6px;
  border-radius: var(--radius-pill);
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
  -webkit-tap-highlight-color: transparent;
  text-align: center;
}
.priority-picker input { position: absolute; opacity: 0; pointer-events: none; }
.priority-picker label .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-soft);
  flex-shrink: 0;
}
.priority-picker label[data-p="0"] .dot { background: #8a91a8; }
.priority-picker label[data-p="1"] .dot { background: var(--info); }
.priority-picker label[data-p="2"] .dot { background: var(--warning); }
.priority-picker label[data-p="3"] .dot { background: var(--danger); }
.priority-picker input:checked + .pick-content {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .priority-picker input:checked + .pick-content { background: var(--elevated); }
.priority-picker .pick-content {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 6px 4px;
  border-radius: var(--radius-pill);
}

/* ---------- Activity card ---------- */
.activity-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}
@media (min-width: 900px) {
  .activity-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
}
.activity {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), border-color var(--transition);
}
.activity:hover { box-shadow: var(--shadow); }
.activity::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--brand-500);
  border-radius: var(--radius) 0 0 var(--radius);
}
.activity[data-priority="0"]::before { background: #8a91a8; }
.activity[data-priority="1"]::before { background: var(--info); }
.activity[data-priority="2"]::before { background: var(--warning); }
.activity[data-priority="3"]::before { background: var(--danger); }

.activity__head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.activity__date {
  font-size: .82rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.activity__badges { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* Status badges */
.badge-status-not_started { background: var(--brand-50); color: var(--brand-600); }
.badge-status-in_progress { background: rgba(246,183,60,.18); color: #8b6500; }
.badge-status-completed   { background: rgba(28,200,138,.14); color: #0e8e5c; }
[data-theme="dark"] .badge-status-not_started { background: rgba(255,255,255,.06); color: var(--text); }

.activity__body {
  color: var(--text);
  line-height: 1.55;
  font-size: .94rem;
  word-break: break-word;
}

/* Inline customer field with + button */
.field-with-add {
  display: flex; gap: 8px; align-items: stretch;
}
.field-with-add .field { flex: 1; margin-bottom: 0; }
.field-with-add .add-btn {
  flex-shrink: 0;
  width: 56px;
  border: 1px dashed var(--border-strong);
  background: var(--surface-2);
  color: var(--brand-500);
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.field-with-add .add-btn:hover { background: var(--brand-50); border-color: var(--brand-300); border-style: solid; }
.field-with-add .add-btn svg { width: 22px; height: 22px; }

/* ---------- FAQ accordion ---------- */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
  overflow: hidden;
}
.faq-item:hover { border-color: var(--border-strong); }
.faq-item.is-open {
  border-color: var(--brand-300);
  box-shadow: var(--shadow);
}

.faq-summary {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4);
  cursor: pointer;
  list-style: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.faq-summary::-webkit-details-marker { display: none; }
.faq-summary__icon {
  flex: 0 0 36px;
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--brand-50);
  color: var(--brand-500);
  display: grid; place-items: center;
  font-weight: 800;
  font-size: .9rem;
}
.faq-summary__icon svg { width: 18px; height: 18px; }
.faq-summary__text {
  flex: 1; min-width: 0;
  font-weight: 700;
  color: var(--text);
  word-break: break-word;
  font-size: .98rem;
}
.faq-summary__chevron {
  flex-shrink: 0;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  color: var(--text-muted);
  transition: transform var(--transition), color var(--transition);
}
.faq-summary__chevron svg { width: 18px; height: 18px; }
.faq-item.is-open .faq-summary__chevron {
  transform: rotate(180deg);
  color: var(--brand-500);
}
.faq-item.is-open .faq-summary__icon {
  background: var(--brand-500);
  color: #fff;
}

.faq-body {
  padding: 0 var(--space-4) var(--space-4);
  color: var(--text-muted);
  line-height: 1.6;
  font-size: .92rem;
  word-break: break-word;
}
.faq-body__content {
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
  color: var(--text);
  white-space: normal;
}
.faq-body__actions {
  display: flex; justify-content: flex-end;
  margin-top: var(--space-3);
}

/* ---------- Call detail (note cards) ---------- */
.note-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}
@media (min-width: 900px) {
  .note-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
}
.note {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.note:hover { box-shadow: var(--shadow); }
.note.is-email { border-left: 3px solid var(--danger); }
.note.is-text  { border-left: 3px solid var(--brand-500); }
.note__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}
.note__type {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .82rem; font-weight: 600;
  color: var(--text-muted);
}
.note__type-icon {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: var(--brand-50);
  color: var(--brand-500);
  display: grid; place-items: center;
}
.note__type-icon svg { width: 16px; height: 16px; }
.note.is-email .note__type-icon { background: rgba(232,62,140,.12); color: var(--danger); }
.note__date { color: var(--text); font-weight: 700; }
.note__actions { display: inline-flex; gap: 4px; }
.note__actions .icon-btn { width: 32px; height: 32px; }
.note__actions .icon-btn svg { width: 14px; height: 14px; }
.note__actions .icon-btn.is-share:hover  { background: var(--brand-50); color: var(--brand-500); }
.note__actions .icon-btn.is-delete:hover { background: rgba(232,62,140,.12); color: var(--danger); }
.note__body {
  color: var(--text);
  font-size: .95rem;
  line-height: 1.55;
  white-space: normal;
  word-break: break-word;
}
.note__body br + br { display: block; content: ""; margin-top: 4px; }

/* ---------- Call log (registry) ---------- */
.calls-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2);
}
@media (min-width: 768px) {
  .calls-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
}
@media (min-width: 1080px) {
  .calls-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.call-card {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
  position: relative;
}
.call-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.call-card.is-this-month { border-left: 3px solid var(--brand-500); }

.call-dir {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.call-dir svg { width: 20px; height: 20px; }
.call-dir.is-in  { background: rgba(28,200,138,.14); color: var(--success); }
.call-dir.is-out { background: rgba(108,117,255,.14); color: #6c75ff; }

.call-body { min-width: 0; }
.call-body__top {
  display: flex; align-items: baseline; gap: 8px;
  font-weight: 600;
}
.call-name {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text);
}
.call-name.is-unknown { color: var(--text-soft); font-style: italic; font-weight: 500; }
.call-number {
  font-variant-numeric: tabular-nums;
  font-size: .85rem;
  color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.call-meta {
  margin-top: 2px;
  display: flex; align-items: center;
  gap: 10px;
  font-size: .76rem;
  color: var(--text-muted);
}
.call-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--text-soft); display: inline-block; }
.call-duration {
  font-variant-numeric: tabular-nums;
  font-weight: 700; color: var(--text);
}

.call-actions {
  display: inline-flex; gap: 4px;
  align-items: center;
}
.call-actions .icon-btn { width: 36px; height: 36px; }
.call-actions .icon-btn svg { width: 16px; height: 16px; }
.call-actions .icon-btn.is-info:hover { background: var(--brand-50); color: var(--brand-500); }
.call-actions .icon-btn.is-call:hover { background: rgba(28,200,138,.12); color: var(--success); }

/* Calls table specifics */
.calls-table { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.calls-table table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.calls-table thead th {
  position: sticky; top: 0;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.calls-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
.calls-table tbody tr:last-child td { border-bottom: 0; }
.calls-table tbody tr:hover { background: var(--brand-50); }
[data-theme="dark"] .calls-table tbody tr:hover { background: rgba(255,255,255,.03); }
.calls-table tbody tr.is-this-month td { background: rgba(58,65,111,.05); }
[data-theme="dark"] .calls-table tbody tr.is-this-month td { background: rgba(255,255,255,.04); }

.calls-table .col-dir   { width: 1%; white-space: nowrap; }
.calls-table .col-date  { width: 1%; white-space: nowrap; font-variant-numeric: tabular-nums; }
.calls-table .col-time  { white-space: nowrap; color: var(--text-muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.calls-table .col-num   { font-variant-numeric: tabular-nums; white-space: nowrap; }
.calls-table .col-dur   { width: 1%; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 700; }
.calls-table .col-info  { width: 1%; white-space: nowrap; text-align: right; }
.calls-table .col-info .icon-btn { width: 34px; height: 34px; }
.calls-table .col-info .icon-btn svg { width: 16px; height: 16px; }
.calls-table .row-name-line {
  display: flex; flex-direction: column;
  min-width: 0;
}
.calls-table .row-name-line strong {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 240px;
}
.calls-table .row-name-line strong.is-unknown { font-weight: 500; color: var(--text-soft); font-style: italic; }
.calls-table .row-name-line small {
  color: var(--text-muted); font-size: .76rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 240px;
}

@media (max-width: 720px) {
  .calls-table table { min-width: 480px; font-size: .85rem; }
  .calls-table thead th, .calls-table tbody td { padding: 10px 12px; }
  .calls-table .row-name-line strong, .calls-table .row-name-line small { max-width: 140px; }
}

/* Page-level pagination row */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-4);
  flex-wrap: wrap;
}
.pager[hidden] { display: none !important; }
.pager .pager__info { font-size: .82rem; color: var(--text-muted); }
.pager .pager__nav { display: inline-flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
@media (max-width: 480px) {
  .pager { justify-content: center; }
  .pager .pager__nav .btn { min-width: 110px; }
}

/* Quick CTA chips (Mese Corrente / Precedente) */
.quick-cta {
  display: flex; gap: var(--space-2); flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.quick-cta .btn { padding: .55rem 1rem; min-height: 40px; font-size: .88rem; }

/* ---------- State-card (clickable status toggle) ---------- */
.state-card {
  display: flex; align-items: center;
  gap: var(--space-3);
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  position: relative;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition), background var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.state-card:hover { box-shadow: var(--shadow); }
.state-card:active { transform: translateY(1px); }
.state-card__icon {
  flex: 0 0 44px;
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--brand-50);
  color: var(--text-muted);
  display: grid; place-items: center;
  transition: background var(--transition), color var(--transition);
}
.state-card__icon svg { width: 22px; height: 22px; }
.state-card__body { flex: 1; min-width: 0; }
.state-card__title {
  font-weight: 700; color: var(--text);
  font-size: .98rem;
}
.state-card__hint {
  margin-top: 2px;
  font-size: .76rem;
  color: var(--text-muted);
}
.state-card__pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  flex-shrink: 0;
}
.state-card__pill .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-soft);
}

/* VIP variant — gold accents when on */
.state-card[data-state="on"][data-variant="vip"] {
  border-color: rgba(246,183,60,.55);
  background: linear-gradient(180deg, rgba(246,183,60,.08), var(--surface) 60%);
}
.state-card[data-state="on"][data-variant="vip"] .state-card__icon {
  background: rgba(246,183,60,.16); color: var(--warning);
}
.state-card[data-state="on"][data-variant="vip"] .state-card__pill {
  background: rgba(246,183,60,.16);
  border-color: rgba(246,183,60,.4);
  color: #8b6500;
}
.state-card[data-state="on"][data-variant="vip"] .state-card__pill .dot { background: var(--warning); }

/* Blacklist variant — danger accents when on */
.state-card[data-state="on"][data-variant="blacklist"] {
  border-color: rgba(232,62,140,.5);
  background: linear-gradient(180deg, rgba(232,62,140,.06), var(--surface) 60%);
}
.state-card[data-state="on"][data-variant="blacklist"] .state-card__icon {
  background: rgba(232,62,140,.14); color: var(--danger);
}
.state-card[data-state="on"][data-variant="blacklist"] .state-card__pill {
  background: rgba(232,62,140,.12);
  border-color: rgba(232,62,140,.3);
  color: #b3286a;
}
.state-card[data-state="on"][data-variant="blacklist"] .state-card__pill .dot { background: var(--danger); }

/* Customer hero (top of single_customer.php) */
.customer-hero {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.customer-hero__avatar {
  flex: 0 0 64px;
  width: 64px; height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-300));
  color: #fff;
  display: grid; place-items: center;
  font-size: 1.6rem; font-weight: 800;
  text-transform: uppercase;
  position: relative;
}
.customer-hero__avatar.is-blacklist { background: linear-gradient(135deg, #5a6483, #353a55); }
.customer-hero__body { flex: 1; min-width: 0; }
.customer-hero__name {
  font-size: 1.25rem; font-weight: 700;
  letter-spacing: -.01em;
  word-break: break-word;
}
.customer-hero__phone {
  margin-top: 4px;
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-muted);
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
}
.customer-hero__phone a { color: var(--text); font-weight: 600; }
.customer-hero__actions {
  display: flex; gap: var(--space-2);
  margin-left: auto;
  flex-wrap: wrap;
}
@media (max-width: 480px) {
  .customer-hero { padding: var(--space-3); gap: var(--space-3); }
  .customer-hero__avatar { flex: 0 0 52px; width: 52px; height: 52px; font-size: 1.3rem; border-radius: 14px; }
  .customer-hero__name { font-size: 1.05rem; }
  .customer-hero__actions { width: 100%; margin-left: 0; }
  .customer-hero__actions .btn { flex: 1; }
}

/* save indicator pill (subtle visual feedback while inputs auto-save) */
.save-indicator {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + 12px);
  left: 50%; transform: translateX(-50%) translateY(8px);
  z-index: 70;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  display: inline-flex; align-items: center; gap: 8px;
  box-shadow: var(--shadow);
  opacity: 0; pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
}
.save-indicator.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.save-indicator svg { width: 16px; height: 16px; }
.save-indicator.is-success { color: var(--success); border-color: rgba(28,200,138,.3); }
.save-indicator.is-error   { color: var(--danger);  border-color: rgba(232,62,140,.3); }

/* ---------- Page header with back ---------- */
.page-head {
  display: flex; align-items: center; gap: var(--space-3);
  margin: var(--space-2) 0 var(--space-4);
}
.page-head .icon-btn { background: var(--surface); border: 1px solid var(--border); }
.page-head h1 { margin: 0; font-size: 1.5rem; line-height: 1.2; }
.page-head .muted { font-size: .82rem; }

/* ---------- Form grid + sections ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}
@media (min-width: 640px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
  .form-grid .col-full { grid-column: 1 / -1; }
}
.form-section { margin-bottom: var(--space-5); }
.form-section__title {
  font-size: .78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted);
  margin: 0 0 var(--space-3);
}

/* ---------- Toggle switch (option pair) ---------- */
.option-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.option-row__icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--brand-50);
  color: var(--brand-500);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.option-row__label {
  flex: 1; min-width: 0;
}
.option-row__label strong { display: block; font-size: .95rem; color: var(--text); }
.option-row__label small { display: block; font-size: .78rem; color: var(--text-muted); margin-top: 2px; }
.option-row.is-warning .option-row__icon { background: rgba(246,183,60,.16); color: var(--warning); }
.option-row.is-danger  .option-row__icon { background: rgba(232,62,140,.14); color: var(--danger); }

.switch {
  position: relative;
  display: inline-block;
  width: 50px; height: 28px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0; width: 0; height: 0;
  position: absolute;
}
.switch__slider {
  position: absolute; inset: 0;
  background: var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--transition);
}
.switch__slider::before {
  content: "";
  position: absolute;
  width: 22px; height: 22px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
.switch input:checked + .switch__slider { background: var(--brand-500); }
.switch.is-warning input:checked + .switch__slider { background: var(--warning); }
.switch.is-danger  input:checked + .switch__slider { background: var(--danger); }
.switch input:checked + .switch__slider::before { transform: translateX(22px); }
.switch input:focus-visible + .switch__slider { box-shadow: 0 0 0 4px rgba(58,65,111,.18); }

/* ---------- Form actions row ---------- */
.form-actions {
  display: flex; gap: var(--space-3);
  align-items: center; justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: var(--space-5);
}
.form-actions .btn-primary { min-width: 160px; }
@media (max-width: 480px) {
  .form-actions { flex-direction: column-reverse; align-items: stretch; }
  .form-actions .btn { width: 100%; }
}

/* ---------- Segmented view toggle ---------- */
.view-toggle {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}
.view-toggle button {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  width: 38px; height: 38px;
  border-radius: var(--radius-pill);
  display: grid; place-items: center;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.view-toggle button svg { width: 18px; height: 18px; }
.view-toggle button:hover { color: var(--brand-500); }
.view-toggle button.is-active {
  background: var(--surface);
  color: var(--brand-500);
  box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .view-toggle button.is-active { background: var(--elevated); }

/* ---------- View switcher visibility ---------- */
.view-card  .contact-table { display: none; }
.view-table .contact-list  { display: none; }

/* Container width stays the same in card and table view */

/* ---------- Contacts table ---------- */
.contact-table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.contact-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  min-width: 640px;
}
.contact-table thead th {
  position: sticky; top: 0;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.contact-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
.contact-table tbody tr:last-child td { border-bottom: 0; }
.contact-table tbody tr:hover { background: var(--brand-50); }
[data-theme="dark"] .contact-table tbody tr:hover { background: rgba(255,255,255,.03); }

.contact-table .row-name {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600;
  min-width: 0;
}
.contact-table .row-name .mini-avatar {
  flex: 0 0 32px;
  width: 32px; height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-300));
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: .82rem;
  text-transform: uppercase;
}
.contact-table .row-name .mini-avatar.is-blacklist {
  background: linear-gradient(135deg, #5a6483, #353a55);
}
.contact-table .row-name .name-stack {
  display: flex; flex-direction: column;
  min-width: 0;
}
.contact-table .row-name .name-stack strong {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 220px;
}
.contact-table .row-name .name-stack small {
  color: var(--text-muted);
  font-size: .76rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 220px;
}
.contact-table .row-phone {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  width: 1%;        /* shrink to content so Contact/Email get the leftover space */
}
.contact-table .row-status {
  width: 1%;
  white-space: nowrap;
}
.contact-table tbody td:first-child { min-width: 220px; }
.contact-table tbody td:nth-child(3) { word-break: break-word; }
.contact-table .row-actions {
  text-align: right;
  white-space: nowrap;
  width: 1%; /* shrink to content so action column never steals row width */
}
.contact-table .row-actions__group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
}
.contact-table .row-actions .icon-btn {
  width: 34px; height: 34px;
  display: inline-grid;
}
.contact-table .row-actions .icon-btn svg { width: 16px; height: 16px; }
.contact-table .row-actions .icon-btn.is-call   { color: var(--success); }
.contact-table .row-actions .icon-btn.is-call:hover   { background: rgba(28,200,138,.12); }
.contact-table .row-actions .icon-btn.is-edit:hover   { background: var(--brand-50); color: var(--brand-500); }
.contact-table .row-actions .icon-btn.is-delete:hover { background: rgba(232,62,140,.12); color: var(--danger); }
.contact-table .row-status .badge { font-size: .68rem; padding: 2px 8px; }

@media (min-width: 1100px) {
  .contact-table .row-name .name-stack strong,
  .contact-table .row-name .name-stack small { max-width: 380px; }
  .contact-table thead th, .contact-table tbody td { padding: 14px 18px; }
}

@media (max-width: 720px) {
  .contact-table table { min-width: 480px; font-size: .85rem; }
  .contact-table thead th, .contact-table tbody td { padding: 10px 12px; }
  /* Hide email column on narrower screens to keep the table readable */
  .contact-table thead th:nth-child(3),
  .contact-table tbody td:nth-child(3) { display: none; }
  .contact-table .row-name .name-stack strong,
  .contact-table .row-name .name-stack small { max-width: 140px; }
}
@media (max-width: 480px) {
  .contact-table table { min-width: 380px; }
  .contact-table .row-name .mini-avatar { flex: 0 0 28px; width: 28px; height: 28px; font-size: .72rem; }
  /* Hide status column on tiny screens — VIP/Blacklist still indicated by avatar tint */
  .contact-table thead th:nth-child(4),
  .contact-table tbody td:nth-child(4) { display: none; }
}

/* ---------- Contacts list ---------- */
.toolbar {
  display: flex; gap: var(--space-3);
  align-items: center;
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.search {
  position: relative;
  flex: 1; min-width: 220px;
}
.search .input {
  padding-left: 2.6rem;
  height: 48px;
  border-radius: var(--radius-pill);
}
.search .field-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  width: 20px; height: 20px;
  color: var(--text-soft);
  pointer-events: none;
}
.search .clear {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 0; background: transparent;
  color: var(--text-muted); cursor: pointer;
  display: none;
  align-items: center; justify-content: center;
}
.search .clear.is-visible { display: inline-flex; }
.search .clear:hover { background: var(--brand-50); color: var(--brand-500); }

.contact-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);  /* prevent grid items from blowing the row width */
  gap: var(--space-3);
  grid-auto-rows: 1fr;
}
@media (min-width: 768px) {
  .contact-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1080px) {
  .contact-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* Hide initial cards/rows past first page server-side to avoid FOUC */
.contact-list .contact[data-initial-hidden],
#contactTable tbody tr[data-initial-hidden] { display: none; }

.contact {
  display: flex; align-items: stretch;
  gap: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  position: relative;
}
.contact:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.contact.is-blacklist { border-color: rgba(232,62,140,.4); background: linear-gradient(180deg, rgba(232,62,140,.05), var(--surface) 40%); }
.contact.is-vip      { border-color: rgba(246,183,60,.5); }

.contact__avatar {
  flex-shrink: 0;
  width: 48px; height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-300));
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 1.05rem;
  text-transform: uppercase;
  position: relative;
}
.contact.is-blacklist .contact__avatar {
  background: linear-gradient(135deg, #5a6483, #353a55);
}
.contact__avatar .crown {
  position: absolute;
  top: -6px; right: -6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--warning);
  color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.18);
}
.contact__avatar .crown svg { width: 12px; height: 12px; }

.contact__body {
  flex: 1 1 0;
  min-width: 0;
  display: flex; flex-direction: column;
  justify-content: center;
  gap: 2px;
  overflow: hidden;
}
.contact__name {
  font-weight: 700; color: var(--text);
  font-size: .98rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.contact__company {
  font-size: .78rem;
  color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.contact__phone {
  font-size: .85rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  display: flex; align-items: center; gap: 6px;
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.contact__phone svg { width: 14px; height: 14px; color: var(--text-soft); flex-shrink: 0; }

.contact__badges {
  display: inline-flex; gap: 4px; flex-wrap: wrap;
  margin-top: 4px;
}
.contact__badges .badge { padding: 2px 8px; font-size: .68rem; }

/* Pager numbered buttons */
.pager__pages { display: inline-flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.pager__pages .pager__page {
  min-width: 34px; height: 34px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 600;
  font-size: .85rem;
  padding: 0 8px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.pager__pages .pager__page:hover { color: var(--brand-500); border-color: var(--brand-200); }
.pager__pages .pager__page.is-active {
  background: var(--brand-500); color: #fff; border-color: var(--brand-500);
}
.pager__pages .pager__ellipsis { color: var(--text-soft); padding: 0 4px; }
@media (max-width: 480px) { .pager__pages { display: none; } }

.contact__actions {
  display: flex; align-items: center;
  gap: 4px;
  margin-left: auto;
  align-self: center;
}
.contact__actions .icon-btn { width: 38px; height: 38px; }
.contact__actions .icon-btn svg { width: 18px; height: 18px; }
.contact__actions .icon-btn.is-call { color: var(--success); }
.contact__actions .icon-btn.is-call:hover { background: rgba(28,200,138,.12); }
.contact__actions .icon-btn.is-edit:hover { background: var(--brand-50); color: var(--brand-500); }
.contact__actions .icon-btn.is-delete:hover { background: rgba(232,62,140,.12); color: var(--danger); }

.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-7) var(--space-5);
  text-align: center;
}
.empty-state__icon {
  width: 72px; height: 72px;
  margin: 0 auto var(--space-3);
  border-radius: 50%;
  background: var(--brand-50); color: var(--brand-500);
  display: grid; place-items: center;
}
.empty-state h3 { margin-bottom: 6px; }
.empty-state p { color: var(--text-muted); margin-bottom: var(--space-4); }

.fab {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + 16px);
  z-index: 35;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-400));
  color: #fff;
  display: grid; place-items: center;
  border: 0;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  text-decoration: none;
  transition: transform var(--transition), filter var(--transition);
}
.fab:hover { color: #fff; filter: brightness(1.06); transform: translateY(-2px); }
.fab:active { transform: translateY(0); }
.fab svg { width: 26px; height: 26px; }

/* ---------- iOS install instructions modal ---------- */
.ios-install-modal {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: end center;
}
.ios-install-modal[hidden] { display: none; }
.ios-install-modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(15,18,38,.55);
  animation: fade-in .2s ease;
}
.ios-install-modal__sheet {
  position: relative;
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-5) var(--space-5) calc(env(safe-area-inset-bottom) + var(--space-5));
  animation: slide-sheet .25s cubic-bezier(.2,.8,.2,1);
}
@media (min-width: 640px) {
  .ios-install-modal { place-items: center; }
  .ios-install-modal__sheet {
    border-radius: var(--radius-lg);
    padding-bottom: var(--space-5);
  }
}
.ios-install-modal__handle {
  width: 40px; height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
  margin: 0 auto var(--space-4);
}
.ios-steps {
  list-style: none;
  padding: 0; margin: 0;
  display: flex; flex-direction: column;
  gap: var(--space-3);
}
.ios-steps li {
  display: flex; gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: .92rem;
}
.ios-steps__num {
  flex: 0 0 28px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--brand-500);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 800; font-size: .85rem;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-sheet { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ---------- Install banner ---------- */
.install-banner {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + 12px);
  transform: translateX(-50%);
  z-index: 80;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: var(--space-3) var(--space-4);
  display: flex; align-items: center; gap: var(--space-3);
  width: min(94vw, 480px);
  animation: slide-up .3s ease;
}
.install-banner__icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--brand-50); color: var(--brand-500);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.install-banner__body { flex: 1; min-width: 0; }
.install-banner__title { font-weight: 700; font-size: .9rem; }
.install-banner__hint { font-size: .78rem; color: var(--text-muted); }

@keyframes slide-up {
  from { opacity: 0; transform: translate(-50%, 16px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Utilities ---------- */
.hide { display: none !important; }
.center { text-align: center; }
.muted  { color: var(--text-muted); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }

/* ---------- Mobile-first responsive overrides ---------- */
html, body { overflow-x: hidden; max-width: 100%; }

/* ===========================================================
   Mobile (≤720px): force card view + anti-overflow guarantees
   =========================================================== */
@media (max-width: 720px) {
  /* The Card/Table toggle is desktop-only — mobile uses cards */
  .view-toggle { display: none !important; }

  /* Hide any "horizontally-scrolling" table on mobile.
     The card-list version is always rendered server-side and used instead. */
  .contact-table,
  .calls-table { display: none !important; }

  /* Make sure the card list is visible regardless of the saved view mode */
  .contact-list,
  .calls-list,
  #callsCardList { display: grid !important; }

  /* Keep all cards/sections within the viewport */
  main, .container,
  .card, .stat,
  .contact, .call-card, .activity, .note, .faq-item,
  .customer-hero, .profile-hero, .credit-card {
    max-width: 100%;
  }

  /* Flex children that hold text MUST allow shrinking; otherwise
     ellipsis fails and the parent grows past 100% width. */
  .stat__body,
  .contact__body,
  .call-body,
  .customer-hero__body,
  .profile-hero__body,
  .drawer__user-info,
  .row-name-line,
  .field-with-add .field { min-width: 0; }

  /* Long words / phone numbers / emails: never let them push the layout */
  .activity__body,
  .note__body,
  .faq-summary__text,
  .faq-body,
  .alert,
  .empty-state p,
  .customer-hero__name,
  .profile-hero__name { word-break: break-word; overflow-wrap: anywhere; }

  /* Stats: on mobile let the value wrap (better than silent ellipsis) */
  .stat__value { white-space: normal; word-break: break-word; line-height: 1.25; }

  /* Toolbar: never overflow */
  .toolbar { flex-wrap: wrap; }
  .toolbar .btn { flex: 0 0 auto; }
  .pager__nav { flex-wrap: wrap; }
}


@media (max-width: 480px) {
  :root { --header-h: 52px; --bottom-nav-h: 64px; }

  /* Page rhythm */
  .container { padding: var(--space-3); }
  h1 { font-size: 1.35rem; }
  h2 { font-size: 1.15rem; }
  h3 { font-size: 1rem; }

  /* Header */
  .app-header { padding-left: var(--space-3); padding-right: var(--space-3); }
  .app-header__title { font-size: .95rem; }
  .app-header__title .logo-mark { width: 26px; height: 26px; font-size: .8rem; }
  .icon-btn { width: 38px; height: 38px; }
  .icon-btn svg { width: 20px; height: 20px; }
  .theme-toggle { padding: 5px 8px; font-size: .72rem; }
  .theme-toggle [data-label] { display: none; }

  /* Cards & sections */
  .card { padding: var(--space-3) var(--space-4); border-radius: var(--radius); }
  .form-section { margin-bottom: var(--space-4); }
  .section-title { margin: var(--space-5) 0 var(--space-2); }

  /* Stat grid: tighter, value smaller */
  .stat-grid { gap: var(--space-2); }
  .stat { padding: var(--space-3); gap: var(--space-2); }
  .stat__icon { flex: 0 0 38px; width: 38px; height: 38px; border-radius: 10px; }
  .stat__icon svg { width: 18px; height: 18px; }
  .stat__label { font-size: .65rem; }
  .stat__value { font-size: .98rem; }

  /* Notes / form grid */
  .notes-grid { gap: var(--space-3); }
  .form-grid  { gap: var(--space-3); }
  .textarea { min-height: 110px; }

  /* Option-row (toggles) */
  .option-row { padding: var(--space-3); gap: var(--space-2); }
  .option-row__icon { width: 34px; height: 34px; border-radius: 9px; }
  .option-row__icon svg { width: 18px; height: 18px; }
  .option-row__label strong { font-size: .9rem; }
  .option-row__label small  { font-size: .72rem; }
  .switch { width: 46px; height: 26px; }
  .switch__slider::before { width: 20px; height: 20px; }
  .switch input:checked + .switch__slider::before { transform: translateX(20px); }

  /* Toolbar / search */
  .toolbar { gap: var(--space-2); }
  .toolbar .btn { padding: .6rem .95rem; font-size: .9rem; min-height: 42px; }
  .search { min-width: 0; width: 100%; }
  .search .input { height: 44px; padding-left: 2.4rem; }
  .search .field-icon { left: 12px; width: 18px; height: 18px; }

  /* Contacts */
  .contact { padding: var(--space-3); gap: var(--space-2); }
  .contact__avatar { width: 42px; height: 42px; font-size: .95rem; border-radius: 12px; }
  .contact__name { font-size: .92rem; }
  .contact__company, .contact__phone { font-size: .78rem; }
  .contact__actions .icon-btn { width: 36px; height: 36px; }
  .contact__actions .icon-btn svg { width: 16px; height: 16px; }
  .contact__badges .badge { font-size: .62rem; padding: 2px 6px; }

  /* Page header (back button + title) */
  .page-head h1 { font-size: 1.2rem; }
  .page-head .muted { font-size: .78rem; }

  /* Apply bar — compact sizing on mobile */
  .apply-bar { margin-top: var(--space-4); padding-bottom: var(--space-2); }
  .apply-bar .btn {
    padding: .8rem 1.4rem;
    min-height: 48px;
    font-size: .95rem;
    width: calc(100% - 16px);
    max-width: 360px;
  }

  /* Buttons */
  .btn-lg { min-height: 48px; padding: .8rem 1.2rem; font-size: .95rem; }

  /* Form actions */
  .form-actions { margin-top: var(--space-4); }

  /* Drawer */
  .drawer { width: 88vw; }
  .drawer__user-name, .drawer__user-mail { max-width: 60vw; }
  .drawer__nav a { padding: .75rem .9rem; font-size: .92rem; }

  /* Auth / login */
  .auth-form { padding: var(--space-5) var(--space-4); }
  .auth-form h2 { font-size: 1.4rem; }
  .auth-form .lead { font-size: .9rem; }

  /* Tenant switch (admin) */
  .tenant-switch { padding: 3px 4px 3px 10px; font-size: .78rem; }
  .tenant-switch select { max-width: 130px; }

  /* FAB sits a touch lower on small screens to clear the bottom-nav comfortably */
  .fab { width: 52px; height: 52px; }
  .fab svg { width: 24px; height: 24px; }

  /* Install banner */
  .install-banner { padding: var(--space-2) var(--space-3); width: calc(100vw - 16px); }
  .install-banner__title { font-size: .82rem; }
  .install-banner__hint  { font-size: .7rem; }
  .install-banner .btn   { padding: .5rem .8rem; font-size: .82rem; min-height: 38px; }
}

/* Very small phones (≤360px: SE, older Androids) */
@media (max-width: 360px) {
  .container { padding: var(--space-2); }
  h1 { font-size: 1.2rem; }
  .stat__value { font-size: .9rem; }
  .stat__label { font-size: .62rem; letter-spacing: .03em; }
  .profile-hero__avatar { width: 50px; height: 50px; font-size: 1.15rem; }
  .profile-hero__name { font-size: .98rem; }
  .ring { --size: 130px; }
  .ring__value { font-size: 1.5rem; }
  .bottom-nav__item { font-size: .62rem; }
  .bottom-nav__item svg { width: 20px; height: 20px; }
  .form-grid .field.is-floating .input { height: 52px; }
}

/* Landscape phones: keep apply-bar usable */
@media (max-height: 480px) and (orientation: landscape) {
  .ring { --size: 110px; }
  .profile-hero { padding: var(--space-3) var(--space-4); }
  .profile-hero__avatar { width: 50px; height: 50px; font-size: 1.2rem; }
}

:focus:not(:focus-visible) { outline: none; }
:focus-visible { outline: 2px solid var(--brand-400); outline-offset: 2px; border-radius: 4px; }
