/* ══════════════════════════════════════════════════════════
   oprex.css — Warm Grey + Dark Mode design system
   Fonts: DM Sans (body) + DM Mono (numbers)
   Icons: Bootstrap Icons (bi-*) + Phosphor Icons (ph *)
══════════════════════════════════════════════════════════ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

/* ══════════════════════════════════════════════
   TOKENS — Light (warm grey)
══════════════════════════════════════════════ */
[data-theme="light"], :root {
  --nav-bg:         #2c2825;
  --nav-border:     #3d3733;
  --nav-text:       #c8bfb8;
  --nav-text-dim:   #8a7f78;
  --nav-active:     #ffffff;
  --nav-hover-bg:   rgba(255,255,255,.07);
  --nav-active-bg:  rgba(255,255,255,.12);

  --sidebar-bg:     #f5f0ec;
  --sidebar-border: #e8e0d8;
  --sidebar-text:   #5c524a;
  --sidebar-dim:    #9e9189;
  --sidebar-active-bg:     #ffffff;
  --sidebar-active-text:   #2c2825;
  --sidebar-active-border: #c9a87c;
  --sidebar-section:       #b5a89e;

  --content-bg:  #ede8e3;
  --card-bg:     #ffffff;
  --card-border: #e8e0d8;
  --card-shadow: 0 1px 3px rgba(60,40,20,.07), 0 1px 2px rgba(60,40,20,.04);
  --card-shadow-md: 0 4px 12px rgba(60,40,20,.09);

  --accent:       #c9883c;
  --accent-hover: #b5742a;
  --accent-soft:  #fdf3e6;
  --accent-text:  #8a5420;

  --teal:      #2d9a8a;
  --teal-soft: #e6f5f2;

  --text-main:  #1e1a17;
  --text-muted: #7a6e66;
  --text-faint: #b0a49b;
  --border:     #e3dbd3;
  --border-soft:#f0ebe5;

  --green:      #2d9b5a;
  --green-soft: #e6f5ec;
  --red:        #d94f3d;
  --red-soft:   #fdecea;
  --amber:      #c9883c;
  --amber-soft: #fdf3e6;
  --pink:       #c0546a;
  --pink-soft:  #fceef1;

  --radius:    10px;
  --radius-sm: 6px;
  --radius-xs: 4px;

  --scrollbar-thumb: #cfc8c0;
  --input-bg: #ffffff;
}

/* ══════════════════════════════════════════════
   TOKENS — Dark
══════════════════════════════════════════════ */
[data-theme="dark"] {
  --nav-bg:         #1a1714;
  --nav-border:     #2a2420;
  --nav-text:       #a89f98;
  --nav-text-dim:   #5c5550;
  --nav-active:     #ffffff;
  --nav-hover-bg:   rgba(255,255,255,.06);
  --nav-active-bg:  rgba(255,255,255,.1);

  --sidebar-bg:     #211e1b;
  --sidebar-border: #2e2a26;
  --sidebar-text:   #9e9189;
  --sidebar-dim:    #5c524a;
  --sidebar-active-bg:     rgba(201,136,60,.12);
  --sidebar-active-text:   #e8c898;
  --sidebar-active-border: #c9883c;
  --sidebar-section:       #4a4440;

  --content-bg:  #181512;
  --card-bg:     #221f1c;
  --card-border: #2e2a26;
  --card-shadow: 0 1px 4px rgba(0,0,0,.3);
  --card-shadow-md: 0 4px 16px rgba(0,0,0,.35);

  --accent:       #c9883c;
  --accent-hover: #d9984c;
  --accent-soft:  rgba(201,136,60,.14);
  --accent-text:  #e8c898;

  --teal:      #2db8a4;
  --teal-soft: rgba(45,184,164,.14);

  --text-main:  #e8e0d8;
  --text-muted: #8a7f78;
  --text-faint: #5c524a;
  --border:     #2e2a26;
  --border-soft:#272320;

  --green:      #3dbc72;
  --green-soft: rgba(61,188,114,.14);
  --red:        #e05c4a;
  --red-soft:   rgba(224,92,74,.14);
  --amber:      #c9883c;
  --amber-soft: rgba(201,136,60,.14);
  --pink:       #d06078;
  --pink-soft:  rgba(208,96,120,.14);

  --scrollbar-thumb: #3a3430;
  --input-bg: #2c2825;
}

/* ══════════════════════════════════════════════
   BASE
══════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; }

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 13.5px;
  background: var(--content-bg);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background .25s, color .2s;
}

/* App-shell layout (when using sidebar) */
body.op-app {
  height: 100vh;
  overflow: hidden;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

a { color: var(--accent-text); }
a:hover { color: var(--accent); }

.op-mono {
  font-family: 'DM Mono', monospace;
  font-size: 12.5px;
}

/* ══════════════════════════════════════════════
   TOP NAV
══════════════════════════════════════════════ */
.op-nav {
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  height: 50px;
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 20px;
  flex-shrink: 0;
  z-index: 200;
  transition: background .25s, border-color .25s;
}

.op-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--nav-active);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  letter-spacing: -.3px;
  flex-shrink: 0;
}
.op-logo:hover { color: var(--nav-active); text-decoration: none; }

.op-logo-mark {
  width: 27px;
  height: 27px;
  background: var(--accent);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
  transition: background .25s;
}

