@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap");

:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --ink: #1f1f1f;
  --muted: #444746;
  --faint: #767676;
  --line: #e1e3e1;
  --nav-hover: #e8eaed;
  --nav-active: #d3e3fd;
  --row-hover: #f2f6fc;
  --row-selected: #c2e7ff;
  --search: #eaf1fb;
  --search-focus: #ffffff;
  --blue: #0b57d0;
  --blue-hover: #0842a0;
  --star: #f4b400;
  --important: #f9ab00;
  --chip: #e8f0fe;
  --danger: #c5221f;
  --shadow-compose: 0 1px 3px 0 rgba(60,64,67,.3), 0 4px 8px 3px rgba(60,64,67,.15);
  --nav-w: 256px;
  --header-h: 64px;
  --row-h: 40px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.4 Roboto, Arial, sans-serif;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--blue); }

.hidden { display: none !important; }

/* Google-style login */
#login {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 450px;
  border: 1px solid #dadce0;
  border-radius: 8px;
  padding: 48px 40px 36px;
}
.login-card h1 {
  font-size: 24px;
  font-weight: 400;
  margin: 16px 0 0;
  text-align: center;
}
.login-card .sub {
  text-align: center;
  margin: 8px 0 32px;
  color: var(--muted);
  font-size: 16px;
}
.login-logo { display: flex; justify-content: center; }
.field {
  position: relative;
  margin: 0 0 18px;
}
.field input {
  width: 100%;
  height: 56px;
  border: 1px solid #dadce0;
  border-radius: 4px;
  padding: 0 16px;
  background: #fff;
  outline: none;
}
.field input:focus { border: 2px solid var(--blue); padding: 0 15px; }
.login-err { color: var(--danger); min-height: 20px; font-size: 13px; margin: -8px 0 12px; }
.login-actions { display: flex; justify-content: flex-end; margin-top: 24px; }
.btn-blue {
  background: var(--blue);
  color: #fff;
  border: 0;
  border-radius: 20px;
  padding: 10px 24px;
  font-weight: 500;
}
.btn-blue:hover { background: var(--blue-hover); }
.btn-blue:disabled { opacity: .6; cursor: wait; }

/* Shell */
#app { display: none; height: 100%; flex-direction: column; }
html.authed #app { display: flex; }
html.authed #login { display: none; }

header.top {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 8px 8px;
  flex: 0 0 auto;
}
.icon-btn {
  width: 40px; height: 40px;
  border: 0; background: transparent;
  border-radius: 50%;
  color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--nav-hover); }
