/* AVA Classroom PH brand: navy + Amazon orange + grainy white-gray */
:root {
  --navy: #1d2a47;
  --navy-2: #2a3a5f;
  --navy-ink: #131c33;
  --orange: #f39a1d;
  --orange-2: #e07f00;
  --orange-soft: #fff1dc;
  --bg: #efefef;
  --grain: linear-gradient(rgba(242,242,242,.6), rgba(242,242,242,.6)), url("/img/grain.jpg") 0 0 / 150px 150px, #efefef;
  --panel: #ffffff;
  --border: #e3e3e6;
  --text: #1b2236;
  --muted: #4e5568;
  --accent: #f39a1d;
  --accent-soft: #fff1dc;
  --fb: #1877f2;
  --tt: #111111;
  --good: #1f8a4c;
  --good-soft: #e4f5ea;
  --danger: #c0392b;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(29, 42, 71, 0.08);
  --font: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font); background: var(--grain); color: var(--text); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { color: var(--navy); letter-spacing: -0.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* Login */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; width: 100%; max-width: 380px; box-shadow: var(--shadow); text-align: center; }
.login-card form, .login-card .field { text-align: left; }
.login-card img { width: 76px; height: 76px; margin: 0 auto 10px; display: block; border-radius: 16px; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; font-weight: 800; }
.login-card p { margin: 0 0 18px; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
input, select, textarea { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: #fff; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn { border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 8px 16px; font-weight: 600; color: var(--navy); }
.btn:hover { background: #f6f6f8; }
.btn.primary { background: var(--orange); border-color: var(--orange); color: var(--navy-ink); box-shadow: 0 4px 14px rgba(243,154,29,.35); }
.btn.primary:hover { background: var(--orange-2); }
.btn.navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.navy:hover { background: var(--navy-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.small { padding: 4px 8px; font-size: 12px; }
.btn.block { width: 100%; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; }

/* Shell */
.shell { display: grid; grid-template-columns: 220px 1fr; height: 100vh; }
.side { background: var(--navy); color: #d5dbea; display: flex; flex-direction: column; padding: 16px 10px; border-right: 4px solid var(--orange); }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 18px; text-decoration: none; }
.brand img { width: 42px; height: 42px; border-radius: 10px; background: #fff; }
.brand b { color: #fff; font-weight: 800; font-size: 15px; line-height: 1.1; display: block; }
.brand small { color: var(--orange); font-size: 11px; font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: inherit; text-decoration: none; margin-bottom: 2px; }
.nav a:hover { background: rgba(255,255,255,.06); }
.nav a { font-weight: 500; }
.nav a.active { background: var(--orange); color: var(--navy-ink); font-weight: 700; }
.nav .count { margin-left: auto; background: #ef4444; color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; font-weight: 700; }
.side .me { margin-top: auto; padding: 10px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.side .me b { color: #fff; display: block; }
.side .me button { margin-top: 8px; background: transparent; border: 1px solid rgba(255,255,255,.2); color: #cfd3e6; border-radius: 6px; padding: 4px 10px; }
.main { overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.page-head { padding: 18px 22px 8px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 24px; font-weight: 800; }
.page-body { padding: 8px 22px 22px; overflow: auto; flex: 1; }

/* Inbox */
.inbox { display: grid; grid-template-columns: 330px 1fr 300px; flex: 1; min-height: 0; border-top: 1px solid var(--border); }
.col { background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.col:last-child { border-right: 0; }
.filters { padding: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; border-bottom: 1px solid var(--border); }
.filters input { grid-column: 1 / -1; }
.filters select { padding: 6px 8px; font-size: 13px; }
.tlist { overflow: auto; flex: 1; }
.titem { padding: 11px 12px; border-bottom: 1px solid var(--border); cursor: pointer; display: grid; grid-template-columns: 38px 1fr; gap: 10px; }
.titem:hover { background: #fafbff; }
.titem.active { background: var(--orange-soft); box-shadow: inset 4px 0 0 var(--orange); }
.titem .row1 { display: flex; gap: 6px; align-items: center; }
.titem .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titem.unread .nm::after { content: ''; display: inline-block; width: 8px; height: 8px; background: var(--orange); border-radius: 50%; margin-left: 6px; vertical-align: middle; }
.titem .time { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.titem .pv { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.titem .meta { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; position: relative; }
.avatar .pf { position: absolute; right: -3px; bottom: -3px; width: 17px; height: 17px; border-radius: 50%; border: 2px solid #fff; font-size: 9px; display: grid; place-items: center; }
.pf.facebook { background: var(--fb); }
.pf.tiktok { background: var(--tt); }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: #f1f2f6; color: #3d4256; white-space: nowrap; }
.chip.tag { color: #fff; }
.chip .x { cursor: pointer; opacity: .8; font-weight: 700; }
.chip.stage-new { background: #e0e7ff; color: #3730a3; }
.chip.stage-contacted { background: #fef3c7; color: #92400e; }
.chip.stage-interested { background: #dbeafe; color: #1e40af; }
.chip.stage-successful { background: #dcfce7; color: #166534; }
.chip.stage-not_interested { background: #f3f4f6; color: #4b5563; }
.empty { color: var(--muted); padding: 30px; text-align: center; }

.conv-head { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.conv-head .sub { color: var(--muted); font-size: 12px; }
.msgs { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: #fbfbfe; }
.msg { max-width: 72%; padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.msg.in { background: #fff; border: 1px solid var(--border); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.out { background: var(--navy); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg .mt { font-size: 11px; opacity: .7; margin-top: 3px; }
.msg.out.manual { background: #fff7ed; color: #7c2d12; border: 1px dashed #fb923c; }
.msg.out.local { background: #eef2ff; color: #3730a3; border: 1px dashed #818cf8; }
.composer { border-top: 1px solid var(--border); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.composer textarea { resize: none; height: 70px; }
.composer .bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.composer .hint { color: var(--muted); font-size: 12px; margin-right: auto; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.quick button { font-size: 12px; border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 2px 10px; }

.side-panel { overflow: auto; padding: 14px; }
.side-panel h3 { margin: 0 0 2px; font-size: 16px; }
.section { margin-top: 16px; }
.section > label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.section select, .section input, .section textarea { width: 100%; }
.tags-box { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }
.note { background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 8px; margin-top: 6px; font-size: 13px; white-space: pre-wrap; }
.note small, .act small { color: var(--muted); display: block; }
.act { font-size: 12px; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.success-btn { width: 100%; margin-top: 8px; background: var(--good); border-color: var(--good); color: #fff; }
.success-btn:hover { background: #18703d; }

/* Cards / pipeline / team */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .n { font-size: 26px; font-weight: 800; color: var(--navy); }
.stat.hero { background: var(--navy); border-color: var(--navy); }
.stat.hero .n { color: var(--orange); }
.stat.hero .l { color: #c9d1e6; }
.stat .l { color: var(--muted); font-size: 12px; }
.board { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.lane { background: #eef0f6; border-radius: var(--radius); padding: 10px; min-height: 300px; }
.lane.over { outline: 2px dashed var(--accent); }
.lane h4 { margin: 0 0 8px; display: flex; justify-content: space-between; font-size: 13px; }
.card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 8px; cursor: grab; }
.card .nm { font-weight: 600; }
.card .sub { color: var(--muted); font-size: 12px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; color: #fff; background: var(--navy); font-weight: 600; }
tr.clickable:hover td { background: #fafbff; cursor: pointer; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.panel h3 { margin-top: 0; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.form-row .field { margin: 0; flex: 1; min-width: 150px; }
code, .code { background: #f1f2f6; padding: 2px 6px; border-radius: 5px; font-size: 12px; word-break: break-all; }
pre.code { padding: 10px; white-space: pre-wrap; display: block; }
.ok { color: var(--good); font-weight: 700; }
.no { color: var(--danger); font-weight: 700; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1f2333; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 50; max-width: 90vw; }
.back-btn { display: none; }

/* Mobile */
@media (max-width: 1100px) {
  .inbox { grid-template-columns: 300px 1fr; }
  .inbox .col.details { display: none; }
  .inbox.show-details .col.details { display: flex; position: fixed; right: 0; top: 0; bottom: 0; width: min(340px, 100vw); z-index: 30; box-shadow: -10px 0 30px rgba(0,0,0,.15); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { flex-direction: row; align-items: center; padding: 8px; overflow-x: auto; gap: 4px; }
  .brand { padding: 0 8px; font-size: 15px; }
  .nav { display: flex; }
  .nav a { white-space: nowrap; margin: 0; }
  .side .me { margin: 0 0 0 auto; border: 0; padding: 0 6px; }
  .side .me b, .side .me span { display: none; }
  .side .me button { margin: 0; }
  .shell { height: 100dvh; }
  .page-head, .page-body { padding-left: 16px; padding-right: 16px; }
  .inbox { grid-template-columns: 1fr; }
  .inbox .col.conv { display: none; }
  .inbox.open .col.list { display: none; }
  .inbox.open .col.conv { display: flex; }
  .back-btn { display: inline-block; }
  .msg { max-width: 88%; }
}

/* ===== Sales dashboard ===== */
.banner { background: var(--navy); color: #fff; border-radius: var(--radius); padding: 18px 22px; margin-bottom: 18px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; border-bottom: 4px solid var(--orange); box-shadow: var(--shadow); }
.banner h3 { color: var(--orange); margin: 0; font-size: 20px; font-weight: 800; }
.banner p { margin: 2px 0 0; color: #c9d1e6; font-size: 13px; }
.banner .spacer { margin-left: auto; }
.seg { display: inline-flex; background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 6px 14px; font-weight: 600; color: var(--navy); }
.seg button.on { background: var(--navy); color: #fff; }
.grid2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .grid2 { grid-template-columns: 1fr; } }
.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 14px; align-items: end; }
.pod { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 10px; text-align: center; box-shadow: var(--shadow); }
.pod.first { border: 2px solid var(--orange); padding-top: 22px; }
.pod .medal { font-size: 26px; }
.pod .who { font-weight: 700; color: var(--navy); margin-top: 4px; }
.pod .amt { font-weight: 800; font-size: 18px; color: var(--orange-2); }
.pod .sub { color: var(--muted); font-size: 12px; }
.rank { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 800; background: #f1f2f6; color: var(--navy); font-size: 12px; }
.rank.r1 { background: var(--orange); color: var(--navy-ink); }
.lb-bar { height: 8px; background: #eef0f4; border-radius: 999px; overflow: hidden; min-width: 80px; }
.lb-bar i { display: block; height: 100%; background: var(--orange); border-radius: 999px; }
.chart { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding-top: 10px; }
.chart .col-bar { flex: 1; background: var(--navy); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.chart .col-bar:hover { background: var(--orange); }
.chart-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 4px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.badge.approved { background: var(--good-soft); color: var(--good); }
.badge.pending { background: #fff4d6; color: #8a5a00; }
.badge.rejected, .badge.void { background: #fbe7e4; color: var(--danger); }
.badge.web { background: var(--navy); color: #fff; }
.badge.manual { background: #eef0f4; color: var(--navy); }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); cursor: zoom-in; background: #f4f4f4; }
.modal-bg { position: fixed; inset: 0; background: rgba(19,28,51,.6); display: grid; place-items: center; z-index: 60; padding: 16px; }
.modal { background: #fff; border-radius: var(--radius); width: min(560px, 100%); max-height: 90vh; overflow: auto; padding: 20px; box-shadow: 0 24px 60px rgba(0,0,0,.3); }
.modal h3 { margin-top: 0; }
.modal img.full { width: 100%; border-radius: 10px; border: 1px solid var(--border); }
.order-opt { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.order-opt:hover { border-color: var(--orange); background: var(--orange-soft); }
.order-opt.sel { border: 2px solid var(--orange); background: var(--orange-soft); }
.hist { font-size: 12px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.hist b { color: var(--navy); }
.hist small { color: var(--muted); display: block; }
.sale-row { border: 1px solid var(--border); border-radius: 10px; padding: 8px; margin-top: 6px; font-size: 13px; }
.lock-note { background: #eef0f4; border-radius: 10px; padding: 8px 10px; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.pfi { width: 22px; height: 22px; border-radius: 6px; color: #fff; display: inline-grid; place-items: center; font-size: 12px; font-weight: 800; flex: none; }
.pf.website { background: var(--orange); font-size: 8px; }

/* Inbox: the header and reply box never shrink; only the message list scrolls (fixes cut-off Send button) */
.conv-head, .composer, .composer .bar { flex-shrink: 0; }
.msgs { min-height: 0; }
.quick { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.quick::-webkit-scrollbar { display: none; }
.quick button { flex: none; }
@media (max-height: 760px) {
  .composer textarea { height: 56px; }
  .composer { padding: 8px 10px; gap: 6px; }
}
