:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f5f3;
  color: #151515;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: #f5f5f3;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

main { min-height: 100vh; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  border: 1px solid #d9d9d4;
  border-radius: 24px;
  background: #fff;
  padding: 34px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.08);
}

.login-card h1 { margin: 0 0 8px; }
.login-card form { display: grid; gap: 16px; margin-top: 24px; }

label { display: grid; gap: 7px; font-size: 14px; font-weight: 600; }
input, select {
  width: 100%;
  border: 1px solid #cfcfca;
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
  color: #151515;
  outline: none;
}
input:focus, select:focus { border-color: #151515; }

button {
  border: 0;
  border-radius: 10px;
  background: #151515;
  color: #fff;
  padding: 12px 16px;
  font-weight: 700;
}

.secondary {
  border: 1px solid #cfcfca;
  background: #fff;
  color: #151515;
}

.eyebrow {
  margin: 0 0 6px;
  color: #777;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
}

.muted { color: #777; }
.error { margin: 0; color: #b42318; }

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-right: 1px solid #d8d8d3;
  background: #ededeb;
  padding: 28px 22px 20px;
}

.sidebar h1 {
  margin: 0;
  max-width: 205px;
  font-size: 21px;
  line-height: 1.15;
}

.account-row {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 11px;
  align-items: center;
  border-top: 1px solid #d0d0cb;
  border-bottom: 1px solid #d0d0cb;
  padding: 14px 0;
}

.account-row strong, .account-row small { display: block; }
.account-row small { color: #777; overflow: hidden; text-overflow: ellipsis; }

.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  border: 1px solid #9e9e98;
  background: #fff;
  font-weight: 800;
}

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tab {
  border: 1px solid #bdbdb7;
  background: #f7f7f5;
  color: #151515;
  padding: 10px 8px;
}
.tab.active { background: #151515; color: #fff; border-color: #151515; }

.search-wrap input { background: #f8f8f6; }

.sidebar-list {
  display: grid;
  align-content: start;
  gap: 4px;
  min-height: 0;
  overflow: auto;
  flex: 1;
}

.sidebar-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  border-radius: 8px;
  background: transparent;
  color: #4a4a46;
  padding: 10px 8px;
  text-align: left;
  font-weight: 500;
}
.sidebar-item:hover, .sidebar-item.active { background: #fff; color: #151515; }

.crown { font-size: 20px; line-height: 1; }
.primary-action { width: 100%; }
.logout-button { width: 100%; background: transparent; color: #6d6d68; border: 1px solid #c8c8c2; }

.content-area { padding: 34px 48px 70px; }

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border: 1px solid #d9d9d4;
  border-radius: 16px;
  background: #fff;
  padding: 20px 24px;
}

.content-header h2 { margin: 0; font-size: 24px; }
.header-metrics { display: flex; gap: 34px; }
.header-metrics div, .row-metrics div { display: grid; gap: 3px; }
.header-metrics span, .row-metrics span { color: #777; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.header-metrics strong { font-size: 18px; }

.empty-state {
  margin-top: 24px;
  border: 1px dashed #c8c8c2;
  border-radius: 16px;
  background: rgba(255,255,255,.55);
  padding: 34px;
  color: #777;
}

#detail-view { margin-top: 28px; }
.detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}
.detail-toolbar h3 { margin: 0; font-size: 21px; }
.detail-toolbar input { width: min(300px, 100%); }

.detail-list { display: grid; }
.detail-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(280px, auto) auto;
  align-items: center;
  gap: 18px;
  border-bottom: 1px dotted #c9c9c4;
  padding: 18px 8px;
}

.row-metrics { display: flex; gap: 28px; }
.row-metrics strong { font-size: 16px; }

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  padding: 0;
  font-size: 24px;
}
.icon-button.danger { background: #fff0ee; color: #b42318; }

.link-action { margin-top: 28px; min-width: 210px; }
.danger-text { margin-top: 24px; background: transparent; color: #b42318; padding-left: 0; }
.danger-button { justify-self: start; margin-top: 24px; border: 1px solid #d92d20; background: #fff; color: #b42318; padding: 11px 16px; }
.danger-button:hover { background: #fff0ee; }

dialog {
  width: min(520px, calc(100% - 28px));
  border: 1px solid #d9d9d4;
  border-radius: 20px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(0,0,0,.2);
}
dialog::backdrop { background: rgba(0,0,0,.35); }
#modal-form { padding: 24px; }
.modal-heading, .modal-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.modal-heading h3 { margin: 0; }
.modal-fields { display: grid; gap: 16px; margin: 24px 0; }
.modal-actions { justify-content: flex-end; margin-top: 22px; }

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .content-area { padding: 24px 18px 50px; }
  .content-header, .detail-toolbar { align-items: flex-start; flex-direction: column; }
  .header-metrics { width: 100%; justify-content: space-between; }
  .detail-toolbar input { width: 100%; }
  .detail-row { grid-template-columns: 1fr auto; }
  .row-metrics { grid-column: 1 / -1; }
}

.oauth-login {
  display: grid;
  gap: 14px;
}

.google-login-button {
  display: block;
  border-radius: 10px;
  padding: 13px 18px;
  background: #f5f7fa;
  color: #0a0d12;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.google-login-button:hover {
  background: #ffffff;
}

.login-note {
  margin: 0;
  color: #9ca5b4;
  font-size: 13px;
  text-align: center;
}


.menu-toggle {
  position: fixed;
  z-index: 20;
  top: 16px;
  left: 292px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #c8c8c2;
  border-radius: 10px;
  background: #fff;
  color: #151515;
  box-shadow: 0 6px 20px rgba(0,0,0,.08);
  transition: left .22s ease;
}

.admin-shell.menu-closed {
  grid-template-columns: 0 1fr;
}

.admin-shell.menu-closed .sidebar {
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
}

.admin-shell.menu-closed .menu-toggle {
  left: 16px;
}

.sidebar {
  transition: transform .22s ease, opacity .22s ease;
}

@media (max-width: 900px) {
  .menu-toggle {
    left: 16px;
  }

  .admin-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    z-index: 15;
    inset: 0 auto 0 0;
    width: min(320px, 88vw);
    height: 100vh;
    box-shadow: 16px 0 40px rgba(0,0,0,.12);
  }

  .admin-shell.menu-closed .sidebar {
    transform: translateX(-105%);
  }

  .content-area {
    padding-top: 70px;
  }
}

.sidebar-status { display: inline-flex; align-items: center; gap: 7px; }
.pending-badge { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #fff3cd; color: #8a5a00; font-size: 15px; font-weight: 800; }
.invitation-card { display: grid; gap: 12px; margin-bottom: 22px; padding: 18px; border: 1px solid #e4c76c; border-radius: 14px; background: #fffaf0; }
.invitation-card input { background: #fff; }
.invitation-card small { color: #777; }
.invitation-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.button-link { display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; background: #151515; color: #fff; padding: 12px 16px; font-weight: 700; text-decoration: none; }

/* Sidebar overflow fixes */
.sidebar {
  overflow: hidden;
}

.sidebar > * {
  min-width: 0;
}

.sidebar-item {
  min-width: 0;
  overflow: hidden;
}

.sidebar-item > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-status {
  flex: 0 0 auto;
  margin-left: auto;
}

.account-row > div {
  min-width: 0;
}

.account-row strong,
.account-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* Gmail settings */
.settings-button {
  width: 100%;
  border: 1px solid #bdbdb7;
  background: #f7f7f5;
  color: #151515;
}

.settings-button.active {
  border-color: #151515;
  background: #151515;
  color: #fff;
}

.settings-card {
  display: grid;
  gap: 22px;
  max-width: 760px;
  border: 1px solid #d9d9d4;
  border-radius: 16px;
  background: #fff;
  padding: 24px;
}

.settings-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.settings-card-heading p {
  max-width: 560px;
  margin: 7px 0 0;
}

.connection-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #fff3cd;
  color: #8a5a00;
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 800;
}

.connection-badge.connected {
  background: #dcfae6;
  color: #067647;
}

.settings-details {
  display: grid;
  gap: 12px;
  margin: 0;
}

.settings-details div {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 16px;
}

.settings-details dt {
  color: #777;
  font-size: 13px;
  font-weight: 700;
}

.settings-details dd {
  margin: 0;
  font-weight: 700;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.settings-actions .danger-button {
  margin-top: 0;
}

@media (max-width: 700px) {
  .settings-card-heading {
    flex-direction: column;
  }

  .settings-details div {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
