/* Look follows my.oscs.in (customer portal): OSCS orange + blue, white rounded cards, slate text. */
:root {
  --orange: #F7941D;
  --orange-dark: #E8820C;
  --orange-soft: #FFF3E6;
  --blue: #2F86A6;
  --blue-light: #74B7CE;
  --blue-soft: #E6F4F9;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e2e8f0;
  --bg-card: #ffffff;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --bubble-out: #fff3e6;
  --bubble-in: #ffffff;
  --chat-bg: #f6f8fa;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, var(--orange-soft), #ffffff 45%, var(--blue-soft));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue); }
.boot { padding: 40px; text-align: center; color: var(--faint); }
[hidden] { display: none !important; }

/* ---------- buttons / inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; border-radius: 12px;
  padding: 8px 14px; font-size: 14px; font-weight: 600; color: var(--text-2);
  white-space: nowrap; text-decoration: none;
}
.btn:hover { background: #f8fafc; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary {
  border: 0; color: #fff;
  background: linear-gradient(90deg, var(--orange), var(--orange-dark));
  box-shadow: 0 4px 12px rgba(247, 148, 29, .3);
}
.btn-primary:hover { background: linear-gradient(90deg, var(--orange-dark), var(--orange-dark)); }
.btn-blue { border-color: var(--blue-light); color: var(--blue); background: var(--blue-soft); }
.btn-danger { border-color: #fecaca; color: var(--red); background: #fff; }
.btn-danger:hover { background: var(--red-soft); }
.btn-lg { padding: 12px 16px; font-size: 16px; width: 100%; border-radius: 14px; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 10px; }
.btn-icon { padding: 7px; border-radius: 10px; }
.link { background: none; border: 0; padding: 0; color: var(--blue); text-decoration: underline; font-size: 14px; }

.input, .select, textarea.input {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px;
  font-size: 15px; background: #fff; outline: none;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(247, 148, 29, .2); }
.input-lg { border-color: var(--blue-light); padding: 12px 16px; font-size: 18px; border-radius: 14px; }
.otp-input { text-align: center; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 26px; letter-spacing: .45em; }
.label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.hint { font-size: 12px; color: var(--faint); margin-top: 4px; }
.error { color: var(--red); font-size: 14px; margin-top: 8px; }
.field { margin-bottom: 12px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 380px; background: #fff; border-radius: 24px; overflow: hidden;
  border: 1px solid rgba(247, 148, 29, .3); box-shadow: 0 20px 40px rgba(247, 148, 29, .12);
}
.login-card .strip { height: 8px; background: linear-gradient(90deg, var(--orange), var(--blue-light)); }
.login-card .body { padding: 24px; }
.login-logo { display: block; margin: 0 auto; height: 96px; width: auto; }
.login-title { text-align: center; font-size: 21px; font-weight: 800; margin: 8px 0 2px; }
.login-sub { text-align: center; font-size: 14px; color: var(--muted); margin: 0 0 18px; }
.tabs { display: flex; background: #f1f5f9; border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.tabs button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 8px; font-size: 14px; font-weight: 600; color: var(--muted); }
.tabs button.on { background: #fff; color: var(--orange-dark); box-shadow: var(--shadow); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 12px; }

/* ---------- shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-in { max-width: 1400px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 8px 16px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; text-decoration: none; color: var(--text); }
.brand img { height: 34px; width: auto; border-radius: 6px; }
.brand span b { color: var(--orange-dark); }
.nav { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; padding: 7px 12px; border-radius: 10px; white-space: nowrap;
}
.nav a.on { background: var(--orange-soft); color: var(--orange-dark); }
.nav a:hover:not(.on) { background: #f1f5f9; }
.me { display: flex; align-items: center; gap: 8px; }
.me .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--blue-soft); color: var(--blue); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.me .who { line-height: 1.15; }
.me .who b { display: block; font-size: 14px; }
.me .who small { color: var(--muted); font-size: 12px; }
.main { max-width: 1400px; margin: 0 auto; padding: 16px; }
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 14px; }
.page-title h1 { font-size: 20px; margin: 0; }

.card { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px; }
.empty { border: 1px dashed #cbd5e1; border-radius: var(--radius); background: #fff; padding: 24px; text-align: center; color: var(--muted); font-size: 14px; }

.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.b-super { background: #f3e8ff; color: #7e22ce; }
.b-admin { background: var(--blue-soft); color: var(--blue); }
.b-staff { background: #f1f5f9; color: #475569; }
.b-green { background: var(--green-soft); color: #15803d; }
.b-amber { background: #fef3c7; color: #b45309; }
.b-red { background: var(--red-soft); color: #b91c1c; }
.b-grey { background: #f1f5f9; color: #64748b; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.green { background: #22c55e; }
.dot.amber { background: #f59e0b; }
.dot.grey { background: #cbd5e1; }

/* ---------- WhatsApp page ---------- */
.wa-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.wa-bar .acct { display: flex; align-items: center; gap: 8px; min-width: 0; }
.wa-bar .acct .select { width: auto; min-width: 200px; max-width: 320px; font-weight: 600; }
.wa-bar .acct .num { font-size: 13px; color: var(--muted); }
.wa-bar .spacer { flex: 1; }

.wa-panel { display: grid; grid-template-columns: 360px minmax(0, 1fr); height: calc(100vh - 150px); height: calc(100dvh - 150px); min-height: 460px; overflow: hidden; }
.wa-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.wa-list-head { padding: 12px; border-bottom: 1px solid var(--line); }
.wa-list-head .top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.wa-list-head .top b { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.search { position: relative; }
.search .input { padding-left: 34px; border-radius: 999px; font-size: 14px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 11px; font-size: 13px; color: var(--text-2); }
.chip.on { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 600; }
.chats { overflow-y: auto; flex: 1; }
.chat-item { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid #f1f5f9; cursor: pointer; }
.chat-item:hover { background: #f8fafc; }
.chat-item.on { background: var(--orange-soft); }
.pic { width: 42px; height: 42px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; color: #fff; }
.chat-item .mid { flex: 1; min-width: 0; }
.chat-item .name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .last { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.chat-item .time { font-size: 11px; color: var(--faint); }
.unread { background: #22c55e; color: #fff; border-radius: 999px; min-width: 22px; padding: 1px 7px; font-size: 12px; font-weight: 700; text-align: center; }
.star { color: #f59e0b; }

.wa-thread { display: flex; flex-direction: column; min-height: 0; background: var(--chat-bg); }
.thread-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #fff; border-bottom: 1px solid var(--line); }
.thread-head .mid { flex: 1; min-width: 0; }
.thread-head .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-head .sub { font-size: 12px; color: var(--muted); }
.back-btn { display: none; }
.msgs { flex: 1; overflow-y: auto; padding: 14px 18px; display: flex; flex-direction: column; gap: 4px; }
.day { align-self: center; background: #fff; border: 1px solid var(--line); color: var(--muted); font-size: 12px; border-radius: 8px; padding: 2px 10px; margin: 8px 0; }
.msg { max-width: min(75%, 560px); border-radius: 12px; padding: 7px 10px 5px; font-size: 14px; line-height: 1.4; box-shadow: var(--shadow); word-wrap: break-word; overflow-wrap: anywhere; }
.msg.in { align-self: flex-start; background: var(--bubble-in); border-top-left-radius: 4px; }
.msg.out { align-self: flex-end; background: var(--bubble-out); border: 1px solid #fde3c3; border-top-right-radius: 4px; }
.msg .who { font-size: 12px; font-weight: 700; color: var(--blue); margin-bottom: 2px; }
.msg .text { white-space: pre-wrap; }
.msg .meta { font-size: 11px; color: var(--faint); text-align: right; margin-top: 2px; display: flex; justify-content: flex-end; gap: 4px; align-items: center; }
.msg .meta .tick.read { color: #3b82f6; }
.msg .meta .tick.failed { color: var(--red); }
.msg img.media, .msg video.media { display: block; max-width: 100%; max-height: 320px; border-radius: 8px; margin-bottom: 4px; cursor: zoom-in; background: #f1f5f9; }
.msg audio { display: block; max-width: 260px; margin-bottom: 4px; }
.msg .doc { display: flex; align-items: center; gap: 8px; background: rgba(15, 23, 42, .04); border-radius: 8px; padding: 8px; margin-bottom: 4px; text-decoration: none; color: var(--text); font-weight: 600; }
.load-more { align-self: center; margin-bottom: 6px; }

.composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; background: #fff; border-top: 1px solid var(--line); }
.composer textarea { resize: none; max-height: 140px; min-height: 42px; border-radius: 14px; }
.attach-preview { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--orange-soft); font-size: 13px; border-top: 1px solid #fde3c3; }
.attach-preview .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }

.center-box { flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px; }
.new-chat { width: 100%; max-width: 400px; }
.new-chat h3 { text-align: center; font-weight: 600; font-size: 15px; color: var(--text-2); margin: 0 0 12px; }

.qr-wrap { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: center; padding: 24px; }
.qr-wrap ol { padding-left: 20px; line-height: 1.9; color: var(--text-2); }
.qr-box { width: 300px; height: 300px; border-radius: 16px; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; background: #fff; text-align: center; color: var(--muted); font-size: 14px; padding: 12px; }
.qr-box img { width: 100%; height: 100%; image-rendering: pixelated; }

/* ---------- users ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: #f8fafc; }
.table td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.users-cards { display: none; }
.u-card { padding: 12px; border-bottom: 1px solid #f1f5f9; }
.u-card:last-child { border-bottom: 0; }
.u-card .l1 { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.u-card .l2 { font-size: 13px; color: var(--muted); margin: 4px 0 8px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters .input { max-width: 280px; }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: #fff; border-radius: 20px; width: 100%; max-width: 440px; max-height: 92vh; overflow: auto; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal .strip { height: 6px; background: linear-gradient(90deg, var(--orange), var(--blue-light)); }
.modal-body { padding: 20px; }
.modal h2 { margin: 0 0 14px; font-size: 18px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.viewer { position: fixed; inset: 0; background: rgba(0, 0, 0, .88); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; }
.viewer img, .viewer video { max-width: 100%; max-height: 100%; border-radius: 8px; }
.viewer .x { position: absolute; top: 14px; right: 14px; }

/* ---------- settings ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.card h2 { font-size: 16px; margin: 0 0 4px; }
.card .desc { font-size: 13px; color: var(--muted); margin: 0 0 14px; }
.audit { max-height: 420px; overflow: auto; font-size: 13px; }
.audit div { padding: 6px 0; border-bottom: 1px solid #f1f5f9; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 80; max-width: calc(100% - 32px); box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.toast.err { background: #b91c1c; }

/* ---------- phones ---------- */
@media (max-width: 900px) {
  .qr-wrap { grid-template-columns: 1fr; justify-items: center; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .topbar-in { flex-wrap: wrap; gap: 6px 10px; padding: 8px 12px; }
  .nav { order: 3; flex-basis: 100%; }
  .me .who { display: none; }
  .brand { flex: 1; }
  .main { padding: 12px; }
  .wa-panel { grid-template-columns: minmax(0, 1fr); height: calc(100vh - 200px); height: calc(100dvh - 200px); min-height: 380px; }
  .wa-panel.has-chat .wa-list { display: none; }
  .wa-panel:not(.has-chat) .wa-thread { display: none; }
  .back-btn { display: inline-flex; }
  .msg { max-width: 88%; }
  .wa-bar .acct .select { min-width: 0; max-width: 100%; }
  .wa-bar .acct { flex: 1 1 100%; flex-wrap: wrap; }
  .table-wrap { display: none; }
  .users-cards { display: block; }
  .qr-box { width: 260px; height: 260px; }
}