.op-nav-links {
  display: flex;
  align-items: center;
  gap: 1px;
  flex: 1;
  overflow: hidden;
}

.op-nav-link {
  color: var(--nav-text-dim);
  text-decoration: none;
  font-size: 13px;
  padding: 5px 9px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color .12s, background .12s;
  white-space: nowrap;
}
.op-nav-link:hover { color: var(--nav-text); background: var(--nav-hover-bg); text-decoration: none; }
.op-nav-link.active { color: var(--nav-active); background: var(--nav-active-bg); }
.op-nav-link i, .op-nav-link .ph { font-size: 15px; }

.op-nav-right {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}

.op-nav-btn {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  background: transparent;
  border: 1px solid var(--nav-border);
  color: var(--nav-text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  transition: all .12s;
}
.op-nav-btn:hover { color: var(--nav-active); background: var(--nav-hover-bg); }

/* Theme toggle icon swap */
#op-theme-toggle .ph-moon { display: none; }
#op-theme-toggle .ph-sun  { display: block; }
[data-theme="dark"] #op-theme-toggle .ph-moon { display: block; }
[data-theme="dark"] #op-theme-toggle .ph-sun  { display: none; }

.op-user-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px 3px 4px;
  border-radius: 20px;
  background: var(--nav-hover-bg);
  cursor: pointer;
  border: 1px solid var(--nav-border);
  text-decoration: none;
  transition: background .12s;
}
.op-user-chip:hover { background: rgba(255,255,255,.1); }

.op-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.op-user-name {
  color: var(--nav-text);
  font-size: 12.5px;
  font-weight: 500;
}

.op-role-badge {
  background: rgba(201,136,60,.25);
  color: var(--accent);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 500;
}

/* ══════════════════════════════════════════════
   TRIAL BAR
══════════════════════════════════════════════ */
.op-trial-bar {
  background: var(--amber-soft);
  border-bottom: 1px solid var(--border);
  padding: 5px 18px;
  font-size: 12px;
  color: var(--accent-text);
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
  transition: background .25s;
}
.op-trial-bar a { color: var(--accent); font-weight: 600; text-decoration: none; }
.op-trial-bar a:hover { text-decoration: underline; }

/* ══════════════════════════════════════════════
   LAYOUT (app shell)
══════════════════════════════════════════════ */
.op-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ══════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════ */
.op-sidebar {
  width: 205px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  padding: 12px 8px 24px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex-shrink: 0;
  overflow-y: auto;
  transition: background .25s, border-color .25s;
}

.op-sidebar-section {
  color: var(--sidebar-section);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  padding: 12px 10px 5px;
  pointer-events: none;
  user-select: none;
}

.op-sidebar-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 7px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13px;
  transition: all .12s;
  border-left: 2px solid transparent;
}
.op-sidebar-link i,
.op-sidebar-link .ph {
  font-size: 15px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
.op-sidebar-link:hover {
  color: var(--text-main);
  background: rgba(0,0,0,.04);
  text-decoration: none;
}
[data-theme="dark"] .op-sidebar-link:hover {
  background: rgba(255,255,255,.05);
}
.op-sidebar-link.active {
  color: var(--sidebar-active-text);
  background: var(--sidebar-active-bg);
  border-left-color: var(--sidebar-active-border);
  font-weight: 500;
}
[data-theme="light"] .op-sidebar-link.active {
  box-shadow: 0 1px 3px rgba(60,40,20,.08);
}

/* ══════════════════════════════════════════════
   CONTENT AREA
══════════════════════════════════════════════ */
.op-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px 26px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  transition: background .25s;
}

/* Non-shell pages (full width) */
.op-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
  width: 100%;
}

/* ══════════════════════════════════════════════
   PAGE HEADER
══════════════════════════════════════════════ */
.op-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-faint);
  font-size: 12px;
}
.op-breadcrumb a { color: var(--text-muted); text-decoration: none; }
.op-breadcrumb a:hover { color: var(--text-main); }

.op-page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.op-back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: var(--text-muted);
  text-decoration: none;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.op-back-btn:hover { background: var(--border); color: var(--text-main); }
.op-back-btn i { font-size: 18px; }
.op-page-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -.4px;
  line-height: 1;
  margin: 0;
}
.op-page-sub {
  color: var(--text-muted);
  font-size: 12.5px;
  margin-top: 4px;
}

/* ══════════════════════════════════════════════
   STAT CARDS
══════════════════════════════════════════════ */
.op-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.op-stat {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 15px 16px;
  box-shadow: var(--card-shadow);
  border: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background .25s, border-color .25s, box-shadow .15s;
}
.op-stat:hover { box-shadow: var(--card-shadow-md); }
a.op-stat-link { text-decoration: none; color: inherit; cursor: pointer; }
a.op-stat-link:hover { box-shadow: var(--card-shadow-md); border-color: var(--accent); }
.op-stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.op-stat-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.op-stat-label {
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}
.op-stat-value {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.4px;
  font-family: 'DM Mono', monospace;
  line-height: 1.2;
  margin-top: 2px;
}

