/* =============================================================
   Business OS - Design System
   Based on Agrinovo BP preview design language
   ============================================================= */

:root {
  --green: #16a34a;
  --green-bg: #f0fdf4;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --amber: #d97706;
  --amber-bg: #fffbeb;
  --blue: #2563eb;
  --blue-bg: #eff6ff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --sidebar-width: 240px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--gray-900);
  background: var(--gray-50);
  line-height: 1.5;
  overflow-x: hidden;
}

/* --- Bilingual name toggle --- */
.lang-en { display: inline; }
.lang-he { display: none; }
[lang="he"] .lang-en { display: none; }
[lang="he"] .lang-he { display: inline; }

/* --- Layout --- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #1e3a5f, #0f2744);
  color: white;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 200;
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
}

[dir="rtl"] .sidebar {
  left: auto;
  right: 0;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sidebar-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-header .subtitle {
  font-size: 0.75rem;
  opacity: 0.6;
  margin-top: 2px;
}

.sidebar-nav {
  padding: 12px 0;
  flex: 1;
}

.nav-section {
  padding: 8px 20px 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.4);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

[dir="rtl"] .nav-link {
  border-left: none;
  border-right: 3px solid transparent;
}

.nav-link:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}

.nav-link.active {
  background: rgba(255,255,255,0.12);
  color: white;
  border-left-color: var(--blue);
}

[dir="rtl"] .nav-link.active {
  border-left-color: transparent;
  border-right-color: var(--blue);
}

.nav-link .icon {
  width: 20px;
  text-align: center;
  font-size: 1rem;
}

.nav-link .badge {
  margin-left: auto;
  background: var(--blue);
  color: white;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

[dir="rtl"] .nav-link .badge {
  margin-left: 0;
  margin-right: auto;
}

/* Sidebar user info at bottom */
.sidebar-user {
  padding: 0;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.8rem;
}

.sidebar-user-name {
  color: rgba(255,255,255,0.8);
}

.sidebar-user-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}

.sidebar-user-meta span {
  color: rgba(255,255,255,0.4);
  font-size: 0.72rem;
}

.sidebar-user-meta a {
  color: rgba(255,255,255,0.5);
  font-size: 0.72rem;
  text-decoration: none;
}

/* Mobile sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 150;
}

.sidebar-overlay.open {
  display: block;
}

/* Hamburger button */
.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--gray-700);
}

.hamburger svg {
  width: 24px;
  height: 24px;
}

/* --- Main Content --- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  min-width: 0; /* prevent flex overflow */
}

[dir="rtl"] .main-content {
  margin-left: 0;
  margin-right: var(--sidebar-width);
}

.topbar {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gray-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-search {
  flex: 1;
  max-width: 300px;
  margin: 0 16px;
}

.topbar-search-input {
  width: 100%;
  padding: 6px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 0.82rem;
  font-family: inherit;
  background: var(--gray-50);
}

.topbar-search-input:focus {
  outline: none;
  border-color: var(--blue);
  background: white;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.page-content {
  padding: 24px;
  width: 100%;
}

/* --- Grid layouts --- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.grid-2-1 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

/* --- Cards (metric cards) --- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  padding: 20px;
  border-radius: 12px;
  border: 1px solid var(--gray-200);
  background: white;
  transition: box-shadow 0.15s;
  min-width: 0;
}

.card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.card .label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-500);
  margin-bottom: 6px;
}

.card .value {
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.2;
  word-break: break-word;
}

.card .sub {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-top: 4px;
}

.card .delta {
  font-size: 0.82rem;
  font-weight: 600;
  margin-top: 4px;
}

.card.green { background: var(--green-bg); border-color: #bbf7d0; }
.card.green .value { color: var(--green); }
.card.red { background: var(--red-bg); border-color: #fecaca; }
.card.red .value { color: var(--red); }
.card.amber { background: var(--amber-bg); border-color: #fde68a; }
.card.amber .value { color: var(--amber); }
.card.blue { background: var(--blue-bg); border-color: #bfdbfe; }
.card.blue .value { color: var(--blue); }

/* --- Sections --- */
.section {
  background: white;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  border: 1px solid var(--gray-200);
  min-width: 0;
  overflow: hidden;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gray-900);
}

.section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 16px 0 10px;
  color: var(--gray-700);
}

