@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; }

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --dark: #0f172a;
  --dark-2: #1e293b;
  --dark-3: #334155;
  --muted: #64748b;
  --border: #e2e8f0;
  --bg: #f1f5f9;
  --white: #ffffff;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px -1px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.04);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--dark);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

/* ══ TOP NAV ══ */
.top-nav {
  background: var(--dark);
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(255,255,255,.06);
}
.nav-brand {
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  text-decoration: none;
  letter-spacing: -.01em;
}
.nav-brand:hover { color: #93c5fd; }
.nav-dot {
  width: 8px; height: 8px;
  background: var(--primary);
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.nav-right { display: flex; align-items: center; gap: 1.25rem; }
.nav-user-info { color: #94a3b8; font-size: .82rem; display: flex; align-items: center; gap: .5rem; }
.nav-user-info span { color: #cbd5e1; font-weight: 500; }
.btn-nav-logout {
  background: transparent;
  border: 1px solid #334155;
  color: #94a3b8;
  border-radius: 6px;
  padding: .35rem .8rem;
  font-size: .8rem;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
  font-family: inherit;
  font-weight: 500;
}
.btn-nav-logout:hover { border-color: #64748b; color: #fff; background: #1e293b; }

/* ══ PAGE ══ */
.page { padding: 1.75rem 1.5rem; max-width: 1400px; margin: 0 auto; }

/* ══ STATS GRID ══ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.75rem;
}
@media (max-width: 960px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .stats-grid { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: .9rem;
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.si-blue   { background: #dbeafe; }
.si-green  { background: #dcfce7; }
.si-violet { background: #ede9fe; }
.si-amber  { background: #fef3c7; }
.stat-value { font-size: 1.65rem; font-weight: 700; color: var(--dark); line-height: 1.1; }
.stat-label { font-size: .73rem; color: var(--muted); font-weight: 500; margin-top: .15rem; }

/* ══ DATA CARD ══ */
.data-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  overflow: hidden;
}
.data-card-header {
  padding: .9rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
  gap: 1rem;
  flex-wrap: wrap;
}
.data-card-title {
  font-weight: 600;
  font-size: .9rem;
  color: var(--dark);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.count-badge {
  background: #e2e8f0;
  color: #475569;
  font-size: .7rem;
  font-weight: 700;
  border-radius: 100px;
  padding: .15em .65em;
}
.data-card-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ══ TABLE ══ */
.data-table { width: 100%; border-collapse: collapse; font-size: .855rem; }
.data-table th {
  background: #f8fafc;
  color: var(--muted);
  text-transform: uppercase;
  font-size: .68rem;
  letter-spacing: .06em;
  font-weight: 600;
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-align: left;
}
.data-table td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafbfc; }
.empty-state { text-align: center; color: var(--muted); padding: 3rem 1rem !important; font-size: .875rem; }

/* ══ COMPANY CELL ══ */
.co-cell { display: flex; align-items: center; gap: .6rem; }
.avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: white;
  font-size: .72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}
.avatar-admin { background: linear-gradient(135deg, #1e293b, #475569); }
.co-name { font-weight: 500; color: var(--dark); line-height: 1.3; }
.co-email { font-size: .75rem; color: var(--muted); }

/* ══ BADGES ══ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .72rem;
  font-weight: 600;
  padding: .3em .7em;
  border-radius: 100px;
  white-space: nowrap;
}
.badge-admin-role  { background: #1e293b; color: #e2e8f0; }
.badge-client-role { background: #dbeafe; color: #1e40af; }
.badge-ok      { background: #dcfce7; color: #15803d; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-na      { background: #f1f5f9; color: #94a3b8; }

/* ══ SCORE PILL ══ */
.score-pill {
  display: inline-block;
  font-weight: 700;
  font-size: .78rem;
  padding: .25em .75em;
  border-radius: 100px;
  min-width: 42px;
  text-align: center;
}
.sp-high   { background: #dcfce7; color: #15803d; }
.sp-medium { background: #fef3c7; color: #92400e; }
.sp-low    { background: #fee2e2; color: #991b1b; }

/* ══ ACTION BUTTONS ══ */
.btn-act {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .3rem .65rem;
  font-size: .77rem;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
  font-family: inherit;
  background: white;
}
.btn-act:disabled { opacity: .4; cursor: not-allowed; }
.btn-edit   { border-color: #bfdbfe; color: #1d4ed8; }
.btn-edit:hover   { background: #eff6ff; }
.btn-del    { border-color: #fecaca; color: #991b1b; }
.btn-del:hover    { background: #fef2f2; }
.btn-report { border-color: #bbf7d0; color: #15803d; }
.btn-report:hover { background: #f0fdf4; }
.btn-view   { border-color: #ddd6fe; color: #5b21b6; }
.btn-view:hover   { background: #f5f3ff; }

/* ══ PRIMARY BUTTONS ══ */
.btn-primary-app {
  background: var(--primary);
  color: #fff !important;
  border: none;
  border-radius: 8px;
  padding: .5rem 1rem;
  font-size: .855rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  transition: background .15s;
  font-family: inherit;
  white-space: nowrap;
}
.btn-primary-app:hover { background: var(--primary-hover); }
.btn-dark-app {
  background: var(--dark-2);
  color: #fff !important;
  border: none;
  border-radius: 8px;
  padding: .5rem 1rem;
  font-size: .855rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  transition: background .15s;
  font-family: inherit;
  white-space: nowrap;
}
.btn-dark-app:hover { background: var(--dark-3); }

/* ══ FLASH ══ */
.flash-msg {
  padding: .85rem 1.1rem;
  border-radius: 8px;
  font-size: .875rem;
  margin-bottom: 1.25rem;
  border: 1px solid;
}
.flash-success { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.flash-danger  { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.flash-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.flash-info    { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

/* ══ MODAL ══ */
.modal .modal-content {
  border: none;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
.modal .modal-header {
  border-bottom: 1px solid var(--border);
  padding: 1.1rem 1.25rem;
}
.modal .modal-footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.25rem;
}
.modal .modal-title { font-weight: 600; font-size: .95rem; }
.modal .form-label { font-size: .8rem; font-weight: 600; color: var(--dark-3); }

/* ══ AUTH LAYOUT ══ */
.auth-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 380px 1fr;
}
@media (max-width: 768px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-brand-panel { display: none; }
}
.auth-brand-panel {
  background: linear-gradient(160deg, #0f172a 0%, #1e3a6e 55%, #1e40af 100%);
  display: flex;
  flex-direction: column;
  padding: 2.5rem;
  justify-content: center;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.auth-brand-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.auth-logo {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -.02em;
  margin-bottom: .35rem;
  position: relative;
}
.auth-logo-dot {
  display: inline-block;
  width: 9px; height: 9px;
  background: #60a5fa;
  border-radius: 50%;
  margin-left: 2px;
  vertical-align: top;
  margin-top: 4px;
}
.auth-tagline { color: #93c5fd; font-size: .875rem; margin-bottom: 2.5rem; position: relative; }
.auth-feature {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  margin-bottom: 1.25rem;
  position: relative;
}
.auth-feature-icon {
  width: 36px; height: 36px;
  background: rgba(255,255,255,.1);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.auth-feature-text strong { display: block; font-size: .875rem; margin-bottom: .1rem; }
.auth-feature-text small { font-size: .775rem; color: #93c5fd; }

.auth-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: white;
}
.auth-form-inner { width: 100%; max-width: 400px; }
.auth-title { font-size: 1.55rem; font-weight: 700; color: var(--dark); letter-spacing: -.02em; margin-bottom: .35rem; }
.auth-sub { color: var(--muted); font-size: .875rem; margin-bottom: 2rem; }

.field-group { margin-bottom: .9rem; }
.field-label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--dark-3);
  margin-bottom: .35rem;
  letter-spacing: .01em;
}
.field-input {
  width: 100%;
  padding: .6rem .9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .9rem;
  color: var(--dark);
  background: white;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
  outline: none;
  -webkit-appearance: none;
}
.field-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.field-input::placeholder { color: #94a3b8; }

.captcha-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .6rem .9rem;
}
.captcha-q { font-weight: 600; font-size: .9rem; white-space: nowrap; flex-shrink: 0; }
.captcha-sep { color: var(--muted); }
.captcha-input {
  width: 70px;
  padding: .4rem .6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .9rem;
  text-align: center;
  font-family: inherit;
  outline: none;
}
.captcha-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

.btn-auth {
  width: 100%;
  padding: .7rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  font-family: inherit;
  margin-top: .75rem;
}
.btn-auth:hover { background: var(--primary-hover); }
.auth-footer { text-align: center; margin-top: 1.25rem; font-size: .855rem; color: var(--muted); }
.auth-footer a { color: var(--primary); text-decoration: none; font-weight: 500; }
.auth-footer a:hover { text-decoration: underline; }

.hp-field { position: absolute; left: -9999px; top: -9999px; }

/* ══ FORM PAGE ══ */
.form-page { min-height: 100vh; background: var(--bg); }
.form-page-content { max-width: 540px; margin: 0 auto; padding: 2rem 1.25rem; }
.form-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.form-card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fafbfc;
}
.form-card-title { font-weight: 600; font-size: .95rem; color: var(--dark); }
.form-card-body { padding: 1.5rem; }
.form-field { margin-bottom: 1rem; }
.form-field label { display: block; font-size: .8rem; font-weight: 600; color: var(--dark-3); margin-bottom: .35rem; }
.form-field input {
  width: 100%;
  padding: .6rem .9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .9rem;
  color: var(--dark);
  background: white;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.form-field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-field small { display: block; font-size: .75rem; color: var(--muted); margin-top: .3rem; }
.form-actions { display: flex; gap: .6rem; margin-top: 1.25rem; }
.btn-save {
  flex: 1;
  padding: .6rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}
.btn-save:hover { background: var(--primary-hover); }
.btn-cancel {
  flex: 1;
  padding: .6rem;
  background: white;
  color: var(--dark-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  transition: background .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-cancel:hover { background: #f8fafc; color: var(--dark); }

/* ══ USER DASHBOARD ══ */
.user-page { background: var(--bg); min-height: 100vh; }
.user-nav {
  background: var(--dark);
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.user-hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a6e 60%, #2563eb 100%);
  padding: 1.75rem;
  color: white;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  position: relative;
  overflow: hidden;
}
.user-hero::before {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 120px; height: 120px;
  background: rgba(255,255,255,.04);
  border-radius: 50%;
}
.user-hero h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: .25rem; position: relative; }
.user-hero p  { color: #93c5fd; font-size: .875rem; margin: 0; position: relative; }
.user-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-bottom: 1.25rem; }
@media (max-width: 700px) { .user-grid { grid-template-columns: 1fr; } }
.info-card { background: white; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.info-card-hd {
  padding: .85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: .875rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fafbfc;
}
.info-card-bd { padding: 1.25rem; }
.info-row { margin-bottom: .85rem; }
.info-row:last-child { margin-bottom: 0; }
.info-lbl { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin-bottom: .2rem; }
.info-val { font-size: .9rem; color: var(--dark); font-weight: 500; }
.report-card { background: white; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.report-empty { text-align: center; padding: 3rem; color: var(--muted); }
.report-empty-icon { font-size: 3rem; opacity: .25; display: block; margin-bottom: 1rem; }
.gbp-status-connected { display: flex; align-items: flex-start; gap: .75rem; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }
.gbp-status-disconnected { display: flex; align-items: flex-start; gap: .75rem; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }
.gbp-icon { font-size: 1.5rem; line-height: 1; flex-shrink: 0; }
.gbp-status-text strong { display: block; font-size: .9rem; font-weight: 600; margin-bottom: .15rem; }
.gbp-status-text small { color: var(--muted); font-size: .8rem; }
.btn-gbp-connect {
  display: block;
  width: 100%;
  padding: .65rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  font-family: inherit;
  transition: background .15s;
}
.btn-gbp-connect:hover { background: var(--primary-hover); color: white; }
.btn-gbp-reconnect {
  display: block;
  width: 100%;
  padding: .55rem;
  background: white;
  color: var(--dark-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .855rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  font-family: inherit;
  transition: all .15s;
}
.btn-gbp-reconnect:hover { background: #f8fafc; color: var(--dark); }
.btn-view-report {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .7rem 1.5rem;
  background: var(--success);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s;
}
.btn-view-report:hover { background: #15803d; color: white; }
.score-bar { height: 6px; background: #e2e8f0; border-radius: 100px; overflow: hidden; margin-top: .3rem; }
.score-bar-fill { height: 100%; border-radius: 100px; transition: width .3s; }
.score-section { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-top: 1rem; }
@media (max-width: 500px) { .score-section { grid-template-columns: 1fr; } }
.score-item { background: #f8fafc; border-radius: 8px; padding: .75rem; }
.score-item-label { font-size: .72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .35rem; }
.score-item-val { font-size: 1.15rem; font-weight: 700; color: var(--dark); }
