:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-soft: #f1f3f4;
  --hover: #f2f6fc;
  --active: #d3e3fd;
  --line: #e0e3e7;
  --text: #202124;
  --muted: #5f6368;
  --blue: #1a73e8;
  --red: #c5221f;
  --green: #188038;
  --yellow: #fbbc04;
  --shadow: 0 1px 2px rgba(60, 64, 67, 0.2), 0 1px 3px rgba(60, 64, 67, 0.12);
}

* {
  box-sizing: border-box;
}

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

.login-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top left, #d8e7ff, transparent 34%), var(--bg);
}

.login-shell {
  width: min(100%, 440px);
}

.login-card {
  border-radius: 24px;
  padding: 28px;
  background: var(--surface);
  box-shadow: 0 20px 60px rgba(60, 64, 67, 0.2);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.login-brand h1 {
  margin: 0;
  font-size: 28px;
}

.login-brand p {
  margin: 4px 0 0;
  color: var(--muted);
}

.login-form,
.modal-card {
  display: grid;
  gap: 14px;
}

.login-form label,
.modal-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.login-form input,
.login-form select,
.modal-card input,
.modal-card textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
  outline: 0;
}

.modal-card textarea {
  min-height: 180px;
  resize: vertical;
}

.form-error {
  margin: 0;
  color: var(--red);
  font-size: 12px;
}

.login-note {
  margin-top: 18px;
  border-radius: 14px;
  padding: 12px;
  background: #f8fbff;
  color: var(--muted);
  font-size: 12px;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr) 300px;
  grid-template-rows: 64px minmax(0, 1fr);
  height: 100vh;
  min-width: 0;
}

.topbar {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 48px 190px 230px minmax(260px, 620px) 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg);
}

.icon-button,
.right-rail button,
.mail-actions button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
}

.icon-button:hover,
.right-rail button:hover,
.mail-actions button:hover {
  background: #e8eaed;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  color: #3c4043;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 26px;
  place-items: center;
  border-radius: 6px;
  background: linear-gradient(135deg, #ea4335 0 32%, #fbbc04 32% 54%, #34a853 54% 76%, #4285f4 76%);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
}

.search {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  border-radius: 24px;
  padding: 0 18px;
  background: #eaf1fb;
  color: var(--muted);
}

.tenant-switcher {
  display: grid;
  gap: 2px;
}

.tenant-switcher span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.tenant-switcher select {
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  outline: 0;
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 6px;
}

.surface-link {
  border: 0;
  border-radius: 999px;
  padding: 9px 13px;
  background: #e8f0fe;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.avatar {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
}

.sidebar {
  min-width: 0;
  overflow: auto;
  padding: 8px 12px 20px 0;
  background: var(--bg);
}

.compose-button {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 142px;
  height: 56px;
  margin: 0 0 16px 8px;
  border: 0;
  border-radius: 16px;
  padding: 0 24px;
  background: #c2e7ff;
  color: #001d35;
  box-shadow: var(--shadow);
  font-size: 15px;
  font-weight: 600;
}

.compose-button:hover {
  box-shadow: 0 2px 6px rgba(60, 64, 67, 0.28);
}

.product-nav {
  display: grid;
  gap: 1px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: calc(100% - 12px);
  height: 32px;
  border: 0;
  border-radius: 0 16px 16px 0;
  padding: 0 12px 0 24px;
  background: transparent;
  color: #3c4043;
  text-align: left;
}

.nav-item.active {
  background: #fce8e6;
  color: var(--red);
  font-weight: 700;
}

.nav-item:hover {
  background: #e8eaed;
}

.main-area {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 0 14px 16px 0;
}

.hidden {
  display: none;
}

.dashboard-view {
  display: grid;
  gap: 14px;
}

.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 18px;
  padding: 18px 20px;
  background: var(--surface);
}

.eyebrow {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.page-title h1 {
  margin: 4px 0 0;
  font-size: 28px;
  font-weight: 500;
}

.primary-action {
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric-grid article,
.panel {
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-grid article {
  display: grid;
  gap: 5px;
  padding: 16px;
}

.metric-grid small,
.metric-grid span {
  color: var(--muted);
}

.metric-grid strong {
  font-size: 30px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.panel {
  min-width: 0;
  padding: 16px;
}

.panel.wide {
  grid-column: 1 / -1;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 16px;
}

.panel-head button {
  border: 0;
  border-radius: 999px;
  padding: 7px 12px;
  background: #e8f0fe;
  color: var(--blue);
  font-weight: 700;
}

.domain-list,
.user-list {
  display: grid;
  gap: 8px;
}

.domain-row,
.user-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
}

.domain-row strong,
.domain-row span,
.user-row strong,
.user-row span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.domain-row span,
.user-row span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.status-pill {
  border-radius: 999px;
  padding: 5px 9px;
  background: #e6f4ea;
  color: #137333;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.warn {
  background: #fef7e0;
  color: #b06000;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.feature-grid div {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #f8fbff;
}

.feature-grid strong,
.feature-grid span {
  display: block;
}

.feature-grid span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.client-tools {
  margin: 22px 12px 0 16px;
  border-radius: 16px;
  padding: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.client-tools h2 {
  margin: 0 0 12px;
  color: #3c4043;
  font-size: 13px;
}

.client-tools button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 9px 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.client-tools button:hover {
  background: var(--hover);
}

.client-tools small {
  color: var(--muted);
  font-size: 11px;
}

.mail-shell {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: minmax(360px, 56%) minmax(260px, 1fr);
  gap: 14px;
  height: calc(100vh - 80px);
  padding: 0;
}

.inbox-panel,
.reader-panel {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 16px;
  background: var(--surface);
}

.inbox-panel {
  display: grid;
  grid-template-rows: 48px 48px minmax(0, 1fr);
}

.mail-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.mail-actions label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 4px;
}

.mail-actions span {
  flex: 1;
}

.mail-actions small {
  color: var(--muted);
}

.category-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--line);
}

.category-tabs button {
  position: relative;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}

.category-tabs button.active {
  color: var(--blue);
}

.category-tabs button.active::after {
  content: "";
  position: absolute;
  right: 18px;
  bottom: 0;
  left: 18px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--blue);
}