/* --- Tables --- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.section.table-section {
  padding: 0;
}

.section.table-section .table-wrap {
  margin: 0;
  padding: 0;
}

.section.table-section .table-wrap table {
  min-width: 600px;
}

.section.table-section .table-wrap th:first-child,
.section.table-section .table-wrap td:first-child {
  padding-left: 20px;
}

.section.table-section .table-wrap th:last-child,
.section.table-section .table-wrap td:last-child {
  padding-right: 20px;
}

[dir="rtl"] .section.table-section .table-wrap th:first-child,
[dir="rtl"] .section.table-section .table-wrap td:first-child {
  padding-left: 12px;
  padding-right: 20px;
}

[dir="rtl"] .section.table-section .table-wrap th:last-child,
[dir="rtl"] .section.table-section .table-wrap td:last-child {
  padding-right: 12px;
  padding-left: 20px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--gray-100);
}

[dir="rtl"] th,
[dir="rtl"] td {
  text-align: right;
}

th {
  background: var(--gray-50);
  font-weight: 600;
  color: var(--gray-600);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
  white-space: nowrap;
}

tr:hover {
  background: var(--gray-50);
}

tr.clickable {
  cursor: pointer;
}

tr.clickable:hover {
  background: var(--blue-bg);
}

/* --- Badges --- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}

.badge-prospecting { background: var(--gray-100); color: var(--gray-600); }
.badge-qualification { background: var(--blue-bg); color: var(--blue); }
.badge-proposal { background: var(--amber-bg); color: var(--amber); }
.badge-negotiation { background: #fef3c7; color: #92400e; }
.badge-closed_won { background: var(--green-bg); color: var(--green); }
.badge-closed_lost { background: var(--red-bg); color: var(--red); }

/* Task status badges */
.badge-todo { background: var(--blue-bg); color: var(--blue); }
.badge-in_progress { background: var(--amber-bg); color: var(--amber); }
.badge-done { background: var(--green-bg); color: var(--green); }
.badge-cancelled { background: var(--gray-100); color: var(--gray-400); }

/* Priority badges */
.badge-p-urgent { background: var(--red-bg); color: var(--red); }
.badge-p-high { background: var(--amber-bg); color: var(--amber); }
.badge-p-normal { background: var(--gray-100); color: var(--gray-600); }
.badge-p-low { background: var(--gray-100); color: var(--gray-400); }

/* =============================================================
   Microsoft To Do-style Task List
   ============================================================= */

.task-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--gray-100);
  border-radius: 12px;
}

.task-list > .task-item:first-child { border-radius: 12px 12px 0 0; }
.task-list > .task-item:last-child { border-radius: 0 0 12px 12px; }
.task-list > .task-item:only-child { border-radius: 12px; }

.task-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 20px;
  background: white;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}

.task-item:hover {
  background: var(--gray-50);
}

.task-item .task-expand {
  display: none;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--gray-400);
  align-self: center;
}

.task-item:hover .task-expand {
  display: block;
}

[dir="rtl"] .task-item .task-expand {
  transform: scaleX(-1);
}

/* Inline quick-actions on hover */
.task-actions {
  display: none;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  align-self: center;
}

.task-item:hover .task-actions {
  display: flex;
}

.task-item:hover .task-expand {
  display: none;
}

.task-action-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--gray-500);
  transition: all 0.15s;
  padding: 0;
}

.task-action-btn:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
  color: var(--gray-700);
}

.task-action-btn svg {
  width: 15px;
  height: 15px;
}