/* Stacked variant: label above value, no icon (superadmin dashboard tiles) */
.op-stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--card-shadow);
  border: 1px solid var(--card-border);
  transition: background .25s, border-color .25s, box-shadow .15s;
}
.op-stat-card:hover { box-shadow: var(--card-shadow-md); }
.op-stat-card .op-stat-label {
  text-transform: uppercase;
  letter-spacing: .05em;
  font-size: 10.5px;
  font-weight: 600;
}

/* ══════════════════════════════════════════════
   CARDS
══════════════════════════════════════════════ */
.op-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  border: 1px solid var(--card-border);
  overflow: hidden;
  transition: background .25s, border-color .25s;
}
.op-card + .op-card { margin-top: 0; }
.op-filter-card { --card-bg: #f0f6ff; --card-border: #d0e4ff; }
[data-theme="dark"] .op-filter-card { --card-bg: rgba(99,160,255,.07); --card-border: rgba(99,160,255,.18); }

.op-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
  transition: border-color .25s;
}

.op-card-body { padding: 16px; }
.op-card-body + .op-card-body { border-top: 1px solid var(--border); }

.op-card-title {
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-main);
  margin: 0;
}
.op-card-title i,
.op-card-title .ph { color: var(--text-muted); font-size: 15px; }

.op-count-pill {
  background: var(--border-soft);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

/* ══════════════════════════════════════════════
   FORM ELEMENTS
══════════════════════════════════════════════ */
.op-filters { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

.op-card-pad .op-card-pad { padding: 16px; }
.op-card-pad { padding: 16px; }

.op-page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.op-filter-item { display: flex; flex-direction: column; gap: 4px; flex: 1 1 170px; min-width: 150px; }
.op-filter-item .op-btn { flex: 0 1 auto; }
.op-filter-sep { width: 1px; align-self: stretch; min-height: 34px; background: var(--border-soft); margin: 0 4px; }
.op-label-row { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.op-text-link { color: var(--accent-text); }

.op-input-sm, .op-select-sm { padding: 5px 9px; font-size: 12.5px; border-radius: var(--radius-xs, 6px); }

.op-label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.op-label .req { color: var(--red); margin-left: 2px; }

.op-input,
.op-select,
.op-textarea {
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text-main);
  transition: border-color .15s, box-shadow .15s, background .25s;
  outline: none;
  line-height: 1.4;
}
.op-input::placeholder,
.op-textarea::placeholder { color: var(--text-faint); }
.op-input:focus,
.op-select:focus,
.op-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201,136,60,.15);
}
.op-input.is-invalid,
.op-select.is-invalid { border-color: var(--red); }
.op-input.is-invalid:focus { box-shadow: 0 0 0 3px rgba(217,79,61,.15); }

/* Compact (filter bar) inputs */
.op-input-sm,
.op-select-sm {
  height: 31px;
  padding: 0 10px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text-main);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .25s;
}
.op-input-sm::placeholder { color: var(--text-faint); }
.op-input-sm:focus,
.op-select-sm:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201,136,60,.15);
}

.op-select,
.op-select-sm {
  padding-right: 28px;
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a7f78' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
}

.op-textarea { resize: vertical; min-height: 72px; }

.op-field-error {
  font-size: 11.5px;
  color: var(--red);
  margin-top: 3px;
}

/* Form group */
.op-field { margin-bottom: 14px; }
.op-field:last-child { margin-bottom: 0; }

/* Field helper text — referenced by the org config + user forms */
.op-field-hint {
  display: block;
  color: var(--text-faint);
  font-size: 12px;
  margin-top: 5px;
  margin-bottom: 6px;
  line-height: 1.45;
}

/* Section heading inside a card body */
.op-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin: 0 0 10px;
}

/* Remove-row control on dynamic invoice/purchase line items */
.op-remove-row {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}
.op-remove-row:hover { background: var(--red-soft); color: var(--red); border-color: var(--red); }

