/* ==========================================================================
   ApnaCall — Business Dashboard
   Light, warm, consumer-friendly. Not the ops control-room look.
   ========================================================================== */

:root {
  /* Surface */
  --bg: #FAFAF8;
  --panel: #FFFFFF;
  --panel-2: #F4F3EF;
  --panel-raised: #EFEEE9;
  --border: #E7E5DF;
  --border-soft: #EFEDE7;

  /* Text */
  --text: #1E2420;
  --text-dim: #5C6560;
  --text-mute: #8B928D;

  /* Signal colors */
  --ok: #01BE68;
  --ok-dim: #01BE6814;
  --warn: #D97706;
  --warn-dim: #D9770614;
  --crit: #E5484D;
  --crit-dim: #E5484D14;
  --info: #0342E5;
  --info-dim: #0342E514;

  /* Accent — the ApnaCall brand gradient (blue -> green, from the logo) */
  --accent: #0342E5;
  --accent-2: #01BE68;
  --accent-dim: #0342E514;
  --accent-hover: #0233B8;
  --brand-gradient: linear-gradient(135deg, #0342E5 0%, #01BE68 100%);

  /* Secondary accent for WhatsApp-related surfaces */
  --wa: #25D366;
  --wa-dim: #25D36614;

  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;

  --sidebar-w: 240px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: light; }
html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button { font-family: inherit; cursor: pointer; }
table { border-collapse: collapse; width: 100%; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ==========================================================================
   App shell
   ========================================================================== */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "side   top"
    "side   main";
  height: 100vh;
  overflow: hidden;
}

/* ---- Sidebar ---- */
.sidebar {
  grid-area: side;
  background: var(--panel);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 0 0 12px;
  overflow-y: auto;
  height: 100%;
}

.brand {
  display: flex; align-items: center;
  padding: 18px 20px 16px;
}
.brand img.logo { height: 30px; width: auto; display: block; }
.brand-divider { height: 1px; background: var(--border-soft); margin: 0 20px 10px; }

.nav-group { padding: 6px 12px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13.5px; font-weight: 500;
  margin-bottom: 2px;
  transition: background .12s, color .12s;
  position: relative;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .75; }
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
.nav-item.active svg { opacity: 1; }
.nav-item .badge {
  margin-left: auto;
  font-size: 10.5px; font-weight: 700;
  background: var(--crit);
  color: #fff;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 17px; text-align: center;
}
.nav-item.active .badge { background: var(--accent); }

.sidebar-upsell {
  margin: 12px 12px 4px;
  padding: 14px;
  background: linear-gradient(135deg, var(--accent-dim), var(--ok-dim));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}
.sidebar-upsell .su-title { font-size: 12.5px; font-weight: 650; color: var(--text); margin-bottom: 3px; }
.sidebar-upsell .su-sub { font-size: 11px; color: var(--text-dim); line-height: 1.4; margin-bottom: 10px; }
.sidebar-upsell .su-btn {
  display: block; text-align: center;
  background: var(--brand-gradient); color: #fff;
  font-size: 11.5px; font-weight: 600;
  padding: 7px; border-radius: var(--radius-sm);
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 20px;
  border-top: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 10px;
  transition: opacity .12s;
}
.sidebar-footer:hover { opacity: 0.8; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-dim);
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700; color: var(--accent);
  flex-shrink: 0;
}
.sidebar-footer .who { display: flex; flex-direction: column; min-width: 0; }
.sidebar-footer .who .n { font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer .who .r { font-size: 11px; color: var(--text-mute); }

/* ---- Topbar ---- */
.topbar {
  grid-area: top;
  background: var(--panel);
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  z-index: 15;
}
.topbar .crumb { font-size: 15px; font-weight: 650; color: var(--text); }
.topbar .actions { display: flex; align-items: center; gap: 10px; }

.notif-btn {
  position: relative;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-dim);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.notif-btn:hover { background: var(--panel-2); color: var(--text); }
.notif-btn svg { width: 17px; height: 17px; }
.notif-btn .badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 16px; height: 16px; padding: 0 3px;
  border-radius: 20px;
  background: var(--crit);
  color: #fff;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--panel);
}

