:root {
  font-family: 'Google Sans', Roboto, RobotoDraft, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: #202124;
  background: #f6f8fc;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 13px; line-height: 1.45; background: #f6f8fc; color: #202124; }
button, input, select, textarea { font: inherit; }

/* Compact Gmail-style Buttons */
button {
  cursor: pointer;
  border: 1px solid #dadce0;
  background: #ffffff;
  border-radius: 5px;
  padding: 0 12px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #3c4043;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.15px;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
button:hover { background: #f8f9fa; border-color: #dadce0; color: #202124; }
button:disabled { opacity: 0.45; cursor: default; }
button.primary {
  background: #1a73e8;
  border-color: #1a73e8;
  color: #ffffff;
  font-weight: 500;
}
button.primary:hover {
  background: #1557b0;
  border-color: #1557b0;
  box-shadow: 0 1px 2px rgba(60,64,67,0.3), 0 1px 3px 1px rgba(60,64,67,0.15);
}
button.danger { color: #d93025; border-color: #fce8e6; background: #fff; }
button.danger:hover { background: #fce8e6; }

/* Form Elements */
input, select, textarea {
  width: 100%;
  border: 1px solid #dadce0;
  border-radius: 4px;
  padding: 0 10px;
  height: 32px;
  background: #ffffff;
  color: #202124;
  font-size: 12.5px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { height: auto; padding: 8px 10px; resize: vertical; min-height: 120px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #1a73e8;
  box-shadow: 0 0 0 2px rgba(26,115,232,0.2);
}
label {
  display: block;
  margin: 11px 0 4px;
  font-weight: 600;
  font-size: 11.5px;
  color: #5f6368;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 18px; font-weight: 500; color: #1f1f1f; }
h2 { font-size: 14px; font-weight: 600; color: #202124; }
h3 { font-size: 13px; font-weight: 600; }
.muted { color: #5f6368; }
.small { font-size: 11.5px; }

/* Brand & Logo */
.brand {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: #ffffff;
}
.brand span {
  font-size: 9px;
  letter-spacing: 1.2px;
  display: block;
  margin-top: 3px;
  color: #8fa5c5;
  font-weight: 600;
}
.logo {
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: #1a73e8;
  color: white;
  width: 32px;
  height: 32px;
  font-weight: 700;
  font-size: 16px;
  margin-right: 9px;
}
.loading { padding: 60px; text-align: center; color: #5f6368; font-size: 13px; }

/* Login Page */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.login-art {
  background: #182232;
  color: white;
  padding: 10vh 10%;
  display: flex;
  flex-direction: column;
}
.login-art .brand { font-size: 20px; }
.login-art > div:last-child {
  margin: auto 0;
  transform: translateY(-16px);
}
.login-art h1 {
  font-size: 36px;
  line-height: 1.25;
  max-width: 440px;
  color: #ffffff;
  font-weight: 600;
}
.login-art p {
  color: #b0c0d8;
  font-size: 14px;
  line-height: 1.65;
  max-width: 400px;
}
.login-panel {
  display: grid;
  place-items: center;
  padding: 32px;
  background: #ffffff;
}
.login-panel form { max-width: 340px; width: 100%; }
.login-panel h1 { font-size: 22px; font-weight: 600; margin-bottom: 6px; }
.login-panel .subtitle { font-size: 12.5px; color: #5f6368; margin-bottom: 20px; }
.login-panel .primary { width: 100%; margin-top: 20px; height: 38px; font-size: 13px; }
.login-help { margin-top: 18px; font-size: 11.5px; color: #80868b; text-align: center; }
.eyebrow {
  font-size: 10.5px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #1a73e8;
  font-weight: 600;
  margin-bottom: 8px;
}

/* Admin Shell Layout */
.shell {
  display: grid;
  grid-template-columns: 210px 1fr;
  min-height: 100vh;
  background: #f6f8fc;
}
.sidebar {
  background: #182232;
  color: white;
  display: flex;
  flex-direction: column;
  padding: 16px 10px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand {
  margin: 0 8px 18px;
}
.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar button {
  border: 0;
  background: transparent;
  color: #a3b3cc;
  text-align: left;
  margin: 1px 0;
  padding: 0 12px;
  height: 32px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: 6px;
  justify-content: flex-start;
  transition: background 0.15s, color 0.15s;
}
.sidebar button:hover { background: rgba(255,255,255,0.08); color: #ffffff; }
.sidebar button.active { background: #1a73e8; color: #ffffff; font-weight: 600; }
.sidebar .primary {
  background: #1a73e8;
  color: white;
  text-align: center;
  justify-content: center;
  margin-bottom: 16px;
  height: 34px;
}
.sidebar .bottom {
  margin-top: auto;
  padding: 12px 6px 0;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.identity {
  font-size: 11px;
  overflow-wrap: anywhere;
  color: #8ba2c8;
  margin-bottom: 8px;
  font-weight: 500;
}
.sidebar .sidebar-password {
  width: 100%;
  height: 28px;
  margin-bottom: 7px;
  text-align: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,0.15);
  color: #d4e3fb;
  font-size: 11.5px;
}
.sidebar .logout {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.15);
  text-align: center;
  justify-content: center;
  height: 28px;
  font-size: 11.5px;
  color: #cbd5e1;
  border-radius: 4px;
}
.sidebar .logout:hover {
  background: rgba(217,48,37,0.15);
  border-color: rgba(217,48,37,0.4);
  color: #ff8a80;
}
.sidebar-version { margin: 10px 0 0; font-size: 10px; color: #8ba2c8; text-align: center; }

/* Main & Sleek Topbar */
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  height: 52px;
  background: #ffffff;
  border-bottom: 1px solid #dadce0;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.topbar h1 {
  font-size: 16px;
  font-weight: 500;
  color: #1f1f1f;
  margin: 0;
}
.topbar #refresh {
  height: 30px;
  font-size: 12px;
  padding: 0 12px;
  border-radius: 5px;
}

/* Content Area - Full Width & Clean */
.content {
  padding: 16px 24px;
  flex: 1;
}
.subtitle {
  color: #5f6368;
  font-size: 12.5px;
  line-height: 1.5;
  margin-bottom: 16px;
}

/* Compact Metrics Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.card {
  background: #ffffff;
  border: 1px solid #dadce0;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 1px 2px rgba(60,64,67,0.04);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: #5f6368;
  font-weight: 600;
}
.card strong {
  font-size: 20px;
  font-weight: 600;
  display: block;
  margin: 4px 0 2px;
  color: #1f1f1f;
  letter-spacing: -0.3px;
}
.card .unit {
  font-size: 11px;
  color: #80868b;
  text-transform: none;
  font-weight: 400;
  display: block;
}

/* Panels & Tables */
.panel {
  background: #ffffff;
  border: 1px solid #dadce0;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(60,64,67,0.04);
}
.panel-head {
  padding: 7px 16px;
  min-height: 46px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  border-bottom: 1px solid #edf0f4;
  gap: 10px;
}
.panel-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #202124;
  display: flex;
  align-items: center;
}
.panel-head button.primary { height: 32px; font-size: 12px; padding: 0 12px; border-radius: 5px; }

.panel-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #5f6368;
  background: #f1f3f4;
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: 6px;
}
.table-search {
  position: relative;
  display: flex;
  align-items: center;
  background: #f1f3f4;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: all 0.2s;
  height: 32px;
}
.table-search:focus-within {
  background: #ffffff;
  border-color: #1a73e8;
  box-shadow: 0 1px 3px rgba(26,115,232,0.15);
}
.table-search .search-icon {
  font-size: 13px;
  color: #5f6368;
  padding: 0 6px 0 10px;
  user-select: none;
  line-height: 1;
}
.table-search input {
  border: none !important;
  background: transparent !important;
  font-size: 12px !important;
  padding: 4px 6px 4px 0 !important;
  outline: none !important;
  width: 200px;
  color: #202124;
  box-shadow: none !important;
}
.table-search .clear-search {
  border: none;
  background: transparent;
  color: #80868b;
  font-size: 11px;
  cursor: pointer;
  padding: 0 8px;
  height: 100%;
}
.table-search .clear-search:hover {
  color: #202124;
}
.table-select-filter {
  height: 32px;
  padding: 0 10px;
  font-size: 12px;
  border: 1px solid #dadce0;
  border-radius: 6px;
  background: #ffffff;
  color: #3c4043;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}
.table-select-filter:focus {
  border-color: #1a73e8;
}
.active-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 16px;
  background: #e8f0fe;
  border-bottom: 1px solid #d2e3fc;
  font-size: 12px;
  color: #1967d2;
}
.active-filter-bar strong {
  font-weight: 600;
}
.active-filter-bar .btn-text {
  background: transparent;
  border: none;
  color: #1a73e8;
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
}
.active-filter-bar .btn-text:hover {
  background: #d2e3fc;
}
.btn-link {
  background: transparent;
  border: none;
  color: #1a73e8;
  cursor: pointer;
  text-decoration: underline;
  font-size: inherit;
  padding: 0;
}
.btn-link:hover {
  color: #1557b0;
}

/* Zone Mailbox Column */
.zone-mailbox-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.zone-filter-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #1a73e8;
  text-decoration: none;
  font-size: 12.5px;
}
.zone-filter-link strong {
  color: #1a73e8;
}
.zone-filter-link:hover {
  text-decoration: underline;
}
.zone-filter-link .arrow-icon {
  font-size: 11px;
  color: #1a73e8;
  font-weight: 400;
}
.zone-email-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}
.email-chip {
  display: inline-block;
  padding: 2px 7px;
  background: #f1f3f4;
  border: 1px solid #dadce0;
  border-radius: 12px;
  font-size: 11px;
  color: #3c4043;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.email-chip:hover {
  background: #e8f0fe;
  border-color: #c2e7ff;
  color: #0b57d0;
}
.email-chip.more {
  background: #f8f9fa;
  color: #5f6368;
  font-weight: 500;
}
.email-chip.more:hover {
  background: #e8f0fe;
  color: #1a73e8;
}

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12.5px;
}
th {
  font-size: 11px;
  letter-spacing: 0.3px;
  color: #5f6368;
  background: #f8f9fa;
  font-weight: 600;
  padding: 8px 14px;
  border-bottom: 1px solid #dadce0;
}
td {
  padding: 8px 14px;
  border-top: 1px solid #f1f3f4;
  font-size: 12.5px;
  color: #202124;
  vertical-align: middle;
}
td strong { font-weight: 500; }
td small {
  display: block;
  margin-top: 2px;
  color: #70757a;
  font-size: 11px;
  line-height: 1.4;
  font-weight: 400;
}
tr:hover td { background: #f8fafd; }
td button {
  height: 26px;
  padding: 0 10px;
  font-size: 11.5px;
  border-radius: 4px;
}
.account-table td:nth-child(2), .account-table td:nth-child(3) { white-space: nowrap; }
.account-actions { display: flex; align-items: flex-start; justify-content: flex-end; gap: 6px; min-width: 230px; }
.account-actions button { white-space: nowrap; }
.account-actions .account-retry { border-color: #c5d7fb; color: #185abc; background: #f5f8ff; font-weight: 600; }
.account-actions .account-retry:hover { background: #e8f0fe; }
.account-more { width: 82px; flex-shrink: 0; }
.account-more summary { list-style: none; cursor: pointer; border: 1px solid #dadce0; border-radius: 4px; background: #fff; padding: 5px 9px; font-size: 11.5px; white-space: nowrap; }
.account-more summary::-webkit-details-marker { display: none; }
.account-more summary:hover { background: #f8f9fa; }
.account-more-actions { display: grid; gap: 5px; padding-top: 5px; }
.routing-hint { max-width: 310px; overflow-wrap: anywhere; }
.account-confirm-email { background: #f8f9fa; border: 1px solid #e8eaed; border-radius: 5px; padding: 9px 11px; font-size: 13px; font-weight: 600; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 500;
  white-space: nowrap;
  background: #fef7e0;
  color: #b06000;
}
.badge.ok { background: #e6f4ea; color: #137333; }
.badge.off { background: #f1f3f4; color: #5f6368; }
.empty { padding: 40px 16px; text-align: center; color: #70757a; font-size: 13px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; }
.usage { height: 4px; background: #e0e3e7; border-radius: 2px; margin: 8px 0; overflow: hidden; }
.usage > div { height: 100%; background: #1a73e8; border-radius: 2px; }

/* Plan card grid */
.plan-card { padding: 14px 16px; }
.plan-card .eyebrow { margin-bottom: 4px; }
.plan-card strong { font-size: 16px; margin: 2px 0 6px; }
.plan-card p { font-size: 12px; margin-bottom: 4px; line-height: 1.4; }
.plan-card button { margin-top: 10px; height: 28px; font-size: 12px; }
.plan-card-heading, .plan-actions, .plan-order { display: flex; align-items: center; gap: 8px; }
.plan-card-heading { justify-content: space-between; }
.plan-card .plan-order button { margin-top: 0; width: 28px; padding: 0; }
.plan-actions { flex-wrap: wrap; }
.plan-card .plan-usage { margin-top: 10px; }
.plan-card .plan-usage button { margin-top: 0; height: auto; padding: 0 4px; }
.plan-email-list { list-style: none; padding: 0; max-height: 350px; overflow: auto; }
.plan-email-list li { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 10px 0; border-bottom: 1px solid #e0e3e7; overflow-wrap: anywhere; }

/* Fallback Mail Workspace */
.mail-workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - 52px);
}
.mail-list { border-right: 1px solid #dadce0; background: #fff; overflow: auto; }
.list-tools {
  padding: 8px 12px;
  display: flex;
  gap: 6px;
  border-bottom: 1px solid #dadce0;
  position: sticky;
  top: 0;
  background: white;
}
.mail-row {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: 0;
  border-bottom: 1px solid #f1f3f4;
  text-align: left;
  border-radius: 0;
  height: auto;
}
.mail-row.selected { background: #e8f0fe; border-left: 3px solid #1a73e8; }
.mail-row .sender { font-size: 12px; font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-row .subject { display: block; margin: 4px 0; color: #3c4043; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.mail-row .date { font-size: 11px; color: #80868b; }
.reader { background: #fff; overflow: auto; padding: 24px; }
.reader h2 { font-size: 18px; line-height: 1.4; }
.reader .meta { color: #5f6368; font-size: 11.5px; line-height: 1.8; overflow-wrap: anywhere; }
.reader .body { white-space: pre-wrap; line-height: 1.7; margin-top: 24px; font-size: 13px; }
.reader iframe { border: 0; width: 100%; height: 55vh; margin-top: 16px; }
.reader .reader-actions { display: flex; gap: 6px; justify-content: flex-end; margin-bottom: 18px; }
.reader .reader-actions button { height: 28px; font-size: 12px; }
.attachments { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.attachments a { padding: 6px 10px; background: #f1f3f4; border-radius: 4px; text-decoration: none; color: #1a73e8; font-size: 11.5px; }
.reader-empty { height: 100%; display: grid; place-content: center; text-align: center; color: #80868b; background: #fafbfd; }
.reader-empty .envelope { font-size: 36px; margin-bottom: 10px; }

/* Dialogs & Utilities */
.grid-two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 12.5px; text-transform: none; margin: 12px 0; cursor: pointer; color: #202124; }
.check input { width: 15px; height: 15px; margin: 0; accent-color: #1a73e8; }
.form-error { color: #d93025; font-size: 12px; line-height: 1.5; margin-top: 10px; }
dialog {
  border: 0;
  border-radius: 8px;
  width: min(520px, 94vw);
  padding: 20px 24px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.22);
  max-height: 92vh;
  font-family: inherit;
}
dialog::backdrop { background: rgba(32,33,36,0.5); }
dialog h2 { margin-bottom: 4px; font-size: 16px; font-weight: 600; color: #202124; }
dialog p.muted { font-size: 12px; margin-bottom: 12px; }
dialog .actions { margin-top: 18px; }
dialog .actions button { height: 32px; padding: 0 14px; font-size: 12px; border-radius: 4px; }
#notice {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #323232;
  color: white;
  padding: 10px 16px;
  border-radius: 6px;
  max-width: 440px;
  z-index: 100;
  box-shadow: 0 3px 10px rgba(0,0,0,0.25);
  font-size: 12.5px;
  line-height: 1.5;
}
.pager { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 10px; }
.pager button { height: 26px; padding: 0 8px; font-size: 12px; }
.visually-hidden { position: absolute; clip: rect(0,0,0,0); width: 1px; height: 1px; overflow: hidden; }

.imap-import-form { padding: 18px 22px 22px; max-width: 760px; }
.imap-import-form > label, .imap-import-form .grid-two label { display: block; margin: 12px 0 5px; font-size: 12px; font-weight: 600; }
.imap-import-form > input, .imap-import-form > select, .imap-import-form .grid-two input { width: 100%; }
.imap-import-form .grid-two { gap: 14px; }
.imap-import-form .select2-container { width: 100%; }
.imap-import-form .select2-selection--single { height: 32px; border: 1px solid #d4d9e2; border-radius: 4px; }
.imap-import-form .select2-selection--single .select2-selection__rendered { line-height: 30px; padding-left: 10px; }
.imap-import-form .select2-selection--single .select2-selection__arrow { height: 30px; }
.imap-import-form .select2-search__field { width: 100%; }
#imap-user-help { margin: 6px 0; line-height: 1.5; }
.imap-actions { display: flex; gap: 9px; margin: 16px 0; flex-wrap: wrap; }
.imap-actions button { min-height: 34px; }
.imap-folders { border: 1px solid #e0e4eb; border-radius: 8px; padding: 12px 14px; margin: 14px 0; }
.imap-folders h3 { margin: 0; font-size: 14px; }
.imap-folder-row { display: grid; grid-template-columns: minmax(180px,1fr) 150px; gap: 10px; align-items: center; padding: 7px 0; border-top: 1px solid #eef0f3; }
.imap-folder-row label { display: flex; align-items: center; gap: 8px; min-width: 0; overflow-wrap: anywhere; font-size: 12px; }
.imap-folder-row select { width: 100%; }
.imap-status { padding: 16px 22px 20px; font-size: 12.5px; }
.imap-status-title { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.imap-status-title strong { color: #1d4ed8; font-size: 14px; }
.imap-status progress { width: min(100%,540px); height: 12px; display: block; margin: 8px 0; }

@media (max-width: 1100px) {
  .shell { grid-template-columns: 180px 1fr; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 14px 16px; }
}
@media (max-width: 760px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .shell { display: block; }
  .sidebar { position: static; height: auto; padding: 12px; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px; }
  .sidebar .brand { margin: 0 12px 0 0; }
  .sidebar .bottom { margin: 0 0 0 auto; padding: 0; border-top: 0; }
  .sidebar .identity, .sidebar .storage-usage { display: none; }
  .sidebar .primary { margin: 0; }
  .sidebar .brand span { display: none; }
  .sidebar .logout { width: auto; }
  .topbar { padding: 0 14px; height: 48px; }
  .content { padding: 12px; }
  .cards { grid-template-columns: 1fr; gap: 8px; }
  .sidebar nav { flex-direction: row; order: 3; width: 100%; margin-top: 8px; }
  .sidebar nav button { flex: 1; text-align: center; justify-content: center; }
}

.login-version { margin: 10px 0 0; font-size: 10px; color: #9aa0a6; text-align: center; }