.task-action-btn.task-action-delete:hover {
  background: var(--red-50, #fef2f2);
  border-color: var(--red);
  color: var(--red);
}
.task-action-btn.task-action-delete:hover svg {
  stroke: var(--red);
}

/* Inline popover for quick assign/date */
.task-popover {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 100;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  padding: 8px;
  min-width: 180px;
  display: none;
}

[dir="rtl"] .task-popover {
  right: auto;
  left: 0;
}

.task-popover.open {
  display: block;
}

.task-popover select,
.task-popover input[type="date"] {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 0.85rem;
  background: white;
}

.task-popover label {
  display: block;
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-bottom: 4px;
  font-weight: 600;
}

.task-popover .popover-group {
  margin-bottom: 8px;
}

.task-popover .popover-group:last-child {
  margin-bottom: 0;
}

.task-item.active {
  background: var(--blue-bg);
}

/* Priority left border indicator */
.task-item[data-priority="urgent"] { border-left: 3px solid var(--red); }
.task-item[data-priority="high"] { border-left: 3px solid var(--amber); }
.task-item[data-priority="normal"] { border-left: 3px solid transparent; }
.task-item[data-priority="low"] { border-left: 3px solid transparent; }

[dir="rtl"] .task-item[data-priority="urgent"] { border-left: none; border-right: 3px solid var(--red); }
[dir="rtl"] .task-item[data-priority="high"] { border-left: none; border-right: 3px solid var(--amber); }
[dir="rtl"] .task-item[data-priority="normal"] { border-left: none; border-right: 3px solid transparent; }
[dir="rtl"] .task-item[data-priority="low"] { border-left: none; border-right: 3px solid transparent; }

/* Circular checkbox (Microsoft To Do style) */
.task-checkbox {
  position: relative;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-top: 1px;
}

.task-checkbox input {
  position: absolute;
  opacity: 0;
  width: 22px;
  height: 22px;
  cursor: pointer;
  z-index: 2;
  margin: 0;
}

.task-checkbox .check-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--gray-300);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  background: white;
}

.task-checkbox input:hover + .check-circle {
  border-color: var(--green);
}

.task-checkbox input:checked + .check-circle {
  background: var(--green);
  border-color: var(--green);
}

.task-checkbox .check-circle svg {
  opacity: 0;
  transition: opacity 0.15s;
}

.task-checkbox input:checked + .check-circle svg {
  opacity: 1;
}

/* Task content */
.task-body {
  flex: 1;
  min-width: 0;
}

.task-title {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--gray-900);
  line-height: 1.4;
  word-break: break-word;
}

.task-item.is-done .task-title {
  text-decoration: line-through;
  color: var(--gray-400);
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--gray-500);
  flex-wrap: wrap;
}

.task-meta .meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.task-meta .meta-icon {
  width: 13px;
  height: 13px;
  opacity: 0.6;
}

.task-meta .overdue-date {
  color: var(--red);
  font-weight: 600;
}

.task-meta .status-chip {
  display: inline-block;
  font-size: 0.7rem;
  padding: 1px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.task-meta .status-chip.in_progress {
  background: var(--amber-bg);
  color: var(--amber);
}

.task-meta .status-chip.cancelled {
  background: var(--gray-100);
  color: var(--gray-400);
}

/* Task detail panel (To Do style) */
.task-detail-props {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.task-detail-prop {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.88rem;
}

.task-detail-prop:last-child {
  border-bottom: none;
}

.task-detail-prop .prop-icon {
  width: 20px;
  height: 20px;
  color: var(--gray-400);
  flex-shrink: 0;
}

.task-detail-prop .prop-label {
  color: var(--gray-500);
  min-width: 100px;
  font-size: 0.82rem;
}

.task-detail-prop .prop-value {
  flex: 1;
  font-weight: 500;
}

.task-detail-prop .prop-value select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding: 6px 30px 6px 10px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gray-700);
  cursor: pointer;
  background: white 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='%239ca3af' stroke-width='2.5' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 8px center;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.task-detail-prop .prop-value select:hover {
  border-color: var(--gray-300);
  background-color: var(--gray-50);
}

.task-detail-prop .prop-value select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.task-detail-prop .prop-value input[type="date"] {
  -webkit-appearance: none;
  padding: 6px 10px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gray-700);
  background: white;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.task-detail-prop .prop-value input[type="date"]:hover {
  border-color: var(--gray-300);
  background-color: var(--gray-50);
}

.task-detail-prop .prop-value input[type="date"]:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Quick-add input (To Do style) */
.task-quick-add {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  background: white;
  border: 2px dashed var(--gray-200);
  border-radius: 12px;
  margin-bottom: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.task-quick-add:focus-within {
  border-color: var(--blue);
  border-style: solid;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.task-quick-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 0.92rem;
  background: transparent;
  color: var(--gray-900);
  padding: 0;
  line-height: 1.4;
}

.task-quick-input::placeholder {
  color: var(--gray-400);
}

/* Empty task state */
.task-empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--gray-400);
}