.icon-btn svg { width: 24px; height: 24px; fill: currentColor; }
.brand {
  display: flex; align-items: center; gap: 8px;
  min-width: 180px; text-decoration: none; color: inherit;
  padding-inline-end: 12px;
}
.brand .word {
  font-size: 22px; color: #5f6368; font-weight: 400; letter-spacing: .15px;
}
.search-wrap {
  flex: 1; max-width: 720px; position: relative;
}
.search-wrap input {
  width: 100%; height: 46px;
  border: 0; border-radius: 24px;
  background: var(--search);
  padding: 0 52px;
  outline: none;
}
.search-wrap input:focus {
  background: var(--search-focus);
  box-shadow: 0 1px 3px rgba(60,64,67,.3), 0 4px 8px 3px rgba(60,64,67,.15);
}
.search-wrap .s-icon {
  position: absolute; inset-inline-start: 12px; top: 3px;
}
.search-wrap .s-clear {
  position: absolute; inset-inline-end: 8px; top: 3px;
}
.header-right {
  margin-inline-start: auto;
  display: flex; align-items: center; gap: 2px;
}
.app-switch {
  display: inline-flex;
  align-items: center;
  background: #e8eaed;
  border-radius: 22px;
  padding: 3px;
  flex: 0 0 auto;
  margin-inline-end: 4px;
}
.app-switch a {
  height: 36px;
  padding: 0 16px;
  border-radius: 19px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  color: #444746;
  display: inline-flex;
  align-items: center;
}
.app-switch a:hover { color: #1f1f1f; background: rgba(255,255,255,.45); }
.app-switch a.on {
  background: #fff;
  color: #0b57d0;
  box-shadow: 0 1px 2px rgba(60,64,67,.3);
}
.app-switch a.on:hover { background: #fff; }
.nav-item.jump-crm {
  height: 40px;
  margin: 0 0 10px;
  background: #f0fdfa;
  color: #0f766e;
  font-weight: 600;
}
.nav-item.jump-crm svg { fill: #0f766e; }
.nav-item.jump-crm:hover { background: #ccfbf1; }
.nav-item.jump-crm .jump-ic { display: inline-flex; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: #7b1fa2; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 500; font-size: 14px;
  margin: 0 8px;
}

.shell { display: flex; flex: 1; min-height: 0; }

nav.side {
  width: var(--nav-w);
  flex: 0 0 var(--nav-w);
  padding: 0 12px 16px 0;
  overflow: auto;
}
.compose {
  height: 56px;
  margin: 8px 0 16px 8px;
  padding: 0 24px 0 16px;
  border: 0;
  border-radius: 16px;
  background: #c2e7ff;
  color: #001d35;
  display: inline-flex; align-items: center; gap: 12px;
  font-weight: 500; font-size: 14px;
  box-shadow: none;
}
.compose:hover { box-shadow: var(--shadow-compose); background: #b3dffc; }
.compose .c-icon { display: inline-flex; }
.compose .c-icon svg { width: 24px; height: 24px; fill: #001d35; }

.nav-item {
  height: 32px;
  display: flex; align-items: center; gap: 18px;
  padding: 0 12px 0 26px;
  border: 0;
  background: transparent;
  border-radius: 0 16px 16px 0;
  width: 100%;
  color: var(--ink);
  font-size: 14px;
  text-align: start;
}
html[dir="rtl"] .nav-item { border-radius: 16px 0 0 16px; }
.nav-item svg { width: 20px; height: 20px; fill: #444746; flex: 0 0 auto; }
.nav-item .label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item .count { color: var(--muted); font-size: 14px; font-weight: 700; }
.nav-item:hover { background: var(--nav-hover); }
.nav-item.active {
  background: var(--nav-active);
  font-weight: 700;
}
.nav-item.active svg { fill: #041e49; }
.nav-sec {
  margin: 16px 0 6px 26px;
  font-size: 14px; font-weight: 500; color: var(--ink);
}
.dot {
  width: 12px; height: 12px; border-radius: 2px; flex: 0 0 auto;
}

main.main {
  flex: 1; min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
  border-radius: 16px 0 0 0;
  margin-inline-end: 0;
}
html[dir="rtl"] main.main { border-radius: 0 16px 0 0; }

.toolbar {
  height: 48px;
  display: flex; align-items: center; gap: 2px;
  padding: 0 8px;
  flex: 0 0 auto;
}
#listTools, #mailTools { display: flex; align-items: center; }
.toolbar .grow { flex: 1; }
.page-info { color: var(--muted); font-size: 12px; padding: 0 8px; }

.list {
  flex: 1; overflow: auto; min-height: 0;
  border-top: 1px solid transparent;
}
.row {
  display: grid;
  grid-template-columns: 40px 32px 28px 28px minmax(140px, 200px) 1fr 108px;
  align-items: center;
  height: var(--row-h);
  padding: 0 8px 0 4px;
  border-bottom: 1px solid #eceff1;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
}
.row.unread {
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  box-shadow: inset 0 -1px 0 #eceff1;
}
.row:hover { background: var(--row-hover); box-shadow: inset 1px 0 0 var(--row-hover), inset -1px 0 0 var(--row-hover), 0 1px 2px 0 rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15); z-index: 1; position: relative; }
.row.selected { background: var(--row-selected); }
.row .who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-inline-end: 12px; }
.row .mid { display: flex; min-width: 0; align-items: baseline; gap: 6px; }
.row .subj { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sep { color: var(--faint); font-weight: 400; }
.row .snip { color: var(--faint); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .labs { display: flex; gap: 4px; flex: 0 0 auto; }
.lab-chip {
  font-size: 11px; font-weight: 500; padding: 0 6px; height: 18px;
  border-radius: 4px; display: inline-flex; align-items: center;
  color: #1f1f1f;
}
.row .end { display: flex; justify-content: flex-end; align-items: center; min-width: 0; }
.row .when { text-align: end; font-size: 12px; padding-inline-end: 8px; white-space: nowrap; }
.row.unread .when { font-weight: 700; color: var(--ink); }
.row .hover-acts { display: none; justify-content: flex-end; gap: 0; }
.row:hover .when { display: none; }
.row:hover .hover-acts { display: flex; }
.cust-row-btn { color: #5f6368; }
.cust-row-btn.has-phone { color: #137333; }
.cust-row-btn svg { width: 20px; height: 20px; fill: currentColor; }
.star, .imp {
  border: 0; background: transparent; color: #b9b9b9;
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}
.star:hover, .imp:hover { background: var(--nav-hover); }
.star.on { color: var(--star); }
.imp.on { color: var(--important); }
.star svg, .imp svg { width: 20px; height: 20px; fill: currentColor; }
.phone-mark {
  border: 0; background: transparent;
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #c4c7c5;
}
.phone-mark svg { width: 18px; height: 18px; fill: currentColor; }
.phone-mark:hover { background: var(--nav-hover); }
.phone-mark.on { color: #1e8e3e; }
.phone-mark.off { color: #b9b9b9; }
.phone-mark.off:hover { color: #80868b; }
.phone-mark.copied { color: var(--blue); background: var(--chip); }
.row.has-phone .who { color: inherit; }
.check {
  width: 18px; height: 18px; accent-color: var(--blue);
  margin: 0 11px;
}

.empty {
  padding: 80px 24px; text-align: center; color: var(--muted);
}
.empty h2 { font-weight: 400; color: var(--ink); margin: 0 0 8px; }

.thread {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  background: var(--bg);
}
.thread-head {
  padding: 8px 16px 8px 72px;
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
}
.thread-head h2 {
  font-size: 22px; font-weight: 400; margin: 0; flex: 1; min-width: 140px;
}
.cust-pop {
  position: fixed; inset: 0; background: rgba(32,33,36,.6);
  z-index: 40; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.cust-pop.hidden { display: none !important; }
.cust-pop-card {
  position: relative;
  width: min(400px, 92vw);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 10px 1px rgba(0,0,0,.14), 0 3px 14px 2px rgba(0,0,0,.12), 0 5px 5px -3px rgba(0,0,0,.2);
  padding: 20px 12px 12px;
  text-align: start;
}
.cust-pop-close {
  position: absolute; top: 8px; inset-inline-end: 8px;
  color: #5f6368;
}
.cust-pop-close svg { width: 20px; height: 20px; fill: currentColor; }
.cust-wrap { position: relative; flex: 0 0 auto; }
.cust-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 10px 0 12px;
  border: 1px solid #dadce0; background: #fff;
  border-radius: 18px; color: #1f1f1f;
  font-weight: 500; font-size: 14px; white-space: nowrap;
}
.cust-btn svg { width: 18px; height: 18px; fill: #5f6368; }
.cust-btn:hover { background: #f6f8fc; box-shadow: 0 1px 2px 0 rgba(60,64,67,.3); }
.cust-btn.crm-add { border-color: #99f6e4; background: #f0fdfa; }
.cust-btn.crm-add svg { fill: #0f766e; }
.cust-btn.crm-open { border-color: #99f6e4; }
.cust-btn.has-phone { border-color: #ceead6; background: #f0faf3; }
.cust-btn.has-phone svg { fill: #137333; }
.cust-pop-card > .cust-btn { margin: 12px 8px 4px; }
.cust-btn.no-phone { border-color: #e1e3e1; }
.cust-flag {
  width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}
.cust-flag svg { width: 14px; height: 14px; }
.cust-flag.on { background: #ceead6; color: #137333; }
.cust-flag.on svg { fill: #137333; }
.cust-flag.off { background: #f1f3f4; color: #80868b; }
.cust-flag.off svg { fill: #80868b; }
.cust-card {
  background: #fff;
  border-radius: 12px;
  padding: 0;
  text-align: start;
}
.cust-hero {
  display: flex; align-items: center; gap: 14px;
  padding: 4px 12px 14px;
}
.cust-av {
  width: 56px; height: 56px; border-radius: 50%;
  background: #1a73e8; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 500; flex: 0 0 auto;
}
.cust-av.ok { background: #137333; }
.cust-name { font-size: 18px; font-weight: 500; line-height: 1.3; }
.cust-status { font-size: 13px; margin-top: 2px; color: var(--muted); }
.cust-status.ok { color: #137333; font-weight: 500; }
.cust-status.miss { color: #5f6368; }
.cust-rows { padding: 0 4px 4px; }
.cust-row {
  display: flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 4px 8px; border-radius: 8px;
}
.cust-row:hover { background: #f6f8fc; }
.cust-k {
  width: 96px; flex: 0 0 96px;
  color: var(--muted); font-size: 12px; font-weight: 500;
}
.cust-v {
  flex: 1; min-width: 0;
  color: var(--ink); font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-decoration: none;
}
a.cust-v:hover { color: var(--blue); text-decoration: underline; }
.cust-v.miss { color: var(--faint); font-style: italic; }
.cust-copy { width: 32px; height: 32px; color: #5f6368; }
.cust-copy svg { width: 18px; height: 18px; fill: currentColor; }
.cust-copy.copied { color: var(--blue); }
.thread-scroll { flex: 1; overflow: auto; padding: 0 16px 24px 16px; }
.msg-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 2px 0 rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
  margin: 0 56px 8px;
  padding: 12px 16px 16px;
}
.msg-card.collapsed {
  cursor: pointer;
  padding: 8px 16px;
  box-shadow: none;
  border-bottom: 1px solid #eceff1;
  border-radius: 0;
  background: transparent;
  margin: 0 56px;
}
.msg-top { display: flex; gap: 12px; align-items: flex-start; }
.av {
  width: 40px; height: 40px; border-radius: 50%;
  background: #1a73e8; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 500; flex: 0 0 auto;
}
.av.out { background: #188038; }
.who-block { flex: 1; min-width: 0; }
.who-line { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.who-line .name { font-weight: 700; }
.who-line .addr { color: var(--faint); font-size: 12px; }
.who-line .dt { margin-inline-start: auto; color: var(--muted); font-size: 12px; }
.msg-body {
  margin: 12px 0 0 52px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  direction: ltr; text-align: left;
  font-size: 14px; line-height: 1.55;
  color: #222;
}
.msg-card.collapsed .msg-body { display: none; }
.msg-card.collapsed .who-line .addr { display: none; }
.quote { margin-top: 12px; color: var(--faint); font-size: 12px; direction: ltr; text-align: left; }
.quote summary { cursor: pointer; }
.job-fail { color: var(--danger); margin-top: 8px; }

.reply-box {
  margin: 12px 56px 24px;
  background: #fff;
  border: 1px solid #dadce0;
  border-radius: 8px;
  padding: 12px 16px;
}
.reply-box textarea {
  width: 100%; min-height: 120px; border: 0; resize: vertical; outline: none;
  direction: ltr; text-align: left;
}
.reply-acts { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.send {
  background: var(--blue); color: #fff; border: 0;
  border-radius: 18px; padding: 8px 24px; font-weight: 500;
}
.send:hover { background: var(--blue-hover); }
.send:disabled { opacity: .6; }
.ghost {
  border: 0; background: transparent; color: var(--muted);
  border-radius: 18px; padding: 8px 12px;
}
.ghost:hover { background: var(--nav-hover); }

.notes {
  margin: 0 56px 16px;
  color: var(--muted); font-size: 13px;
}
.notes textarea {
  width: 100%; min-height: 52px; border: 1px solid #dadce0; border-radius: 8px;
  padding: 8px 10px; background: #fff;
}

/* Compose popup — Gmail */
.compose-win {
  position: fixed;
  inset-inline-end: 16px;
  bottom: 0;
  width: 480px;
  height: 540px;
  background: #fff;
  border-radius: 8px 8px 0 0;
  box-shadow: 0 8px 10px 1px rgba(0,0,0,.14), 0 3px 14px 2px rgba(0,0,0,.12), 0 5px 5px -3px rgba(0,0,0,.2);
  display: flex; flex-direction: column;
  z-index: 20;
}
.compose-win.min { height: 48px; }
.cw-top {
  background: #404040; color: #fff;
  border-radius: 8px 8px 0 0;
  height: 48px;
  display: flex; align-items: center;
  padding: 0 8px 0 16px;
  font-weight: 500;
  cursor: move;
}
.cw-top .grow { flex: 1; }
.cw-top .icon-btn { color: #fff; width: 32px; height: 32px; }
.cw-top .icon-btn:hover { background: #5f5f5f; }
.cw-field {
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid #eceff1;
  padding: 0 16px; height: 40px;
}
.cw-field label { color: var(--faint); font-size: 13px; width: 44px; flex: 0 0 44px; }
.cw-field input, .cw-field select {
  flex: 1; border: 0; outline: none; background: transparent; min-width: 0;
}
.cw-body {
  flex: 1; border: 0; outline: none; padding: 12px 16px;
  resize: none; direction: ltr; text-align: left;
}
.cw-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px 12px;
}

.menu {
  position: absolute;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 2px 6px 2px rgba(60,64,67,.15);
  padding: 8px 0;
  z-index: 30;
  min-width: 240px;
}
.menu button {
  display: block; width: 100%; text-align: start;
  border: 0; background: transparent;
  padding: 8px 16px; color: var(--ink);
}
.menu button:hover { background: #f1f3f4; }
.menu .hint { float: inline-end; color: var(--faint); font-size: 12px; }

.overlay {
  position: fixed; inset: 0; background: transparent; z-index: 25;
}

.kbd {
  position: fixed; inset: 0; background: rgba(32,33,36,.6);
  z-index: 40; display: flex; align-items: center; justify-content: center;
}
.kbd-card {
  background: #fff; border-radius: 8px; width: min(720px, 92vw);
  max-height: 80vh; overflow: auto; padding: 20px 24px;
}
.kbd-card h3 { margin: 0 0 12px; font-weight: 500; }
.kbd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px; }
.kbd-grid div { display: flex; justify-content: space-between; gap: 16px; padding: 4px 0; border-bottom: 1px solid #f1f3f4; }
.kbd-grid kbd {
  background: #f1f3f4; border-radius: 4px; padding: 1px 6px;
  font-family: Roboto, monospace; font-size: 12px;
}

a.nav-item { text-decoration: none; color: inherit; }
.nav-item.add { color: var(--muted); margin-top: 8px; }
.nav-item.add .add-ic { display: inline-flex; width: 20px; height: 20px; flex: 0 0 auto; }
.nav-item.add .add-ic svg { width: 20px; height: 20px; fill: #444746; }

.acct-add {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  margin: 8px 16px 4px; padding: 8px 18px;
  border: 1px solid #dadce0; background: #fff; border-radius: 20px;
  color: #1f1f1f; font-weight: 500; text-decoration: none; font-size: 14px;
}
.acct-add:hover { background: #f6f8fc; }
.acct-add .add-ic, .acct-add svg { width: 20px; height: 20px; fill: #5f6368; display: inline-flex; }

.cw-add {
  color: var(--blue); text-decoration: none; font-size: 13px; font-weight: 500;
  white-space: nowrap; padding: 0 4px;
}
.cw-add:hover { text-decoration: underline; }

.acct {
  position: absolute; top: 56px; inset-inline-end: 12px;
  background: #fff; border-radius: 28px;
  box-shadow: 0 4px 8px 3px rgba(60,64,67,.15);
  width: 354px; padding: 20px 8px 12px; z-index: 30;
  text-align: center;
}
.acct .big {
  width: 80px; height: 80px; border-radius: 50%;
  background: #7b1fa2; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; margin: 0 auto 8px;
}
.acct .mail { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.acct .signout {
  border: 1px solid #dadce0; background: #fff; border-radius: 20px;
  padding: 8px 20px; margin: 8px auto 12px;
}

.status-sel {
  border: 1px solid #dadce0; border-radius: 16px; padding: 4px 10px;
  background: #fff;
}

@media (max-width: 900px) {
  nav.side { width: 72px; flex-basis: 72px; }
  .nav-item .label, .nav-item .count, .nav-sec, .compose span, .brand .word, .nav-item.add .label { display: none; }
  .compose { width: 56px; height: 56px; padding: 0; justify-content: center; border-radius: 16px; margin: 8px; }
  .brand { min-width: 0; padding-inline-end: 4px; }
  .app-switch a { padding: 0 12px; }
  .msg-card, .msg-card.collapsed, .reply-box, .notes { margin-inline: 8px; }
  .thread-head { padding-inline-start: 8px; }
  .row { grid-template-columns: 36px 28px 0 28px minmax(80px, 120px) 1fr 72px; }
  .imp { display: none; }
  .compose-win { width: 100%; inset-inline: 0; }
}
