/* ═══════════════════════════════════════════════════════════════════════════
   Customer Portal — Stylesheet
   Clean, modern SaaS customer portal design
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Reset & Base ────────────────────────────────────────────────────────── */

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

:root {
  --navy: #1a365d;
  --navy-light: #2a4a7f;
  --navy-dark: #0f2440;
  --teal: #0d9488;
  --teal-light: #14b8a6;
  --teal-dark: #0f766e;
  --bg: #ffffff;
  --bg-gray: #f8fafc;
  --bg-muted: #f1f5f9;
  --border: #e2e8f0;
  --border-dark: #cbd5e1;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --red: #dc2626;
  --red-light: #fef2f2;
  --amber: #d97706;
  --amber-light: #fffbeb;
  --green: #16a34a;
  --green-light: #f0fdf4;
  --blue: #2563eb;
  --blue-light: #eff6ff;
  --purple: #7c3aed;
  --purple-light: #f5f3ff;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
  --transition: 150ms ease;
}

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg-gray);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--teal);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover {
  color: var(--teal-dark);
  text-decoration: underline;
}

/* ── Navigation Bar ──────────────────────────────────────────────────────── */

.portal-nav {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 24px;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow-md);
}

.portal-nav__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}
.portal-nav__logo:hover { color: #fff; text-decoration: none; }

.portal-nav__logo-icon {
  width: 32px;
  height: 32px;
  background: var(--teal);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
}

.portal-nav__links {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 40px;
  flex: 1;
}

.portal-nav__link {
  color: rgba(255,255,255,0.75);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.portal-nav__link:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
  text-decoration: none;
}
.portal-nav__link.active {
  color: #fff;
  background: rgba(255,255,255,0.15);
}

.portal-nav__user {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  position: relative;
}

.portal-nav__user-name {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
}

.portal-nav__user-btn {
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background var(--transition);
}
.portal-nav__user-btn:hover {
  background: rgba(255,255,255,0.22);
}

.portal-nav__dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  min-width: 180px;
  display: none;
  z-index: 1001;
}
.portal-nav__dropdown.open {
  display: block;
}
.portal-nav__dropdown a,
.portal-nav__dropdown button {
  display: block;
  width: 100%;
  padding: 10px 16px;
  text-align: left;
  color: var(--text);
  font-size: 0.9rem;
  border: none;
  background: none;
  cursor: pointer;
  transition: background var(--transition);
  text-decoration: none;
}
.portal-nav__dropdown a:hover,
.portal-nav__dropdown button:hover {
  background: var(--bg-gray);
  text-decoration: none;
}
.portal-nav__dropdown button.logout {
  color: var(--red);
  border-top: 1px solid var(--border);
}

/* Mobile nav toggle */
.portal-nav__toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  margin-left: auto;
  padding: 4px;
}

/* ── Page Layout ─────────────────────────────────────────────────────────── */

.portal-page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

.portal-page--wide {
  max-width: 1440px;
}

.portal-page__header {
  margin-bottom: 24px;
}

.portal-page__title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.3px;
}

.portal-page__subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 4px;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  transition: box-shadow var(--transition);
}
.card:hover {
  box-shadow: var(--shadow);
}

.card--flat {
  box-shadow: none;
}
.card--flat:hover {
  box-shadow: none;
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card__title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

/* Summary cards row */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.summary-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.summary-card__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.summary-card__label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.summary-card__value {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1;
}

.summary-card--blue .summary-card__icon { background: var(--blue-light); color: var(--blue); }
.summary-card--blue .summary-card__value { color: var(--blue); }

.summary-card--teal .summary-card__icon { background: #f0fdfa; color: var(--teal); }
.summary-card--teal .summary-card__value { color: var(--teal); }

.summary-card--amber .summary-card__icon { background: var(--amber-light); color: var(--amber); }
.summary-card--amber .summary-card__value { color: var(--amber); }

.summary-card--gray .summary-card__icon { background: var(--bg-muted); color: var(--text-secondary); }
.summary-card--gray .summary-card__value { color: var(--text-secondary); }

.summary-card--green .summary-card__icon { background: var(--green-light); color: var(--green); }
.summary-card--green .summary-card__value { color: var(--green); }

/* ── Tables ──────────────────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  background: var(--bg-gray);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr {
  transition: background var(--transition);
}
tbody tr:hover {
  background: var(--bg-gray);
}

tbody tr.clickable {
  cursor: pointer;
}

/* ── Status Badges ───────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge--blue     { background: var(--blue-light); color: var(--blue); }
.badge--teal     { background: #f0fdfa; color: var(--teal); }
.badge--green    { background: var(--green-light); color: var(--green); }
.badge--amber    { background: var(--amber-light); color: var(--amber); }
.badge--red      { background: var(--red-light); color: var(--red); }
.badge--purple   { background: var(--purple-light); color: var(--purple); }
.badge--gray     { background: var(--bg-muted); color: var(--text-secondary); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:hover {
  text-decoration: none;
}

.btn--primary {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.btn--primary:hover {
  background: var(--navy-light);
  color: #fff;
}

.btn--teal {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}
.btn--teal:hover {
  background: var(--teal-dark);
  color: #fff;
}

.btn--green {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}
.btn--green:hover {
  background: #15803d;
  color: #fff;
}

.btn--outline {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border-dark);
}
.btn--outline:hover {
  background: var(--bg-gray);
  border-color: var(--text-secondary);
}

.btn--sm {
  padding: 4px 12px;
  font-size: 0.8rem;
}

.btn--danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
.btn--danger:hover {
  background: #b91c1c;
  color: #fff;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Forms ────────────────────────────────────────────────────────────────── */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(13,148,136,0.12);
}

textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ── Filter Tabs ─────────────────────────────────────────────────────────── */

.filter-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-tab {
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
}
.filter-tab:hover {
  background: var(--bg-muted);
  color: var(--text);
}
.filter-tab.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

/* ── Detail Panel (inline expand) ────────────────────────────────────────── */

.detail-panel {
  background: var(--bg-gray);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin: 8px 0 16px;
  animation: slideDown 200ms ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.detail-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.detail-panel__title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--navy);
}