.task-empty svg {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

/* Scroll sentinel for task list */
.task-list .scroll-sentinel-item {
  padding: 14px 20px;
  background: white;
  text-align: center;
  color: var(--gray-400);
  font-size: 0.85rem;
}

/* Legacy task helpers (still used in some places) */
.task-check { width: 18px; height: 18px; cursor: pointer; accent-color: var(--green); }
.task-done { text-decoration: line-through; color: var(--gray-400); }
.overdue { color: var(--red); font-weight: 600; }

.badge-new { background: var(--blue-bg); color: var(--blue); }
.badge-contacted { background: var(--amber-bg); color: var(--amber); }
.badge-in_process { background: #fef3c7; color: #92400e; }
.badge-converted { background: var(--green-bg); color: var(--green); }
.badge-dead { background: var(--gray-100); color: var(--gray-500); }

/* Account types */
.badge-supplier { background: #ede9fe; color: #5b21b6; }
.badge-reseller { background: #e0f2fe; color: #0369a1; }
.badge-partner { background: #d1fae5; color: #065f46; }
.badge-investor { background: #fef3c7; color: #92400e; }
.badge-other { background: var(--gray-100); color: var(--gray-600); }

/* --- Progress bar (pipeline stages) --- */
.stage-progress {
  display: flex;
  gap: 3px;
  margin: 0;
}

.stage-step {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--gray-200);
  transition: background 0.2s;
}

.stage-step.active {
  background: var(--gray-500);
}

/* Reusable styled select — use .form-select on any <select> outside .form-group */
.form-select,
#stage-section select,
.note-form select {
  padding: 7px 28px 7px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 0.82rem;
  font-family: inherit;
  background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M1.5 3.5L5 7L8.5 3.5' stroke='%236b7280' stroke-width='1.3' fill='none'/%3E%3C/svg%3E") no-repeat right 10px center;
  color: var(--gray-600);
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.form-select:focus,
#stage-section select:focus,
.note-form select:focus {
  outline: none;
  border-color: var(--blue);
}

/* Compact variant for search bars / inline filters */
.form-select-sm {
  padding: 6px 26px 6px 10px;
  font-size: 0.78rem;
  border-radius: 6px;
}

.stage-step.won {
  background: var(--green);
}

.stage-step.lost {
  background: var(--red);
}

/* --- Notes --- */
.notes-stream {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.note-item {
  padding: 14px 16px;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  background: white;
}

.note-item.pinned {
  border-color: var(--amber);
  background: var(--amber-bg);
}

.note-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.note-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gray-200);
  color: var(--gray-600);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
}

.note-entity-link {
  color: var(--blue);
  text-decoration: none;
  font-weight: 500;
}

.note-entity-link:hover {
  text-decoration: underline;
}

.note-delete-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  line-height: 0;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

[dir="rtl"] .note-delete-btn {
  margin-left: 0;
  margin-right: auto;
}

.note-item:hover .note-delete-btn {
  opacity: 1;
}

.note-delete-btn:hover {
  color: var(--red);
  background: var(--red-bg);
}

.note-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--gray-500);
  flex: 1;
  min-width: 0;
}

.note-meta .author {
  font-weight: 600;
  color: var(--gray-700);
}

.note-meta .type-badge {
  background: var(--gray-100);
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 0.7rem;
  text-transform: uppercase;
}

.note-content {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--gray-800);
  white-space: pre-wrap;
  word-break: break-word;
  padding-left: 42px;  /* align with text after avatar (32px + 10px gap) */
}

[dir="rtl"] .note-content {
  padding-left: 0;
  padding-right: 42px;
}

/* --- Note Form --- */
.note-form {
  padding: 16px;
  background: var(--gray-50);
  border-radius: 10px;
  border: 1px solid var(--gray-200);
  margin-bottom: 16px;
}

.note-form textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  margin-bottom: 8px;
}

.note-form textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.note-form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.note-form-actions .btn {
  margin-left: auto;
}

[dir="rtl"] .note-form-actions .btn {
  margin-left: 0;
  margin-right: auto;
}

/* .note-form select — now styled via shared .form-select rule above */

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--blue);
  color: white;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-secondary {
  background: white;
  color: var(--gray-700);
  border-color: var(--gray-300);
}

