/* MSP Portal styles — same tokens as theme.css */
:root {
  --bg: #faf8f4;
  --fg: #1a1a18;
  --accent: #1a4d2e;
  --accent-light: #e8f0ea;
  --amber: #e8a838;
  --amber-light: #fdf3e3;
  --muted: #6b6b63;
  --border: #e2e0d8;
  --card-bg: #ffffff;
  --danger: #c0392b;
  --danger-light: #fdecea;
  --success: #27ae60;
  --success-light: #e8f8ef;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--fg); font-family: 'Instrument Sans', system-ui, sans-serif; font-size: 16px; -webkit-font-smoothing: antialiased; }

/* Auth pages — centered card */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg); }
.auth-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 16px; padding: 48px; width: 100%; max-width: 480px; }
.auth-logo { font-family: 'Instrument Serif', serif; font-size: 24px; color: var(--accent); text-decoration: none; display: block; margin-bottom: 32px; }
.auth-title { font-size: 24px; font-weight: 600; margin-bottom: 8px; }
.auth-subtitle { color: var(--muted); font-size: 14px; margin-bottom: 32px; }
.auth-link { color: var(--accent); text-decoration: none; font-weight: 500; }
.auth-link:hover { text-decoration: underline; }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.form-input { width: 100%; padding: 12px 16px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 16px; font-family: inherit; background: var(--bg); transition: border-color 0.2s; }
.form-input:focus { outline: none; border-color: var(--accent); background: var(--card-bg); }
.form-select { width: 100%; padding: 12px 16px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 16px; font-family: inherit; background: var(--bg); }
.form-error { background: var(--danger-light); color: var(--danger); padding: 12px 16px; border-radius: 8px; font-size: 14px; margin-bottom: 20px; }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 12px 24px; border-radius: 8px; font-size: 15px; font-weight: 600; font-family: inherit; cursor: pointer; text-decoration: none; transition: all 0.2s; border: none; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: #163d24; }
.btn-secondary { background: var(--accent-light); color: var(--accent); }
.btn-secondary:hover { background: #d4e6da; }
.btn-danger { background: var(--danger); color: white; }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 8px 16px; font-size: 13px; }

/* Portal layout */
.msp-layout { display: flex; min-height: 100vh; }
.msp-sidebar { width: 260px; background: var(--card-bg); border-right: 1px solid var(--border); padding: 0; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.msp-main { flex: 1; min-width: 0; }
.msp-topbar { background: var(--card-bg); border-bottom: 1px solid var(--border); padding: 20px 32px; display: flex; align-items: center; justify-content: space-between; }
.msp-content { padding: 32px; }
.msp-page-title { font-size: 22px; font-weight: 600; }

/* Sidebar */
.sidebar-logo { padding: 24px 24px 16px; border-bottom: 1px solid var(--border); }
.sidebar-logo a { font-family: 'Instrument Serif', serif; font-size: 20px; color: var(--accent); text-decoration: none; }
.sidebar-logo span { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-top: 2px; }
.sidebar-nav { padding: 16px 12px; }
.sidebar-section-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); padding: 8px 12px 4px; }
.sidebar-link { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; transition: all 0.15s; margin-bottom: 2px; }
.sidebar-link:hover { background: var(--accent-light); color: var(--accent); }
.sidebar-link.active { background: var(--accent); color: white; }
.sidebar-link .link-icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-footer { padding: 16px 24px; border-top: 1px solid var(--border); margin-top: auto; }
.msp-user-info { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.msp-user-info strong { color: var(--fg); display: block; font-size: 14px; }
.logout-btn { font-size: 13px; color: var(--muted); text-decoration: none; cursor: pointer; border: none; background: none; font-family: inherit; }
.logout-btn:hover { color: var(--danger); }

/* Cards */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 24px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.card-title { font-size: 16px; font-weight: 600; }
.card-subtitle { color: var(--muted); font-size: 13px; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 32px; }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.stat-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--fg); }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 10px 16px; border-bottom: 1.5px solid var(--border); }
td { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--accent-light); }