.detail-panel__close {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
  line-height: 1;
}
.detail-panel__close:hover {
  color: var(--text);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.detail-grid__item {
  display: flex;
  flex-direction: column;
}
.detail-grid__label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.detail-grid__value {
  font-size: 0.95rem;
  color: var(--text);
  font-weight: 500;
}

/* ── Activity Timeline ───────────────────────────────────────────────────── */

.timeline {
  list-style: none;
}

.timeline__item {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.timeline__item:last-child {
  border-bottom: none;
}

.timeline__icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.timeline__icon--order   { background: var(--blue-light); color: var(--blue); }
.timeline__icon--ship    { background: #f0fdfa; color: var(--teal); }
.timeline__icon--invoice { background: var(--amber-light); color: var(--amber); }
.timeline__icon--payment { background: var(--green-light); color: var(--green); }

.timeline__content {
  flex: 1;
}
.timeline__text {
  font-size: 0.9rem;
  color: var(--text);
}
.timeline__date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Quick Actions ───────────────────────────────────────────────────────── */

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.quick-action {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  color: var(--text);
}
.quick-action:hover {
  border-color: var(--teal);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
}

.quick-action__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: #f0fdfa;
  color: var(--teal);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.quick-action__label {
  font-weight: 600;
  font-size: 0.9rem;
}

/* ── Welcome Banner ──────────────────────────────────────────────────────── */

.welcome-banner {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 24px;
}

.welcome-banner__title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.welcome-banner__subtitle {
  color: rgba(255,255,255,0.7);
  font-size: 0.95rem;
}

/* ── Login Page ──────────────────────────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--navy-dark) 0%, var(--navy) 50%, var(--navy-light) 100%);
  padding: 20px;
}

.login-card {
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}

.login-card__logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-card__logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: var(--navy);
  color: #fff;
  border-radius: 12px;
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 12px;
}

.login-card__logo-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--navy);
}

.login-card__logo-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.login-card .btn--primary {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  margin-top: 4px;
}

.login-error {
  background: var(--red-light);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 16px;
  display: none;
}
.login-error.visible {
  display: block;
}

/* ── Unit Passport ───────────────────────────────────────────────────────── */

.passport-sections {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.passport-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.passport-section__title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ── Search Bar ──────────────────────────────────────────────────────────── */

.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.search-bar .form-control {
  flex: 1;
}

/* ── Toasts ──────────────────────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  top: 72px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 300ms ease, toastOut 300ms ease 3700ms forwards;
  min-width: 280px;
  max-width: 420px;
}

.toast--success { background: var(--green); }
.toast--error   { background: var(--red); }
.toast--info    { background: var(--blue); }
.toast--warning { background: var(--amber); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(40px); }
}

/* ── Loading Spinner ─────────────────────────────────────────────────────── */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 0.95rem;
  gap: 10px;
}

.loading__spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Empty State ─────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state__icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}
.empty-state__text {
  font-size: 1rem;
}

/* ── Grid helpers ────────────────────────────────────────────────────────── */

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.mt-24 { margin-top: 24px; }
.mb-24 { margin-bottom: 24px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 1024px) {
  .summary-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .portal-nav {
    padding: 0 16px;
    flex-wrap: wrap;
    height: auto;
    min-height: 60px;
  }

  .portal-nav__links {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    margin-left: 0;
    padding: 8px 0;
    gap: 2px;
  }
  .portal-nav__links.open {
    display: flex;
  }

  .portal-nav__link {
    width: 100%;
  }

  .portal-nav__toggle {
    display: block;
  }

  .portal-nav__user {
    display: none;
  }

  .portal-page {
    padding: 16px;
  }

  .summary-cards {
    grid-template-columns: 1fr 1fr;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr 1fr;
  }

  .welcome-banner {
    padding: 20px;
  }

  .welcome-banner__title {
    font-size: 1.2rem;
  }
}

@media (max-width: 480px) {
  .summary-cards {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .login-card {
    padding: 24px;
  }

  .filter-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
}