/* ══════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════ */
.op-btn {
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: -.1px;
  line-height: 1;
}
.op-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.op-btn-primary { background: var(--accent); color: #fff; }
.op-btn-primary:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }
.op-btn-teal { background: var(--teal); color: #fff; }
.op-btn-teal:hover { background: color-mix(in srgb, var(--teal) 85%, #000); color: #fff; text-decoration: none; }

.op-btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.op-btn-ghost:hover {
  background: var(--border-soft);
  color: var(--text-main);
  border-color: var(--border);
  text-decoration: none;
}

.op-btn-danger { background: var(--red); color: #fff; }
.op-btn-danger:hover { background: #c23f2e; color: #fff; text-decoration: none; }

.op-btn-success { background: var(--green); color: #fff; }
.op-btn-success:hover { background: #258a4e; color: #fff; text-decoration: none; }

.op-btn-warning { background: var(--amber-soft); color: var(--accent-text); border: 1px solid var(--amber); }
.op-btn-warning:hover { background: var(--amber); color: #fff; text-decoration: none; }

.op-btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.op-btn-outline:hover {
  background: var(--border-soft);
  color: var(--text-main);
  border-color: var(--accent);
  text-decoration: none;
}

.op-btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.op-btn-icon { width: 34px; padding: 0; justify-content: center; }
.op-btn-icon.op-btn-sm { width: 28px; }

/* ══════════════════════════════════════════════
   STATUS PILLS
══════════════════════════════════════════════ */
.op-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}
.op-status::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.op-status-paid         { background: var(--green-soft); color: var(--green); }
.op-status-paid::before { background: var(--green); }

.op-status-unpaid         { background: var(--red-soft); color: var(--red); }
.op-status-unpaid::before { background: var(--red); }

.op-status-partial         { background: var(--amber-soft); color: var(--amber); }
.op-status-partial::before { background: var(--amber); }

.op-status-overdue         { background: var(--pink-soft); color: var(--pink); }
.op-status-overdue::before { background: var(--pink); }

.op-status-partial_overdue         { background: var(--pink-soft); color: var(--pink); }
.op-status-partial_overdue::before { background: var(--pink); }

.op-status-draft         { background: var(--border-soft); color: var(--text-muted); }
.op-status-draft::before { background: var(--text-faint); }

.op-status-approved         { background: var(--green-soft); color: var(--green); }
.op-status-approved::before { background: var(--green); }

.op-status-rejected         { background: var(--red-soft); color: var(--red); }
.op-status-rejected::before { background: var(--red); }

.op-status-pending         { background: var(--amber-soft); color: var(--amber); }
.op-status-pending::before { background: var(--amber); }

.op-status-collected         { background: var(--green-soft); color: var(--green); }
.op-status-collected::before { background: var(--green); }

.op-status-bounced         { background: var(--red-soft); color: var(--red); }
.op-status-bounced::before { background: var(--red); }

/* Stock transfers settle the moment they are created — InventoryService
   .execute_transfer sets "completed" — so that is the status the transfer
   list actually shows, and it had no colour of its own. */
.op-status-completed         { background: var(--green-soft); color: var(--green); }
.op-status-completed::before { background: var(--green); }

.op-status-cancelled         { background: var(--border-soft); color: var(--text-muted); }
.op-status-cancelled::before { background: var(--text-faint); }

/* ══════════════════════════════════════════════
   DATA TABLE
   ══════════════════════════════════════════════ */
.op-table-wrap { overflow-x: auto; }

.op-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.op-table th,
.op-table td {
  padding: 9px 12px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
.op-table td.wrap { white-space: normal; }
.op-table thead th {
  background: var(--border-soft);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.op-table tbody tr { transition: background .1s; }
.op-table tbody tr:hover { background: var(--border-soft); }
.op-table tbody tr:last-child td { border-bottom: none; }
.op-table tfoot td {
  background: var(--border-soft);
  font-weight: 600;
  border-top: 1px solid var(--border);
  border-bottom: none;
}

/* Alignment / numeric helpers, usable in any op table. */
.right { text-align: right; }
.num { font-family: 'DM Mono', monospace; font-size: 12.5px; }

/* ══════════════════════════════════════════════
   TABS
   ══════════════════════════════════════════════ */
.op-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.op-tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 9px 14px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: color .12s, border-color .12s;
}
.op-tab:hover { color: var(--text-main); }
.op-tab.active { color: var(--accent-text); border-bottom-color: var(--accent); }

.op-tabpanel { display: none; }
.op-tabpanel.active { display: block; }

/* ══════════════════════════════════════════════
   CARD GRID + CLICKABLE CARDS
   ══════════════════════════════════════════════ */
.op-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.op-grid-card { height: 100%; }

.op-simple-list { display: flex; flex-direction: column; }
.op-simple-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
}
.op-simple-item + .op-simple-item { border-top: 1px solid var(--border-soft); }
.op-text-strike { text-decoration: line-through; }

.op-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .15s, border-color .15s, background .25s;
}
.op-card-link:hover {
  box-shadow: var(--card-shadow-md);
  text-decoration: none;
  color: inherit;
}

/* ══════════════════════════════════════════════
   PILLS (tags)
   ══════════════════════════════════════════════ */
.op-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--border-soft);
  color: var(--text-muted);
}
.op-pill-success { background: var(--green-soft);  color: var(--green); }
.op-pill-info    { background: var(--teal-soft);   color: var(--teal); }
.op-pill-warning { background: var(--amber-soft);  color: var(--amber); }
.op-pill-danger  { background: var(--red-soft);    color: var(--red); }
.op-pill-pink    { background: var(--pink-soft);   color: var(--pink); }
.op-pill-accent  { background: var(--accent-soft); color: var(--accent-text); }
.op-pill-muted   { background: var(--border-soft); color: var(--text-muted); }

/* ══════════════════════════════════════════════
   MENU CARDS (admin index)
   ══════════════════════════════════════════════ */
.op-menu-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  height: 100%;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  text-decoration: none;
  color: inherit;
  transition: box-shadow .15s, background .25s, border-color .25s;
}
.op-menu-card:hover {
  box-shadow: var(--card-shadow-md);
  text-decoration: none;
  color: inherit;
}
.op-menu-card.op-is-inactive { opacity: .55; }
.op-menu-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  margin-bottom: 8px;
  background: var(--accent-soft);
  color: var(--accent-text);
}
.op-menu-label { font-size: 13.5px; font-weight: 600; }
.op-menu-desc  { color: var(--text-muted); font-size: 12.5px; }

.op-menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 10px;
  max-width: 780px;
}

/* ══════════════════════════════════════════════
   ACTION CARDS (dashboard daily ops / money)
   ══════════════════════════════════════════════ */
.op-action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-width: 540px;
}
.op-action-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px 12px 12px;
  border-radius: var(--radius);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: box-shadow .15s, background .2s;
  position: relative;
}
.op-action-card:hover {
  box-shadow: var(--card-shadow-md);
  text-decoration: none;
  color: inherit;
}
.op-action-card-wide {
  grid-column: 1 / -1;
  max-width: 540px;
}
.op-action-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.op-action-body { flex: 1; min-width: 0; }
.op-action-label { font-size: 13px; font-weight: 600; line-height: 1.3; }
.op-action-sub   { font-size: 11px; color: var(--text-muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ══════════════════════════════════════════════
   DETAIL TABLE (key-value)
   ══════════════════════════════════════════════ */
.op-detail-table { width: 100%; border-collapse: collapse; }
.op-detail-table th,
.op-detail-table td { padding: 7px 0; vertical-align: top; }
.op-detail-table th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12.5px;
  width: 38%;
  padding-right: 16px;
}
.op-detail-table td { font-size: 13px; }
.op-detail-table tr + tr th,
.op-detail-table tr + tr td { border-top: 1px solid var(--border-soft); }

/* ══════════════════════════════════════════════
   TABULATOR OVERRIDES
══════════════════════════════════════════════ */
.op-table-wrap .tabulator {
  border: none !important;
  font-family: 'DM Sans', sans-serif !important;
  font-size: 13px !important;
  background: transparent !important;
}
.op-table-wrap .tabulator-header {
  background: var(--border-soft) !important;
  border-bottom: 1px solid var(--border) !important;
}
.op-table-wrap .tabulator-col {
  background: transparent !important;
  border-right: none !important;
}
.op-table-wrap .tabulator-col-title {
  font-weight: 500 !important;
  font-size: 11.5px !important;
  color: var(--text-muted) !important;
  letter-spacing: .04em !important;
  text-transform: uppercase !important;
}
.op-table-wrap .tabulator-row {
  background: var(--card-bg) !important;
  border-bottom: 1px solid var(--border-soft) !important;
  transition: background .1s !important;
}
.op-table-wrap .tabulator-row:hover {
  background: var(--border-soft) !important;
}
.op-table-wrap .tabulator-cell {
  padding: 10px 12px !important;
  color: var(--text-main) !important;
  border-right: none !important;
}
.op-table-wrap .tabulator-footer {
  background: var(--border-soft) !important;
  border-top: 1px solid var(--border) !important;
  font-size: 12px !important;
  color: var(--text-muted) !important;
}
.op-table-wrap .tabulator-page,
.op-table-wrap .tabulator-page-size {
  font-family: 'DM Sans', sans-serif !important;
  font-size: 12px !important;
  border: 1px solid var(--border) !important;
  border-radius: 5px !important;
  background: var(--card-bg) !important;
  color: var(--text-main) !important;
  padding: 2px 8px !important;
}
.op-table-wrap .tabulator-page.active {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #fff !important;
}

/* ══════════════════════════════════════════════
   FLASH MESSAGES
══════════════════════════════════════════════ */
.op-alerts { display: flex; flex-direction: column; gap: 8px; }

.op-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid;
}
.op-alert-success  { background: var(--green-soft);  color: var(--green);  border-color: var(--green); }
.op-alert-danger   { background: var(--red-soft);    color: var(--red);    border-color: var(--red); }
.op-alert-warning  { background: var(--amber-soft);  color: var(--amber);  border-color: var(--amber); }
.op-alert-info     { background: var(--teal-soft);   color: var(--teal);   border-color: var(--teal); }

