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

:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --border: #e0e0e0;
  --text-primary: #202124;
  --text-secondary: #5f6368;
  --accent: #1a73e8;
  --accent-hover: #1557b0;
  --unread-bg: #ffffff;
  --read-bg: #f2f6fc;
  --hover-bg: #f0f4ff;
  --danger: #d93025;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.15);
}

body {
  font-family: 'Google Sans', Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- Header ---------- */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

#user-section { display: flex; align-items: center; }

#user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

#user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

#user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

#user-name {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, box-shadow 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--shadow); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--hover-bg); color: var(--accent); border-color: var(--accent); }

.btn-large { padding: 12px 28px; font-size: 16px; }

/* ---------- Main / Layout ---------- */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.center-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  gap: 16px;
}

/* ---------- Landing ---------- */
.landing-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 56px 48px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 420px;
}

.landing-card h1 { font-size: 24px; font-weight: 600; }
.landing-card p { color: var(--text-secondary); line-height: 1.6; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-left { display: flex; align-items: center; gap: 10px; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }

.toolbar h2 { font-size: 20px; font-weight: 600; }

.badge {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
}

select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--surface);
  cursor: pointer;
}

/* ---------- Email List ---------- */
#email-list {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--border);
}

.email-row {
  display: grid;
  grid-template-columns: 44px 180px 1fr 72px;
  align-items: center;
  gap: 0;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
  min-width: 0;
}

.email-row:last-child { border-bottom: none; }
.email-row:hover { background: var(--hover-bg); }
.email-row.unread { font-weight: 600; background: var(--unread-bg); }
.email-row.read { font-weight: 400; background: var(--read-bg); }

.email-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.email-from {
  padding: 0 12px 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  min-width: 0;
}

.email-subject-snippet {
  overflow: hidden;
  min-width: 0;
}

.email-subject {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}

.email-snippet {
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 400;
}

.email-date {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  text-align: right;
  font-weight: 400;
}

.email-row.unread .email-date { font-weight: 600; color: var(--text-primary); }

/* ---------- Spinner ---------- */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Error ---------- */
.error-banner {
  background: #fce8e6;
  border: 1px solid #f5c6c3;
  color: var(--danger);
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
}

#page-info { color: var(--text-secondary); font-size: 13px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25);
  max-width: 720px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.15s ease;
}

@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 24px 12px;
  gap: 12px;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.4;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
  line-height: 1;
  padding: 0 4px;
  flex-shrink: 0;
}
.modal-close:hover { color: var(--text-primary); }

.modal-meta {
  padding: 0 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text-secondary);
}
.modal-meta strong { color: var(--text-primary); }

.modal-divider { height: 1px; background: var(--border); }

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.7;
  flex: 1;
}

.modal-body iframe {
  width: 100%;
  border: none;
  min-height: 300px;
}

/* ---------- Utilities ---------- */
.hidden { display: none !important; }

/* ---------- Split Layout ---------- */
.split-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  align-items: start;
}

.split-left { min-width: 0; }

.split-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 76px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
}

.right-panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-scroll {
  overflow-y: auto;
  max-height: 280px;
}

/* ---------- Calendar Panel ---------- */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.panel-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-header h2 { font-size: 15px; font-weight: 600; }

.btn-sm { padding: 5px 10px; font-size: 12px; }

.cal-loading {
  display: flex;
  justify-content: center;
  padding: 24px;
}

.spinner-sm {
  width: 24px;
  height: 24px;
  border-width: 2px;
}

#cal-list {
  overflow-y: auto;
  max-height: 280px;
}

.cal-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
}

.cal-date-divider {
  padding: 8px 16px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}

.cal-event {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.cal-event:last-child { border-bottom: none; }
.cal-event:hover { background: var(--hover-bg); }

.cal-event.cal-past { opacity: 0.5; }

.cal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}

.cal-color-default { background: #1a73e8; }
.cal-color-1  { background: #ac725e; }
.cal-color-2  { background: #d06b64; }
.cal-color-3  { background: #f83a22; }
.cal-color-4  { background: #fa573c; }
.cal-color-5  { background: #ff7537; }
.cal-color-6  { background: #ffad46; }
.cal-color-7  { background: #42d692; }
.cal-color-8  { background: #16a765; }
.cal-color-9  { background: #7bd148; }
.cal-color-10 { background: #b3dc6c; }
.cal-color-11 { background: #fbe983; }

.cal-event-body { min-width: 0; }

.cal-event-title {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.cal-event-time {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Calendar Modal ---------- */
.cal-modal-title-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.cal-modal-body {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 !important;
}

.cal-detail-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
}

.cal-detail-row:last-child { border-bottom: none; }

.cal-detail-icon {
  font-size: 16px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
  padding-top: 1px;
}

.cal-detail-content { min-width: 0; flex: 1; }

.cal-detail-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.cal-detail-value {
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-word;
}

.cal-detail-value a {
  color: var(--accent);
  text-decoration: none;
}
.cal-detail-value a:hover { text-decoration: underline; }

.cal-detail-notes {
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
}

.cal-detail-notes .cal-detail-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.cal-detail-notes-body {
  font-size: 13px;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}

.cal-detail-notes-body a {
  color: var(--accent);
  text-decoration: none;
}
.cal-detail-notes-body a:hover { text-decoration: underline; }

.cal-attendees-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.cal-attendee {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 2px 10px;
  font-size: 12px;
  color: var(--text-primary);
}

/* ---------- Responsive ---------- */
/* ---------- HubSpot Deals ---------- */
.badge-orange { background: #FF7A59; }

.panel-header-actions { display: flex; gap: 4px; }

.hs-connect {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.hs-connect p { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

.hs-token-row { display: flex; gap: 8px; }

.hs-input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: monospace;
  min-width: 0;
}
.hs-input:focus { outline: 2px solid var(--accent); border-color: transparent; }

.hs-help {
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
}
.hs-help:hover { text-decoration: underline; }

.hs-deal {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.hs-deal:last-child { border-bottom: none; }
.hs-deal:hover { background: var(--hover-bg); }

.hs-deal-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.hs-deal-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.hs-stage-pill {
  font-size: 11px;
  font-weight: 500;
  background: #fef3e2;
  color: #b45309;
  border: 1px solid #fde68a;
  border-radius: 99px;
  padding: 1px 8px;
}

.hs-prob {
  font-size: 11px;
  font-weight: 700;
  border-radius: 99px;
  padding: 1px 8px;
}
.hs-prob-high { background: #dcfce7; color: #166534; }
.hs-prob-mid  { background: #fef9c3; color: #854d0e; }
.hs-prob-low  { background: #fee2e2; color: #991b1b; }
.hs-prob-none { display: none; }

.hs-amount {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-left: auto;
}

.hs-close-date {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 3px;
}

.hs-deal-dates {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 3px;
}

.hs-deal { cursor: pointer; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .split-layout { grid-template-columns: 1fr; }
  .split-right { position: static; max-height: none; }
}

@media (max-width: 600px) {
  .email-row { grid-template-columns: 36px 1fr 60px; }
  .email-from { display: none; }
  main { padding: 12px; }
  .header-inner { padding: 0 12px; }
}