/* Status badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-pending { background: var(--amber-light); color: #a06800; }
.badge-won { background: var(--success-light); color: var(--success); }
.badge-lost { background: var(--danger-light); color: var(--danger); }
.badge-paid { background: var(--success-light); color: var(--success); }
.badge-new { background: var(--accent-light); color: var(--accent); }
.badge-active { background: var(--accent-light); color: var(--accent); }

/* Lead card */
.lead-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 12px; }
.lead-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.lead-id { font-size: 12px; color: var(--muted); }
.lead-industry { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.lead-meta { font-size: 13px; color: var(--muted); }
.lead-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag { background: var(--accent-light); color: var(--accent); padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }

/* Alert banners */
.alert { padding: 14px 20px; border-radius: 8px; font-size: 14px; margin-bottom: 20px; display: flex; align-items: center; gap: 10px; }
.alert-success { background: var(--success-light); color: var(--success); }
.alert-error { background: var(--danger-light); color: var(--danger); }
.alert-warning { background: var(--amber-light); color: #a06800; }

/* Quote form */
.quote-form { background: var(--accent-light); border-radius: 12px; padding: 24px; }
.quote-form-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; }

/* Catalog grid */
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; margin-top: 32px; }
.msp-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 24px; transition: box-shadow 0.2s, transform 0.2s; }
.msp-card:hover { box-shadow: 0 8px 24px rgba(0,0,0,0.08); transform: translateY(-2px); }
.msp-card-header { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.msp-logo { width: 48px; height: 48px; background: var(--accent); color: white; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; flex-shrink: 0; }
.msp-card-name { font-size: 18px; font-weight: 600; }
.msp-card-location { font-size: 13px; color: var(--muted); }
.msp-rating { display: flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 600; }
.msp-rating-stars { color: var(--amber); }
.msp-services { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.msp-price { font-size: 20px; font-weight: 700; color: var(--accent); margin-top: 12px; }
.msp-price-label { font-size: 12px; color: var(--muted); font-weight: 400; }

/* Payment section */
.payment-box { background: var(--amber-light); border: 2px solid var(--amber); border-radius: 12px; padding: 24px; text-align: center; }
.payment-box h3 { margin-bottom: 8px; }
.payment-box p { color: var(--muted); font-size: 14px; margin-bottom: 20px; }

/* Profile form */
.profile-section { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 24px; margin-bottom: 24px; }
.profile-section-title { font-size: 16px; font-weight: 600; margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }

/* Checkbox groups */
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.checkbox-item { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.checkbox-item input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }

/* Responsive */
@media (max-width: 1023px) {
  .msp-layout { flex-direction: column; }
  .msp-sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border); }
  .msp-content { padding: 24px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .catalog-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .detail-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 767px) {
  /* Hamburger menu for sidebar */
  .msp-sidebar {
    display: none;
  }

  .msp-sidebar.msp-sidebar-open {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 200;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
  }

  .msp-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
  }

  .msp-sidebar-overlay.msp-sidebar-overlay-active {
    display: block;
  }

  .msp-topbar {
    padding: 16px;
    flex-wrap: wrap;
    gap: 12px;
  }

  .hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--accent-light);
    border: 1.5px solid var(--accent);
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    color: var(--accent);
    flex-shrink: 0;
  }

  .msp-content {
    padding: 16px;
  }

  .msp-page-title {
    font-size: 18px;
  }

  /* Stats grid 2-col on mobile */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .stat-value {
    font-size: 22px;
  }

  /* Catalog single col */
  .catalog-grid {
    grid-template-columns: 1fr;
  }

  /* Card padding on mobile */
  .card {
    padding: 16px;
  }

  /* Tables: horizontal scroll */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    font-size: 13px;
  }

  th, td {
    padding: 10px 12px;
    min-width: 44px;
  }

  /* Buttons: 44px touch target */
  .btn {
    min-height: 44px;
    min-width: 44px;
    padding: 10px 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .btn-sm {
    min-height: 40px;
    padding: 8px 16px;
  }

  /* Lead cards on mobile */
  .lead-card {
    padding: 16px;
  }

  /* Auth pages: full width on mobile */
  .auth-card {
    padding: 32px 24px;
    max-width: 100%;
  }

  /* Detail grid: stack on small */
  .detail-grid {
    grid-template-columns: 1fr;
  }

  /* Form inputs: prevent iOS zoom */
  .form-input,
  .form-select {
    font-size: 16px;
  }

  /* Checkbox groups */
  .checkbox-grid {
    grid-template-columns: 1fr 1fr;
  }

  /* Sidebar nav links: 44px touch target */
  .sidebar-link {
    min-height: 44px;
    padding: 10px 12px;
  }

  .sidebar-logo {
    padding: 16px;
  }
}

@media (max-width: 479px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .msp-topbar {
    padding: 12px;
  }

  .msp-content {
    padding: 12px;
  }
}

/* Notification badge in sidebar */
.sidebar-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--danger, #e74c3c);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 5px;
  margin-left: auto;
}

/* Ghost button variant */
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn-ghost:hover {
  background: var(--bg-subtle);
}