:root {
  /* Odoo-inspired palette (aubergine/violet chrome). --teal* kept for compat. */
  --teal: #714b67;
  --teal-dark: #5b3c53;
  --teal-light: #f3edf1;
  --primary: #714b67;
  --primary-dark: #5b3c53;
  --primary-soft: #f3edf1;
  /* Sidebar (Odoo purple chrome) */
  --sidebar: #714b67;
  --sidebar-2: #5b3c53;
  --sidebar-text: #e7dbe4;
  --sidebar-active-bg: rgba(255, 255, 255, 0.16);
  /* Surfaces */
  --bg: #f3f2f5;
  --card: #ffffff;
  --text: #313131;
  --muted: #6c757d;
  --border: #dee2e6;
  --danger: #e4606d;
  --danger-bg: #fdf0f1;
  --warn: #f0ad4e;
  --ok: #28a745;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(33, 37, 41, 0.06);
  --shadow-lg: 0 10px 30px rgba(33, 37, 41, 0.16);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
a { cursor: pointer; text-decoration: none; color: inherit; }

/* Buttons */
.btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}
.btn:hover { background: #f6f4f6; border-color: #cfc4cc; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(113, 75, 103, 0.25); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

input, textarea, select {
  font-family: inherit;
  font-size: 14px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 100%;
  background: #fff;
  color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
label { display: block; font-weight: 600; margin-bottom: 5px; font-size: 13px; }

/* Login */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1100px 560px at 18% -10%, #8e5f81 0%, transparent 60%), linear-gradient(135deg, #2b1c27 0%, #4a3143 55%, #714b67 135%);
}
.login-card {
  background: #fff; padding: 40px; border-radius: 20px; width: 340px;
  box-shadow: var(--shadow-lg); text-align: center;
  display: flex; flex-direction: column; gap: 12px;
}
.login-logo { font-size: 46px; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p.muted { margin: 0 0 8px; }

/* Modal cards (openModal / forward / merge) must scroll if taller than the viewport */
.login-screen > .card { max-height: 90vh; overflow-y: auto; }

/* ===================== Odoo-style shell ===================== */
.app { display: flex; flex-direction: column; height: 100vh; }

/* Top navbar (aubergine chrome) */
.o-navbar { display: flex; align-items: stretch; height: 46px; background: var(--primary); color: #fff; flex-shrink: 0; position: relative; z-index: 40; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2); }
.o-apps-toggle { width: 46px; border: none; background: transparent; cursor: pointer; display: grid; grid-template-columns: repeat(3, 4px); grid-template-rows: repeat(3, 4px); gap: 3px; align-content: center; justify-content: center; flex-shrink: 0; }
.o-apps-toggle span { width: 4px; height: 4px; border-radius: 1px; background: rgba(255, 255, 255, 0.82); transition: background 0.15s; }
.o-apps-toggle:hover { background: rgba(255, 255, 255, 0.12); }
.o-apps-toggle:hover span { background: #fff; }
.o-brand { display: flex; align-items: center; gap: 8px; padding: 0 16px 0 8px; font-weight: 700; font-size: 15px; border-right: 1px solid rgba(255, 255, 255, 0.16); white-space: nowrap; }
.o-brand-icon { font-size: 18px; }
.o-menu { display: flex; align-items: stretch; flex: 1; overflow-x: auto; scrollbar-width: none; }
.o-menu::-webkit-scrollbar { display: none; }
.o-menu-item { display: flex; align-items: center; gap: 6px; padding: 0 15px; color: rgba(255, 255, 255, 0.82); font-weight: 500; font-size: 13.5px; cursor: pointer; white-space: nowrap; border-bottom: 3px solid transparent; transition: background 0.12s, color 0.12s; }
.o-menu-item:hover { background: rgba(255, 255, 255, 0.10); color: #fff; }
.o-menu-item.active { color: #fff; font-weight: 600; border-bottom-color: #fff; background: rgba(255, 255, 255, 0.08); }
.o-systray { display: flex; align-items: center; gap: 12px; padding: 0 10px 0 12px; flex-shrink: 0; }
.o-bot-status { font-size: 12px; color: rgba(255, 255, 255, 0.9); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.o-bot-status .dot { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15); }
.o-user { position: relative; display: flex; align-items: center; gap: 4px; cursor: pointer; padding: 4px 2px; }
.o-user-avatar { width: 30px; height: 30px; border-radius: 50%; background: rgba(255, 255, 255, 0.22); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.o-user-caret { font-size: 10px; opacity: 0.85; }
.o-user-pop { position: absolute; top: 44px; right: 0; background: #fff; color: var(--text); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg); min-width: 200px; padding: 6px; z-index: 50; }
.o-user-pop-head { font-size: 12px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.o-user-pop-item { display: block; width: 100%; text-align: left; border: none; background: none; padding: 9px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text); }
.o-user-pop-item:hover { background: var(--primary-soft); }
.o-user-pop-item.danger { color: var(--danger); }
.o-badge { background: #fff; color: var(--primary); border-radius: 20px; padding: 0 6px; font-size: 11px; font-weight: 700; min-width: 17px; text-align: center; }

/* App switcher overlay (Odoo home menu) */
.o-apps-overlay { position: fixed; inset: 46px 0 0 0; background: rgba(243, 242, 245, 0.96); backdrop-filter: blur(4px); z-index: 35; display: flex; flex-direction: column; align-items: center; padding: 46px 20px; overflow-y: auto; animation: o-fade 0.14s ease; }
@keyframes o-fade { from { opacity: 0; } to { opacity: 1; } }
.o-apps-search { width: 100%; max-width: 420px; margin-bottom: 36px; }
.o-apps-search input { text-align: center; font-size: 16px; padding: 12px 18px; border-radius: 24px; box-shadow: var(--shadow); }
.o-apps-grid { display: grid; grid-template-columns: repeat(auto-fill, 132px); gap: 8px 24px; justify-content: center; max-width: 780px; }
.o-app-tile { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 22px 8px; border-radius: 12px; cursor: pointer; transition: transform 0.14s, box-shadow 0.14s, background 0.14s; }
.o-app-tile:hover { background: #fff; box-shadow: var(--shadow-lg); transform: translateY(-3px); }
.o-app-ico { font-size: 42px; line-height: 1; }
.o-app-lbl { font-size: 13px; font-weight: 600; color: var(--text); }

/* Content shell */
.o-content { flex: 1; overflow-y: auto; background: var(--bg); }
.view { max-width: 1320px; margin: 0 auto; padding: 22px 26px 44px; }

h2.page-title { margin: 0; font-size: 21px; font-weight: 600; letter-spacing: -0.01em; color: #2b2b2b; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stat .num { font-size: 30px; font-weight: 700; color: var(--teal-dark); }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* Badges */
.badge { background: var(--danger); color: #fff; border-radius: 20px; padding: 1px 8px; font-size: 11px; font-weight: 700; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.pill-requested { background: #fef3c7; color: #92400e; }
.pill-confirmed { background: #dcfce7; color: #166534; }
.pill-cancelled { background: #fee2e2; color: #991b1b; }
.pill-completed { background: #e0e7ff; color: #3730a3; }
.pill-grey { background: var(--bg); color: var(--muted); }
.pill-green { background: #dcfce7; color: #166534; }
.pill-amber { background: #fef3c7; color: #92400e; }
.pill-red { background: #fee2e2; color: #991b1b; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }

/* Conversations — Odoo-styled chat */
.chat-layout { display: grid; grid-template-columns: 340px 1fr; gap: 16px; height: calc(100vh - 150px); }
.conv-col { display: flex; flex-direction: column; min-height: 0; }
.conv-tabs { display: flex; gap: 4px; margin-bottom: 8px; flex-shrink: 0; }
.conv-tab { padding: 5px 12px; border-radius: 6px; font-size: 12.5px; font-weight: 500; color: var(--muted); cursor: pointer; border: 1px solid transparent; }
.conv-tab:hover { background: #fff; }
.conv-tab.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.conv-list { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding-right: 4px; }
.conv-item { padding: 9px 10px; border-radius: 8px; cursor: pointer; display: flex; gap: 11px; align-items: center; border: 1px solid transparent; }
.conv-item:hover { background: #fff; }
.conv-item.active { background: #fff; border-color: var(--border); box-shadow: var(--shadow); }
.avatar { width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0; color: #fff; font-weight: 600; font-size: 15px; display: flex; align-items: center; justify-content: center; }
.conv-main { flex: 1; min-width: 0; }
.conv-row1 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.conv-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.conv-row2 { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 2px; }
.conv-preview { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.conv-item.unread .conv-name { font-weight: 700; }
.conv-item.unread .conv-preview { color: var(--text); font-weight: 500; }
.conv-icons { display: inline-flex; gap: 4px; align-items: center; font-size: 11px; color: var(--muted); flex-shrink: 0; }
.unread-badge { background: var(--primary); color: #fff; border-radius: 20px; min-width: 18px; height: 18px; padding: 0 5px; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }

.chat-panel { position: relative; display: flex; flex-direction: column; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.chat-head { padding: 9px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 11px; }
.chat-head .avatar { width: 40px; height: 40px; font-size: 14px; }
.chat-head-info { flex: 1; min-width: 0; }
.chat-head-info strong { display: block; }
.chat-sub { font-size: 12px; color: var(--muted); }
.chat-head-actions { display: flex; gap: 6px; align-items: center; }
.chat-search { padding: 8px 14px; border-bottom: 1px solid var(--border); background: #faf9fb; display: none; }
.chat-search.open { display: block; }
.chat-meta { display: flex; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--border); background: #faf9fb; }
.chat-meta input { font-size: 12px; padding: 6px 10px; border-radius: 6px; }

.chat-body { flex: 1; overflow-y: auto; padding: 14px 6%; background: #f3f2f5; display: flex; flex-direction: column; gap: 3px; }
.date-sep, .unread-sep { text-align: center; margin: 12px 0 6px; }
.date-sep span { background: #fff; color: var(--muted); font-size: 11px; font-weight: 500; padding: 4px 11px; border-radius: 6px; box-shadow: var(--shadow); }
.unread-sep span { background: var(--primary-soft); color: var(--primary); font-size: 11px; font-weight: 600; padding: 3px 12px; border-radius: 6px; }
.bubble { position: relative; max-width: 66%; padding: 7px 10px; border-radius: 8px; font-size: 13.5px; line-height: 1.38; white-space: pre-wrap; word-wrap: break-word; box-shadow: var(--shadow); }
.bubble.inbound { background: #fff; border: 1px solid var(--border); align-self: flex-start; border-top-left-radius: 2px; margin-right: 22px; }
.bubble.outbound { background: var(--primary); color: #fff; align-self: flex-end; border-top-right-radius: 2px; margin-left: 22px; }
.bubble.hit { outline: 2px solid var(--primary); outline-offset: 1px; }
.bubble-meta { font-size: 10px; color: var(--muted); text-align: right; margin-top: 2px; user-select: none; }
.bubble.outbound .bubble-meta { color: rgba(255, 255, 255, 0.75); }
.ticks { opacity: 0.9; }
.ticks.read { color: #7fd4ff; }
.ticks.fail { color: #ffd0d0; }
.bubble-star { position: absolute; top: 5px; font-size: 12px; color: #d1a000; cursor: pointer; opacity: 0; transition: opacity 0.12s; user-select: none; }
.bubble.inbound .bubble-star { right: -20px; }
.bubble.outbound .bubble-star { left: -20px; }
.bubble:hover .bubble-star { opacity: 0.4; }
.bubble-star.on { opacity: 1; }

/* Per-message actions, quotes & tombstones */
.msg-menu { position: absolute; top: 3px; right: 4px; width: 20px; height: 18px; border: none; background: rgba(0,0,0,0.06); color: inherit; border-radius: 4px; font-size: 12px; line-height: 1; cursor: pointer; opacity: 0; transition: opacity 0.12s; padding: 0; z-index: 2; }
.bubble.outbound .msg-menu { background: rgba(255,255,255,0.22); color: #fff; }
.bubble:hover .msg-menu { opacity: 1; }
.msg-pop { position: absolute; min-width: 152px; padding: 5px; z-index: 30; }
.msg-pop button { display: block; width: 100%; text-align: left; border: none; background: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text); }
.msg-pop button:hover { background: var(--primary-soft); }
.msg-pop button[data-act="delete"] { color: var(--danger); }
.bubble-quote { border-left: 3px solid var(--primary); background: rgba(0,0,0,0.05); padding: 4px 8px; border-radius: 4px; font-size: 12px; margin-bottom: 4px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.bubble.outbound .bubble-quote { background: rgba(255,255,255,0.18); color: rgba(255,255,255,0.88); border-left-color: #fff; }
.deleted-text { font-style: italic; opacity: 0.75; }
.star-mark { color: #f0b429; }
.bubble.outbound .star-mark { color: #ffe08a; }

.reply-bar { display: none; }
.reply-bar.open { display: flex; align-items: center; gap: 8px; padding: 8px 12px 0; background: #faf9fb; }
.reply-quote { flex: 1; min-width: 0; background: #fff; border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: 4px; padding: 5px 9px; }
.reply-quote-label { display: block; font-size: 11px; font-weight: 600; color: var(--primary); }
.reply-quote-body { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-x { border: none; background: none; cursor: pointer; font-size: 15px; color: var(--muted); padding: 4px 6px; }
.reply-x:hover { color: var(--danger); }

.chat-settings { display: none; flex-direction: column; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); background: #faf9fb; }
.chat-settings.open { display: flex; }
.cs-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.chat-settings input, .chat-settings textarea { font-size: 13px; }

.forward-preview { background: #f3f2f5; border: 1px solid var(--border); border-radius: 6px; padding: 9px 11px; font-size: 13px; max-height: 90px; overflow-y: auto; white-space: pre-wrap; }
.forward-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; }
.forward-list .qr-item { border-bottom: 1px solid var(--border); }
.forward-list .qr-item:last-child { border-bottom: none; }
.bubble.media-bubble { padding: 3px; }
.media-img { display: block; max-width: 260px; max-height: 300px; border-radius: 6px; cursor: pointer; }
.media-cap { padding: 5px 7px 2px; }
.doc-chip { display: flex; align-items: center; gap: 9px; padding: 8px 10px; text-decoration: none; color: inherit; }
.doc-chip .doc-ico { font-size: 24px; }

.chat-input { position: relative; padding: 8px 12px; border-top: 1px solid var(--border); display: flex; gap: 6px; align-items: flex-end; background: #faf9fb; }
.icon-btn { width: 38px; height: 38px; border-radius: 6px; border: 1px solid transparent; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--primary-soft); color: var(--primary); }
.chat-input textarea { resize: none; height: 38px; max-height: 120px; border-radius: 8px; padding: 9px 12px; flex: 1; min-width: 0; }
.send-btn { width: 38px; height: 38px; border-radius: 6px; border: none; background: var(--primary); color: #fff; font-size: 16px; cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.send-btn:hover { background: var(--primary-dark); }
.scroll-btn { position: absolute; right: 18px; bottom: 74px; width: 38px; height: 38px; border-radius: 50%; background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow-lg); cursor: pointer; font-size: 15px; color: var(--muted); display: none; align-items: center; justify-content: center; z-index: 10; }
.scroll-btn.show { display: flex; }

/* Popovers — emoji, quick replies, chat menu */
.pop { position: absolute; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg); z-index: 30; }
.emoji-pop { bottom: 54px; left: 12px; width: 268px; padding: 8px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-pop button { border: none; background: none; font-size: 20px; cursor: pointer; padding: 3px; border-radius: 6px; line-height: 1; }
.emoji-pop button:hover { background: var(--primary-soft); }
.qr-pop { bottom: 54px; left: 12px; right: 12px; max-height: 240px; overflow-y: auto; padding: 5px; }
.qr-item { padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qr-item:hover { background: var(--primary-soft); }
.qr-empty { padding: 12px; color: var(--muted); font-size: 12px; text-align: center; }
.menu-pop { top: 50px; right: 14px; min-width: 190px; padding: 5px; }
.menu-pop button { display: flex; gap: 9px; align-items: center; width: 100%; text-align: left; border: none; background: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text); }
.menu-pop button:hover { background: var(--primary-soft); }

.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Odoo control panel — the sticky action bar at the top of a view */
.view > .toolbar:first-child,
.view > .o-cp:first-child {
  margin: -22px -26px 22px; padding: 11px 26px; background: #fff;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
  box-shadow: 0 1px 2px rgba(33, 37, 41, 0.04);
}
.view > .page-title:first-child { display: block; margin: -6px 0 20px; }
.o-cp { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.o-breadcrumb { display: flex; align-items: center; gap: 7px; font-size: 15px; font-weight: 600; }
.o-breadcrumb .o-bc-back { font-size: 13px; font-weight: 500; color: var(--primary); cursor: pointer; }
.o-breadcrumb .o-bc-sep { color: var(--muted); font-weight: 400; }
.o-breadcrumb .o-bc-parent { color: var(--muted); font-weight: 500; cursor: pointer; }
.o-breadcrumb .o-bc-parent:hover { color: var(--primary); }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 12px 20px; border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3); z-index: 100; font-size: 13px;
}
.toast.err { background: var(--danger); }

.field { margin-bottom: 14px; }
.help { font-size: 12px; color: var(--muted); margin-top: 4px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--muted); }

/* Insights charts */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar-stack { width: 62%; min-height: 3px; display: flex; flex-direction: column; justify-content: flex-end; border-radius: 5px 5px 0 0; overflow: hidden; background: #eef1f6; }
.bar-out { background: var(--primary); }
.bar-in { background: #c7d2fe; }
.bar-lbl { font-size: 10px; color: var(--muted); }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; margin-right: 3px; }

@media (max-width: 900px) {
  .chat-layout { grid-template-columns: 1fr; }
  .view { padding: 16px 14px 40px; }
  .view > .toolbar:first-child { margin: -16px -14px 16px; padding: 10px 14px; }
}
@media (max-width: 640px) {
  .o-brand-name { display: none; }
  .o-menu-item { padding: 0 11px; font-size: 13px; }
  .grid-stats { grid-template-columns: 1fr 1fr; }
}

/* Patients */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.mrn { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; color: var(--muted); }
tr.row-click { cursor: pointer; }
tr.row-click:hover td { background: var(--primary-soft); }
.avatar-lg { width: 60px; height: 60px; font-size: 22px; }
.patient-head { display: flex; align-items: center; gap: 16px; }
.patient-head-info { min-width: 0; }
.pat-tags { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 5px; }
.pat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0; }
.pat-grid h3, .card > h3 { margin: 0 0 10px; font-size: 14px; }
.d-row { display: flex; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.d-row:last-child { border-bottom: none; }
.d-k { color: var(--muted); min-width: 130px; flex-shrink: 0; }
.d-v { color: var(--text); word-break: break-word; }
.picker-list { max-height: 190px; overflow-y: auto; margin-top: 4px; }
.picker-item { padding: 8px 10px; border-radius: var(--radius); cursor: pointer; font-size: 13px; }
.picker-item:hover { background: var(--primary-soft); }

/* Pain-score trend chart */
.pain-chart { display: flex; align-items: flex-end; gap: 8px; height: 110px; padding: 8px 2px 0; overflow-x: auto; }
.pain-col { display: flex; flex-direction: column; align-items: center; gap: 4px; justify-content: flex-end; min-width: 22px; }
.pain-bar { width: 20px; border-radius: 4px 4px 0 0; }
.pain-val { font-size: 11px; color: var(--muted); }
.pain-lo { background: #2e9b5b; }
.pain-mid { background: #e0a020; }
.pain-hi { background: #d64545; }
.pain-summary { margin-top: 10px; font-size: 13px; color: var(--muted); }
.pain-summary.good { color: #2e9b5b; font-weight: 600; }
.pain-summary.bad { color: #d64545; font-weight: 600; }
.pain-badge { font-size: 11px; font-weight: 600; color: #fff; padding: 2px 8px; border-radius: 20px; }
.pain-badge.pain-lo { background: #2e9b5b; }
.pain-badge.pain-mid { background: #e0a020; }
.pain-badge.pain-hi { background: #d64545; }

/* Visit cards */
.visit-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.visit-card:last-child { margin-bottom: 0; }
.visit-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.visit-actions { display: flex; align-items: center; gap: 6px; }
.visit-row { font-size: 13px; line-height: 1.5; padding: 1px 0; }
.visit-row .vk { color: var(--muted); font-weight: 600; margin-right: 4px; }
.visit-row.followup { margin-top: 6px; color: var(--primary); font-weight: 600; }
.icon-btn { background: none; border: none; cursor: pointer; font-size: 13px; padding: 2px 4px; border-radius: 4px; opacity: 0.6; }
.icon-btn:hover { opacity: 1; background: var(--primary-soft); }
input[type="range"] { width: 100%; accent-color: var(--primary); }

/* Prescriptions */
.rx-card { border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.rx-card:last-child { margin-bottom: 0; }
.rx-items { margin: 6px 0; }
.rx-item { font-size: 13px; line-height: 1.5; padding: 3px 0; border-bottom: 1px dashed var(--border); }
.rx-item:last-child { border-bottom: none; }
.rx-num { color: var(--muted); font-weight: 600; }
.rx-instr { font-size: 12px; color: var(--muted); margin-left: 16px; }
.rx-edit-head { display: grid; grid-template-columns: 1.4fr 0.9fr 0.9fr 1fr 0.9fr 1.4fr 32px; gap: 6px; font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 4px; padding: 0 2px; }
.rx-edit-row { display: grid; grid-template-columns: 1.4fr 0.9fr 0.9fr 1fr 0.9fr 1.4fr 32px; gap: 6px; margin-bottom: 6px; align-items: center; }
.rx-edit-row input { width: 100%; padding: 6px 8px; font-size: 13px; }
.rx-edit-row .rx-del { color: var(--danger); }

/* Billing */
.inv-card { border-left-color: #2e9b5b; }
.inv-totals { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--border); }
.inv-due { color: var(--danger); font-weight: 600; }
.inv-edit-head { display: grid; grid-template-columns: 1fr 70px 100px 100px 32px; gap: 8px; font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 4px; padding: 0 2px; }
.inv-edit-row { display: grid; grid-template-columns: 1fr 70px 100px 100px 32px; gap: 8px; margin-bottom: 6px; align-items: center; }
.inv-edit-row input { width: 100%; padding: 6px 8px; font-size: 13px; }
.inv-amt { font-size: 13px; text-align: right; color: var(--muted); }
.inv-edit-row .inv-del { color: var(--danger); }
.inv-summary { margin-top: 10px; padding: 10px 12px; background: var(--primary-soft); border-radius: var(--radius); font-size: 13px; }

/* Practice command-center (Overview) */
.section-h { margin: 22px 0 10px; font-size: 15px; }
.kpi-money { color: #2e9b5b; }
.kpi-due { color: var(--danger); }
.kpi-good { color: #2e9b5b; }
.pt-list { display: flex; flex-direction: column; }
.pt-row { display: grid; grid-template-columns: 88px 1fr auto; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border); font-size: 13px; }
.pt-row:last-child { border-bottom: none; }
.pt-row:hover { background: var(--primary-soft); border-radius: 4px; }
.pt-time { color: var(--primary); font-weight: 600; font-size: 12px; }
.pt-main { display: flex; flex-direction: column; min-width: 0; }
.pt-name { font-weight: 600; }
.pt-meta { color: var(--muted); font-size: 12px; }
.svc-row { display: grid; grid-template-columns: 120px 1fr auto; align-items: center; gap: 10px; padding: 5px 0; font-size: 13px; }
.svc-bar-wrap { grid-column: 1; background: var(--bg); border-radius: 4px; height: 10px; overflow: hidden; }
.svc-bar { height: 100%; background: var(--primary); border-radius: 4px; }
.svc-name { grid-column: 2; }
.svc-amt { grid-column: 3; font-weight: 600; color: var(--muted); }
.pt-amt { font-weight: 600; text-align: right; white-space: nowrap; }
.mode-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.mode-chip { background: var(--primary-soft); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; font-size: 13px; }

/* Clinical-safety alert banner */
.med-alert { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 12px 0; padding: 10px 14px; border-radius: var(--radius); background: #fff7ed; border: 1px solid #fed7aa; font-size: 13px; }
.med-alert-danger { background: #fef2f2; border-color: #fecaca; }
.med-alert-item strong { color: #92400e; }
.med-alert-danger .med-alert-item:first-child strong { color: #991b1b; }

/* ===================== Dashboard ===================== */
.o-hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.o-hero-greet { font-size: 22px; font-weight: 700; color: #2b2b2b; letter-spacing: -0.01em; }
.o-hero-date { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.o-hero-clinic { font-size: 13px; font-weight: 600; color: var(--primary); background: var(--primary-soft); padding: 8px 14px; border-radius: 999px; }

.o-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.o-kpi { position: relative; display: flex; align-items: center; gap: 14px; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; box-shadow: var(--shadow); overflow: hidden; transition: transform 0.14s, box-shadow 0.14s; }
.o-kpi[data-goto]:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.o-kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--k-accent, var(--primary)); }
.o-kpi-ico { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; background: var(--k-soft, var(--primary-soft)); flex-shrink: 0; }
.o-kpi-body { min-width: 0; }
.o-kpi-val { font-size: 27px; font-weight: 700; color: #2b2b2b; line-height: 1.1; letter-spacing: -0.02em; }
.o-kpi-val.sm { font-size: 20px; }
.o-kpi-lbl { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.o-kpi.tone-violet { --k-accent: #714b67; --k-soft: #f3edf1; }
.o-kpi.tone-blue { --k-accent: #0ea5e9; --k-soft: #e0f2fe; }
.o-kpi.tone-green { --k-accent: #10b981; --k-soft: #d1fae5; }
.o-kpi.tone-amber { --k-accent: #f59e0b; --k-soft: #fef3c7; }
.o-kpi.tone-red { --k-accent: #ef4444; --k-soft: #fee2e2; }

.o-dash-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.o-panel { padding: 16px 18px; }
.o-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.o-panel-head h3 { margin: 0; font-size: 14px; }
.o-panel-link { font-size: 12.5px; color: var(--primary); font-weight: 600; cursor: pointer; }
.o-panel-link:hover { text-decoration: underline; }
.o-empty-sm { color: var(--muted); font-size: 13px; padding: 18px 4px; text-align: center; }
.o-month-mini { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.o-mm { text-align: center; }
.o-mm-v { font-size: 18px; font-weight: 700; color: var(--primary); }
.o-mm-l { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.o-outcome { margin-top: 14px; padding: 10px 12px; background: #ecfdf5; border: 1px solid #a7f3d0; border-radius: var(--radius); font-size: 12.5px; color: #065f46; }

/* Team roster (Settings) */
.team-list { display: flex; flex-direction: column; gap: 8px; }
.team-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; }
.team-row.inactive { opacity: 0.55; }
.team-av { width: 38px; height: 38px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.team-main { flex: 1; min-width: 0; }
.team-name { font-weight: 600; }
.team-sub { font-size: 12px; color: var(--muted); }
.team-role { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 9px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); }
.team-acts { display: flex; gap: 4px; }

/* Documents & reports */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; }
.doc-card { position: relative; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; cursor: pointer; background: #fff; transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s; }
.doc-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--primary); }
.doc-thumb { position: relative; height: 104px; background: linear-gradient(135deg, #f7f5f9, #eee9f0); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-big-ico { font-size: 40px; }
.doc-cat-badge { position: absolute; left: 6px; bottom: 6px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; padding: 2px 7px; border-radius: 999px; background: rgba(0, 0, 0, 0.62); color: #fff; }
.doc-info { padding: 8px 10px 10px; }
.doc-title { font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.doc-del { position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; border: none; border-radius: 50%; background: rgba(0, 0, 0, 0.55); color: #fff; cursor: pointer; font-size: 12px; line-height: 1; opacity: 0; transition: opacity 0.12s; }
.doc-card:hover .doc-del { opacity: 1; }
.doc-del:hover { background: var(--danger); }
.pick-doc-list { max-height: 340px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; margin-top: 6px; border-top: 1px solid var(--border); padding-top: 10px; }
.pick-doc { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.pick-doc:hover { background: var(--primary-soft); }
.pick-doc input { flex-shrink: 0; }
.pick-thumb { width: 42px; height: 42px; border-radius: 6px; overflow: hidden; background: #f1eef3; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.pick-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pick-meta { min-width: 0; display: flex; flex-direction: column; }

@media (max-width: 900px) {
  .pat-grid { grid-template-columns: 1fr; }
  .o-dash-2col { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: 1fr; }
}

/* Segmented control (Day / List toggle) */
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 2px; gap: 2px; }
.seg button { border: none; background: transparent; padding: 5px 12px; border-radius: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }

/* Day-picker chips (Settings → Availability) */
.daypick { display: flex; flex-wrap: wrap; gap: 6px; }
.daychip { display: inline-flex; align-items: center; gap: 5px; font-weight: 500; font-size: 13px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; background: #fff; margin: 0; }
.daychip input { width: auto; margin: 0; accent-color: var(--primary); }

/* Appointment day calendar */
.cal-weekstrip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 12px; }
.cal-wday { position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 2px; background: #fff; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; transition: border-color 0.12s, background 0.12s; }
.cal-wday:hover { border-color: var(--primary); }
.cal-wday.closed { background: #faf9fb; color: var(--muted); }
.cal-wday.sel { background: var(--primary); border-color: var(--primary); color: #fff; }
.cal-wday-d { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.cal-wday-n { font-size: 17px; font-weight: 700; }
.cal-wday-c { position: absolute; top: 4px; right: 5px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--primary); color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.cal-wday.sel .cal-wday-c { background: #fff; color: var(--primary); }

.cal-card { padding: 0; overflow: hidden; }
.cal-dayhead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.cal-dayhead strong { font-size: 15px; }
.cal-closed-note { padding: 9px 16px; background: #fff7ed; border-bottom: 1px solid #fed7aa; color: #92400e; font-size: 12.5px; }
.cal-grid { display: flex; flex-direction: column; }
.cal-slot { display: grid; grid-template-columns: 78px 1fr; border-bottom: 1px solid var(--border); min-height: 46px; }
.cal-slot:last-child { border-bottom: none; }
.cal-time { padding: 8px 10px; font-size: 12px; color: var(--muted); font-weight: 600; border-right: 1px solid var(--border); background: #faf9fb; white-space: nowrap; }
.cal-cell { padding: 6px; display: flex; flex-wrap: wrap; gap: 6px; cursor: pointer; align-items: flex-start; }
.cal-cell:hover { background: var(--primary-soft); }
.cal-empty { color: transparent; font-size: 16px; align-self: center; }
.cal-cell:hover .cal-empty { color: var(--primary); }
.cal-appt { display: flex; flex-direction: column; gap: 1px; min-width: 150px; max-width: 240px; padding: 6px 9px; border-radius: 7px; background: var(--primary-soft); border-left: 3px solid var(--primary); cursor: pointer; transition: transform 0.1s; }
.cal-appt:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.cal-appt-t { font-size: 11px; font-weight: 700; color: var(--primary); }
.cal-appt-nm { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-appt-meta { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-appt.s-confirmed { background: #dcfce7; border-left-color: #16a34a; }
.cal-appt.s-confirmed .cal-appt-t { color: #166534; }
.cal-appt.s-requested { background: #fef3c7; border-left-color: #d97706; }
.cal-appt.s-requested .cal-appt-t { color: #92400e; }
.cal-appt.s-completed { background: #e0e7ff; border-left-color: #4f46e5; }
.cal-appt.s-completed .cal-appt-t { color: #3730a3; }
.cal-appt.s-no_show { background: #fee2e2; border-left-color: #dc2626; }
.cal-appt.s-no_show .cal-appt-t { color: #991b1b; }
.cal-off { padding: 12px 16px; border-top: 1px solid var(--border); background: #faf9fb; }
.cal-off-h { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 8px; }
.cal-off .cal-appt { display: inline-flex; margin: 0 6px 6px 0; }

@media (max-width: 640px) {
  .cal-slot { grid-template-columns: 62px 1fr; }
  .cal-wday-n { font-size: 15px; }
}

/* WhatsApp message templates */
.tpl-rec-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.tpl-rec { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.tpl-rec-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tpl-desc { font-size: 12px; color: var(--muted); }
.tpl-body { font-size: 12.5px; background: var(--bg); border-radius: 6px; padding: 8px 10px; white-space: pre-wrap; line-height: 1.4; margin-top: 2px; }
.tpl-vars { display: flex; flex-wrap: wrap; gap: 5px; }
.tpl-var { font-size: 11px; background: var(--primary-soft); color: var(--primary); padding: 2px 7px; border-radius: 999px; font-weight: 600; }
.tpl-actions { margin-top: 4px; }
.tpl-h { margin: 16px 0 8px; font-size: 13px; }
.tpl-list { display: flex; flex-direction: column; gap: 8px; }
.tpl-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.tpl-warn { background: #fff7ed; border: 1px solid #fed7aa; color: #92400e; font-size: 12.5px; padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; line-height: 1.5; }
.tpl-warn code { background: rgba(0, 0, 0, 0.06); padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }
.tpl-custom { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.tpl-custom summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--primary); }

/* Roles */
.o-role-chip { display: inline-block; margin-top: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 9px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); }
.team-role.role-admin, .o-role-chip.role-admin { background: #e0e7ff; color: #3730a3; }
.team-role.role-doctor, .o-role-chip.role-doctor { background: #dcfce7; color: #166534; }
.team-role.role-receptionist, .o-role-chip.role-receptionist { background: #fef3c7; color: #92400e; }

/* Multi-doctor day calendar columns */
.cal-cols-scroll { overflow-x: auto; }
.cal-cols { display: grid; min-width: 100%; }
.cal-corner { background: #faf9fb; border-bottom: 1px solid var(--border); position: sticky; left: 0; z-index: 3; }
.cal-colhead { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); font-weight: 600; font-size: 13px; background: #fff; position: sticky; top: 0; z-index: 2; }
.cal-colav { width: 26px; height: 26px; border-radius: 50%; color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cal-colnm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-cols .cal-time { padding: 8px 10px; font-size: 12px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); background: #faf9fb; white-space: nowrap; position: sticky; left: 0; z-index: 1; display: flex; align-items: center; }
.cal-cols .cal-cell { padding: 5px; display: flex; flex-direction: column; gap: 5px; cursor: pointer; border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); min-height: 44px; align-items: stretch; }
.cal-cols .cal-cell:hover { background: var(--primary-soft); }
.cal-cols .cal-cell.dim { background-color: #fafafa; background-image: repeating-linear-gradient(45deg, transparent, transparent 7px, rgba(0, 0, 0, 0.03) 7px, rgba(0, 0, 0, 0.03) 8px); }
.cal-cols .cal-cell.dim:hover { background-color: var(--primary-soft); }
.cal-cols .cal-appt { min-width: 0; max-width: none; }
.cal-cols .cal-empty { align-self: center; margin: 0 auto; }

