:root {
  --bg: #f6f6f9;
  --panel: #ffffff;
  --line: #e3e4ec;
  --text: #121a2c;
  --muted: #5d6b85;
  --accent: #c106b1;
  --accent-hover: #a10594;
  --accent-soft: #fbe9f9;
  --green: #16a34a;
  --green-hover: #15913f;
  --red: #dc2626;
  --red-hover: #c21f1f;
  --key: #f1f1f6;
  --key-hover: #e6e6ef;
  --key-press: #d9d9e6;
  --shadow: 0 1px 2px rgba(18, 26, 44, .06), 0 8px 24px rgba(18, 26, 44, .06);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ---------- basics ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.centered {
  max-width: 340px;
  margin: 12vh auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

h1 { font-size: 22px; margin: 0 0 8px; text-align: center; color: var(--accent); }

/* ---------- branding ---------- */

.login-card { max-width: 360px; padding: 32px 28px; }
.login-logo { display: block; height: 52px; width: auto; margin: 0 auto 6px; }
.login-card h1 { margin: 8px 0 0; font-size: 20px; color: var(--text); }
.login-sub { margin: 0 0 8px; text-align: center; font-size: 13px; color: var(--muted); }

.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { display: block; height: 30px; width: auto; }
.brand-divider { width: 1px; height: 24px; background: var(--line); }
h2 { font-size: 20px; margin: 0; }
h3 { font-size: 16px; margin: 0 0 12px; }

input, select {
  width: 100%;
  padding: 11px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 15px;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

button {
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 10px 14px;
  font-size: 15px;
}

button:hover { background: var(--key); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.link { background: none; border: none; color: var(--muted); }
button.link:hover { color: var(--accent); }

.msg { color: var(--muted); min-height: 22px; font-size: 14px; margin: 4px 0 0; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 12px; }

/* ---------- header ---------- */

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

header strong { color: var(--text); font-size: 16px; font-weight: 600; letter-spacing: -.2px; }
header nav { margin-left: auto; display: flex; gap: 6px; }

.signout {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 10px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  position: relative;
}

/* thin divider between the tabs and Sign out */
.signout::before {
  content: "";
  position: absolute;
  left: -11px;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: var(--line);
}

.signout:hover { color: var(--red); border-color: #f3c3bf; background: #fff5f4; }

button.tab { border-color: transparent; background: none; color: var(--muted); font-weight: 500; }
button.tab:hover { background: var(--key); color: var(--text); }
button.tab.active { background: var(--accent-soft); color: var(--accent); }

.pill {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: var(--key);
  border-radius: 999px;
  padding: 2px 10px;
}

.pill.ok { color: #0f7a36; background: #dcf7e6; }
.pill.bad { color: #b42318; background: #fde6e4; }

.view { padding: 20px; }

/* ---------- phone ---------- */

.phone {
  max-width: 360px;
  margin: 8px auto 0;
  padding: 22px 24px 26px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.from-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  padding: 4px 6px 4px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.from-chip select {
  width: auto;
  min-width: 0;
  max-width: 230px;
  padding: 4px 8px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.from-chip select:focus { box-shadow: none; }

.display {
  position: relative;
  display: flex;
  align-items: center;
  margin-top: 18px;
}

.display input {
  border: none;
  background: none;
  text-align: center;
  font-size: 30px;
  font-weight: 500;
  letter-spacing: .5px;
  padding: 6px 44px;
  font-variant-numeric: tabular-nums;
}

.display input:focus { box-shadow: none; }
.display input::placeholder { color: #aab4c6; font-size: 22px; font-weight: 400; }

.icon-btn {
  position: absolute;
  right: 0;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--muted);
}

.icon-btn:hover { background: var(--key); color: var(--text); }

.dial-hint {
  margin: 4px 0 6px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.dial-hint b { color: var(--accent); }

.call-info {
  min-height: 48px;
  text-align: center;
}

.call-info .msg { margin: 0; }

.timer {
  display: block;
  font-size: 18px;
  font-weight: 600;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  justify-content: center;
  gap: 16px 26px;
  margin: 6px 0 24px;
}

.keypad button {
  width: 72px;
  height: 72px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--key);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  user-select: none;
  transition: background .12s, transform .08s;
}

.keypad button:hover { background: var(--key-hover); }
.keypad button:active, .keypad button.pressed { background: var(--key-press); transform: scale(.95); }

.keypad b { font-size: 28px; font-weight: 500; }
.keypad small { margin-top: 3px; font-size: 10px; font-weight: 600; letter-spacing: 1.5px; color: var(--muted); }

.call-row {
  display: grid;
  grid-template-columns: 72px 72px 72px;
  justify-content: center;
  align-items: center;
  column-gap: 26px;
}

.round-btn {
  grid-row: 1;
  width: 72px;
  height: 72px;
  padding: 0;
  border: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  transition: background .12s, transform .08s;
}

.round-btn:active { transform: scale(.95); }

.round-btn.call { grid-column: 2; background: var(--green); box-shadow: 0 6px 16px rgba(22, 163, 74, .35); }
.round-btn.call:hover { background: var(--green-hover); }

.round-btn.hangup { grid-column: 2; background: var(--red); box-shadow: 0 6px 16px rgba(220, 38, 38, .35); }
.round-btn.hangup:hover { background: var(--red-hover); }

.round-btn.mute {
  grid-column: 1;
  width: 60px;
  height: 60px;
  justify-self: center;
  align-content: center;
  gap: 2px;
  background: var(--key);
  color: var(--text);
  font-size: 10px;
  font-weight: 600;
}

.round-btn.mute:hover { background: var(--key-hover); }
.round-btn.mute.on { background: var(--text); color: #fff; }

.round-spacer { grid-column: 3; }

/* ---------- history ---------- */

.totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.totals div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.totals span { display: block; font-size: 26px; font-weight: 700; color: var(--accent); }
.totals div:nth-child(2) span { color: var(--green); }
.totals label { color: var(--muted); font-size: 13px; }

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.filters input[type=search] { flex: 1 1 150px; width: auto; min-width: 0; }
.filters select { flex: 0 1 150px; width: auto; min-width: 0; }
.filters button { flex: none; }

.date-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.date-filter input { width: auto; padding: 9px 10px; }

.table-wrap {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-top: 10px;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 14px; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; background: #f8faff; }
tr:last-child td { border-bottom: none; }

/* ---------- settings ---------- */


.settings { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.settings-head { display: flex; align-items: center; gap: 12px; }
.settings-head .msg { margin: 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.grid label, label.block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

label.block { margin: 8px 0 14px; }

.field-hint { font-size: 12px; font-weight: 400; color: var(--muted); }

.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; background: #f8faff; }

.number-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }

.number-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(0, 1.3fr);
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.number-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- small screens ---------- */

@media (max-width: 560px) {
  header { flex-wrap: wrap; padding: 10px 16px; }
  header nav { margin-left: 0; order: 3; width: 100%; }
  .signout { margin-left: auto; }
  .signout::before { display: none; }
  .view { padding: 16px; }
  .phone { padding: 18px 12px 22px; border-radius: 22px; }
  .keypad { grid-template-columns: repeat(3, 64px); gap: 14px 22px; }
  .keypad button, .round-btn.call, .round-btn.hangup { width: 64px; height: 64px; }
  .call-row { grid-template-columns: 64px 64px 64px; column-gap: 22px; }
  .number-row { grid-template-columns: auto 1fr; }
  .number-row .label-input { grid-column: 1 / -1; }
}

.auto-setup {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 14px;
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: #f0fbf4;
  border: 1px solid #c9eed6;
  font-size: 13px;
}

.auto-setup dt { color: var(--muted); font-weight: 600; }
.auto-setup dd { margin: 0; font-family: ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }

/* ---------- show / hide sensitive values ---------- */

.secret-field { position: relative; display: block; }
.secret-field input { padding-right: 44px; }
.secret-field .eye-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }

.secret-text { display: flex; align-items: center; gap: 6px; }

.eye-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--muted);
}

.eye-btn:hover { background: var(--key); color: var(--text); }
.eye-btn .eye-closed { display: none; }
.eye-btn.shown .eye-open { display: none; }
.eye-btn.shown .eye-closed { display: block; }

/* ---------- incoming calls ---------- */

.tab-badge {
  display: inline-block;
  min-width: 18px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  vertical-align: 1px;
}

.missed-banner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  max-width: 1100px;
  margin: 16px auto 0;
  padding: 14px 16px;
  border: 1px solid #f5c2c0;
  border-left: 5px solid var(--red);
  border-radius: 12px;
  background: #fff4f3;
  box-shadow: var(--shadow);
}

.missed-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  animation: missed-pulse 2s ease-in-out infinite;
}

@keyframes missed-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .45); }
  50% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}

.missed-body { flex: 1; min-width: 0; }
.missed-body strong { display: block; color: #9f1d17; font-size: 15px; margin-bottom: 4px; }

.missed-body ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

.missed-body li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.missed-who { flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; }
.missed-when { color: var(--muted); font-size: 12px; margin-left: 4px; }
.missed-more { color: var(--muted); font-size: 13px; }

.missed-call {
  padding: 5px 12px;
  border-color: var(--green);
  background: var(--green);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.missed-call:hover { background: var(--green-hover); }
.missed-dismiss { padding: 2px 8px; font-size: 18px; line-height: 1; }
#missedDismissAll { flex: none; font-size: 13px; }

.incoming-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(18, 26, 44, .55);
  backdrop-filter: blur(3px);
}

.incoming-card {
  width: 100%;
  max-width: 360px;
  padding: 28px 24px 22px;
  border-radius: 24px;
  background: var(--panel);
  text-align: center;
  box-shadow: 0 24px 60px rgba(18, 26, 44, .35);
}

.incoming-ring {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  animation: ring-pulse 1.2s ease-out infinite;
}

.incoming-ring svg { animation: ring-shake 1.2s ease-in-out infinite; }

@keyframes ring-pulse {
  0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .55); }
  100% { box-shadow: 0 0 0 22px rgba(22, 163, 74, 0); }
}

@keyframes ring-shake {
  0%, 50%, 100% { transform: rotate(0); }
  10%, 30% { transform: rotate(-14deg); }
  20%, 40% { transform: rotate(14deg); }
}

.incoming-label { margin: 0; color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; }
.incoming-number { margin: 6px 0 2px; font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.incoming-to { margin: 0 0 20px; color: var(--muted); font-size: 14px; min-height: 20px; }

.incoming-actions { display: flex; justify-content: center; gap: 48px; }

.incoming-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: none;
  background: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.incoming-btn:hover { background: none; }

.incoming-btn .round {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  color: #fff;
  font-size: 30px;
  line-height: 1;
  transition: transform .08s, background .12s;
}

.incoming-btn:active .round { transform: scale(.95); }
.incoming-btn.answer .round { background: var(--green); box-shadow: 0 6px 16px rgba(22, 163, 74, .35); }
.incoming-btn.answer:hover .round { background: var(--green-hover); }
.incoming-btn.dismiss .round { background: #6b7280; }
.incoming-btn.dismiss:hover .round { background: #4b5563; }

.incoming-note { margin: 18px 0 0; color: var(--muted); font-size: 12px; }

/* history */

.total-missed span { color: var(--red); }

.type-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.type-badge.outgoing { background: var(--accent-soft); color: var(--accent); }
.type-badge.incoming { background: #dcf7e6; color: #0f7a36; }
.type-badge.missed { background: #fde6e4; color: #b42318; }

.row-missed td { background: #fffafa; }
td .sub { color: var(--muted); font-size: 12px; }

.row-call { padding: 5px 10px; font-size: 13px; white-space: nowrap; }
.row-call:hover { border-color: var(--green); color: var(--green); background: #f0fbf4; }

/* settings */

.switch-row { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-weight: 500; cursor: pointer; }
.switch-row input { width: 18px; height: 18px; accent-color: var(--accent); }

h3 .pill { margin-left: 8px; vertical-align: 2px; }

.hint-list { margin: 12px 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.hint-list li { margin: 3px 0; }

.auto-setup.plain { margin: 0 0 14px; }

@media (max-width: 560px) {
  .missed-banner { margin: 12px 16px 0; flex-wrap: wrap; }
  .incoming-actions { gap: 32px; }
}