.btn-secondary:hover {
  background: var(--gray-50);
}

.btn-danger {
  background: var(--red);
  color: white;
  border-color: var(--red);
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}

.btn-export {
  background: white;
  color: var(--gray-600);
  border-color: var(--gray-300);
  font-size: 0.8rem;
  padding: 6px 12px;
}

.btn-export:hover {
  background: var(--gray-50);
  color: var(--gray-900);
}

/* --- Search bar --- */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.search-input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
}

.search-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

/* --- Filter chips --- */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-chip {
  padding: 5px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 16px;
  font-size: 0.8rem;
  cursor: pointer;
  background: white;
  color: var(--gray-600);
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}

.filter-chip:hover, .filter-chip.active {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}

/* --- Tag pills --- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--gray-100);
  color: var(--gray-600);
}

.tag-remove {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.82rem;
  line-height: 1;
  color: inherit;
  opacity: 0.5;
  padding: 0 0 0 2px;
  transition: opacity 0.15s;
}

.tag-remove:hover {
  opacity: 1;
}

.tag-add-form {
  display: inline-flex;
}

.tag-add-select {
  padding: 3px 20px 3px 8px;
  border: 1px dashed var(--gray-300);
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gray-400);
  background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'%3E%3Cpath d='M1 2.5L4 5.5L7 2.5' stroke='%239ca3af' stroke-width='1.2' fill='none'/%3E%3C/svg%3E") no-repeat right 6px center;
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.tag-add-select:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.tag-add-select:focus {
  outline: none;
  border-color: var(--blue);
  color: var(--gray-700);
  border-style: solid;
}

.tag-aqua { background: #dbeafe; color: #1e40af; }
.tag-soil { background: #fef3c7; color: #92400e; }
.tag-domestic { background: var(--green-bg); color: var(--green); }
.tag-export { background: #e0e7ff; color: #3730a3; }
.tag-strategic { background: #fae8ff; color: #86198f; }

/* --- Helpers --- */
.pos { color: var(--green); }
.neg { color: var(--red); }
.warn { color: var(--amber); }
.muted { color: var(--gray-500); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.78rem; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* Hide on mobile */
@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
}

/* Infinite scroll sentinel */
.scroll-sentinel td {
  text-align: center;
  padding: 20px 12px;
  color: var(--gray-400);
  font-size: 0.82rem;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-400);
}

.empty-state .icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

/* --- Login page --- */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
  background: linear-gradient(135deg, #1e3a5f, #2563eb);
}

.login-box {
  background: white;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}

.login-box h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-box .subtitle {
  color: var(--gray-500);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 4px;
}

.form-group input:not([type="checkbox"]):not([type="radio"]) {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.form-group select {
  width: 100%;
  padding: 10px 32px 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M1.5 3.5L5 7L8.5 3.5' stroke='%236b7280' stroke-width='1.3' fill='none'/%3E%3C/svg%3E") no-repeat right 12px center;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  cursor: pointer;
  color: var(--gray-800);
}

.form-group input[type="date"] {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--gray-800);
}

.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
}