.op-alert-close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  opacity: .6;
  font-size: 14px;
  padding: 0;
  line-height: 1;
}
.op-alert-close:hover { opacity: 1; }

.op-upload-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 8px);
  background: var(--bg-soft);
}
.op-upload-row:hover { background: var(--bg-alt); }

/* ══════════════════════════════════════════════
   EMPTY STATE
══════════════════════════════════════════════ */
.op-empty {
  text-align: center;
  padding: 52px 20px;
  color: var(--text-faint);
}
.op-empty-icon { font-size: 42px; opacity: .3; display: block; margin-bottom: 10px; }
.op-empty p { font-size: 13.5px; margin: 0; }

/* ══════════════════════════════════════════════
   AUDIT FOOTER
══════════════════════════════════════════════ */
.op-audit {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
  color: var(--text-faint);
  font-size: 11.5px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
}

/* ══════════════════════════════════════════════
   MODALS (Bootstrap-based)
══════════════════════════════════════════════ */
.modal-content {
  background: var(--card-bg) !important;
  border: 1px solid var(--card-border) !important;
  border-radius: var(--radius) !important;
  color: var(--text-main) !important;
  box-shadow: var(--card-shadow-md) !important;
}
.modal-header, .modal-footer {
  border-color: var(--border) !important;
}
.modal-title { font-size: 14px; font-weight: 600; }
.btn-close { filter: var(--bs-btn-close-filter, none); }
[data-theme="dark"] .btn-close { filter: invert(1); }

/* ══════════════════════════════════════════════
   MISC UTILITIES
   ══════════════════════════════════════════════ */
.op-hidden { display: none !important; }

.op-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.op-text-money {
  font-family: 'DM Mono', monospace;
  font-size: 12.5px;
}
.op-text-danger { color: var(--red) !important; }
.op-text-success { color: var(--green) !important; }
.op-text-muted { color: var(--text-muted) !important; }
.op-text-faint { color: var(--text-faint) !important; }
.op-text-warning { color: var(--amber) !important; }

