/* ================================================================
   SD SURVEYOR PLATFORM — Premium Design System v5.0
   Enterprise-grade. Built to impress Maersk.
   ================================================================ */

/* ── DESIGN TOKENS ── */
:root {
  /* Brand */
  --brand-50:  #eff6ff;
  --brand-100: #dbeafe;
  --brand-500: #1a56db;
  --brand-600: #1649c9;
  --brand-700: #1340b0;
  --brand-900: #0d2d6e;

  /* Navy (primary surface) */
  --navy:      #0b1930;
  --navy-light:#112240;
  --navy-mid:  #1a3a6e;

  /* Neutrals */
  --slate-50:  #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  /* Semantic */
  --green:     #059669;
  --green-bg:  #ecfdf5;
  --red:       #dc2626;
  --red-bg:    #fef2f2;
  --amber:     #d97706;
  --amber-bg:  #fffbeb;
  --purple:    #7c3aed;
  --purple-bg: #f5f3ff;

  /* Layout */
  --bg:        #f0f4f8;
  --surface:   #ffffff;
  --border:    #e2e8f0;
  --border-md: #cbd5e1;
  --text:      #0f172a;
  --text-muted:#64748b;
  --text-light:#94a3b8;

  /* Radius */
  --r-sm:  8px;
  --r-md:  12px;
  --r-lg:  16px;
  --r-xl:  20px;
  --r-2xl: 24px;

  /* Shadow */
  --sh-xs:  0 1px 2px rgba(0,0,0,.05);
  --sh-sm:  0 2px 8px rgba(0,0,0,.07);
  --sh-md:  0 4px 16px rgba(0,0,0,.10);
  --sh-lg:  0 8px 32px rgba(0,0,0,.14);
  --sh-xl:  0 16px 48px rgba(0,0,0,.18);

  /* Animation */
  --ease: cubic-bezier(.4,0,.2,1);
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, textarea, select { font-family: inherit; }

/* ── BASE ── */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
  line-height: 1.5;
}
#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ── SCROLL ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 4px; }

/* ================================================================
   LAYOUT & PAGE
   ================================================================ */
.page {
  padding: 20px 16px 120px;
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
}
.page-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px; padding-top: 4px;
}
.page-header h2 {
  font-size: 22px; font-weight: 800; color: var(--navy); flex: 1;
  letter-spacing: -.3px;
}

/* ================================================================
   BOTTOM NAV — Premium
   ================================================================ */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-around; align-items: center;
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  box-shadow: 0 -4px 24px rgba(0,0,0,.08);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  flex: 1; padding: 4px 8px; color: var(--text-muted);
  font-size: 10px; font-weight: 600; letter-spacing: .3px;
  transition: color .2s var(--ease);
  position: relative;
}
.nav-item i { font-size: 19px; transition: transform .2s var(--ease); }
.nav-item.active { color: var(--brand-500); }
.nav-item.active i { transform: translateY(-1px); }
.nav-item.active::before {
  content: '';
  position: absolute; top: -8px; left: 50%; transform: translateX(-50%);
  width: 32px; height: 3px;
  background: var(--brand-500); border-radius: 0 0 4px 4px;
}
.nav-item.nav-add {
  color: white;
}
.nav-item.nav-add .nav-add-circle {
  width: 46px; height: 46px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(26,86,219,.4);
  transition: transform .2s var(--ease), box-shadow .2s;
  margin-bottom: -4px;
}
.nav-item.nav-add:active .nav-add-circle {
  transform: scale(.93); box-shadow: 0 2px 8px rgba(26,86,219,.3);
}
.nav-item.nav-add i { font-size: 20px; color: white; }

/* ================================================================
   CARDS
   ================================================================ */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  padding: 20px;
  margin-bottom: 12px;
  border: 1px solid rgba(226,232,240,.6);
  transition: box-shadow .2s var(--ease);
}
.card:focus-within { box-shadow: var(--sh-md); }
.card-label {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .8px; color: var(--text-muted); margin-bottom: 14px;
  display: flex; align-items: center; gap: 6px;
}
.card-label::before {
  content: ''; display: inline-block;
  width: 3px; height: 12px;
  background: var(--brand-500); border-radius: 2px;
}