.topbar-profile {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 30px;
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer;
  transition: background .12s;
}
.topbar-profile:hover { background: var(--panel-2); }
.topbar-profile .avatar { width: 28px; height: 28px; font-size: 11px; }
.topbar-profile .tp-name { font-size: 12.5px; color: var(--text); font-weight: 600; }

.btn {
  font-size: 13px; font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  transition: background .12s, border-color .12s;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--panel-2); border-color: #D5D2C9; }
.btn.primary { background: var(--brand-gradient); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn.wa:hover { background: #1FB855; }
.btn.sm { padding: 6px 12px; font-size: 12px; }

/* ---- Main content ---- */
.main {
  grid-area: main;
  padding: 28px;
  overflow-y: auto;
  height: 100%;
}

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap; gap: 12px;
}
.page-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.page-head p { font-size: 13.5px; color: var(--text-mute); margin-top: 4px; }

/* ==========================================================================
   Components
   ========================================================================== */

/* ---- Today hero (signature element): status-segmented activity bar ---- */
.hero-today {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 0;
  margin-bottom: 22px;
  overflow: hidden;
}
.hero-today .ht-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 0;
}
.hero-today .ht-label { font-size: 13px; font-weight: 600; color: var(--text-dim); }
.hero-today .ht-live {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; color: var(--ok);
}
.hero-today .ht-live .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); animation: htpulse 2s ease-in-out infinite; }
@keyframes htpulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.hero-today .ht-body {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}
.hero-today .ht-stat {
  padding: 18px 24px 20px;
  border-right: 1px solid var(--border-soft);
  display: flex; align-items: flex-start; gap: 12px;
}
.hero-today .ht-stat:last-child { border-right: none; }
.hero-today .ht-stat .ht-icon {
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 2px;
}
.hero-today .ht-stat .ht-icon svg { width: 16px; height: 16px; }
.hero-today .ht-stat.answered .ht-icon { background: var(--ok-dim); color: var(--ok); }
.hero-today .ht-stat.missed .ht-icon { background: var(--crit-dim); color: var(--crit); }
.hero-today .ht-stat.wa .ht-icon { background: var(--wa-dim); color: #1A9F4E; }
.hero-today .ht-stat.balance .ht-icon { background: var(--accent-dim); color: var(--accent); }
.hero-today .ht-stat .n { font-size: 26px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.1; color: var(--text); }
.hero-today .ht-stat .n .unit { font-size: 13px; font-weight: 600; color: var(--text-mute); }
.hero-today .ht-stat .l { font-size: 11.5px; color: var(--text-mute); margin-top: 4px; font-weight: 500; }

.hero-today .ht-breakdown {
  border-top: 1px solid var(--border-soft);
  padding: 14px 24px 18px;
}
.hero-today .ht-breakdown .hb-label { font-size: 10.5px; color: var(--text-mute); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px; }
.hero-today .hb-track { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--panel-2); margin-bottom: 10px; }
.hero-today .hb-seg { height: 100%; }
.hero-today .hb-legend { display: flex; gap: 18px; flex-wrap: wrap; }
.hero-today .hb-legend-item { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-dim); }
.hero-today .hb-legend-item .sw { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.hero-today .hb-legend-item .cnt { font-weight: 700; color: var(--text); }

@media (max-width: 980px) {
  .hero-today .ht-body { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Metric cards ---- */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.metric-card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.metric-card .m-label { font-size: 12px; color: var(--text-mute); margin-bottom: 8px; font-weight: 500; }
.metric-card .m-value { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.metric-card .m-value .unit { font-size: 12.5px; color: var(--text-mute); font-weight: 500; margin-left: 3px; }
.metric-card .m-delta { font-size: 11.5px; margin-top: 6px; display: flex; align-items: center; gap: 4px; font-weight: 500; }
.m-delta.up { color: var(--ok); }
.m-delta.down { color: var(--crit); }
.m-delta.flat { color: var(--text-mute); }

/* ---- Panels ---- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
}
.panel-head h2 { font-size: 15px; font-weight: 650; }
.panel-head .hint { font-size: 12px; color: var(--text-mute); }
.panel-body { padding: 4px 0; }
.panel-body.pad { padding: 18px 20px; }

.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }

/* ---- Tables ---- */
.data-table th {
  text-align: left;
  font-size: 11px; letter-spacing: .03em; text-transform: uppercase;
  color: var(--text-mute); font-weight: 600;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
.data-table td {
  padding: 13px 20px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13.5px;
  white-space: nowrap;
}
.data-table tbody tr { transition: background .1s; }
.data-table tbody tr:hover { background: var(--panel-2); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table td.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---- Pills ---- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
}
.pill.ok { background: var(--ok-dim); color: var(--ok); }
.pill.warn { background: var(--warn-dim); color: var(--warn); }
.pill.crit { background: var(--crit-dim); color: var(--crit); }
.pill.info { background: var(--info-dim); color: var(--info); }
.pill.wa { background: var(--wa-dim); color: #1A9F4E; }
.pill.mute { background: var(--panel-raised); color: var(--text-mute); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---- Call direction icon chip ---- */
.call-dir { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; }
.call-dir.in { background: var(--ok-dim); color: var(--ok); }
.call-dir.out { background: var(--info-dim); color: var(--info); }
.call-dir.miss { background: var(--crit-dim); color: var(--crit); }
.call-dir svg { width: 13px; height: 13px; }

/* ---- Toolbar / filters ---- */
.toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--border-soft); flex-wrap: wrap; }
.search-box {
  flex: 1; max-width: 300px;
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text-mute);
}
.search-box svg { width: 15px; height: 15px; flex-shrink: 0; }
.search-box input { background: none; border: none; outline: none; color: var(--text); font-size: 13px; width: 100%; font-family: var(--font-ui); }
.search-box input::placeholder { color: var(--text-mute); }

.fb-select {
  appearance: none; -webkit-appearance: none;
  background: var(--panel-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238B928D' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 30px 9px 12px;
  color: var(--text-dim);
  font-size: 12.5px; cursor: pointer;
}
.fb-select:hover { background-color: var(--panel-raised); }
.fb-select:focus { outline: none; border-color: var(--accent); }

/* ---- Toggle switch ---- */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; }
.toggle-row .t-label { font-size: 13.5px; color: var(--text); font-weight: 500; }
.toggle-row .t-sub { font-size: 11.5px; color: var(--text-mute); margin-top: 2px; }
.switch {
  position: relative; width: 40px; height: 22px;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: 20px; cursor: pointer; flex-shrink: 0;
}
.switch.on { background: var(--accent); border-color: var(--accent); }
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform .15s;
}
.switch.on::after { transform: translateX(18px); }

/* ---- Forms ---- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; padding: 20px; }
.form-grid.single { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.span-2 { grid-column: span 2; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.field input, .field select, .field textarea {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-size: 13.5px;
  font-family: var(--font-ui);
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); background: var(--panel); }
.field textarea { resize: vertical; min-height: 80px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--border-soft); background: var(--panel-2); }

/* ---- Chart container ---- */
.chart-box { padding: 18px 20px; position: relative; height: 260px; }
.chart-box canvas { max-height: 240px; width: 100% !important; height: 100% !important; }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-soft); margin-bottom: 20px; }
.tab {
  padding: 10px 4px; margin-right: 24px;
  font-size: 13.5px; font-weight: 500; color: var(--text-mute);
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: color .12s;
  user-select: none;
}
.tab:hover { color: var(--text-dim); }
.tab.active { color: var(--accent); font-weight: 650; border-bottom-color: var(--accent); }
.tab-panel { animation: fadein .12s ease; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(30,36,32,0.45);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 460px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(30,36,32,0.18);
  animation: modalIn .15s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border-soft); }
