/* My Cloud Phone — visual language from template */
:root {
  --bg: #eef6fb;
  --surface: #ffffff;
  --ink: #1e3346;
  --muted: #5e7285;
  --faint: #8096a8;
  --line: rgba(18, 62, 92, 0.16);
  --orange: #f26522;
  --orange-deep: #ea5b15;
  --orange-ink: #b8500f;
  --blue: #1b8dc4;
  --blue-ink: #11648f;
  --danger: #c6322a;
  --ok: #17794f;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(18, 62, 92, 0.12);
  --font: "Manrope", "Segoe UI", sans-serif;
  --mono: "Roboto Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(27, 141, 196, 0.18), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(242, 101, 34, 0.16), transparent 55%),
    var(--bg);
  min-height: 100vh;
}

button, input, select, textarea { font: inherit; }
a { color: var(--blue-ink); }
.hidden { display: none !important; }
button:focus-visible, input:focus-visible { outline: 2px solid rgba(27,141,196,.45); outline-offset: 2px; }

#app { min-height: 100vh; }

/* —— Login —— */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(920px, 100%);
  background: var(--surface);
  border: 2px solid var(--blue);
  border-radius: 28px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  overflow: hidden;
}
.login-form { padding: 36px 34px; display: flex; flex-direction: column; gap: 14px; }
.brand-row { display: flex; align-items: center; gap: 12px; }
.brand-row img { height: 42px; width: auto; }
.brand-row h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.brand-row p { font-size: 13px; color: var(--muted); }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #f8fcff;
  outline: none;
}
.field input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(27,141,196,.15); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); }
.checkbox { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.captcha {
  display: flex; align-items: center; justify-content: space-between;
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer;
}
.captcha-box {
  width: 22px; height: 22px; border-radius: 6px; border: 2px solid #9bb1c4;
  display: grid; place-items: center; font-weight: 900; color: #fff; font-size: 13px;
}
.captcha-box.on { background: var(--ok); border-color: var(--ok); }
.btn-primary {
  background: linear-gradient(135deg, #ff8a3d, var(--orange-deep));
  color: #fff; font-weight: 800; font-size: 15px; text-align: center;
  padding: 13px; border-radius: 999px; border: 0; cursor: pointer;
  box-shadow: 0 10px 26px rgba(234, 91, 21, 0.32);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.hint { font-size: 12px; color: var(--faint); text-align: center; }
.error-banner {
  background: #fff1f0; color: var(--danger); border: 1px solid #f5c2c0;
  border-radius: 10px; padding: 10px 12px; font-size: 13px;
}
.login-aside {
  padding: 44px 34px;
  background: linear-gradient(160deg, rgba(242,101,34,.10), rgba(27,141,196,.10));
  border-left: 1px solid rgba(18,62,92,.10);
  display: flex; flex-direction: column; justify-content: center; gap: 16px;
}
.login-aside .illus {
  height: 150px; border: 1px dashed rgba(18,62,92,.24); border-radius: 16px;
  display: grid; place-items: center; overflow: hidden; background: rgba(255,255,255,.55);
}
.login-aside .illus img { max-height: 110px; }
.login-aside h2 { font-size: 20px; font-weight: 800; line-height: 1.25; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1px solid rgba(18,62,92,.20); border-radius: 999px;
  padding: 4px 11px; font-size: 12px; color: #3e5567;
}

/* —— App shell —— */
.shell {
  max-width: 1360px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 14px;
  min-height: 100vh;
}
.side-nav {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  box-shadow: var(--shadow);
}
.side-nav .logo-mini { display: grid; place-items: center; padding: 8px 0 14px; }
.side-nav .logo-mini img { width: 40px; height: 40px; object-fit: contain; }
.nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  border-radius: 14px; padding: 9px 4px; text-align: center;
  font-size: 11px; cursor: pointer; line-height: 1.25;
  font-weight: 700; color: var(--muted); border: 1px solid transparent; background: transparent;
}
.nav-btn.active {
  font-weight: 800; color: var(--orange-ink);
  border-color: rgba(242,101,34,.5); background: rgba(242,101,34,.10);
}
.nav-btn .ico { font-size: 18px; display: grid; place-items: center; }
.nav-btn .ico svg { width: 20px; height: 20px; }

.main-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 32px);
  overflow: hidden;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.topbar .who { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--orange));
  color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px;
  flex: none;
}
.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 700;
  border: 1px solid var(--line);
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #9bb1c4; }
.status-dot.online { background: #3fbf7f; box-shadow: 0 0 0 3px rgba(63,191,127,.25); }
.status-dot.busy { background: var(--orange); }
.status-dot.error { background: var(--danger); }

/* Contacts left · Phone right */
.content {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  min-height: 0;
}
.pane { padding: 18px; overflow: auto; }
.pane-contacts {
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #f7fbfe 0%, #ffffff 48%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}
.pane-phone { overflow: auto; }

.contacts-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.contacts-head h2 {
  font-size: 15px; font-weight: 800; letter-spacing: -0.01em;
}
.contacts-count {
  font-size: 11px; font-weight: 700; color: var(--blue-ink);
  background: rgba(27,141,196,.12); border-radius: 999px; padding: 3px 9px;
}
.contact-search {
  position: relative;
}
.contact-search svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--faint); pointer-events: none;
}
.contact-search input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px 11px 36px;
  background: #fff;
  outline: none;
}
.contact-search input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(27,141,196,.12);
}
.contact-list {
  display: flex; flex-direction: column; gap: 6px;
  overflow: auto; flex: 1; padding-right: 2px;
}
.contact-empty {
  text-align: center; color: var(--muted); font-size: 13px; padding: 28px 12px;
}
.contact-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 10px;
  background: rgba(255,255,255,.72);
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .12s;
}
.contact-row:hover {
  border-color: rgba(27,141,196,.28);
  background: #fff;
  transform: translateY(-1px);
}
.contact-row.active {
  border-color: rgba(242,101,34,.45);
  background: rgba(242,101,34,.08);
}
.contact-avatar {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; font-weight: 800; font-size: 12px; color: #fff;
  background: linear-gradient(135deg, #1b8dc4, #3aa4d4);
  position: relative;
}
.contact-avatar.sm { width: 32px; height: 32px; border-radius: 10px; font-size: 11px; }
.contact-avatar.tone-1 { background: linear-gradient(135deg, #1b8dc4, #3aa4d4); }
.contact-avatar.tone-2 { background: linear-gradient(135deg, #f26522, #ff8a3d); }
.contact-avatar.tone-3 { background: linear-gradient(135deg, #11648f, #2bb673); }
.contact-avatar.tone-4 { background: linear-gradient(135deg, #5b6cff, #1b8dc4); }
.presence-dot {
  position: absolute; right: -2px; bottom: -2px;
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid #fff;
  background: #9bb1c4;
}
.presence-dot.online { background: #3fbf7f; }
.presence-dot.offline { background: #9bb1c4; }

.contact-section { margin-bottom: 8px; }
.contact-section-head {
  width: 100%;
  display: flex; align-items: center; gap: 8px;
  border: 0; background: transparent; cursor: pointer;
  padding: 8px 4px; color: var(--muted); font-weight: 800; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.contact-section-head:hover { color: var(--ink); }
.contact-section-head .chev { width: 12px; color: var(--faint); }
.contact-section-head .sec-title { flex: 1; text-align: left; }
.contact-section-head .sec-count {
  font-size: 11px; font-weight: 700; color: var(--blue-ink);
  background: rgba(27,141,196,.1); border-radius: 999px; padding: 2px 8px;
  text-transform: none; letter-spacing: 0;
}
.contact-section-body { display: flex; flex-direction: column; gap: 6px; }
.contact-section-body.collapsed { display: none; }
.contact-more {
  border: 1px dashed var(--line); background: rgba(255,255,255,.7);
  border-radius: 12px; padding: 8px 10px; cursor: pointer;
  font-size: 12px; font-weight: 700; color: var(--blue-ink);
}
.contact-more:hover { background: #fff; border-color: rgba(27,141,196,.35); }
.contact-more.dim { color: var(--muted); }
.contact-meta { min-width: 0; }
.contact-meta .name {
  font-weight: 800; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.contact-meta .sub {
  font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px;
}
.contact-actions { display: flex; gap: 4px; }
.icon-mini {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; display: grid; place-items: center; cursor: pointer; color: var(--ink);
}
.icon-mini:hover { border-color: var(--blue); color: var(--blue-ink); background: #f3f9fd; }
.icon-mini.call:hover { border-color: var(--ok); color: var(--ok); }
.icon-mini svg { width: 16px; height: 16px; }

.dial-wrap { position: relative; }
.dial-display {
  width: 100%;
  font-family: var(--mono);
  font-size: 26px; font-weight: 600; letter-spacing: 0.04em;
  border: 1px solid var(--line); border-radius: 14px; padding: 14px 48px 14px 16px;
  background: #f7fbfe; min-height: 56px; outline: none; color: var(--ink);
}
.dial-display::placeholder { color: #9bb1c4; font-weight: 500; letter-spacing: 0; font-size: 18px; }
.dial-display:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(27,141,196,.12); }
.dial-clear {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border-radius: 9px; border: 0; background: transparent;
  color: var(--faint); cursor: pointer; display: grid; place-items: center;
}
.dial-clear:hover { color: var(--ink); background: rgba(18,62,92,.06); }

.keypad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px;
  max-width: 360px;
}
.key {
  border: 1px solid var(--line); border-radius: 16px; background: #fff;
  padding: 14px 8px; cursor: pointer; font-weight: 800; font-size: 20px;
}
.key:hover { background: #f3f9fd; }
.key:active { transform: scale(.98); }
.key small { display: block; font-size: 10px; color: var(--faint); font-weight: 600; letter-spacing: 0.08em; }

.call-actions {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; align-items: center;
  max-width: 420px;
}
.icon-ctrl {
  width: 52px; height: 52px; border-radius: 16px;
  border: 1px solid rgba(18,62,92,.18);
  background: #fff; color: var(--ink);
  display: inline-grid; place-items: center; cursor: pointer;
  transition: background .15s, border-color .15s, transform .12s, color .15s;
  position: relative;
}
.icon-ctrl svg { width: 22px; height: 22px; }
.icon-ctrl:hover { background: #f3f9fd; border-color: rgba(27,141,196,.35); }
.icon-ctrl:active { transform: scale(.96); }
.icon-ctrl.on {
  border-color: rgba(242,101,34,.7);
  background: rgba(242,101,34,.14);
  color: var(--orange-ink);
}
.icon-ctrl.call {
  width: 64px; height: 64px; border-radius: 20px;
  background: linear-gradient(145deg, #2bb673, var(--ok));
  border-color: transparent; color: #fff;
  box-shadow: 0 10px 22px rgba(23, 121, 79, .28);
}
.icon-ctrl.call:hover { filter: brightness(1.05); }
.icon-ctrl.end {
  background: var(--danger); border-color: transparent; color: #fff;
  box-shadow: 0 10px 22px rgba(198, 50, 42, .25);
}
.icon-ctrl:disabled { opacity: 0.4; cursor: not-allowed; filter: none; box-shadow: none; }
.icon-ctrl[data-tip]::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: #1e3346; color: #fff; font-size: 11px; font-weight: 700;
  padding: 4px 8px; border-radius: 8px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .12s;
}
.icon-ctrl:hover[data-tip]::after { opacity: 1; }

.section-title {
  font-size: 12px; font-weight: 800; color: var(--muted);
  margin: 18px 0 10px; text-transform: uppercase; letter-spacing: 0.06em;
}

.call-card, .line-card, .hist-row {
  border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px;
  background: #fbfdff;
}
.call-card.active { border-color: rgba(242,101,34,.55); background: rgba(242,101,34,.08); }
.call-card .meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.call-card .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.incoming-banner {
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(135deg, #fff7f0, #eef8ff);
  border: 1px solid rgba(242,101,34,.35);
  border-radius: 14px; padding: 12px 14px; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #1e3346; color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 13px; font-weight: 600; z-index: 1000; box-shadow: var(--shadow);
}

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(18, 62, 92, 0.45);
  display: grid; place-items: center; z-index: 900; padding: 16px;
}
.modal {
  width: min(440px, 100%); background: #fff; border-radius: 18px;
  padding: 22px; box-shadow: var(--shadow);
}
.transfer-modal { width: min(480px, 100%); }
.transfer-picker { margin-top: 4px; }
.transfer-results {
  margin-top: 8px;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fcff;
}
.transfer-result {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; cursor: pointer; text-align: left;
}
.transfer-result:last-child { border-bottom: 0; }
.transfer-result:hover { background: rgba(27,141,196,.08); }
.transfer-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.transfer-meta strong {
  font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.transfer-meta small { color: var(--muted); font-size: 12px; }
.modal h3 { margin-bottom: 10px; }
.modal p { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.btn-ghost {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 8px 14px; font-weight: 700; cursor: pointer;
}

.settings-grid { display: grid; gap: 12px; }
.settings-grid .field input, .settings-grid .field select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}

.video-stage {
  position: relative; background: #0f1c27; border-radius: 16px; overflow: hidden;
  aspect-ratio: 16/10; margin-bottom: 12px;
}
.video-stage video { width: 100%; height: 100%; object-fit: cover; }
.video-stage .local {
  position: absolute; right: 10px; bottom: 10px; width: 28%;
  border-radius: 10px; border: 2px solid rgba(255,255,255,.4); aspect-ratio: 4/3; object-fit: cover;
}

.ctrl {
  display: inline-flex; align-items: center; gap: 8px;
  border-radius: 999px; padding: 8px 16px; font-size: 13px; cursor: pointer;
  border: 1px solid rgba(18,62,92,.22); color: var(--ink); font-weight: 700; background: #fff;
}
.ctrl.on {
  border-color: rgba(242,101,34,.7); background: rgba(242,101,34,.14); color: var(--orange-ink);
}
.ctrl.end { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 800; }
.ctrl.call { background: var(--ok); border-color: var(--ok); color: #fff; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; padding: 10px; padding-bottom: 84px; }
  .side-nav {
    position: fixed; left: 10px; right: 10px; bottom: 10px; z-index: 50;
    flex-direction: row; justify-content: space-around; border-radius: 18px; padding: 8px;
  }
  .side-nav .logo-mini { display: none; }
  .content { grid-template-columns: 1fr; }
  .pane-contacts {
    border-right: 0; border-bottom: 1px solid var(--line);
    max-height: 280px;
  }
  .login-card { grid-template-columns: 1fr; }
  .login-aside { border-left: 0; border-top: 1px solid rgba(18,62,92,.10); }
  .keypad, .call-actions { max-width: none; }
}