.login-btn {
  width: 100%;
  padding: 12px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.login-btn:hover {
  background: #1d4ed8;
}

.login-error {
  background: var(--red-bg);
  color: var(--red);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

/* --- Sidebar bottom (lang + user) --- */
.sidebar-bottom {
  margin-top: auto;
  padding: 0 16px 16px;
}

.sidebar-lang {
  margin-bottom: 12px;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 12px;
}

.sidebar-lang select {
  width: 100%;
  padding: 6px 10px;
  font-size: 0.75rem;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='rgba(255,255,255,0.5)'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

[dir="rtl"] .sidebar-lang select {
  background-position: left 10px center;
}

.sidebar-lang select option {
  background: #1e3a5f;
  color: white;
}

/* --- Pipeline summary bar --- */
.pipeline-bar {
  display: flex;
  height: 32px;
  border-radius: 8px;
  overflow: hidden;
  margin: 12px 0;
}

.pipeline-bar .segment {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: white;
  transition: width 0.3s;
}

.pipeline-bar .segment-prospecting { background: var(--gray-400); }
.pipeline-bar .segment-qualification { background: var(--blue); }
.pipeline-bar .segment-proposal { background: var(--amber); }
.pipeline-bar .segment-negotiation { background: #f59e0b; }

/* --- Info / Warning boxes --- */
.info-box {
  background: var(--blue-bg);
  border: 1px solid #93c5fd;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.88rem;
  margin: 12px 0;
}

.warning-box {
  background: var(--amber-bg);
  border: 1px solid #fbbf24;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.88rem;
  margin: 12px 0;
}

/* =============================================================
   Side Panel (detail drawer)
   ============================================================= */

.panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 200;
  transition: opacity 0.2s;
}

.panel-overlay.open {
  display: block;
}

.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 560px;
  max-width: 90vw;
  background: var(--gray-50);
  z-index: 210;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,0.12);
  overflow: hidden;
}

[dir="rtl"] .panel {
  right: auto;
  left: 0;
  transform: translateX(-100%);
  box-shadow: 4px 0 24px rgba(0,0,0,0.12);
}

.panel.open {
  transform: translateX(0);
}

[dir="rtl"] .panel.open {
  transform: translateX(0);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: white;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
}

.panel-header-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-900);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  margin-right: 12px;
}

[dir="rtl"] .panel-header-title {
  margin-right: 0;
  margin-left: 12px;
}

.panel-header-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.panel-header-actions .btn {
  padding: 5px 8px;
}

.panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
  -webkit-overflow-scrolling: touch;
}

.panel-body .cards {
  grid-template-columns: repeat(2, 1fr);
}

.panel-body .grid-2-1,
.panel-body .grid-2 {
  grid-template-columns: 1fr;
}

.panel-body .section {
  padding: 16px;
}

/* =============================================================
   Responsive
   ============================================================= */

