:root {
  --forest: #1f3a33;
  --forest-2: #284a41;
  --forest-3: #35594f;
  --gold: #c9a46a;
  --gold-d: #a8834a;
  --cream: #f7f3ec;
  --paper: #fffdf9;
  --ink: #1d2422;
  --muted: #6b7570;
  --line: #e6dfd2;
  --danger: #b4483c;
  --ok: #3f8a5f;
  --ro: #8a5a12;
  --ro-bg: #fbefd6;
  --radius: 12px;
  --serif: 'Noto Serif Bengali', 'Hind Siliguri', Georgia, serif;
  --sans: 'Hind Siliguri', 'Noto Sans Bengali', system-ui, -apple-system, Segoe UI, sans-serif;
}
* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body { font-family: var(--sans); color: var(--ink); background: var(--cream); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* ---------- Login ---------- */
.login { min-height: 100%; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: radial-gradient(120% 90% at 20% 10%, var(--forest-3), var(--forest) 60%); color: var(--cream); padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art::after { content: ''; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%; border: 1px solid rgba(201,164,106,.35); box-shadow: 0 0 0 40px rgba(201,164,106,.06), 0 0 0 90px rgba(201,164,106,.04); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { width: 40px; height: 40px; }
.brand-name { font-family: var(--serif); font-size: 22px; line-height: 1.3; }
.brand-name small { display: block; font-family: var(--sans); font-size: 13px; letter-spacing: 0; color: var(--gold); margin-top: 2px; }
.login-art h1 { font-family: var(--serif); font-weight: 600; font-size: 46px; line-height: 1.35; margin: 0 0 16px; max-width: 12ch; }
.login-art p { color: rgba(247,243,236,.75); max-width: 38ch; line-height: 1.6; margin: 0; }
.login-form-wrap { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.login-form { width: 100%; max-width: 360px; }
.login-form h2 { font-family: var(--serif); font-size: 34px; font-weight: 600; margin: 0 0 6px; }
.login-form .sub { color: var(--muted); margin: 0 0 28px; }

.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 14px; font-weight: 600; letter-spacing: 0; color: var(--muted); margin-bottom: 6px; }
.field input, .field select { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); outline: none; transition: border-color .15s, box-shadow .15s; }
.field input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,164,106,.2); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 10px; border: 1px solid transparent; font-weight: 500; transition: background .15s, border-color .15s, opacity .15s; white-space: nowrap; }
.btn-primary { background: var(--forest); color: var(--cream); }
.btn-primary:hover { background: var(--forest-2); }
.btn-gold { background: var(--gold); color: var(--forest); }
.btn-gold:hover { background: var(--gold-d); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: #fff; border-color: #d6cdbd; }
.btn-danger { background: transparent; border-color: #e9c7c2; color: var(--danger); }
.btn-danger:hover { background: #fbeeec; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; padding: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.form-error { color: var(--danger); font-size: 14px; min-height: 20px; margin: 4px 0 12px; }

/* ---------- Shell ---------- */
.shell { height: 100%; display: flex; flex-direction: column; }
.ro-banner { background: var(--ro-bg); color: var(--ro); border-bottom: 1px solid #ecd6a8; padding: 9px 16px; display: flex; align-items: center; gap: 12px; font-size: 14px; flex-wrap: wrap; }
.ro-banner .eye { width: 18px; height: 18px; flex: none; }
.ro-banner strong { font-weight: 600; }
.ro-banner .btn { margin-left: auto; background: var(--ro); color: #fff; }
.main { flex: 1; display: grid; grid-template-columns: 240px 300px minmax(0, 1fr); min-height: 0; }
.main.no-list { grid-template-columns: 240px minmax(0, 1fr); }

.nav { background: var(--forest); color: var(--cream); display: flex; flex-direction: column; padding: 20px 14px; gap: 4px; min-height: 0; }
.nav .brand { padding: 0 6px 20px; }
.nav .brand-name { font-size: 20px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: rgba(247,243,236,.8); background: none; border: 0; text-align: left; width: 100%; }
.nav-item svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav-item:hover { background: rgba(255,255,255,.06); color: var(--cream); }
.nav-item.active { background: rgba(201,164,106,.16); color: var(--gold); }
.nav-item .count { margin-left: auto; background: var(--gold); color: var(--forest); font-size: 11px; font-weight: 600; border-radius: 10px; padding: 1px 7px; }
.nav-section { font-size: 13px; letter-spacing: 0; color: rgba(247,243,236,.45); padding: 16px 12px 6px; }
.nav-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding-top: 14px; display: flex; align-items: center; gap: 10px; }
.nav-foot .who { min-width: 0; flex: 1; }
.nav-foot .who div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-foot .who .t { font-size: 12px; color: rgba(247,243,236,.55); }
.icon-btn { background: none; border: 0; color: inherit; padding: 6px; border-radius: 8px; opacity: .75; display: inline-flex; }
.icon-btn:hover { opacity: 1; background: rgba(255,255,255,.08); }
.icon-btn svg { width: 18px; height: 18px; }

.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; flex: none; position: relative; color: #fff; letter-spacing: .02em; }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.avatar .dot { position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; background: #2fb36b; border: 2px solid var(--paper); }
.nav .avatar .dot { border-color: var(--forest); }

/* conversation list */
.convs { background: var(--paper); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.convs-head { padding: 20px 18px 12px; display: flex; align-items: center; justify-content: space-between; }
.convs-head h2 { font-family: var(--serif); font-size: 26px; margin: 0; font-weight: 600; }
.convs-search { margin: 0 14px 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--cream); outline: none; width: calc(100% - 28px); }
.conv-list { overflow-y: auto; flex: 1; padding: 0 8px 12px; }
.conv { display: flex; gap: 11px; align-items: center; width: 100%; padding: 10px; border-radius: 10px; border: 0; background: none; text-align: left; }
.conv:hover { background: var(--cream); }
.conv.active { background: #efe7d8; }
.conv .meta { flex: 1; min-width: 0; overflow: hidden; }
.conv .row { display: flex; align-items: baseline; gap: 8px; }
.conv .name { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .time { font-size: 12px; color: var(--muted); flex: none; }
.conv .preview { min-width: 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.conv.unread .preview { color: var(--ink); font-weight: 500; }
.conv .badge { background: var(--gold); color: var(--forest); font-size: 11px; font-weight: 600; border-radius: 10px; padding: 1px 7px; margin-left: 6px; }
.hash { background: var(--forest); color: var(--gold); font-family: var(--serif); font-size: 20px; }
.list-label { font-size: 13px; letter-spacing: 0; color: var(--muted); padding: 14px 10px 6px; }

/* chat */
.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--cream); }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 22px; border-bottom: 1px solid var(--line); background: var(--paper); min-height: 68px; }
.chat-head .t { font-weight: 600; }
.chat-head .s { font-size: 13px; color: var(--muted); }
.back-btn { display: none; }
.msgs { flex: 1; overflow-y: auto; padding: 18px 22px 8px; display: flex; flex-direction: column; gap: 2px; }
.day-sep { align-self: center; font-size: 12px; color: var(--muted); background: #efe8db; border-radius: 20px; padding: 3px 12px; margin: 14px 0 8px; }
.msg { display: flex; gap: 10px; max-width: 72%; margin-top: 8px; }
.msg.cont { margin-top: 0; }
.msg.cont .avatar { visibility: hidden; height: 0; }
.msg .bubble { background: var(--paper); border: 1px solid var(--line); padding: 8px 12px; border-radius: 4px 14px 14px 14px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.msg .by { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.msg .by b { color: var(--ink); font-weight: 600; margin-right: 6px; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg.mine .bubble { background: var(--forest); color: var(--cream); border-color: var(--forest); border-radius: 14px 4px 14px 14px; }
.msg.mine .by { text-align: right; }
.msg .stamp { font-size: 11px; color: var(--muted); margin-top: 2px; }
.msg.mine .stamp { text-align: right; }
.load-more { align-self: center; margin: 4px 0 10px; }
.empty { margin: auto; text-align: center; color: var(--muted); max-width: 320px; padding: 40px 20px; }
.empty h3 { font-family: var(--serif); font-size: 26px; color: var(--ink); margin: 10px 0 6px; font-weight: 600; }
.composer { display: flex; gap: 10px; padding: 12px 22px 18px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); background: var(--paper); border-radius: 12px; padding: 11px 14px; max-height: 160px; min-height: 46px; outline: none; line-height: 1.4; }
.composer textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,164,106,.2); }
.composer .btn { height: 46px; padding: 0 18px; }
.composer-ro { margin: 10px 22px 18px; padding: 12px 14px; border: 1px dashed #dcc394; color: var(--ro); background: var(--ro-bg); border-radius: 12px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.composer-ro svg { width: 16px; height: 16px; flex: none; }

/* pages */
.page { overflow-y: auto; padding: 32px clamp(16px, 4vw, 48px); min-width: 0; }
.page h1 { font-family: var(--serif); font-size: 38px; font-weight: 600; margin: 0 0 4px; }
.page .lede { color: var(--muted); margin: 0 0 28px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 22px; }
.card h3 { margin: 0 0 16px; font-size: 16px; }
.grid-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 12px; align-items: end; }
.grid-form .field { margin: 0; }
.staff-table { width: 100%; border-collapse: collapse; }
.staff-table th { text-align: left; font-size: 14px; letter-spacing: 0; color: var(--muted); font-weight: 600; padding: 0 12px 10px; border-bottom: 1px solid var(--line); }
.staff-table td { padding: 12px; border-bottom: 1px solid #f0eadf; vertical-align: middle; }
.staff-table tr:last-child td { border-bottom: 0; }
.person { display: flex; gap: 12px; align-items: center; }
.person .n { font-weight: 600; }
.person .e { font-size: 13px; color: var(--muted); }
.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.pill { font-size: 12px; padding: 2px 9px; border-radius: 20px; background: #eef3ef; color: var(--forest-2); }
.pill.on { background: #e1f3e8; color: #23784a; }
.log-row { display: flex; gap: 14px; padding: 10px 0; border-bottom: 1px solid #f0eadf; font-size: 14px; }
.log-row:last-child { border-bottom: 0; }
.log-row .when { color: var(--muted); width: 150px; flex: none; }
.muted { color: var(--muted); }

.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.team-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.team-card .n, .team-card .e { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-card .btn { align-self: flex-start; }
.team-meta { font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.team-mail { color: var(--forest-2); text-decoration: none; overflow-wrap: anywhere; }
.team-mail:hover { text-decoration: underline; }

/* modal & toast */
.modal-bg.locked { background: rgba(20,30,27,.82); backdrop-filter: blur(4px); }
.modal-bg { position: fixed; inset: 0; background: rgba(20,30,27,.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: var(--paper); border-radius: 16px; width: 100%; max-width: 420px; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal h3 { font-family: var(--serif); font-size: 28px; margin: 0 0 6px; font-weight: 600; }
.modal p { color: var(--muted); margin: 0 0 18px; line-height: 1.5; }
.modal .row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.picker { max-height: 320px; overflow-y: auto; margin: 0 -8px 8px; }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--forest); color: var(--cream); padding: 10px 18px; border-radius: 10px; opacity: 0; transition: all .2s; pointer-events: none; z-index: 60; font-size: 14px; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--danger); }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .main, .main.no-list { grid-template-columns: 76px 280px 1fr; }
  .main.no-list { grid-template-columns: 76px 1fr; }
  .nav { padding: 18px 10px; align-items: center; }
  .nav .brand-name, .nav-item span, .nav-section, .nav-foot .who, .nav-item .count { display: none; }
  .nav .brand { padding: 0 0 18px; }
  .nav-item { justify-content: center; position: relative; }
  .nav-foot { flex-direction: column; }
  .grid-form { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .login { grid-template-columns: 1fr; }
  .login-art { padding: 28px 20px; min-height: 0; }
  .login-art h1 { font-size: 34px; margin-top: 28px; }
  .login-art::after { display: none; }
  .main, .main.no-list { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .nav { order: 2; flex-direction: row; padding: 6px 8px; justify-content: space-around; }
  .nav .brand, .nav-foot .who { display: none; }
  .nav-foot { margin: 0; border: 0; padding: 0; flex-direction: row; }
  .nav-item { width: auto; padding: 10px 14px; }
  .convs, .chat, .page { order: 1; min-height: 0; }
  .main.chat-open .convs { display: none; }
  .main:not(.chat-open) .chat { display: none; }
  .back-btn { display: inline-flex; color: var(--ink); }
  .msg { max-width: 88%; }
  .chat-head, .msgs, .composer { padding-left: 14px; padding-right: 14px; }
  .composer-ro { margin: 10px 14px 14px; }
  .grid-form { grid-template-columns: 1fr; }
  .staff-table thead { display: none; }
  .staff-table tr { display: block; padding: 12px 0; border-bottom: 1px solid #f0eadf; }
  .staff-table td { display: block; border: 0; padding: 4px 0; }
  .actions { justify-content: flex-start; }
  .log-row { flex-direction: column; gap: 2px; }
}