.modal-head h3 { font-size: 14.5px; font-weight: 650; }
.modal-close { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); color: var(--text-mute); cursor: pointer; }
.modal-close:hover { background: var(--panel-2); color: var(--text); }
.modal-body { padding: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border-soft); background: var(--panel-2); }

/* ---- Notification panel (dropdown, not full modal-overlay) ---- */
.notif-panel {
  position: absolute; top: calc(100% + 10px); right: 0;
  width: 360px; max-height: 420px; overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 44px rgba(30,36,32,0.16);
  display: none;
  z-index: 60;
}
.notif-panel.open { display: block; }
.notif-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border-soft); }
.notif-panel-head h3 { font-size: 13.5px; font-weight: 650; }
.notif-panel-head a { font-size: 11.5px; color: var(--accent); font-weight: 600; cursor: pointer; }
.notif-row { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border-soft); }
.notif-row:last-child { border-bottom: none; }
.notif-row.unread { background: var(--accent-dim); }
.notif-row .nr-icon { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-row .nr-icon svg { width: 14px; height: 14px; }
.notif-row .nr-text { font-size: 12.5px; color: var(--text); line-height: 1.4; }
.notif-row .nr-time { font-size: 10.5px; color: var(--text-mute); margin-top: 3px; }
.topbar-wrap { position: relative; }

/* ---- IVR builder ---- */
.ivr-step {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 16px;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  margin-bottom: 10px;
}
.ivr-step .ivr-key {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.ivr-step .ivr-body { flex: 1; }
.ivr-step .ivr-body input { width: 100%; margin-bottom: 6px; }
.ivr-step .ivr-body select { width: 100%; }
.ivr-step .ivr-remove { color: var(--text-mute); cursor: pointer; padding: 6px; flex-shrink: 0; }
.ivr-step .ivr-remove:hover { color: var(--crit); }
.ivr-add-btn {
  width: 100%; padding: 10px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: none; color: var(--text-mute);
  font-size: 12.5px; font-weight: 600;
  cursor: pointer;
}
.ivr-add-btn:hover { border-color: var(--accent); color: var(--accent); }
.mode-switch { display: flex; gap: 8px; margin-bottom: 16px; }
.mode-switch .ms-opt {
  flex: 1; padding: 12px; text-align: center;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--text-dim);
}
.mode-switch .ms-opt.active { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }

/* ---- Chat attach button + composer ---- */
.chat-input-row { align-items: center; }
.attach-btn {
  width: 38px; height: 38px; flex-shrink: 0;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-mute); cursor: pointer;
  transition: background .12s, color .12s;
}
.attach-btn:hover { background: var(--panel-2); color: var(--text-dim); }
.attach-menu {
  position: absolute; bottom: calc(100% + 8px); left: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(30,36,32,0.16);
  padding: 6px;
  display: none;
  min-width: 170px;
}
.attach-menu.open { display: block; }
.attach-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  font-size: 12.5px; color: var(--text-dim); cursor: pointer;
}
.attach-menu-item:hover { background: var(--panel-2); color: var(--text); }
.attach-menu-item .ami-icon { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.attach-wrap { position: relative; }
.chat-bubble.file-bubble { display: flex; align-items: center; gap: 10px; }
.chat-bubble.file-bubble .fb-icon { width: 34px; height: 34px; border-radius: 8px; background: rgba(0,0,0,0.06); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.chat-bubble.image-bubble { padding: 4px; }
.chat-bubble.image-bubble img { width: 100%; max-width: 220px; border-radius: 10px; display: block; }
.chat-bubble.image-bubble .cb-time { padding: 4px 6px 0; }

/* ---- New chat modal contact picker ---- */
.contact-pick-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer; }
.contact-pick-item:hover { background: var(--panel-2); }

/* ---- Click-to-call keypad ---- */
.keypad-display {
  text-align: center;
  padding: 20px 0 16px;
  font-size: 24px; font-weight: 650;
  font-family: var(--font-mono);
  color: var(--text);
  min-height: 40px;
  letter-spacing: 0.02em;
}
.keypad-display.empty { color: var(--text-mute); font-size: 14px; font-weight: 500; font-family: var(--font-ui); }
.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 0 20px 8px;
}
.keypad-key {
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .1s;
  user-select: none;
}
.keypad-key:hover { background: var(--panel-raised); }
.keypad-key:active { background: var(--accent-dim); }
.keypad-key .kk-num { font-size: 19px; font-weight: 650; color: var(--text); line-height: 1; }
.keypad-key .kk-letters { font-size: 8.5px; color: var(--text-mute); letter-spacing: .06em; margin-top: 2px; }
.keypad-actions {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 18px 20px 8px;
}
.keypad-backspace {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-mute); cursor: pointer;
}
.keypad-backspace:hover { background: var(--panel-2); color: var(--text-dim); }
.keypad-call-btn {
  width: 62px; height: 62px; border-radius: 50%;
  background: var(--ok);
  display: flex; align-items: center; justify-content: center;
  color: #fff; cursor: pointer;
  box-shadow: 0 6px 18px rgba(1,190,104,0.35);
  transition: transform .1s, background .12s;
}
.keypad-call-btn:hover { background: #00A85C; transform: scale(1.04); }
.keypad-call-btn.disabled { opacity: .4; pointer-events: none; box-shadow: none; }
.keypad-spacer { width: 44px; height: 44px; }

/* ---- KYC banner (Home page) ---- */
.kyc-banner {
  display: flex; align-items: center; gap: 16px;
  background: linear-gradient(135deg, #FFF7E6, #FFF0D6);
  border: 1px solid #F5DFA8;
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 22px;
}
.kyc-banner .kb-icon { width: 40px; height: 40px; border-radius: 12px; background: rgba(217,119,6,0.14); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: #B45F06; }
.kyc-banner .kb-text { flex: 1; }
.kyc-banner .kb-title { font-size: 13.5px; font-weight: 650; color: #7A5A0A; }
.kyc-banner .kb-sub { font-size: 12px; color: #8A6C1E; margin-top: 2px; }
.kyc-banner.verified { background: linear-gradient(135deg, var(--ok-dim), rgba(1,190,104,0.06)); border-color: rgba(1,190,104,0.25); }
.kyc-banner.verified .kb-icon { background: var(--ok-dim); color: var(--ok); }
.kyc-banner.verified .kb-title { color: #0A7A46; }
.kyc-banner.verified .kb-sub { color: #1A9F63; }

/* ---- KYC status stepper ---- */
.kyc-stepper { display: flex; align-items: center; margin-bottom: 6px; }
.kyc-step { display: flex; flex-direction: column; align-items: center; flex: 1; position: relative; }
.kyc-step .ks-dot {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  background: var(--panel-2); border: 2px solid var(--border);
  color: var(--text-mute); z-index: 2;
}
.kyc-step.done .ks-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.kyc-step.current .ks-dot { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.kyc-step .ks-label { font-size: 11px; color: var(--text-mute); margin-top: 6px; text-align: center; }
.kyc-step.done .ks-label, .kyc-step.current .ks-label { color: var(--text); font-weight: 600; }
.kyc-step::after {
  content: ''; position: absolute; top: 15px; left: 50%; width: 100%; height: 2px;
  background: var(--border); z-index: 1;
}
.kyc-step:last-child::after { display: none; }
.kyc-step.done::after { background: var(--ok); }

/* ---- Document upload card ---- */
.doc-upload {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
}
.doc-upload.uploaded { border-style: solid; border-color: var(--ok); background: var(--ok-dim); }
.doc-upload .du-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--panel-2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--text-mute); }
.doc-upload.uploaded .du-icon { background: #fff; color: var(--ok); }
.doc-upload .du-body { flex: 1; }
.doc-upload .du-title { font-size: 13px; font-weight: 600; color: var(--text); }
.doc-upload .du-sub { font-size: 11px; color: var(--text-mute); margin-top: 2px; }
.doc-upload .du-action { flex-shrink: 0; }

/* ---- Floating active-call widget (persists like a mini native call bar) ---- */
.call-widget {
  position: fixed;
  bottom: 20px; right: 20px;
  z-index: 500;
  display: none;
  align-items: center; gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 8px 16px 8px 8px;
  box-shadow: 0 14px 36px rgba(30,36,32,0.22);
  animation: callWidgetIn .25s cubic-bezier(.34,1.56,.64,1);
  cursor: default;
}
.call-widget.show { display: flex; }
@keyframes callWidgetIn {
  from { opacity: 0; transform: translateY(16px) scale(.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.call-widget .cw-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--ok);
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0;
  position: relative;
}
.call-widget .cw-avatar::after {
  content: '';
  position: absolute; inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--ok);
  opacity: .5;
  animation: cwRing 1.6s ease-out infinite;
}
@keyframes cwRing {
  0% { transform: scale(0.9); opacity: .6; }
  100% { transform: scale(1.35); opacity: 0; }
}
.call-widget .cw-avatar svg { width: 16px; height: 16px; }
.call-widget .cw-info { display: flex; flex-direction: column; min-width: 0; }
.call-widget .cw-number { font-size: 12.5px; font-weight: 650; color: var(--text); font-family: var(--font-mono); white-space: nowrap; }
.call-widget .cw-timer { font-size: 11px; color: var(--ok); font-family: var(--font-mono); font-weight: 600; }
.call-widget .cw-actions { display: flex; align-items: center; gap: 6px; margin-left: 4px; }
.call-widget .cw-btn {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  color: var(--text-mute);
  transition: background .12s;
}
.call-widget .cw-btn:hover { background: var(--panel-2); }
.call-widget .cw-btn.mute.active { background: var(--warn-dim); color: var(--warn); }
.call-widget .cw-btn.hangup { background: var(--crit); color: #fff; }
.call-widget .cw-btn.hangup:hover { background: #C93B3F; }
.call-widget .cw-btn svg { width: 15px; height: 15px; }

@media (max-width: 640px) {
  .call-widget { left: 12px; right: 12px; bottom: 12px; border-radius: var(--radius-lg); }
  .call-widget .cw-info { flex: 1; }
}

/* ---- Empty state ---- */
.empty-state { padding: 52px 24px; text-align: center; }
.empty-state .icon { width: 40px; height: 40px; margin: 0 auto 14px; color: var(--text-mute); opacity: .6; }
.empty-state .t { font-size: 14px; color: var(--text); font-weight: 600; margin-bottom: 4px; }
.empty-state .d { font-size: 12.5px; color: var(--text-mute); }

/* ---- Chat / WhatsApp inbox ---- */
.inbox-layout { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - var(--topbar-h) - 56px); }
.inbox-list { border-right: 1px solid var(--border-soft); overflow-y: auto; }
.inbox-item { display: flex; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border-soft); cursor: pointer; }
.inbox-item:hover, .inbox-item.active { background: var(--panel-2); }
.inbox-item .ii-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--wa-dim); color: #1A9F4E; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.inbox-item .ii-body { flex: 1; min-width: 0; }
.inbox-item .ii-name { font-size: 13.5px; font-weight: 600; display: flex; justify-content: space-between; }
.inbox-item .ii-name .time { font-size: 10.5px; color: var(--text-mute); font-weight: 400; }
.inbox-item .ii-preview { font-size: 12px; color: var(--text-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.inbox-item .ii-unread { width: 8px; height: 8px; border-radius: 50%; background: var(--wa); flex-shrink: 0; margin-top: 5px; }

.chat-thread { display: flex; flex-direction: column; height: 100%; }
.chat-header { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--border-soft); }
.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; background: #F7F6F2; }
.chat-bubble { max-width: 65%; padding: 9px 13px; border-radius: 14px; font-size: 13px; line-height: 1.4; }
.chat-bubble.in { background: #fff; border: 1px solid var(--border-soft); align-self: flex-start; border-bottom-left-radius: 3px; }
.chat-bubble.out { background: var(--wa-dim); color: #12341F; align-self: flex-end; border-bottom-right-radius: 3px; }
.chat-bubble .cb-time { font-size: 9.5px; color: var(--text-mute); margin-top: 3px; text-align: right; }
.chat-input-row { display: flex; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border-soft); }
.chat-input-row input { flex: 1; background: var(--panel-2); border: 1px solid var(--border); border-radius: 20px; padding: 10px 16px; font-size: 13px; outline: none; }
.chat-input-row input:focus { border-color: var(--wa); }

/* ---- Toast ---- */
.toast-stack { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: 340px; }
.toast { display: flex; align-items: flex-start; gap: 10px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 15px; box-shadow: 0 10px 30px rgba(30,36,32,0.12); animation: toastIn .18s ease; font-size: 13px; }
.toast.leaving { animation: toastOut .15s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }
.toast .t-icon { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.toast.success .t-icon { color: var(--ok); }
.toast.error .t-icon { color: var(--crit); }
.toast .t-text { color: var(--text); flex: 1; }
.toast .t-close { color: var(--text-mute); cursor: pointer; flex-shrink: 0; }

/* ---- Pagination ---- */
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-top: 1px solid var(--border-soft); flex-wrap: wrap; gap: 10px; }
.pagination .p-info { font-size: 12px; color: var(--text-mute); }
.pagination .p-controls { display: flex; align-items: center; gap: 3px; }
.pagination .p-btn { min-width: 30px; height: 30px; padding: 0 8px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); color: var(--text-dim); font-size: 12.5px; cursor: pointer; }
.pagination .p-btn:hover { background: var(--panel-2); }
.pagination .p-btn.active { background: var(--accent); color: #fff; font-weight: 600; }
.pagination .p-btn.disabled { opacity: .35; pointer-events: none; }
.pagination .p-btn svg { width: 15px; height: 15px; }

/* ---- Bottom-sheet style upgrade banner ---- */
.upgrade-banner {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, #FFF7E6, #FFF0D6);
  border: 1px solid #F5DFA8;
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  gap: 16px; flex-wrap: wrap;
}
.upgrade-banner .ub-text .ub-title { font-size: 13.5px; font-weight: 650; color: #7A5A0A; }
.upgrade-banner .ub-text .ub-sub { font-size: 12px; color: #8A6C1E; margin-top: 2px; }

/* ---- Hamburger menu (mobile) ---- */
.hamburger-btn {
  display: none;
  width: 38px; height: 38px;
  align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-dim);
  cursor: pointer;
  flex-shrink: 0;
}
.hamburger-btn svg { width: 18px; height: 18px; }
.sidebar-scrim {
  display: none;
  position: fixed; inset: 0;
  background: rgba(30,36,32,0.45);
  z-index: 40;
}
.sidebar-scrim.open { display: block; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; grid-template-areas: "top" "main"; }
  .hamburger-btn { display: flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 280px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 8px 0 30px rgba(30,36,32,0.15);
  }
  .sidebar.open { transform: translateX(0); }
  .two-col { grid-template-columns: 1fr; }
  .inbox-layout { grid-template-columns: 1fr; }
}

/* ==== ApnaCall patch 007: phone fixes ==== */
@media (max-width: 640px) {
  .topbar .crumb { font-size: 14px; line-height: 1.2; max-width: 38vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-profile .tp-name { display: none; }
  .kyc-banner { flex-wrap: wrap; gap: 10px; }
  .kyc-banner .kb-text { flex: 1 1 calc(100% - 60px); min-width: 0; }
  .kyc-banner .btn { width: 100%; justify-content: center; }
  .form-grid { grid-template-columns: 1fr; padding: 16px; }
  .form-grid > * { min-width: 0; }
  .form-grid input, .form-grid select, .form-grid textarea { max-width: 100%; }
  .inbox-layout { grid-template-columns: 1fr; height: auto; }
  .inbox-list { border-right: 0; border-bottom: 1px solid var(--border-soft); max-height: 280px; }
  .card, .panel-card { overflow-x: auto; }
  .modal, .modal-box { max-width: calc(100vw - 24px); }
  input, select, textarea { font-size: 16px; }
}
