/* Touchwell — Techno Help brand: black / navy hexagons, blue #4472C4, light blue #B4C6E7, Gill Sans headings, Open Sans body. */
:root {
  --th-black: #05070c;
  --th-navy: #0a1a3f;
  --th-navy-2: #0f2a66;
  --th-blue: #4472c4;
  --th-blue-600: #3a62ad;
  --th-electric: #2f7bff;
  --th-sky: #b4c6e7;
  --bg: #f3f5fa;
  --surface: #ffffff;
  --line: #e3e8f2;
  --text: #0f172a;
  --muted: #64748b;
  --urgent: #d92d20;
  --concern: #f79009;
  --ok: #12b76a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --head: "Gill Sans MT", "Gill Sans", "Gill Sans Nova", Calibri, "Segoe UI", sans-serif;
  --bs-primary: var(--th-blue);
  --bs-primary-rgb: 68,114,196;
  --bs-link-color: var(--th-blue);
  --bs-link-color-rgb: 68,114,196;
  --bs-body-font-family: "Open Sans", Arial, sans-serif;
}
html { font-size: 14.5px; }
body { background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
h1, h2, h3, .h1, .h2, .h3, .h4, .h5, .h6 { font-family: var(--head); letter-spacing: .01em; font-weight: 600; }
h1, .h3 { font-size: 1.75rem; }
a { text-decoration: none; }

/* ---------- App shell ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 248px; z-index: 1040;
  display: flex; flex-direction: column; color: #fff;
  background: linear-gradient(180deg, rgba(5,7,12,.96) 0%, rgba(5,7,12,.9) 45%, rgba(10,26,63,.82) 100%), url("/img/hex-bg.png") center bottom / cover;
  border-right: 1px solid rgba(180,198,231,.08);
}
.brand { display: block; padding: 1.4rem 1.4rem 1.2rem; border-bottom: 1px solid rgba(180,198,231,.1); }
.brand img { width: 100%; height: auto; display: block; }
.brand .product { display: block; margin-top: .7rem; font-family: var(--head); font-size: 1.35rem; color: #fff; letter-spacing: .04em; }
.brand .product::before { content: ""; display: inline-block; width: .6rem; height: .7rem; margin-right: .5rem; background: var(--th-electric);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); box-shadow: 0 0 12px var(--th-electric); vertical-align: 1px; }
.sidebar nav { padding: 1rem .75rem; flex: 1; }
.nav-item { display: flex; align-items: center; gap: .75rem; padding: .62rem .8rem; margin-bottom: .2rem; border-radius: 10px;
  color: var(--th-sky); font-weight: 500; transition: background .15s, color .15s; }
.nav-item svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover { background: rgba(68,114,196,.16); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, rgba(68,114,196,.45), rgba(68,114,196,.12)); color: #fff; box-shadow: inset 3px 0 0 var(--th-electric); }
.sidebar-foot { padding: 1rem 1.25rem 1.25rem; border-top: 1px solid rgba(180,198,231,.1); }
.user { display: flex; align-items: center; gap: .6rem; color: #fff; margin-bottom: .6rem; min-width: 0; }
.avatar { flex: 0 0 32px; height: 32px; display: grid; place-items: center; font-weight: 700; background: var(--th-blue);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.signout { color: var(--th-sky); font-size: .85rem; }
.signout:hover { color: #fff; }
.tagline { margin-top: .9rem; font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: rgba(180,198,231,.55); }

.main { margin-left: 248px; min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 1030; display: flex; align-items: center; gap: 1rem; height: 60px; padding: 0 2rem;
  background: rgba(243,245,250,.85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.crumb { font-family: var(--head); font-size: 1.05rem; color: var(--muted); }
.env { margin-left: auto; font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--th-blue);
  background: rgba(68,114,196,.1); border: 1px solid rgba(68,114,196,.25); padding: .2rem .6rem; border-radius: 999px; }
.menu-btn { display: none; border: 0; background: none; font-size: 1.4rem; }
.content { padding: 2rem; max-width: 1440px; }

@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .main { margin-left: 0; }
  .menu-btn { display: block; }
  .content, .topbar { padding-left: 1rem; padding-right: 1rem; }
}

/* ---------- Components ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); background: var(--surface); }
.card h2.h6, .card .h6 { font-family: var(--head); font-size: 1rem; color: var(--text); margin-bottom: .8rem; }
.stat { font-family: var(--head); font-size: 2.1rem; font-weight: 600; line-height: 1.1; color: var(--th-navy); }
.card .text-muted.small { text-transform: uppercase; letter-spacing: .06em; font-size: .72rem; font-weight: 600; }
a .card { transition: transform .15s, box-shadow .15s; }
a .card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(15,42,102,.12); }

.btn { border-radius: 10px; font-weight: 600; }
.btn-primary { background: var(--th-blue); border-color: var(--th-blue); }
.btn-primary:hover, .btn-primary:focus { background: var(--th-blue-600); border-color: var(--th-blue-600); }
.btn-outline-primary { color: var(--th-blue); border-color: var(--th-blue); }
.btn-outline-primary:hover { background: var(--th-blue); border-color: var(--th-blue); }
.btn-success { background: var(--ok); border-color: var(--ok); }
.form-control, .form-select { border-radius: 10px; border-color: #d5dcea; }
.form-control:focus, .form-select:focus { border-color: var(--th-blue); box-shadow: 0 0 0 .2rem rgba(68,114,196,.18); }
.form-label { font-weight: 600; color: #344054; }

.table { --bs-table-bg: transparent; margin: 0; }
.table thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; border-bottom-color: var(--line); background: #f8fafd; }
.table td { border-color: var(--line); vertical-align: middle; }
.card > .table thead th:first-child, .card > .table td:first-child { padding-left: 1.1rem; }
.card > .table { border-radius: var(--radius); overflow: hidden; }

.badge { font-weight: 600; border-radius: 999px; padding: .35em .7em; }
.badge-urgent { background: var(--urgent); color: #fff; }
.badge-concern { background: #fff4e5; color: #b54708; border: 1px solid #fedf89; }
.alert { border-radius: 12px; border: 0; }
.alert-info { background: rgba(68,114,196,.1); color: var(--th-navy-2); }

.q-card { border-left: 4px solid var(--th-blue) !important; }

/* WhatsApp-style chat */
.chat { background: #efeae2 radial-gradient(rgba(0,0,0,.035) 1px, transparent 1px) 0 0 / 14px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); padding: 1.1rem; height: 62vh; overflow-y: auto; }
.bubble { max-width: 78%; padding: .5rem .75rem .35rem; border-radius: 10px; margin-bottom: .45rem; white-space: pre-wrap;
  box-shadow: 0 1px .5px rgba(11,20,26,.13); font-size: .93rem; }
.bubble.out { background: #fff; border-top-left-radius: 2px; }
.bubble.in { background: #d9fdd3; margin-left: auto; border-top-right-radius: 2px; }
.bubble .time { font-size: .68rem; color: #667781; display: block; text-align: right; margin-top: .1rem; }
.choice-btn { margin: .3rem .3rem 0 0; color: #027eb5 !important; font-weight: 600; background: #fff !important; }

/* ---------- Public pages (login, opt-in) ---------- */
body.public { min-height: 100vh; color: #fff;
  background: linear-gradient(180deg, rgba(5,7,12,.2), rgba(5,7,12,.1)), url("/img/hex-bg.png") center bottom / cover, var(--th-black); }
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { padding: 3.5rem; display: flex; flex-direction: column; justify-content: space-between; }
.auth-hero img { height: 72px; align-self: flex-start; }
.auth-hero h1 { font-size: 3rem; line-height: 1.1; margin: 0 0 1rem; color: #fff; }
.auth-hero h1 span { color: var(--th-electric); text-shadow: 0 0 24px rgba(47,123,255,.5); }
.auth-hero p { color: var(--th-sky); font-size: 1.1rem; max-width: 30rem; }
.auth-hero .tagline { font-size: .8rem; }
.auth-panel { display: grid; place-items: center; padding: 2rem; }
.auth-card { width: 100%; max-width: 420px; background: rgba(255,255,255,.97); color: var(--text); border-radius: 18px; padding: 2.4rem;
  box-shadow: 0 30px 80px rgba(0,0,0,.45), 0 0 0 1px rgba(180,198,231,.2); }
.auth-card h2 { font-size: 1.6rem; margin-bottom: .3rem; }
.auth-card .btn { padding: .7rem; }
.auth-center { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2rem; padding: 2rem 1rem; }
.auth-logo { width: 300px; max-width: 80vw; height: auto; }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; } .auth-hero { padding: 2rem; } .auth-hero h1 { font-size: 2.1rem; } }

/* ---------- ⚡ Spark ---------- */
.spark-card { border: 1px solid rgba(47,123,255,.35); background: linear-gradient(135deg, #fff 0%, #f1f6ff 100%);
  box-shadow: 0 0 0 3px rgba(47,123,255,.06), var(--shadow); }
.spark-bolt { display: grid; place-items: center; width: 38px; height: 38px; font-size: 1.2rem; color: #fff; background: var(--th-navy-2);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); text-shadow: 0 0 10px var(--th-electric); }
.spark-chip { background: #fff; border: 1px solid var(--line); color: var(--th-navy-2); border-radius: 999px; font-weight: 500; }
.spark-chip:hover { border-color: var(--th-electric); color: var(--th-electric); }
.btn-spark { position: relative; overflow: hidden; color: #fff; border: 0; padding: .55rem 1.3rem; letter-spacing: .02em;
  background: linear-gradient(135deg, var(--th-navy-2), var(--th-electric)); box-shadow: 0 4px 18px rgba(47,123,255,.4); }
.btn-spark:hover, .btn-spark:focus { color: #fff; box-shadow: 0 6px 26px rgba(47,123,255,.6); transform: translateY(-1px); }
.btn-spark:disabled { color: #fff; opacity: .5; box-shadow: none; }
.btn-spark.loading::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.45) 50%, transparent 80%);
  animation: spark-shimmer 1.1s infinite; }
.btn-spark.loading:disabled { opacity: .85; }
@keyframes spark-shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

  /* Loader: dark glass card, 3D coin-flip on the vertical axis (logo never upside down) */
  .te-overlay{position:fixed;inset:0;z-index:1000;display:none;place-items:center;background:radial-gradient(ellipse at center,rgba(15,42,102,.55),rgba(5,7,12,.75));backdrop-filter:blur(6px)}
  .te-overlay.show{display:grid;animation:te-fade .25s ease-out}
  .te-ov-card{position:relative;width:min(340px,90vw);padding:36px 32px 28px;text-align:center;color:#e8eefc;border-radius:22px;
    background:linear-gradient(160deg,rgba(15,42,102,.92),rgba(5,7,12,.95));border:1px solid rgba(180,198,231,.18);
    box-shadow:0 30px 80px rgba(0,0,0,.55),inset 0 1px 0 rgba(255,255,255,.08);animation:te-rise .35s cubic-bezier(.2,.8,.2,1)}
  .te-stage{perspective:700px;height:120px;display:grid;place-items:center;margin-bottom:6px;position:relative}
  .te-stage::before{content:"";position:absolute;width:150px;height:150px;border-radius:50%;background:radial-gradient(circle,rgba(47,123,255,.45),transparent 65%);filter:blur(6px);animation:te-glow 2.4s ease-in-out infinite}
  .te-coin{width:92px;height:102px;transform-style:preserve-3d;animation:te-flip 2.4s cubic-bezier(.45,.05,.55,.95) infinite;position:relative}
  .te-coin img{position:absolute;inset:0;width:100%;height:100%;object-fit:contain;backface-visibility:hidden;filter:drop-shadow(0 6px 14px rgba(47,123,255,.55))}
  .te-coin img.back{transform:rotateY(180deg)}
  .te-shadow{width:70px;height:10px;margin:-4px auto 18px;border-radius:50%;background:rgba(0,0,0,.45);filter:blur(4px);animation:te-shadow 2.4s cubic-bezier(.45,.05,.55,.95) infinite}
  .te-ov-title{font:600 17px var(--head);letter-spacing:.2px}
  .te-ov-sub{font-size:12.5px;color:#a9b8d8;margin-top:4px}
  .te-bar{height:3px;border-radius:3px;background:rgba(180,198,231,.15);overflow:hidden;margin-top:18px}
  .te-bar i{display:block;height:100%;width:40%;border-radius:3px;background:linear-gradient(90deg,transparent,var(--th-electric),#8fb4ff,transparent);animation:te-slide 1.4s ease-in-out infinite}
  @keyframes te-flip{0%{transform:rotateY(0)}100%{transform:rotateY(360deg)}}
  @keyframes te-shadow{0%,50%,100%{transform:scaleX(1);opacity:.55}25%,75%{transform:scaleX(.25);opacity:.25}}
  @keyframes te-glow{50%{opacity:.55;transform:scale(.9)}}
  @keyframes te-slide{0%{transform:translateX(-110%)}100%{transform:translateX(280%)}}
  @keyframes te-rise{from{opacity:0;transform:translateY(12px) scale(.97)}}
  @keyframes te-fade{from{opacity:0}}
  @media (prefers-reduced-motion:reduce){.te-coin,.te-shadow,.te-stage::before{animation:none}.te-bar i{animation-duration:3s}}

/* ---------- Shared dialog (twConfirm / twAlert) ---------- */
.tw-dlg { position: fixed; inset: 0; z-index: 1100; display: none; place-items: center; padding: 16px; background: rgba(5,7,12,.55); backdrop-filter: blur(4px); }
.tw-dlg.show { display: grid; animation: tw-fade .18s ease-out; }
.tw-dlg-card { width: min(440px, 100%); background: var(--surface); border-radius: 20px; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,.35); animation: tw-rise .28s cubic-bezier(.2,.8,.2,1); }
.tw-dlg-head { display: flex; gap: 14px; align-items: center; padding: 20px 22px; color: #fff; background: linear-gradient(135deg, var(--th-navy), var(--th-navy-2)); }
.tw-dlg-head.danger { background: linear-gradient(135deg, #5b1010, #a3231a); }
.tw-dlg-head img { width: 36px; }
.tw-dlg-head h2 { margin: 0; font: 600 17px var(--head); }
.tw-dlg-body { padding: 18px 22px 6px; font-size: 14px; color: var(--text); white-space: pre-line; }
.tw-dlg-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 22px 20px; }
@keyframes tw-fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes tw-rise { from { transform: translateY(14px) scale(.98); opacity: 0 } to { transform: none; opacity: 1 } }

/* ---------- Flash message ---------- */
.tw-flash { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; margin-bottom: 18px; border-radius: 12px; background: #eef4ff; border: 1px solid #cfdcf5; color: var(--th-navy); }
.tw-flash.bad { background: #fff1f0; border-color: #f5c8c3; color: #8a1c13; }
.tw-flash .ico { font-size: 18px; line-height: 1.2; }
.tw-flash ul { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }

/* ---------- Settings ---------- */
.st-head { margin-bottom: 22px; }
.st-head p { color: var(--muted); margin: 4px 0 0; }
.st-grid { display: grid; grid-template-columns: 200px 1fr; gap: 28px; align-items: start; }
.st-nav { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 2px; }
.st-nav a { padding: 8px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.st-nav a:hover, .st-nav a.on { background: var(--surface); color: var(--th-navy); box-shadow: var(--shadow); }
.st-sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 22px; scroll-margin-top: 80px; }
.st-sec-h { display: flex; gap: 14px; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.st-ic { flex: 0 0 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: #eef3fc; color: var(--th-blue); }
.st-ic svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.st-sec-h h2 { margin: 0; font-size: 1.1rem; }
.st-sec-h p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.st-sec-b { padding: 20px 22px; }
.st-sec-f { display: flex; gap: 10px; align-items: center; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--line); background: #fafbfe; border-radius: 0 0 var(--radius) var(--radius); }
.st-label { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.st-help { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.st-two { display: grid; grid-template-columns: 1fr 300px; gap: 26px; }
.wa-prev { background: #e7ded3; border-radius: 16px; padding: 14px; }
.wa-prev .cap { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6b5f52; margin-bottom: 8px; }
.wa-bub { background: #fff; border-radius: 4px 12px 12px 12px; padding: 9px 11px; font-size: 13px; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.wa-bub .ft { font-size: 11px; color: #8696a0; margin-top: 6px; }
.wa-btn { background: #fff; border-radius: 10px; margin-top: 4px; padding: 7px; text-align: center; font-size: 13px; font-weight: 600; color: #027eb5; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.st-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-pill.ok { background: #e7f8ef; color: #0b8a4f; } .st-pill.wait { background: #fff5e6; color: #b45d00; }
.st-pill.bad { background: #fdecea; color: #b42318; } .st-pill.none { background: #eef1f6; color: var(--muted); }
.st-num { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 18px; }
.st-num b { font-size: 15px; }
.st-prog { height: 6px; width: 140px; border-radius: 6px; background: #eef1f6; overflow: hidden; } .st-prog i { display: block; height: 100%; background: var(--ok); }
.st-tpls { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.st-tpl { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.st-tpl-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.st-tpl-top b { font-family: var(--head); font-size: 15px; }
.st-tpl code { font-size: 11.5px; color: var(--muted); }
.st-tpl p { margin: 0; font-size: 13px; line-height: 1.5; }
.st-tpl .var { background: #eef3fc; color: var(--th-blue-600); border-radius: 5px; padding: 0 4px; font-weight: 600; }
.st-tpl .meta { font-size: 11.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.st-tpl .why { font-size: 12px; color: #b42318; background: #fff6f5; border-radius: 8px; padding: 6px 8px; }
.st-tpl .cat { font-size: 12px; color: #b45d00; background: #fffaf2; border-radius: 8px; padding: 6px 8px; }
.st-quote { border-left: 3px solid var(--th-sky); padding: 8px 14px; background: #f7f9fd; border-radius: 0 10px 10px 0; font-size: 13.5px; color: var(--text); }
.st-chip { display: inline-block; padding: 3px 10px; margin-right: 6px; border-radius: 8px; background: #eef1f6; font-weight: 700; font-size: 12px; font-family: ui-monospace, monospace; }
@media (max-width: 991px) { .st-grid { grid-template-columns: 1fr; } .st-nav { display: none; } .st-two { grid-template-columns: 1fr; } }