/* Tablet: stack grids */
@media (max-width: 1024px) {
  .grid-2,
  .grid-2-1 {
    grid-template-columns: 1fr;
  }

  .cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Mobile: sidebar drawer + compact layout */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  [dir="rtl"] .sidebar {
    transform: translateX(100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .hamburger {
    display: flex;
  }

  .main-content {
    margin-left: 0;
  }

  [dir="rtl"] .main-content {
    margin-right: 0;
  }

  .topbar {
    padding: 10px 16px;
  }

  .topbar-title {
    font-size: 0.95rem;
  }

  .topbar-actions .btn-export {
    display: none;
  }

  .page-content {
    padding: 16px;
  }

  .section {
    padding: 16px;
    border-radius: 8px;
  }

  .section.table-section .table-wrap th:first-child,
  .section.table-section .table-wrap td:first-child {
    padding-left: 16px;
  }

  .section.table-section .table-wrap th:last-child,
  .section.table-section .table-wrap td:last-child {
    padding-right: 16px;
  }

  table {
    font-size: 0.8rem;
  }

  th, td {
    padding: 8px 10px;
  }

  .card {
    padding: 16px;
  }

  .card .value {
    font-size: 1.4rem;
  }

  .note-form {
    padding: 12px;
  }

  .search-bar {
    flex-wrap: wrap;
  }

  .search-bar .btn {
    flex-shrink: 0;
  }

  .pipeline-bar .segment {
    font-size: 0;
  }
}

/* Small mobile: single column cards */
@media (max-width: 480px) {
  .cards {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .topbar-actions {
    gap: 4px;
  }


  .filters {
    gap: 6px;
  }

  .filter-chip {
    padding: 4px 10px;
    font-size: 0.75rem;
  }

  .login-box {
    padding: 24px;
  }
}

/* --- Avatar Preview (Settings) --- */
.avatar-preview {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--gray-200);
  color: var(--gray-600);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
  border: 2px solid var(--gray-300);
}

/* --- Data Source Indicators --- */
.data-src {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  vertical-align: middle;
  margin-left: 4px;
}
.data-src.live {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green);
}
.data-src.uploaded {
  background: var(--blue-bg);
  color: var(--blue);
  border: 1px solid var(--blue);
}
.data-src.hybrid {
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid var(--amber);
}

/* --- Inventory Badges --- */
.badge-in_stock { background: var(--green-bg); color: var(--green); }
.badge-reserved { background: var(--blue-bg); color: var(--blue); }
.badge-shipped { background: var(--gray-100); color: var(--gray-600); }
.badge-damaged { background: var(--red-bg); color: var(--red); }
.badge-lost { background: var(--amber-bg); color: var(--amber); }

.badge-mv-receive { background: var(--green-bg); color: var(--green); }
.badge-mv-transfer { background: var(--blue-bg); color: var(--blue); }
.badge-mv-ship { background: var(--amber-bg); color: var(--amber); }
.badge-mv-adjust { background: var(--red-bg); color: var(--red); }

/* --- Dropdown (inventory actions) --- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  min-width: 140px;
  z-index: 100;
  padding: 4px 0;
}
[dir="rtl"] .dropdown-menu { right: auto; left: 0; }
.dropdown:hover .dropdown-menu,
.dropdown:focus-within .dropdown-menu { display: block; }
.dropdown-item {
  display: block;
  padding: 8px 16px;
  font-size: 0.85rem;
  color: var(--gray-700);
  text-decoration: none;
}
.dropdown-item:hover { background: var(--gray-50); }

/* --- Form fieldset --- */
.form-fieldset {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.form-fieldset legend {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-600);
  padding: 0 8px;
}

/* --- Units checkbox table --- */
.units-checkbox-table {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  overflow: hidden;
}
.units-select-all {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  font-size: 0.85rem;
  cursor: pointer;
}
.table-compact { font-size: 0.85rem; }
.table-compact th { padding: 6px 10px; }
.table-compact td { padding: 6px 10px; }
.table-compact input[type="checkbox"] { cursor: pointer; }

/* --- Detail grid (used in inventory unit/movement detail) --- */
.detail-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}
.detail-card {
  background: white;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--gray-100);
}
.detail-card h4 {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 12px;
}
.detail-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 12px;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-50);
  font-size: 0.85rem;
}
.detail-row:last-child {
  border-bottom: none;
}
.detail-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* --- Serial textarea --- */
textarea.form-input { font-family: monospace; font-size: 0.9rem; }

/* =============================================================
   Meetings & Calendar
   ============================================================= */

/* View toggle buttons */
.view-toggle-btn {
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gray-600);
  text-decoration: none;
  background: white;
  border-right: 1px solid var(--gray-200);
  transition: background 0.15s, color 0.15s;
}
.view-toggle-btn:last-child { border-right: none; }
.view-toggle-btn.active { background: var(--blue); color: white; }
.view-toggle-btn:hover:not(.active) { background: var(--gray-50); }

/* Calendar header */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.cal-title {
  font-size: 1.1rem;
  font-weight: 700;
}

/* Calendar grid (month) */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-dow-row {
  background: var(--gray-50);
  border-radius: 8px 8px 0 0;
  border: 1px solid var(--gray-200);
  border-bottom: none;
}
.cal-dow {
  padding: 8px 4px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
}
.cal-days {
  border: 1px solid var(--gray-200);
  border-radius: 0 0 8px 8px;
  background: white;
}
.cal-day {
  min-height: 100px;
  padding: 6px 8px;
  border-right: 1px solid var(--gray-100);
  border-bottom: 1px solid var(--gray-100);
  transition: background 0.1s;
}
.cal-day:hover { background: var(--gray-50); }
.cal-day:nth-child(7n) { border-right: none; }
.cal-day.other-month { background: var(--gray-50); }
.cal-day.other-month .cal-day-num { color: var(--gray-300); }
.cal-day.today { background: var(--blue-bg); }
.cal-day.today .cal-day-num { color: var(--blue); font-weight: 700; }
.cal-day-num {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 4px;
}