/* ================================================================
   HERO — Dashboard Header
   ================================================================ */
.hero {
  background: linear-gradient(135deg, #0b1930 0%, #1a3a6e 60%, #1649c9 100%);
  border-radius: var(--r-xl);
  padding: 28px 22px 24px;
  color: white;
  margin-bottom: 14px;
  position: relative; overflow: hidden;
}
.hero::before {
  content: 'SD';
  position: absolute; right: -10px; top: -10px;
  font-size: 120px; font-weight: 900; color: rgba(255,255,255,.04);
  line-height: 1; letter-spacing: -6px; user-select: none;
}
.hero::after {
  content: '';
  position: absolute; bottom: -40px; right: -40px;
  width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(26,86,219,.3) 0%, transparent 70%);
  border-radius: 50%;
}
.hero-eyebrow {
  font-size: 10px; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase; opacity: .6; margin-bottom: 6px;
}
.hero-title {
  font-size: 28px; font-weight: 900; letter-spacing: -.5px;
  margin-bottom: 4px; line-height: 1.1;
}
.hero-sub   { font-size: 13px; opacity: .75; margin-bottom: 18px; }
.hero-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ================================================================
   ANALYTICS / CRM DASHBOARD
   ================================================================ */
.analytics-tabs {
  display: flex; background: var(--slate-100); border-radius: var(--r-md);
  padding: 4px; gap: 2px; margin-bottom: 14px;
}
.analytics-tab {
  flex: 1; padding: 8px 4px; font-size: 12px; font-weight: 600;
  border-radius: var(--r-sm); color: var(--text-muted);
  transition: all .2s var(--ease); text-align: center;
}
.analytics-tab.active {
  background: white; color: var(--brand-500);
  box-shadow: var(--sh-xs);
}