/* Row actions in tables */
.op-row-link { color: var(--accent-text); text-decoration: none; font-weight: 500; }
.op-row-link:hover { color: var(--accent); text-decoration: underline; }

.op-row-actions { display: flex; gap: 4px; justify-content: center; }

/* ══════════════════════════════════════════════
   PHONE FIELD (country select + national number)
                                                */
.phone-row { display: flex; gap: 6px; }
.phone-country {
  flex: 0 0 116px;
  width: 116px;
  padding-right: 26px;
  font-size: 12.5px;
}
.phone-local { flex: 1; min-width: 0; }
.op-contact { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.op-contact a, a.op-contact { text-decoration: none !important; overflow-wrap: anywhere; }
.op-contact-action { color: var(--text-muted); text-decoration: none; flex: 0 0 auto; }
.op-contact-action:hover { color: var(--accent); }
.op-contact-whatsapp, .op-contact-whatsapp:hover { color: #20a464 !important; }
.op-product-thumb, .op-product-thumb-placeholder {
  width: 42px; height: 42px; border-radius: 8px; object-fit: cover;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--border-soft); color: var(--text-muted);
}
.op-product-image { max-width: 220px; max-height: 220px; border-radius: 12px; object-fit: cover; border: 1px solid var(--border); }

/* ══════════════════════════════════════════════
   PASSWORD FIELD + RULES CHECKLIST
══════════════════════════════════════════════ */
.pw-wrap { position: relative; display: flex; align-items: center; }
.pw-input { padding-right: 38px; }
.pw-toggle {
  position: absolute;
  right: 3px;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-faint);
  z-index: 1;
}
.pw-toggle:hover { color: var(--accent); background: transparent; }

#pw-feedback { margin-top: 2px; }

.pw-meter {
  height: 4px;
  border-radius: 3px;
  background: var(--border-soft);
  overflow: hidden;
  margin: 8px 0 10px;
}
.pw-meter-bar {
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: var(--red);
  transition: width .2s, background .2s;
}
.pw-meter-bar.is-weak  { background: var(--red); }
.pw-meter-bar.is-good  { background: var(--amber); }
.pw-meter-bar.is-strong{ background: var(--green); }

.pw-rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.pw-rule {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-faint);
  transition: color .15s;
}
.pw-rule-icon { font-size: 14px; flex-shrink: 0; }
.pw-rule.is-idle  { color: var(--text-faint); }
.pw-rule.is-fail  { color: var(--red); }
.pw-rule.is-pass  { color: var(--green); }

/* ══════════════════════════════════════════════
   AUTH SHELL (login, password reset, set password)
   ══════════════════════════════════════════════ */
