/* AppAlbania WhatsApp Sender — navy / Poppins */
:root {
  --navy-900: #071630;
  --navy-800: #0B1F44;
  --navy-700: #12305F;
  --navy-600: #1C407A;
  --navy-100: #E7ECF6;
  --bg: #F3F5FA;
  --card: #FFFFFF;
  --text: #16223A;
  --muted: #6B7590;
  --line: #E3E7F0;
  --green: #25D366;
  --green-dark: #128C4A;
  --amber: #F5A524;
  --red: #E0374C;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(11, 31, 68, .04), 0 10px 30px -12px rgba(11, 31, 68, .14);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Poppins', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
p { margin: 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--navy-100); padding: 1px 6px; border-radius: 6px; color: var(--navy-700); }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0 8px; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.hidden { display: none !important; }
.spacer { flex: 1; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 250px; flex: 0 0 250px; position: sticky; top: 0; height: 100vh;
  background: linear-gradient(170deg, var(--navy-700) 0%, var(--navy-800) 45%, var(--navy-900) 100%);
  color: #fff; display: flex; flex-direction: column; padding: 22px 18px;
  overflow: hidden;
}
.side::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,.07) 1px, transparent 1px);
  background-size: 22px 22px; mask-image: linear-gradient(to bottom, rgba(0,0,0,.6), transparent 70%);
}
.brand { background: #fff; border-radius: 14px; padding: 12px 16px; display: flex; justify-content: center; box-shadow: 0 8px 24px -10px rgba(0,0,0,.5); position: relative; }
.brand img { width: 100%; max-width: 160px; height: auto; display: block; }
.side-title { margin: 14px 4px 22px; font-size: 12px; letter-spacing: .18em; text-transform: uppercase; opacity: .55; font-weight: 500; }
.nav { display: flex; flex-direction: column; gap: 4px; position: relative; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px;
  color: rgba(255,255,255,.72); text-decoration: none; font-weight: 500; transition: .18s;
}
.nav a .ico { width: 20px; text-align: center; opacity: .8; font-size: 15px; }
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.side-foot { margin-top: auto; position: relative; display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; }
.inst, .worker { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; background: rgba(255,255,255,.06); }
.inst .dot, .worker .dot { width: 8px; height: 8px; border-radius: 50%; background: #98A2B3; flex: 0 0 8px; }
.inst.open .dot, .worker.on .dot { background: var(--green); box-shadow: 0 0 0 4px rgba(37,211,102,.18); }
.inst.closed .dot { background: var(--red); }
.inst.no-token .dot { background: var(--amber); }
.link { background: none; border: 0; color: rgba(255,255,255,.55); cursor: pointer; font: inherit; text-align: left; padding: 6px 12px; }
.link:hover { color: #fff; }

.main { flex: 1; padding: 34px 40px 60px; max-width: 1240px; }
.view { animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.vh { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.vh p { color: var(--muted); flex-basis: 100%; }
.vh > h1 + p { margin-top: -6px; }
.vh .btn { margin-left: auto; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* ---------- cards / forms ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); border: 1px solid rgba(227,231,240,.7); }
.card.mini { padding: 18px 20px; }
.mini-label { font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 500; margin-bottom: 6px; }
.mini-val { font-size: 26px; font-weight: 600; color: var(--navy-800); }
.mini-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.7; }

label { display: block; font-size: 12.5px; font-weight: 500; color: var(--navy-800); margin: 14px 0 6px; }
label:first-child { margin-top: 0; }
input:not([type=range]):not([type=hidden]), textarea, select {
  width: 100%; font: inherit; font-size: 13.5px; color: var(--text);
  padding: 10px 13px; border: 1.5px solid var(--line); border-radius: 11px; background: #FBFCFE;
  transition: .15s; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--navy-600); background: #fff; box-shadow: 0 0 0 4px rgba(28,64,122,.10); }
textarea { resize: vertical; line-height: 1.55; }
.row { display: flex; gap: 10px; align-items: flex-end; }
.row > * { flex: 1; min-width: 0; }
.row > .btn { flex: 0 0 auto; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.hint .bad { color: var(--red); }
input[type=range] { width: 100%; accent-color: var(--navy-700); margin: 6px 0 4px; }

.tpl-preview {
  margin-top: 10px; padding: 12px 14px; border-radius: 12px; background: #E9F9EF; border: 1px dashed rgba(18,140,74,.35);
  white-space: pre-wrap; font-size: 13px; color: #10391F; max-height: 160px; overflow: auto; line-height: 1.5;
}
.tpl-preview.empty { background: var(--bg); border-color: var(--line); color: var(--muted); }
.tpl-preview .media { display: inline-block; margin-top: 6px; font-size: 11.5px; color: var(--green-dark); }

.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.btn {
  font: inherit; font-weight: 500; font-size: 13.5px; border: 1.5px solid var(--line); background: #fff; color: var(--navy-800);
  padding: 9px 16px; border-radius: 11px; cursor: pointer; transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--navy-600); transform: translateY(-1px); }
.btn:active { transform: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(135deg, var(--navy-600), var(--navy-800)); color: #fff; border-color: transparent; box-shadow: 0 8px 18px -8px rgba(11,31,68,.6); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { background: #FFF1F3; color: var(--red); border-color: #F8C9D0; }
.btn.danger:hover { background: var(--red); color: #fff; border-color: var(--red); }
.btn.big { padding: 12px 24px; font-size: 14.5px; border-radius: 13px; }

/* ---------- number check ---------- */
.numtools { align-items: center; margin-top: 6px; }
.numtools .hint { margin: 0; }
.small-btn { padding: 6px 12px; font-size: 12.5px; }
.check-result { margin-top: 10px; padding: 12px 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); font-size: 12.5px; line-height: 1.7; }
.check-result b.on { color: var(--green-dark); }
.check-result b.off { color: var(--red); }
.check-result b.unk { color: var(--amber); }
.check-result .list { color: var(--muted); word-break: break-all; }
.check-result .actions { margin-top: 8px; justify-content: flex-start; }
.check-result details { margin-top: 6px; }
.check-result pre { font-size: 11px; background: #fff; padding: 8px; border-radius: 8px; overflow: auto; max-height: 160px; }
label.chk { display: flex; align-items: flex-start; gap: 8px; font-weight: 400; color: var(--muted); font-size: 12.5px; margin-top: 12px; }
label.chk input[type=checkbox] { width: 16px; height: 16px; flex: 0 0 16px; margin: 2px 0 0; padding: 0; accent-color: var(--navy-700); }

/* ---------- templates ---------- */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.tpl { display: flex; flex-direction: column; gap: 10px; min-height: 160px; }
.tpl h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--navy-800); }
.tpl .body { white-space: pre-wrap; color: #3C4660; font-size: 13px; line-height: 1.5; max-height: 110px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.tpl .foot { margin-top: auto; display: flex; gap: 8px; align-items: center; }
.tpl .foot .tag { font-size: 11px; background: var(--navy-100); color: var(--navy-700); padding: 3px 8px; border-radius: 999px; }
.tpl .foot .btn { padding: 6px 12px; font-size: 12.5px; margin-left: auto; }
.tpl .foot .btn + .btn { margin-left: 0; }

/* ---------- tables ---------- */
.table-card { padding: 8px 0 0; overflow: hidden; }
.table-tools { display: flex; gap: 10px; padding: 8px 18px 14px; }
.table-tools input { max-width: 300px; }
.table-tools select { max-width: 180px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 500; font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 10px 18px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 11px 18px; border-bottom: 1px solid #EEF1F7; vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr.clickable { cursor: pointer; transition: background .12s; }
.tbl tbody tr.clickable:hover { background: #F7F9FD; }
.tbl td.errc { color: var(--red); font-size: 12px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl td.num { font-variant-numeric: tabular-nums; font-weight: 500; white-space: nowrap; }
.tbl td.muted { white-space: nowrap; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.mini-prog { display: flex; align-items: center; gap: 8px; }
.mini-prog .track { width: 90px; height: 6px; background: var(--navy-100); border-radius: 99px; overflow: hidden; display: flex; }
.mini-prog .track i { display: block; height: 100%; }
.mini-prog .track i.s { background: var(--green); }
.mini-prog .track i.f { background: var(--red); }

/* ---------- chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 500; text-transform: capitalize; }
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.pending   { background: #FFF6E5; color: #A15C00; }
.chip.running, .chip.sending { background: #E6F0FF; color: var(--navy-600); }
.chip.running::before, .chip.sending::before { animation: pulse 1s infinite; }
.chip.sent, .chip.done { background: #E4F8EC; color: var(--green-dark); }
.chip.failed    { background: #FFE9EC; color: var(--red); }
.chip.cancelled { background: #EEF0F5; color: var(--muted); }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1);} 50% { opacity: .4; transform: scale(.6);} }

/* ---------- campaign detail ---------- */
.prog-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.prog { height: 12px; background: var(--navy-100); border-radius: 99px; overflow: hidden; }
.prog .bar { display: flex; height: 100%; }
.prog .b { display: block; height: 100%; width: 0; transition: width .5s ease; }
.prog .b.sent { background: linear-gradient(90deg, var(--green-dark), var(--green)); }
.prog .b.failed { background: var(--red); }
.counts { display: flex; gap: 26px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.counts b { color: var(--navy-800); font-size: 18px; font-weight: 600; margin-right: 4px; }

/* ---------- modal / toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(7,22,48,.55); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-card { background: #fff; border-radius: 20px; padding: 26px 28px; width: 100%; max-width: 640px; box-shadow: 0 30px 80px -20px rgba(0,0,0,.5); animation: rise .25s ease; }
.toast { position: fixed; right: 24px; bottom: 24px; background: var(--navy-800); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 13px; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); transition: .25s; pointer-events: none; z-index: 60; max-width: 380px; }
.toast.show { opacity: 1; transform: none; }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green-dark); }

/* ---------- gate (login) ---------- */
body.gate { display: flex; align-items: center; justify-content: center; background: radial-gradient(1200px 700px at 20% -10%, var(--navy-600), transparent 60%), radial-gradient(900px 600px at 110% 110%, #1E4C8F, transparent 55%), var(--navy-900); }
.gate-card { background: #fff; border-radius: 22px; padding: 34px 36px; width: 100%; max-width: 400px; box-shadow: 0 40px 100px -30px rgba(0,0,0,.6); display: flex; flex-direction: column; gap: 12px; animation: rise .4s ease; }
.gate-logo { width: 170px; align-self: center; margin-bottom: 6px; }
.gate-card h1 { font-size: 20px; text-align: center; }
.gate-card .muted { text-align: center; font-size: 13px; }
.gate-card input { margin-top: 4px; }
.gate-card .btn { margin-top: 8px; }
.gate-foot { text-align: center; font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.err { background: #FFE9EC; color: var(--red); padding: 10px 12px; border-radius: 10px; font-size: 13px; }

/* ---------- responsive ---------- */
.table-card { overflow-x: auto; }
@media (max-width: 960px) {
  .shell { flex-direction: column; }
  .side { width: auto; flex: none; height: auto; position: sticky; top: 0; z-index: 20; padding: 10px 12px; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center; }
  .side::before { display: none; }
  .brand { padding: 6px 10px; border-radius: 10px; width: 96px; }
  .side-title { display: none; }
  .nav { grid-column: 2; flex-direction: row; gap: 2px; overflow-x: auto; scrollbar-width: none; justify-content: flex-end; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { padding: 8px 10px; font-size: 12.5px; gap: 6px; border-radius: 9px; }
  .nav a .ico { width: auto; }
  .side-foot { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; gap: 6px; margin-top: 2px; font-size: 11.5px; }
  .inst, .worker { padding: 5px 9px; }
  .link { padding: 5px 8px; margin-left: auto; }
  .main { padding: 18px 14px 40px; }
  .vh { gap: 10px; margin-bottom: 16px; }
  .vh h1 { font-size: 19px; }
  .vh p { font-size: 13px; }
  .vh .btn { margin-left: 0; }
  .grid2 { grid-template-columns: 1fr; }
  .card { padding: 18px 16px; border-radius: 14px; }
  .row { flex-direction: column; align-items: stretch; }
  .counts { flex-wrap: wrap; gap: 10px 18px; }
  .counts b { font-size: 16px; }
  .tbl { min-width: 720px; }
  .table-tools { padding: 8px 14px 12px; }
  .table-tools input, .table-tools select { max-width: none; }
  .tpl-grid { grid-template-columns: 1fr; }
  .toast { left: 14px; right: 14px; bottom: 14px; max-width: none; }
  .modal-card { padding: 20px 18px; }
}
@media (max-width: 480px) {
  .nav a span:not(.ico) { display: none; }
  .nav a { padding: 8px 9px; }
  .nav a .ico { font-size: 17px; opacity: 1; }
}