.category-tabs button:hover {
  background: var(--hover);
}

.message-list {
  min-height: 0;
  overflow: auto;
}

.empty-state {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.message-item {
  display: grid;
  grid-template-columns: 28px minmax(150px, 220px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 0 12px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.message-item:hover {
  position: relative;
  z-index: 1;
  box-shadow: inset 1px 0 0 #dadce0, inset -1px 0 0 #dadce0, 0 1px 2px rgba(60, 64, 67, 0.3);
}

.message-item.active {
  background: #eaf1fb;
}

.message-icon {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  color: #f4b400;
}

.message-icon::before {
  content: "☆";
  font-size: 18px;
}

.message-main {
  min-width: 0;
  display: contents;
}

.message-title {
  min-width: 0;
  font-weight: 700;
}

.message-title span:first-child {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-title span:last-child {
  display: none;
}

.message-preview {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-preview::before {
  content: attr(data-subject);
  color: var(--text);
  font-weight: 700;
}

.message-time {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.reader-panel {
  overflow: auto;
}

.reader {
  margin: 0 auto;
  max-width: 980px;
  padding: 24px 38px 80px;
}

.date-line {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.reader h1 {
  margin: 10px 0 20px;
  font-size: 26px;
  font-weight: 400;
  line-height: 1.25;
}

.message-addresses {
  margin-bottom: 26px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
  color: var(--muted);
  line-height: 1.55;
}

.message-addresses strong {
  display: inline-block;
  width: 48px;
  color: var(--text);
}

.reader-body {
  max-width: 720px;
  color: #303134;
  font-size: 14px;
  line-height: 1.7;
}

.reader-body p {
  margin: 0 0 14px;
}

.client-action-card {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 22px;
}

.client-action-card button {
  border: 1px solid #d8e7ff;
  border-radius: 999px;
  padding: 9px 14px;
  background: #f8fbff;
  color: var(--blue);
  font-weight: 700;
}

.client-action-card button:hover {
  background: #e8f0fe;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(32, 33, 36, 0.36);
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: min(100%, 560px);
  border-radius: 18px;
  padding: 18px;
  background: var(--surface);
  box-shadow: 0 20px 60px rgba(32, 33, 36, 0.24);
}

.compose-card {
  width: min(100%, 720px);
}

.modal-card header,
.modal-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-card footer {
  justify-content: flex-start;
}

.modal-card footer button:not(.primary-action),
.modal-close {
  border: 0;
  border-radius: 999px;
  padding: 9px 13px;
  background: #e8f0fe;
  color: var(--blue);
  font-weight: 800;
}

.right-rail {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 0 16px 16px 14px;
  border-left: 1px solid var(--line);
  background: var(--bg);
}

.admin-app {
  grid-template-columns: 256px minmax(0, 1fr);
}

.admin-main {
  padding-right: 16px;
}

.webmail-app .tenant-switcher {
  display: none;
}

.webmail-app .topbar {
  grid-template-columns: 48px 190px minmax(260px, 720px) 1fr;
}

.plugin-card {
  border-radius: 18px;
  padding: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.plugin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.plugin-head button {
  border: 0;
  border-radius: 999px;
  padding: 6px 10px;
  background: #e8f0fe;
  color: var(--blue);
  font-weight: 700;
}

.signature-preview {
  display: grid;
  gap: 3px;
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fbff;
}

.signature-preview span,
.signature-preview small,
.scheduled-item small {
  color: var(--muted);
}

.signature-swatches {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.signature-swatches span {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--blue);
}

.signature-swatches span:nth-child(2) {
  background: var(--green);
}

.signature-swatches span:nth-child(3) {
  background: var(--red);
}

.agenda-item,
.scheduled-item {
  display: grid;
  gap: 3px;
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.agenda-item:first-of-type,
.scheduled-item:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.agenda-item time {
  color: var(--blue);
  font-weight: 800;
}

@media (max-width: 1100px) {
  .app {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .topbar {
    grid-template-columns: 48px 170px minmax(200px, 1fr) 1fr;
  }

  .tenant-switcher {
    display: none;
  }

  .right-rail {
    display: none;
  }

  .mail-shell {
    grid-template-rows: minmax(360px, 1fr);
    padding-right: 14px;
  }

  .reader-panel {
    display: none;
  }
}

@media (max-width: 760px) {
  .app {
    grid-template-columns: 1fr;
  }

  .topbar {
    grid-template-columns: 40px 1fr 48px;
  }

  .brand strong,
  .top-actions .icon-button,
  .sidebar {
    display: none;
  }

  .search {
    grid-column: 2;
  }

  .mail-shell {
    padding: 0;
  }

  .inbox-panel {
    border-radius: 0;
  }

  .main-area {
    padding: 0;
  }

  .metric-grid,
  .dashboard-grid,
  .feature-grid {
    grid-template-columns: 1fr;
  }

  .panel.wide {
    grid-column: auto;
  }
}