/* Calendar events */
.cal-event {
  font-size: 0.72rem;
  padding: 2px 6px;
  margin-bottom: 2px;
  border-radius: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.cal-event-meeting { background: var(--blue-bg); color: var(--blue); }
.cal-event-call { background: var(--green-bg); color: var(--green); }
.cal-event-cancelled { opacity: 0.5; text-decoration: line-through; }
.cal-event-time {
  font-weight: 700;
  margin-right: 4px;
}
[dir="rtl"] .cal-event-time { margin-right: 0; margin-left: 4px; }
.cal-event-more {
  font-size: 0.7rem;
  color: var(--gray-400);
  padding: 1px 6px;
}
.cal-event-dur {
  font-size: 0.68rem;
  color: var(--gray-400);
  margin-left: 4px;
}

/* Week view */
.cal-week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: white;
  overflow: hidden;
}
.cal-week-day {
  min-height: 200px;
  border-right: 1px solid var(--gray-100);
  transition: background 0.1s;
}
.cal-week-day:last-child { border-right: none; }
.cal-week-day:hover { background: var(--gray-50); }
.cal-week-day.today { background: var(--blue-bg); }
.cal-week-day-header {
  padding: 10px 8px;
  text-align: center;
  border-bottom: 1px solid var(--gray-100);
}
.cal-week-dow {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
}
.cal-week-date {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gray-700);
}
.cal-week-day.today .cal-week-date { color: var(--blue); }
.cal-week-events {
  padding: 6px;
}

/* Day detail items */
.cal-day-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: background 0.1s;
}
.cal-day-item:hover { background: var(--gray-50); }
.cal-day-item:last-child { border-bottom: none; }

/* Meeting type/status badges */
.badge-meeting { background: var(--blue-bg); color: var(--blue); }
.badge-call { background: var(--green-bg); color: var(--green); }
.badge-planned { background: var(--blue-bg); color: var(--blue); }
.badge-held { background: var(--green-bg); color: var(--green); }
.badge-not_held { background: var(--amber-bg); color: var(--amber); }
.badge-cancelled { background: var(--gray-100); color: var(--gray-500); }

/* =============================================================
   Document Badges
   ============================================================= */

/* Document type badges */
.badge-doc-quote { background: var(--blue-bg); color: var(--blue); }
.badge-doc-proforma { background: var(--amber-bg); color: var(--amber); }
.badge-doc-invoice { background: var(--green-bg); color: var(--green); }
.badge-doc-invoice_receipt { background: #dcfce7; color: #15803d; }
.badge-doc-credit_note { background: var(--red-bg); color: var(--red); }
.badge-doc-receipt { background: var(--gray-100); color: var(--gray-600); }

/* Document status badges */
.badge-doc-st-draft { background: var(--gray-100); color: var(--gray-500); }
.badge-doc-st-sent { background: var(--blue-bg); color: var(--blue); }
.badge-doc-st-opened { background: var(--amber-bg); color: var(--amber); }
.badge-doc-st-paid { background: var(--green-bg); color: var(--green); }
.badge-doc-st-partially_paid { background: #d1fae5; color: #059669; }
.badge-doc-st-overdue { background: var(--red-bg); color: var(--red); }
.badge-doc-st-cancelled { background: var(--gray-100); color: var(--gray-400); text-decoration: line-through; }
.badge-doc-st-converted { background: #dbeafe; color: #1e40af; }
.badge-doc-st-closed { background: var(--gray-100); color: var(--gray-500); }

/* Responsive calendar */
@media (max-width: 768px) {
  .cal-day { min-height: 60px; padding: 4px; }
  .cal-day-num { font-size: 0.75rem; }
  .cal-event { font-size: 0.65rem; padding: 1px 3px; }
  .cal-event-time { display: none; }
  .cal-week-grid { grid-template-columns: 1fr; }
  .cal-week-day { min-height: auto; border-right: none; border-bottom: 1px solid var(--gray-100); }
  .cal-week-day-header { display: flex; align-items: center; gap: 8px; padding: 8px 12px; }
  .cal-week-dow { display: inline; }
}

/* --- Print --- */
@media print {
  .sidebar, .topbar, .sidebar-overlay { display: none; }
  .main-content { margin-left: 0; }
  .page-content { padding: 0; }
  .section { box-shadow: none; break-inside: avoid; }
  .btn, .search-bar, .note-form { display: none; }
  .data-src { border: none; }
}