.kpi-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  margin-bottom: 12px;
}
.kpi-card {
  background: var(--surface); border-radius: var(--r-lg); padding: 18px 16px;
  box-shadow: var(--sh-sm); border: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.kpi-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.kpi-total::before   { background: linear-gradient(90deg, var(--brand-500), #60a5fa); }
.kpi-month::before   { background: linear-gradient(90deg, var(--green), #34d399); }
.kpi-week::before    { background: linear-gradient(90deg, var(--purple), #a78bfa); }
.kpi-today::before   { background: linear-gradient(90deg, var(--amber), #fbbf24); }
.kpi-stuffing::before   { background: linear-gradient(90deg, #0891b2, #22d3ee); }
.kpi-unstuffing::before { background: linear-gradient(90deg, #be185d, #f472b6); }

.kpi-icon {
  width: 36px; height: 36px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; margin-bottom: 10px;
}
.kpi-total .kpi-icon   { background: var(--brand-50); color: var(--brand-500); }
.kpi-month .kpi-icon   { background: var(--green-bg); color: var(--green); }
.kpi-week .kpi-icon    { background: var(--purple-bg); color: var(--purple); }
.kpi-today .kpi-icon   { background: var(--amber-bg); color: var(--amber); }
.kpi-stuffing .kpi-icon   { background: #ecfeff; color: #0891b2; }
.kpi-unstuffing .kpi-icon { background: #fdf2f8; color: #be185d; }

.kpi-val   { font-size: 34px; font-weight: 900; color: var(--navy); line-height: 1; margin-bottom: 2px; }
.kpi-label { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.kpi-delta {
  font-size: 10px; font-weight: 700; margin-top: 4px;
  display: inline-flex; align-items: center; gap: 2px;
  padding: 2px 6px; border-radius: 20px;
}
.kpi-delta.up   { background: var(--green-bg); color: var(--green); }
.kpi-delta.same { background: var(--slate-100); color: var(--slate-500); }

/* Bar chart */
.bar-chart {
  display: flex; align-items: flex-end; gap: 4px;
  height: 80px; padding-top: 8px;
}
.bar-col {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.bar-fill {
  width: 100%; border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, var(--brand-500), var(--brand-700));
  min-height: 4px; transition: height .4s var(--ease);
  position: relative;
}
.bar-fill.current { background: linear-gradient(180deg, #60a5fa, var(--brand-500)); }
.bar-label { font-size: 9px; color: var(--text-muted); font-weight: 600; }

/* Activity feed */
.activity-feed { display: flex; flex-direction: column; gap: 0; }
.activity-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
  position: relative;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; margin-top: 1px;
}
.dot-stuff   { background: #ecfeff; color: #0891b2; }
.dot-unstuff { background: #fdf2f8; color: #be185d; }
.dot-empty   { background: var(--slate-100); color: var(--slate-400); }
.activity-body { flex: 1; min-width: 0; }
.activity-ref  { font-size: 13px; font-weight: 700; color: var(--navy); }
.activity-info { font-size: 11px; color: var(--text-muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-time { font-size: 10px; color: var(--text-light); white-space: nowrap; margin-top: 3px; }
.activity-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ================================================================
   QUICK ACTIONS
   ================================================================ */
.quick-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-bottom: 12px;
}
.qa-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 16px; border-radius: var(--r-lg); border: 1.5px solid var(--border);
  background: white; color: var(--navy); font-size: 13px; font-weight: 700;
  transition: all .2s var(--ease); position: relative; overflow: hidden;
}
.qa-btn::before {
  content: ''; position: absolute; inset: 0;
  background: var(--brand-50); opacity: 0; transition: opacity .2s;
}
.qa-btn:hover { border-color: var(--brand-500); color: var(--brand-500); box-shadow: 0 4px 12px rgba(26,86,219,.12); }
.qa-btn:hover::before { opacity: 1; }
.qa-btn:active { transform: scale(.98); }
.qa-icon {
  width: 40px; height: 40px; border-radius: var(--r-sm); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  background: var(--brand-50); color: var(--brand-500);
  transition: background .2s;
}
.qa-btn:hover .qa-icon { background: var(--brand-500); color: white; }
.qa-btn-full {
  grid-column: 1 / -1;
}

/* ================================================================
   REPORT CARDS (list view)
   ================================================================ */
.rep-card {
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--sh-sm); border: 1px solid var(--border);
  margin-bottom: 10px; overflow: hidden;
  transition: box-shadow .2s var(--ease), transform .15s;
}
.rep-card:active { transform: scale(.995); }
.rep-card-top {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 10px;
}
.rep-type-badge {
  width: 38px; height: 38px; border-radius: var(--r-sm); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.type-stuff   { background: #ecfeff; color: #0891b2; }
.type-unstuff { background: #fdf2f8; color: #be185d; }
.rep-main { flex: 1; min-width: 0; }
.rep-ref   { font-size: 14px; font-weight: 800; color: var(--navy); letter-spacing: -.2px; }
.rep-client{ font-size: 12px; color: var(--text-muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rep-meta {
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px 10px; flex-wrap: wrap;
}
.rep-tag {
  font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 20px;
  display: inline-flex; align-items: center; gap: 4px;
}
.tag-stuff   { background: #ecfeff; color: #0891b2; }
.tag-unstuff { background: #fdf2f8; color: #be185d; }
.tag-date    { background: var(--slate-100); color: var(--slate-600); }
.tag-container { background: var(--brand-50); color: var(--brand-600); }
.rep-actions {
  border-top: 1px solid var(--border);
  display: flex; align-items: center;
}
.rep-action-btn {
  flex: 1; padding: 10px 4px; font-size: 11px; font-weight: 600;
  color: var(--text-muted); display: flex; flex-direction: column;
  align-items: center; gap: 3px; transition: all .15s;
  border-right: 1px solid var(--border);
}
.rep-action-btn:last-child { border-right: none; }
.rep-action-btn i { font-size: 15px; }
.rep-action-btn:hover { background: var(--slate-50); color: var(--brand-500); }
.rep-action-btn.btn-del:hover { color: var(--red); background: var(--red-bg); }

/* ================================================================
   SEARCH BAR
   ================================================================ */
.search-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-lg); padding: 10px 14px;
  margin-bottom: 14px; box-shadow: var(--sh-xs);
  transition: border-color .2s, box-shadow .2s;
}
.search-bar:focus-within {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(26,86,219,.08);
}
.search-bar i { color: var(--text-muted); font-size: 15px; flex-shrink: 0; }
.search-bar input {
  flex: 1; border: none; outline: none; font-size: 14px;
  background: none; color: var(--text);
}
.search-bar input::placeholder { color: var(--text-light); }

/* ================================================================
   FORM FIELDS
   ================================================================ */
.field-group { margin-bottom: 14px; }
.field-group:last-child { margin-bottom: 0; }
label {
  display: block; font-size: 11px; font-weight: 700; color: var(--slate-600);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px;
}
.field {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--border); border-radius: var(--r-sm);
  font-size: 14px; color: var(--text); background: var(--surface);
  transition: border-color .2s, box-shadow .2s; outline: none;
  -webkit-appearance: none;
}
.field:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(26,86,219,.08);
}
.field:disabled { background: var(--slate-50); color: var(--text-muted); }
textarea.field { resize: vertical; min-height: 80px; }
.field-hint { font-size: 10px; color: var(--text-muted); font-weight: 400; margin-left: 4px; text-transform: none; letter-spacing: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ================================================================
   CHIPS
   ================================================================ */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
  padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 600;
  border: 1.5px solid var(--border); background: white; color: var(--text-muted);
  cursor: pointer; transition: all .15s var(--ease);
}
.chip-active {
  background: var(--brand-500); border-color: var(--brand-500); color: white;
  box-shadow: 0 2px 8px rgba(26,86,219,.3);
}

/* ================================================================
   BUTTONS
   ================================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 18px; border-radius: var(--r-md); font-size: 13px; font-weight: 700;
  transition: all .2s var(--ease); cursor: pointer; border: none;
  letter-spacing: .1px; white-space: nowrap; position: relative; overflow: hidden;
}
.btn::after {
  content: ''; position: absolute; inset: 0;
  background: white; opacity: 0; transition: opacity .15s;
}
.btn:active::after { opacity: .12; }
.btn:active { transform: scale(.97); }

.btn-primary   { background: linear-gradient(135deg, var(--brand-500), var(--brand-700)); color: white; box-shadow: 0 2px 10px rgba(26,86,219,.3); }
.btn-primary:hover { box-shadow: 0 4px 18px rgba(26,86,219,.45); transform: translateY(-1px); }
.btn-success   { background: linear-gradient(135deg, #059669, #047857); color: white; box-shadow: 0 2px 10px rgba(5,150,105,.3); }
.btn-success:hover { box-shadow: 0 4px 18px rgba(5,150,105,.45); transform: translateY(-1px); }
.btn-danger    { background: linear-gradient(135deg, #dc2626, #b91c1c); color: white; }
.btn-outline   { background: white; border: 1.5px solid var(--border); color: var(--text); box-shadow: var(--sh-xs); }
.btn-outline:hover { border-color: var(--brand-500); color: var(--brand-500); box-shadow: var(--sh-sm); }
.btn-ghost     { background: rgba(255,255,255,.12); color: white; border: 1px solid rgba(255,255,255,.2); }
.btn-ghost:hover { background: rgba(255,255,255,.2); }
.btn-sm  { padding: 6px 12px; font-size: 12px; border-radius: var(--r-sm); }
.btn-lg  { padding: 14px 24px; font-size: 15px; }
.btn-full { width: 100%; justify-content: center; }

.btn-save-pulse {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: white; box-shadow: 0 2px 10px rgba(26,86,219,.3);
}
.btn-save-pulse.saved {
  background: linear-gradient(135deg, #059669, #047857);
  box-shadow: 0 2px 10px rgba(5,150,105,.3);
}

/* ================================================================
   STICKY FORM ACTION BAR
   ================================================================ */
.form-action-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  padding: 10px 16px max(10px, env(safe-area-inset-bottom));
  box-shadow: 0 -4px 20px rgba(0,0,0,.10);
}
.form-action-inner {
  max-width: 680px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px;
  align-items: center;
}
.fab-save {
  padding: 12px 20px; border-radius: var(--r-md); font-size: 14px; font-weight: 800;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: white; box-shadow: 0 2px 12px rgba(26,86,219,.35);
  transition: all .2s var(--ease); display: flex; align-items: center; gap: 8px;
}
.fab-save:hover { box-shadow: 0 6px 20px rgba(26,86,219,.45); transform: translateY(-1px); }
.fab-save.saved { background: linear-gradient(135deg, #059669, #047857); box-shadow: 0 2px 12px rgba(5,150,105,.3); }

.fab-icon-btn {
  width: 44px; height: 44px; border-radius: var(--r-md); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  border: 1.5px solid var(--border); background: white; color: var(--text-muted);
  transition: all .15s var(--ease); box-shadow: var(--sh-xs);
}
.fab-icon-btn:hover { border-color: var(--brand-500); color: var(--brand-500); background: var(--brand-50); box-shadow: 0 2px 10px rgba(26,86,219,.12); }
.fab-icon-btn.fab-share:hover  { border-color: #25D366; color: #25D366; background: #f0fdf4; }
.fab-icon-btn.fab-email:hover  { border-color: var(--brand-500); color: var(--brand-500); }
.fab-icon-btn.fab-pdf:hover    { border-color: var(--red); color: var(--red); background: var(--red-bg); }

/* ================================================================
   PROGRESS BAR
   ================================================================ */
.progress-bar  { height: 6px; background: var(--slate-200); border-radius: 4px; overflow: hidden; margin: 10px 0 6px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--brand-500), #60a5fa); border-radius: 4px; transition: width .6s var(--ease); }
.progress-label{ font-size: 12px; color: var(--text-muted); font-weight: 600; }

/* ================================================================
   BADGES & TAGS
   ================================================================ */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 24px; padding: 0 8px;
  background: var(--brand-500); color: white;
  border-radius: 20px; font-size: 11px; font-weight: 800;
}

/* ================================================================
   MODALS
   ================================================================ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(11,25,48,.7);
  display: flex; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  animation: fadeIn .2s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
  background: var(--surface); border-radius: var(--r-2xl) var(--r-2xl) 0 0;
  width: 100%; max-width: 520px; padding: 20px 20px max(20px, env(safe-area-inset-bottom));
  max-height: 90vh; overflow-y: auto;
  animation: slideUp .25s var(--ease);
}
@keyframes slideUp { from { transform: translateY(40px); opacity: .5; } to { transform: translateY(0); opacity: 1; } }
.modal-handle {
  width: 40px; height: 4px; background: var(--slate-200);
  border-radius: 4px; margin: 0 auto 16px; display: block;
}
.modal-header {
  display: flex; align-items: center; margin-bottom: 16px;
}
.modal-header h3 {
  font-size: 17px; font-weight: 800; color: var(--navy); flex: 1; letter-spacing: -.2px;
}
.modal-close {
  width: 32px; height: 32px; border-radius: 50%; background: var(--slate-100);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--text-muted); transition: background .15s;
}
.modal-close:hover { background: var(--slate-200); color: var(--text); }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }

/* ================================================================
   SHARE MODAL
   ================================================================ */
.share-ref-info {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 14px; padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.share-ref-badge {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: white; font-size: 11px; font-weight: 800;
  padding: 4px 10px; border-radius: 20px; letter-spacing: .3px;
}
.share-client-name { font-size: 13px; font-weight: 700; color: var(--navy); }
.share-date-label  { font-size: 11px; color: var(--text-muted); margin-left: auto; }

.share-link-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--slate-50); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 10px 12px; margin-bottom: 18px;
}
.share-link-text {
  flex: 1; font-size: 11px; color: var(--text-muted);
  word-break: break-all; line-height: 1.4; font-family: monospace;
}
.share-copy-btn {
  flex-shrink: 0; padding: 6px 14px; font-size: 12px; font-weight: 700;
  background: var(--brand-500); color: white;
  border: none; border-radius: var(--r-sm); cursor: pointer;
  transition: all .15s;
}
.share-copy-btn:hover { background: var(--brand-600); }

.share-section-label {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .8px; color: var(--text-muted); margin-bottom: 10px;
}
.share-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
@media (max-width: 380px) { .share-grid { grid-template-columns: repeat(3, 1fr); } }
.share-tile {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 12px 4px; border-radius: var(--r-md); border: 1.5px solid var(--border);
  font-size: 10px; font-weight: 700; cursor: pointer; text-decoration: none;
  background: white; color: var(--text-muted);
  transition: all .15s var(--ease); letter-spacing: .2px;
}
.share-tile i { font-size: 20px; }
.share-tile:hover { transform: translateY(-2px); box-shadow: var(--sh-md); }
.share-tile:active { transform: scale(.95); }
.share-whatsapp  { color: #25D366; border-color: rgba(37,211,102,.25); }
.share-whatsapp:hover  { background: #25D366; color: white; border-color: #25D366; }
.share-telegram  { color: #0088cc; border-color: rgba(0,136,204,.25); }
.share-telegram:hover  { background: #0088cc; color: white; border-color: #0088cc; }
.share-email     { color: var(--navy); border-color: var(--border); }
.share-email:hover     { background: var(--navy); color: white; }
.share-gmail     { color: #EA4335; border-color: rgba(234,67,53,.25); }
.share-gmail:hover     { background: #EA4335; color: white; border-color: #EA4335; }
.share-outlook   { color: #0072C6; border-color: rgba(0,114,198,.25); }
.share-outlook:hover   { background: #0072C6; color: white; border-color: #0072C6; }
.share-pdf       { color: var(--red); border-color: rgba(220,38,38,.25); }
.share-pdf:hover       { background: var(--red); color: white; border-color: var(--red); }
.share-native    { color: var(--slate-500); border-color: var(--border); }
.share-native:hover    { background: var(--slate-700); color: white; }
.share-preview   { color: var(--brand-500); border-color: rgba(26,86,219,.25); }
.share-preview:hover   { background: var(--brand-500); color: white; border-color: var(--brand-500); }

/* ================================================================
   AUTOCOMPLETE
   ================================================================ */
.autocomplete-wrap { position: relative; }
.party-dropdown {
  display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 300;
  background: var(--surface); border: 1.5px solid var(--brand-500);
  border-top: none; border-radius: 0 0 var(--r-md) var(--r-md);
  box-shadow: var(--sh-lg); max-height: 260px; overflow-y: auto;
}
.party-option {
  padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 1px;
  transition: background .1s;
}
.party-option:last-child { border-bottom: none; }
.party-option:hover { background: var(--brand-50); }
.party-opt-name  { font-size: 13px; font-weight: 700; color: var(--navy); }
.party-opt-email { font-size: 11px; color: var(--text-muted); }

/* ================================================================
   SIGNATURES
   ================================================================ */
.sig-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sig-box {
  border: 1.5px dashed var(--border); border-radius: var(--r-md);
  overflow: hidden; background: var(--slate-50);
  transition: border-color .2s;
}
.sig-box:focus-within { border-color: var(--brand-500); }
.sig-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-muted); padding: 8px 10px 0; display: block;
}
.sig-canvas { display: block; touch-action: none; width: 100%; height: 100px; }
.sig-actions { display: flex; gap: 6px; padding: 6px; }
.sig-btn {
  flex: 1; padding: 5px; font-size: 11px; font-weight: 600;
  border-radius: var(--r-sm); border: 1px solid var(--border);
  background: white; color: var(--text-muted); transition: all .15s;
}
.sig-btn:hover { border-color: var(--brand-500); color: var(--brand-500); }

/* ================================================================
   PHOTO UPLOAD
   ================================================================ */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.photo-thumb {
  aspect-ratio: 4/3; border-radius: var(--r-sm); overflow: hidden;
  position: relative; background: var(--slate-100);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-del {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,.6); color: white;
  display: flex; align-items: center; justify-content: center; font-size: 10px;
}
.photo-add {
  aspect-ratio: 4/3; border-radius: var(--r-sm);
  border: 2px dashed var(--border); background: var(--slate-50);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; cursor: pointer; color: var(--text-muted); font-size: 11px; font-weight: 600;
  transition: all .15s;
}
.photo-add:hover { border-color: var(--brand-500); color: var(--brand-500); background: var(--brand-50); }
.photo-add i { font-size: 22px; }

/* ================================================================
   LOGIN PAGE
   ================================================================ */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #0b1930 0%, #1a3a6e 50%, #0b1930 100%);
  padding: 20px; position: relative; overflow: hidden;
}
.login-page::before {
  content: ''; position: absolute; top: -100px; right: -100px;
  width: 400px; height: 400px; border-radius: 50%;
  background: radial-gradient(circle, rgba(26,86,219,.2) 0%, transparent 70%);
}
.login-page::after {
  content: ''; position: absolute; bottom: -80px; left: -80px;
  width: 300px; height: 300px; border-radius: 50%;
  background: radial-gradient(circle, rgba(96,165,250,.15) 0%, transparent 70%);
}
.login-card {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--r-2xl);
  padding: 40px 32px;
  width: 100%; max-width: 360px;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 32px 80px rgba(0,0,0,.4);
  z-index: 1; position: relative;
}
.login-logo { text-align: center; margin-bottom: 36px; }
.logo-mark {
  width: 64px; height: 64px; border-radius: 18px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: white; font-size: 22px; font-weight: 900; letter-spacing: -1px;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 32px rgba(26,86,219,.4);
  margin-bottom: 14px;
}
.login-logo h1 { font-size: 22px; font-weight: 900; color: white; letter-spacing: -.4px; }
.login-logo p  { font-size: 12px; color: rgba(255,255,255,.5); margin-top: 4px; }

.pin-dots {
  display: flex; justify-content: center; gap: 14px; margin-bottom: 8px;
}
.dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.3); background: transparent;
  transition: all .2s var(--ease);
}
.dot.filled {
  background: var(--brand-500); border-color: var(--brand-500);
  box-shadow: 0 0 12px rgba(26,86,219,.5);
  transform: scale(1.1);
}
.pin-error { height: 20px; text-align: center; font-size: 12px; color: #fca5a5; margin-bottom: 8px; font-weight: 600; }

.pin-pad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.pin-btn {
  aspect-ratio: 1; border-radius: var(--r-lg);
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
  color: white; font-size: 20px; font-weight: 700; display: flex;
  align-items: center; justify-content: center;
  transition: all .15s var(--ease);
}
.pin-btn:not(.pin-btn-empty):hover { background: rgba(255,255,255,.16); transform: scale(1.03); }
.pin-btn:not(.pin-btn-empty):active { background: var(--brand-500); border-color: var(--brand-500); transform: scale(.96); }
.pin-btn-empty { cursor: default; background: transparent; border-color: transparent; }

/* ================================================================
   SETTINGS PAGE
   ================================================================ */
.settings-section {
  margin-bottom: 20px;
}
.setting-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-icon {
  width: 36px; height: 36px; border-radius: var(--r-sm); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.setting-body { flex: 1; }
.setting-label { font-size: 13px; font-weight: 700; color: var(--navy); }
.setting-desc  { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.setting-action { flex-shrink: 0; }

/* Toggle switch */
.toggle {
  width: 46px; height: 26px; border-radius: 13px;
  background: var(--slate-200); position: relative; cursor: pointer;
  transition: background .2s;
}
.toggle.on { background: var(--brand-500); }
.toggle::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: white; box-shadow: var(--sh-sm);
  transition: transform .2s var(--ease);
}
.toggle.on::after { transform: translateX(20px); }

/* API Key cards */
.api-key-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.api-key-item:last-child { border-bottom: none; }
.api-key-mono {
  flex: 1; font-family: monospace; font-size: 12px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.api-key-label { font-size: 13px; font-weight: 700; color: var(--navy); }
.api-key-date  { font-size: 10px; color: var(--text-light); margin-top: 1px; }

/* ================================================================
   EMPTY / ERROR STATES
   ================================================================ */
.empty-state {
  text-align: center; padding: 60px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.empty-state i { font-size: 48px; color: var(--slate-300); }
.empty-state p { font-size: 14px; color: var(--text-muted); font-weight: 500; }
.empty-state .empty-sub { font-size: 12px; color: var(--text-light); }
.error-page { text-align: center; padding: 60px 20px; color: var(--text-muted); }

/* ================================================================
   TOAST NOTIFICATIONS
   ================================================================ */
.toast-container {
  position: fixed; top: 16px; right: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--r-md);
  font-size: 13px; font-weight: 600; color: white;
  box-shadow: var(--sh-lg); pointer-events: all; max-width: 320px;
  animation: toastIn .3s var(--ease);
}
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast-success { background: linear-gradient(135deg, #059669, #047857); }
.toast-warning { background: linear-gradient(135deg, #d97706, #b45309); }
.toast-error   { background: linear-gradient(135deg, #dc2626, #b91c1c); }
.toast-info    { background: linear-gradient(135deg, var(--brand-500), var(--brand-700)); }
.toast i { font-size: 16px; }

/* ================================================================
   SHARE PAGE (public read-only)
   ================================================================ */
.share-page   { max-width: 640px; margin: 0 auto; padding: 20px 16px 40px; }
.share-header { text-align: center; padding: 32px 0 20px; }
.share-header .logo-mark { margin: 0 auto 14px; }
.share-header h1 { font-size: 22px; font-weight: 900; color: var(--navy); }
.share-header p  { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.share-footer    { text-align: center; font-size: 11px; color: var(--text-light); margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ================================================================
   HELPERS
   ================================================================ */
.text-muted  { color: var(--text-muted); }
.text-small  { font-size: 12px; }
.divider     { height: 1px; background: var(--border); margin: 14px 0; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }

/* ================================================================
   SECTION BREAK (form)
   ================================================================ */
.section-rule {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-muted); font-size: 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .8px;
  margin: 20px 0 6px;
}
.section-rule::before, .section-rule::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 420px) {
  .kpi-grid        { grid-template-columns: 1fr 1fr; }
  .field-row       { grid-template-columns: 1fr; }
  .sig-row         { grid-template-columns: 1fr; }
  .form-action-inner { grid-template-columns: 1fr auto auto auto; }
}
@media (min-width: 640px) {
  .page { padding-left: 24px; padding-right: 24px; }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .quick-actions { grid-template-columns: repeat(4, 1fr); }
  .qa-btn-full { grid-column: auto; }
}

/* ── TYPE TOGGLE ── */
.type-toggle {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.type-btn {
  padding: 12px 8px; border-radius: var(--r-md); font-size: 13px; font-weight: 700;
  border: 2px solid var(--border); background: white; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all .2s var(--ease);
}
.type-btn i { font-size: 16px; }
.type-btn.active {
  border-color: var(--brand-500); background: var(--brand-50); color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(26,86,219,.1);
}

/* ── TOAST (old style override) ── */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(80px);
  opacity: 0; transition: all .3s var(--ease);
  white-space: nowrap; z-index: 9999;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ── MODAL SHOW ── */
.modal-overlay { display: none; }
.modal-overlay.show { display: flex; }

/* ── SIGNATURE PANELS ── */
.sig-panel {
  border: 1.5px dashed var(--border); border-radius: var(--r-md);
  overflow: hidden; background: var(--slate-50);
}
.sig-panel .sig-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-muted); padding: 8px 10px 4px; display: block;
}
.sig-canvas { display: block; touch-action: none; width: 100%; }
.btn-xs { padding: 4px 10px; font-size: 11px; border-radius: var(--r-sm); }

/* ── SETTINGS ICON COLORS ── */
.icon-blue   { background: var(--brand-50); color: var(--brand-500); }
.icon-green  { background: var(--green-bg); color: var(--green); }
.icon-amber  { background: var(--amber-bg); color: var(--amber); }
.icon-red    { background: var(--red-bg); color: var(--red); }
.icon-purple { background: var(--purple-bg); color: var(--purple); }

/* ── DETAIL GRID (share view) ── */
.detail-grid {
  display: grid; grid-template-columns: 1fr 2fr; gap: 8px 12px;
  font-size: 13px;
}
.detail-grid span:nth-child(odd) { color: var(--text-muted); font-weight: 600; font-size: 12px; }
.detail-grid span:nth-child(even) { color: var(--navy); font-weight: 500; }