.op-auth-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.op-auth-card { width: 100%; max-width: 420px; }
.op-auth-head { text-align: center; margin-bottom: 20px; }
.op-auth-head .op-page-title { font-size: 20px; margin: 12px 0 4px; }
.op-auth-link {
  display: block;
  text-align: center;
  font-size: 12.5px;
  color: var(--accent-text);
  text-decoration: none;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.op-auth-link:hover { text-decoration: underline; color: var(--accent-hover); }
.op-input-otp {
  display: block;
  margin: 0 auto;
  text-align: center;
  font-size: 24px;
  letter-spacing: 10px;
  font-family: 'DM Mono', monospace;
  max-width: 220px;
}
.op-logo-mark-lg {
  width: 46px;
  height: 46px;
  font-size: 22px;
  margin: 0 auto;
  border-radius: 13px;
}
.op-btn-block { width: 100%; justify-content: center; }

/* ══════════════════════════════════════════════
   RESPONSIVE — the whole app is built desktop-first
   (a fixed 50px top nav + a 205px sidebar and no
   media queries at all), which made it unusable in
   portrait on a phone. Everything below re-flows
   the shell for narrow screens.
══════════════════════════════════════════════ */

/* ── Small tablets / large phones ── */
@media (max-width: 1100px) {
  .op-nav-links { display: none; }
}

@media (max-width: 900px) {
  .op-content { padding: 16px 16px 40px; gap: 14px; }
  .op-sidebar { width: 168px; }
  .op-page-title { font-size: 18px; }
}

/* ── Portrait phone ──
   The sidebar stops being a column and becomes a horizontal, swipeable
   strip under the nav, so the whole menu is reachable with a thumb
   instead of pushing the page content off-screen. */
@media (max-width: 720px) {
  body.op-app { height: auto; overflow: visible; }

  .op-nav {
    height: 48px;
    padding: 0 12px;
    gap: 10px;
    position: sticky;
    top: 0;
  }
  .op-user-name { display: none; }
  .op-user-chip { padding: 3px; }
  .op-role-badge { display: none; }

  .op-body {
    flex-direction: column;
    overflow: visible;
    min-height: 0;
  }

  .op-sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: 8px 10px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-right: none;
    border-bottom: 1px solid var(--sidebar-border);
    position: sticky;
    top: 48px;
    z-index: 150;
  }
  .op-sidebar::-webkit-scrollbar { display: none; }
  .op-sidebar-section { display: none; }
  .op-sidebar-link {
    border-left: none;
    border-bottom: 2px solid transparent;
    border-radius: 20px;
    padding: 6px 12px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .op-sidebar-link.active {
    border-bottom-color: var(--accent);
    background: var(--sidebar-active-bg);
  }

  .op-content { padding: 14px 12px 48px; }

  /* Tables scroll sideways rather than squashing every column. */
  .op-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .op-table { min-width: 520px; }
  .table-responsive { overflow-x: auto; }
  .table { min-width: 560px; }

  /* Grids and button rows go full width. */
  .op-grid { grid-template-columns: 1fr !important; }
  .op-stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .op-menu-grid { grid-template-columns: 1fr 1fr; }
  .op-btn { height: 40px; padding: 0 16px; }
  .op-btn-sm { height: 34px; }

  /* Tap targets. */
  .op-nav-btn { width: 38px; height: 38px; }
  .op-btn-icon { width: 38px; }
  .op-avatar { width: 30px; height: 30px; }

  /* Forms: Bootstrap grid halves are useless at this width. */
  .row > [class*="col-"] { flex: 0 0 100%; max-width: 100%; }
  .row.g-2, .row.g-3 { --bs-gutter-x: 10px; }
  .d-flex.gap-2 { flex-wrap: wrap; }

  /* The dialogs that were sized for a wide window. */
  .op-modal, .modal-dialog { max-width: 100% !important; margin: 10px; }
  .modal-body { max-height: 65vh; overflow-y: auto; }
}

/* ── Narrow phone ── */
@media (max-width: 480px) {
  .op-content { padding: 12px 10px 44px; }
  .op-card-body { padding: 13px; }
  .op-card-header { padding: 10px 13px; }
  .op-page-title { font-size: 16.5px; }
  .op-menu-grid { grid-template-columns: 1fr; }
  /* Keep the international prefix and national number together on phones. */
  .phone-row { flex-wrap: nowrap; }
  .phone-country { flex: 0 0 108px; width: 108px; }
  .op-alert { font-size: 12.5px; }
  .op-pill { font-size: 11px; }
}

/* ── Short landscape phones: reclaim the vertical space ── */
@media (max-height: 480px) and (orientation: landscape) {
  .op-nav { height: 44px; }
  .op-sidebar { top: 44px; }
}

/* ── Print: never print the chrome ── */
@media print {
  .op-nav, .op-sidebar, .op-alerts, .op-btn, .op-page-actions { display: none !important; }
  .op-content { overflow: visible; padding: 0; }
}

/* ═══════════════════════════════════════════════════════════
   CHAT / CONVERSATION
═══════════════════════════════════════════════════════════ */

/* Layout */
#chat-app { display: flex; flex-direction: column; }

.chat-wrapper {
  min-height: 280px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 14px 6px 18px;
  background: var(--bg-muted, #f8f9fa);
  border-radius: 10px;
  margin-bottom: 4px;
  overscroll-behavior: contain;
}

/* Message rows */
.msg-row { display: flex; width: 100%; margin-bottom: 6px; }
.msg-row.mine { justify-content: flex-end; }
.msg-col { max-width: 82%; min-width: 100px; }

/* Bubbles */
.msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.5;
  max-width: 100%;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0,0,0,.07);
}
.msg-mine {
  background: #cfeee0;
  color: #0f4a28;
  border: 1px solid #a3d9be;
  border-bottom-right-radius: 4px;
}
.msg-other {
  background: #fff;
  color: #212529;
  border: 1px solid #e9ecef;
  border-bottom-left-radius: 4px;
}

/* System messages */
.msg-row-system { display: flex; justify-content: center; margin: 10px 0; width: 100%; }
.system-inner {
  background: rgba(0,0,0,.05);
  color: #6c757d;
  font-size: 12px;
  padding: 3px 12px;
  border-radius: 50rem;
  text-align: center;
  max-width: 85%;
  border: 1px dashed rgba(0,0,0,.08);
}
.system-time { opacity: .6; font-size: 11px; margin-left: 4px; }

