:root {
  --bg: #f6f8fc; --panel: #ffffff; --line: #e3e8ef; --text: #1f2933; --muted: #6b7785; --soft: #eef3fb;
  --accent: #1565c0; --accent-2: #1e88e5; --accent-soft: #e3effd; --danger: #c62828; --ok: #2e7d32; --warn: #ef6c00;
  --unread: #0d1b2a; --sel: #dbe9fc; --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --c-omicron: #1565c0; --c-chase: #546e7a; --c-astron: #6a1b9a; --c-fillpro: #2e7d32; --c-personal: #ef6c00;
  --top: 56px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 "Noto Sans Gujarati", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.hidden { display: none !important; }

/* ---- buttons / inputs ---- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 14px; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #0d47a1; }
.btn.danger { color: var(--danger); border-color: #f3c7c7; }
.btn.danger:hover { background: #fdecec; }
.btn.ok { color: #fff; background: var(--ok); border-color: var(--ok); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { border: 0; background: transparent; width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; cursor: pointer; color: var(--muted); font-size: 18px; flex: none; }
.icon-btn:hover { background: var(--soft); color: var(--text); }
.icon-btn.on { color: #f9a825; }
input[type=text], input[type=password], input[type=tel], input[type=email], input[type=number], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: #fff; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 120px; }
label.f { display: block; margin: 10px 0 4px; font-weight: 500; font-size: 13px; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.err { color: var(--danger); }
.okc { color: var(--ok); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 500; background: var(--soft); color: var(--muted); white-space: nowrap; }
.chip.co { color: #fff; }
.co-Omicron { background: var(--c-omicron) !important; } .co-Chase { background: var(--c-chase) !important; } .co-Astron { background: var(--c-astron) !important; }
.co-Fillpro { background: var(--c-fillpro) !important; } .co-personal { background: var(--c-personal) !important; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

/* ---- top bar ---- */
.top { height: var(--top); display: flex; align-items: center; gap: 8px; padding: 0 12px; padding-top: env(safe-area-inset-top); background: var(--bg); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; color: var(--accent); min-width: 196px; text-decoration: none; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.searchbox { flex: 1; max-width: 720px; display: flex; align-items: center; gap: 6px; background: #e9eef6; border-radius: 999px; padding: 0 6px 0 14px; }
.searchbox input { border: 0; background: transparent; box-shadow: none !important; padding: 10px 4px; }
.searchbox:focus-within { background: #fff; box-shadow: var(--shadow); }
.ai-btn { background: linear-gradient(135deg, #1e88e5, #7e57c2); color: #fff; border: 0; }
.ai-btn:hover { filter: brightness(1.05); background: linear-gradient(135deg, #1e88e5, #7e57c2); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 600; cursor: pointer; flex: none; }

/* ---- layout ---- */
.main { display: flex; height: calc(100vh - var(--top) - env(safe-area-inset-top)); height: calc(100dvh - var(--top) - env(safe-area-inset-top)); }
.side { width: 248px; flex: none; overflow-y: auto; padding: 4px 8px 24px; }
.compose-btn { display: flex; align-items: center; gap: 10px; background: #c2e7ff; color: #001d35; border: 0; border-radius: 16px; padding: 14px 20px; font-weight: 600; cursor: pointer; margin: 4px 0 12px; box-shadow: var(--shadow); }
.compose-btn:hover { box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-radius: 0 999px 999px 0; margin-left: -8px; padding-left: 20px; color: var(--text); text-decoration: none; cursor: pointer; }
.nav a:hover { background: #e8edf5; }
.nav a.active { background: var(--sel); font-weight: 600; color: #0b3d91; }
.nav a .n { margin-left: auto; font-size: 12px; font-weight: 600; }
.nav a .ic { width: 20px; text-align: center; }
.nav .acc-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; font-size: 13px; }
.nav-h { font-size: 12px; font-weight: 600; color: var(--muted); margin: 14px 4px 4px 12px; text-transform: none; }
.badge { background: var(--danger); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 700; }
.panes { flex: 1; display: flex; min-width: 0; background: var(--panel); border-radius: 16px 16px 0 0; margin-right: 12px; overflow: hidden; box-shadow: var(--shadow); }
.list { width: 420px; flex: none; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.list-h { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); min-height: 52px; }
.list-h h2 { margin: 0; font-size: 16px; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-f { display: flex; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.items { flex: 1; overflow-y: auto; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 1px 8px; padding: 10px 14px; border-bottom: 1px solid #f0f2f5; cursor: pointer; position: relative; }
.item:hover { background: #f5f8fd; box-shadow: inset 3px 0 0 var(--accent-2); }
.item.sel { background: var(--sel); }
.item .from { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .date { font-size: 12px; color: var(--muted); white-space: nowrap; }
.item .subj { grid-column: 1 / -1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .snip { grid-column: 1 / -1; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { grid-column: 1 / -1; display: flex; gap: 6px; align-items: center; margin-top: 3px; }
.item.unread .from, .item.unread .subj { font-weight: 700; color: var(--unread); }
.item.unread::before { content: ""; position: absolute; left: 4px; top: 16px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-2); }
.more { padding: 14px; text-align: center; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

.read { flex: 1; min-width: 0; overflow-y: auto; display: flex; flex-direction: column; }
.read-ph { margin: auto; text-align: center; color: var(--muted); }
.read-ph img { width: 84px; opacity: .35; }
.read-bar { display: flex; align-items: center; gap: 2px; padding: 6px 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 2; }
.msg { padding: 16px 22px 30px; }
.msg h1 { font-size: 21px; font-weight: 600; margin: 4px 0 14px; line-height: 1.35; word-break: break-word; }
.msg-head { display: flex; gap: 12px; align-items: flex-start; }
.msg-head .av { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; flex: none; }
.msg-head .who { flex: 1; min-width: 0; }
.msg-head .who b { font-weight: 600; }
.msg-head .to { color: var(--muted); font-size: 12.5px; word-break: break-word; }
.msg-body { margin-top: 18px; }
.msg-body iframe { width: 100%; border: 0; min-height: 120px; display: block; }
.msg-body pre.plain { white-space: pre-wrap; word-break: break-word; font: inherit; margin: 0; }
.atts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line); }
.att { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; text-decoration: none; color: var(--text); max-width: 280px; background: #fafbfd; }
.att:hover { border-color: var(--accent-2); background: #fff; }
.att .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.att .ext { font-size: 10px; font-weight: 700; color: #fff; background: #90a4ae; border-radius: 4px; padding: 2px 5px; text-transform: uppercase; }
.att .ext.pdf { background: #e53935; } .att .ext.xls, .att .ext.xlsx, .att .ext.csv { background: #2e7d32; } .att .ext.doc, .att .ext.docx { background: #1565c0; } .att .ext.jpg, .att .ext.png, .att .ext.jpeg { background: #8e24aa; }
.reply-row { display: flex; gap: 8px; margin-top: 24px; flex-wrap: wrap; }

/* ---- page (admin / AI) ---- */
.page { flex: 1; overflow-y: auto; padding: 20px 26px 40px; }
.page h2 { margin: 0 0 4px; font-size: 20px; }
.page .sub { color: var(--muted); margin: 0 0 18px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.card h3 { margin: 0 0 10px; font-size: 15.5px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 14px; }
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 8px; border-bottom: 1px solid #f0f2f5; vertical-align: top; }
.tbl tr:hover td { background: #fafcff; }
.note { background: #fff8e1; border: 1px solid #ffe082; border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; }
.note.info { background: var(--accent-soft); border-color: #bbd6fb; }
.note.okn { background: #e8f5e9; border-color: #a5d6a7; }
.note.errn { background: #fdecea; border-color: #f5b7b1; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.copybox { display: flex; gap: 6px; align-items: stretch; margin: 6px 0 10px; }
.copybox code { flex: 1; background: #f3f5f9; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; word-break: break-all; white-space: pre-wrap; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; padding: 4px 12px; border-radius: 999px; }
.status-pill.on { background: #e8f5e9; color: var(--ok); } .status-pill.off { background: #eceff1; color: #546e7a; }
.perm-tbl td, .perm-tbl th { text-align: center; } .perm-tbl td:first-child, .perm-tbl th:first-child { text-align: left; }
.switch { position: relative; width: 38px; height: 22px; display: inline-block; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cfd8dc; border-radius: 999px; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(16px); }
.appr { border-left: 4px solid var(--warn); }
.ai-answer { background: linear-gradient(135deg, #f3f8ff, #f7f3ff); border: 1px solid #d9e4fb; border-radius: var(--radius); padding: 16px 18px; white-space: pre-wrap; line-height: 1.7; }
.ai-answer a { font-weight: 600; text-decoration: none; background: #e3effd; border-radius: 6px; padding: 0 5px; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid #bbd6fb; border-top-color: var(--accent); border-radius: 50%; animation: sp .8s linear infinite; vertical-align: -3px; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ---- compose ---- */
.compose { position: fixed; right: 24px; bottom: 0; width: 560px; max-width: 100vw; max-height: 92vh; background: #fff; border-radius: 14px 14px 0 0; box-shadow: 0 8px 30px rgba(0,0,0,.25); z-index: 50; display: flex; flex-direction: column; }
.compose-h { display: flex; align-items: center; padding: 8px 8px 8px 16px; background: #f2f6fc; border-radius: 14px 14px 0 0; font-weight: 600; }
.compose-b { padding: 6px 16px 12px; overflow-y: auto; }
.compose-b .ln { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.compose-b .ln span { color: var(--muted); width: 56px; flex: none; font-size: 13px; }
.compose-b .ln input, .compose-b .ln select { border: 0; box-shadow: none !important; border-radius: 0; padding: 9px 4px; }
.compose-b textarea { border: 0; box-shadow: none !important; padding: 12px 2px; min-height: 220px; }
.compose-f { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #263238; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 100; box-shadow: 0 4px 14px rgba(0,0,0,.25); max-width: 90vw; }
.menu { position: absolute; right: 12px; top: 52px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.15); z-index: 60; min-width: 220px; padding: 8px; }
.menu a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; cursor: pointer; }
.menu a:hover { background: var(--soft); }

/* ---- login ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, #dbeafe, transparent), radial-gradient(900px 500px at 110% 110%, #ede7f6, transparent), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 18px; padding: 28px 26px; box-shadow: 0 10px 40px rgba(21,101,192,.12); }
.login-card h1 { margin: 10px 0 2px; font-size: 24px; color: var(--accent); }
.login-card img { width: 64px; border-radius: 14px; }

/* ---- mobile ---- */
.only-m { display: none; }
@media (max-width: 1100px) { .list { width: 360px; } }
@media (max-width: 860px) {
  .only-m { display: inline-grid; }
  .no-m { display: none !important; }
  .brand { min-width: 0; font-size: 16px; }
  .brand span { display: none; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; background: #fff; z-index: 40; width: 280px; transform: translateX(-100%); transition: transform .2s; padding-top: calc(12px + env(safe-area-inset-top)); box-shadow: 0 0 30px rgba(0,0,0,.2); }
  body.drawer .side { transform: none; }
  body.drawer .scrim { display: block; }
  .scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 35; }
  .panes { margin: 0; border-radius: 0; }
  .list { width: 100%; border: 0; }
  .read { display: none; }
  body.reading .list { display: none; }
  body.reading .read { display: flex; }
  .msg { padding: 12px 14px 90px; }
  .msg h1 { font-size: 18px; }
  .page { padding: 14px 14px 80px; }
  .compose { right: 0; left: 0; top: 0; width: 100%; max-height: none; border-radius: 0; }
  .compose-h { border-radius: 0; padding-top: calc(8px + env(safe-area-inset-top)); }
  .compose-b { flex: 1; }
  .fab { position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 30; border-radius: 18px; padding: 16px 20px; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
  body.reading .fab { display: none; }
  .searchbox { padding-left: 10px; }
}
@media (min-width: 861px) { .fab { display: none; } }