/* Meta / ticks */
.msg-meta { font-size: 11px; margin-top: 5px; display: flex; justify-content: flex-end; gap: 4px; align-items: center; white-space: nowrap; opacity: .75; }
.msg-status { font-size: 12px; letter-spacing: -1px; line-height: 1; }
.ticks-sent, .ticks-delivered { color: #9aa0a6; }
.ticks-seen { color: #198754; font-weight: 600; }

/* Day separator */
.chat-day-separator {
  text-align: center;
  margin: 16px 0;
  position: relative;
  color: #6c757d;
  font-size: 12px;
}
.chat-day-separator::before,
.chat-day-separator::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 44%;
  height: 1px;
  background: #dee2e6;
}
.chat-day-separator::before { left: 0; }
.chat-day-separator::after  { right: 0; }
.chat-day-separator span {
  background: #f8f9fa;
  padding: 2px 10px;
  border-radius: 10px;
  position: relative;
  z-index: 1;
}

/* Presence dot */
.presence-dot     { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.presence-online  { background: #22c55e; }
.presence-offline { background: #adb5bd; }

/* Typing indicator */
#typing-indicator { font-size: 13px; padding: 0 8px; height: 22px; }

/* Input area */
.chat-input-area { border-top: 1px solid #e9ecef; padding-top: 10px; }

/* Pill container — pure flexbox, no Bootstrap input-group */
.chat-pill {
  display: flex;
  align-items: center;
  gap: 2px;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 999px;
  padding: 4px 4px 4px 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.chat-text-input {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14.5px;
  font-family: inherit;
  color: var(--text-main, #212529);
  padding: 6px 4px;
  line-height: 1.4;
}
.chat-text-input::placeholder { color: var(--text-faint, #adb5bd); }
.chat-pill-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 6px 8px;
  color: #6c757d;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.chat-pill-btn:hover { background: #f1f3f5; color: #495057; }
.chat-send-btn {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent, #0d6efd);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.chat-send-btn:hover { background: var(--accent-dark, #0b5ed7); }
[data-theme="dark"] .chat-pill { background: #1e2124; border-color: #3a3d42; }
[data-theme="dark"] .chat-text-input { color: #e8eaed; }
[data-theme="dark"] .chat-pill-btn { color: #9aa0a6; }

/* Voice recorder overlay */
.chat-rec-overlay { z-index: 10; }
.rec-dot-container { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; }
.rec-dot-pulse {
  width: 10px; height: 10px;
  background: #ef4444;
  border-radius: 50%;
  animation: rec-pulse 1.2s infinite ease-in-out;
}
@keyframes rec-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.4); opacity: .55; }
}
.rec-timer-text { font-variant-numeric: tabular-nums; color: #ef4444; font-size: 1rem; font-weight: 600; min-width: 44px; }

/* Search highlight */
.msg-highlight { background: #fff3cd; color: #856404; border-bottom: 2px solid #ffeeba; font-weight: 600; border-radius: 2px; padding: 0 1px; }
.active-search-match { background: #ffc107; color: #000; }

/* Media */
.asset-img { max-width: 220px; max-height: 180px; border-radius: 8px; display: block; object-fit: cover; }
.asset-video { max-width: 220px; border-radius: 8px; }
.asset-img:hover, .asset-video:hover { transform: scale(1.03); transition: transform .15s; }
.msg-bubble img, .msg-bubble video { max-width: 100%; height: auto; }

/* Audio player */
.chat-audio-player {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: rgba(0,0,0,.06);
  border-radius: 20px;
  min-width: 180px; max-width: 260px;
}
.chat-audio-play-btn { background: none; border: none; padding: 0; font-size: 22px; line-height: 1; color: inherit; cursor: pointer; opacity: .8; }
.chat-audio-play-btn:hover { opacity: 1; }
.chat-audio-bar { flex: 1; height: 4px; background: rgba(0,0,0,.15); border-radius: 2px; cursor: pointer; }
.chat-audio-progress { height: 100%; width: 0%; background: currentColor; border-radius: 2px; transition: width .1s linear; }
.chat-audio-time { font-size: 11px; opacity: .7; min-width: 32px; text-align: right; }

/* File preview */
.chat-input-area #chat-file-list:empty { display: none; }

/* Dark mode */
[data-theme="dark"] .chat-wrapper { background: rgba(255,255,255,.04); }
[data-theme="dark"] .msg-other { background: #2a2d31; color: #e8eaed; border-color: #3a3d42; }
[data-theme="dark"] .msg-mine  { background: #1a4a32; color: #d1f0e0; border-color: #2a6a4a; }
[data-theme="dark"] .chat-day-separator span { background: var(--bg); }
[data-theme="dark"] .chat-input-area { border-top-color: #3a3d42; }

/* ── Notes field with RTL/LTR toggle ── */
.op-notes-wrap { position: relative; }
.op-notes-wrap .op-input { padding-right: 48px; }
.op-notes-dir-btn {
  position: absolute; top: 6px; right: 6px;
  background: var(--bg-muted); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px;
  font-size: 10px; font-weight: 700; line-height: 1.6;
  color: var(--text-muted); cursor: pointer;
  letter-spacing: .3px; transition: background .15s, color .15s;
  font-family: inherit;
}
.op-notes-dir-btn:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.op-notes-dir-btn.is-rtl { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

/* Notes display — preserve line breaks + auto direction */
.op-notes-display { white-space: pre-wrap; word-break: break-word; }

/* ── Date picker inputs — tinted so they stand out from plain inputs ── */
[data-flatpickr], .flatpickr-input {
  background-color: var(--accent-soft) !important;
  border-color: color-mix(in srgb, var(--accent) 30%, transparent) !important;
}
[data-flatpickr]:focus, .flatpickr-input:focus {
  border-color: var(--accent) !important;
}

/* ── Month navigator ── */
.op-month-nav { position: relative; display: inline-flex; align-items: center; gap: 2px; }
.op-month-label-btn { min-width: 148px; justify-content: center; font-weight: 500; }
.op-month-picker {
  position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 4px 20px rgba(0,0,0,.14);
  padding: 10px; z-index: 300; width: 224px;
}
.op-month-picker-year {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;
}
.op-month-picker-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 4px; }
.op-mpicker-month {
  padding: 7px 4px; border-radius: 6px; font-size: 12px;
  border: 1px solid transparent; background: none; cursor: pointer;
  color: var(--text); transition: background .12s;
}
.op-mpicker-month:hover { background: var(--hover); }
.op-mpicker-month.is-active { background: var(--accent); color: #fff; border-color: var(--accent); }

@keyframes spin { to { transform: rotate(360deg); } }
