:root {
  --primary: #A67C3D;
  --primary-dark: #7A5A2A;
  --bg: #f7f5f1;
  --card: #ffffff;
  --border: #e7dfce;
  --text: #1f1b16;
  --text-muted: #6b6354;
  --success: #16a34a;
  --error: #dc2626;
  --warning: #d97706;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Heebo", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  font-size: 14.5px;
}

a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: #fff;
  border-bottom: 3px solid var(--primary);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  min-height: 76px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 10px rgba(31,27,22,0.07);
}
.topbar .brand { font-weight: 700; font-size: 17px; color: var(--text); display: flex; align-items: center; }
.topbar .brand-logo { height: 58px; width: auto; display: block; }
.topbar nav { display: flex; gap: 4px; align-items: center; }
.topbar nav a, .topbar nav .navlink {
  color: #4a4438; padding: 8px 12px; border-radius: 8px; font-size: 13.5px;
}
.topbar nav a:hover { background: #F6EEDF; text-decoration: none; }
.topbar nav a.active { background: #F6EEDF; color: var(--primary-dark); font-weight: 700; }
.topbar .user-box { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #4a4438; }

.container { max-width: 1200px; margin: 24px auto; padding: 0 20px; }
.container.wide { max-width: 1440px; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.page-header h1 { font-size: 21px; margin: 0; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card h2 { font-size: 16px; margin: 0 0 12px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; border-radius: 8px;
  padding: 9px 16px; font-size: 13.5px; cursor: pointer; background: var(--primary); color: #fff;
  font-weight: 600; transition: all .15s;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: #f1f5f9; }
.btn.danger { background: #fff; color: var(--error); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--text-muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .02em; background: #f8fafc; }
tr:hover td { background: #fafbff; }
/* כותרות עמודה שממיינים לפיהן בלחיצה (מאגר המוצרים) */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--text); }
th.sortable .sort-arrow { display: inline-block; margin-right: 5px; font-size: 11px; opacity: .35; }
th.sortable.sorted { color: var(--primary); }
th.sortable.sorted .sort-arrow { opacity: 1; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.form-group label { font-size: 12.5px; color: var(--text-muted); font-weight: 600; }
.form-group.full { grid-column: 1 / -1; }
input, select, textarea {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 13.5px;
  font-family: inherit; background: #fff; color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(166,124,61,.18); }
textarea { resize: vertical; min-height: 60px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; color: #fff; }

.flash-list { position: fixed; top: 66px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(90vw, 480px); }
.flash { padding: 11px 16px; border-radius: 8px; font-size: 13.5px; box-shadow: 0 4px 14px rgba(0,0,0,.12); }
.flash.success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash.error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .form-group { margin-bottom: 0; min-width: 150px; }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat-box { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat-box .label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.stat-box .value { font-size: 20px; font-weight: 700; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }

.thumb { width: 42px; height: 42px; border-radius: 6px; object-fit: cover; background: #f1f5f9; border: 1px solid var(--border); }
.thumb.lg { width: 120px; height: 120px; }

/* quote editor */
.editor-layout { display: grid; grid-template-columns: 2.1fr 1fr; gap: 16px; align-items: flex-start; }
@media (max-width: 980px) { .editor-layout { grid-template-columns: 1fr; } }

.item-row { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; background: #fff; }
.item-row.section-row { background: #F6EEDF; border-color: #e3d4b5; font-weight: 700; }
.item-row.text-row { background: #fffbeb; border-color: #fde68a; font-style: italic; color: #78350f; }
.row-no { margin: 0; }
.item-row .row-no-input { width: 52px; padding: 6px 4px; text-align: center; font-weight: 700; }
.drag-handle { cursor: grab; color: #94a3b8; font-size: 16px; padding: 0 4px; user-select: none; }
.item-row .qty-input, .item-row .price-input, .item-row .disc-input { width: 68px; text-align: center; padding: 6px; }
/* the unit price can be a large number (up to 10 digits + agorot), so it gets a wider box than
   the quantity / discount-percent fields next to it */
.item-row .price-input { width: 132px; }
.item-fields { display: flex; align-items: center; gap: 8px; flex: 1; flex-wrap: wrap; }
.item-meta { flex: 1; min-width: 160px; }
.item-meta .name { font-weight: 600; font-size: 13.5px; }
.item-meta .sku { color: var(--text-muted); font-size: 11.5px; }
.item-meta .name-input { font-weight: 600; font-size: 13.5px; padding: 5px 8px; width: 100%; margin-bottom: 2px; }
.item-meta .desc-input { display: block; width: 100%; min-height: 0; padding: 4px 8px; margin-bottom: 4px; font-size: 12px; line-height: 1.45; color: var(--text-muted); font-family: inherit; overflow: hidden; }
.badge-manual { display: inline-block; background: #fef3c7; color: #92400e; font-size: 10px; font-weight: 700; border-radius: 10px; padding: 1px 8px; margin-right: 6px; }
.thumb-wrap { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 68px; flex-shrink: 0; }
.file-btn {
  display: inline-block; width: 68px; text-align: center; font-size: 9.5px; color: var(--text-muted);
  border: 1px dashed var(--border); border-radius: 6px; padding: 3px 2px; cursor: pointer;
  background: #f8fafc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-btn:hover { background: #f1f5f9; }
.file-btn input[type="file"] { display: none; }
.file-btn.full-width { width: 100%; box-sizing: border-box; font-size: 12.5px; padding: 8px; }
.item-meta .sku-input { width: 110px; padding: 3px 6px; font-size: 11.5px; display: inline-block; }
.cat-name { color: var(--text-muted); font-size: 11.5px; }
.cost-tip-btn {
  position: relative; border: none; background: none; cursor: pointer; font-size: 13px;
  padding: 2px 4px; vertical-align: middle;
}
.mini-label { font-size: 10.5px; color: var(--text-muted); display: block; margin-bottom: 2px; }

.totals-box { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.totals-box .row { display: flex; justify-content: space-between; padding: 4px 0; }
.totals-box .row.grand { font-size: 17px; font-weight: 800; border-top: 2px solid var(--border); padding-top: 10px; margin-top: 4px; }
.totals-box .row.profit { color: var(--success); font-weight: 700; }

.autocomplete-wrap { position: relative; }
.autocomplete-list { position: absolute; z-index: 30; top: 100%; right: 0; left: 0; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 320px; overflow-y: auto; margin-top: 4px; display: none; }
.autocomplete-list.open { display: block; }
.autocomplete-item { display: flex; gap: 10px; align-items: center; padding: 8px 10px; cursor: pointer; border-bottom: 1px solid #f1f5f9; }
.autocomplete-item:hover, .autocomplete-item.active { background: #f8fafc; }
.autocomplete-item.active { background: #F6EEDF; }
.autocomplete-item .name { font-weight: 600; font-size: 13px; }
.autocomplete-item .sub { font-size: 11.5px; color: var(--text-muted); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a { padding: 10px 16px; border-bottom: 2px solid transparent; color: var(--text-muted); font-weight: 600; font-size: 13.5px; }
.tabs a.active { color: var(--primary); border-color: var(--primary); }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1f1b16, #3a2f22); }
.login-card { background: #fff; border-radius: 14px; padding: 34px; width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-card h1 { text-align: center; font-size: 20px; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--text-muted); font-size: 12.5px; margin-bottom: 20px; }

.chip { display: inline-flex; align-items: center; gap: 4px; background: #F6EEDF; color: var(--primary-dark); padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }

.help-text { font-size: 11.5px; color: var(--text-muted); }
hr.sep { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

.details-card summary {
  cursor: pointer; list-style: none; font-size: 14.5px; padding: 2px 0;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.details-card summary::-webkit-details-marker { display: none; }
.details-card summary::before { content: '▸'; color: var(--text-muted); font-size: 12px; transition: transform .15s; }
.details-card[open] summary::before { transform: rotate(90deg); }

#email-box.open-box { display: block !important; }

.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  display: none; position: absolute; top: 100%; right: 0; margin-top: 4px; z-index: 40;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); min-width: 190px; padding: 6px; flex-direction: column; gap: 2px;
}
.dropdown-menu.open { display: flex; }
.dropdown-menu a, .dropdown-menu button {
  display: block; width: 100%; text-align: right; background: none; border: none; padding: 9px 10px;
  border-radius: 6px; font-size: 13.5px; color: var(--text); cursor: pointer; font-family: inherit;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: #f1f5f9; text-decoration: none; }
.dropdown-menu button.danger-item { color: var(--error); }
.dropdown-menu button.danger-item:hover { background: #fef2f2; }

.sku-hoverable { position: relative; cursor: pointer; border-bottom: 1px dotted var(--text-muted); }
.cost-tip {
  display: none; position: absolute; bottom: 100%; right: 0; margin-bottom: 6px; z-index: 35;
  background: #1e293b; color: #fff; padding: 7px 11px; border-radius: 6px; font-size: 12px;
  white-space: nowrap; box-shadow: 0 6px 16px rgba(0,0,0,.2);
}
.cost-tip.open { display: block; }

.reveal-btn {
  background: none; border: 1px dashed var(--border); border-radius: 6px; padding: 3px 8px;
  font-size: 11.5px; color: var(--text-muted); cursor: pointer; font-family: inherit;
}
.reveal-btn:hover { background: #f1f5f9; }
.profit-toggle-wrap { display: flex; flex-direction: column; gap: 3px; }

.link-btn {
  background: none; border: none; color: var(--primary); font-size: 12px; cursor: pointer;
  padding: 4px 0; font-family: inherit; text-decoration: underline;
}

details.profit-details summary { font-size: 13px; color: var(--text-muted); }

/* נעילת עריכה של הצעה מאושרת */
.lock-banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  background: #fff7e6; border: 1px solid #e6c98a; color: #5C4220; border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; }
.lock-banner.unlocked { background: #f4f7ee; border-color: #c9d8b0; color: #3b4a1f; }
.lock-banner form { margin: 0; }
#editor-main[data-locked="1"] .item-row { opacity: 0.85; }


/* ===== מסכים קטנים (טלפון) ===== */
html { -webkit-text-size-adjust: 100%; }
@media (max-width: 700px) {
  body { font-size: 15px; }
  /* 16px בשדות: אחרת הדפדפן בטלפון מגדיל את המסך אוטומטית בכל לחיצה על שדה */
  input, select, textarea { font-size: 16px; }
  .btn { min-height: 40px; }
  .btn.small { min-height: 36px; }

  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 4px 10px; }
  .topbar .brand { order: 1; }
  .topbar .user-box { order: 2; margin-inline-start: auto; font-size: 12px; gap: 8px; }
  .topbar nav { order: 3; flex: 0 0 100%; overflow-x: auto; white-space: nowrap; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .topbar nav a { flex: 0 0 auto; padding: 8px 10px; }

  .container, .container.wide { margin: 12px auto; padding: 0 10px; }
  .page-header h1 { font-size: 18px; }
  .card { padding: 12px; }

  .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .filters .form-group { flex: 1 1 45%; min-width: 0; }

  /* טבלאות: גוללים הצידה במקום לשבור את הדף */
  .table-wrap table { min-width: 620px; }

  .editor-layout { grid-template-columns: 1fr; }
  .card[style*="sticky"] { position: static !important; }

  /* שורות בהצעה: הכול בעמודה אחת קריאה */
  .item-row { flex-wrap: wrap; gap: 8px; }
  .item-row .drag-handle { display: none; }
  .item-row .thumb-wrap { order: 2; width: 60px; }
  .item-row .row-no { order: 1; }
  .item-row .item-meta { order: 3; flex: 1 1 calc(100% - 80px); min-width: 0; }
  .item-row .item-fields { order: 4; flex: 1 1 100%; gap: 10px; }
  .item-row .item-fields > div { flex: 1 1 28%; min-width: 80px; }
  .item-row .qty-input, .item-row .disc-input, .item-row .price-input { width: 100%; }
  .item-row > form:last-child { order: 5; margin-inline-start: auto; }
  .item-meta .sku-input { width: 100%; }

  .autocomplete-list { max-height: 50vh; }
  .dropdown-menu { right: auto; left: 0; }
}

/* בחירת סטטוס ישירה (כותרת ההצעה ורשימת ההצעות) */
.status-form { display: inline-block; margin: 0; }
.status-select { color: #fff; font-weight: 700; font-size: 12.5px; border: 0; border-radius: 20px; padding: 5px 12px; cursor: pointer; width: auto; }
.status-select option { color: #1f1b16; background: #fff; }
.status-select:disabled { opacity: .85; cursor: not-allowed; }

/* תפריט משנה: מוצרים (מוצרים, קטגוריות, פריסטים) והגדרות (כל השאר) */
.subnav { background: #fbf8f2; border-bottom: 1px solid var(--border); padding: 0 20px; display: flex; gap: 2px; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
.subnav a { flex: 0 0 auto; padding: 11px 14px; color: var(--text-muted); font-size: 13.5px; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.subnav a:hover { color: var(--text); text-decoration: none; }
.subnav a.active { color: var(--primary-dark); border-bottom-color: var(--primary); font-weight: 700; }
@media (max-width: 700px) { .subnav { padding: 0 8px; } }

@media (max-width: 700px) { .topbar .brand-logo { height: 44px; } }

/* הערות מוכנות: תפריט נפתח עם תיבות סימון, רואים רק את הנושא */
.note-dd { position: relative; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.note-dd-panel { display: none; position: absolute; top: 100%; right: 0; z-index: 40; min-width: 260px; max-width: calc(100vw - 30px);
  max-height: 260px; overflow-y: auto; background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(31,27,22,.14); padding: 4px; margin-top: 4px; }
.note-dd-panel.open { display: block; }
.note-dd-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 6px; cursor: pointer; margin: 0; font-weight: 600; }
.note-dd-item:hover { background: #F6EEDF; }
.note-dd-item input { width: auto; margin: 0; }

/* השאלה בעריכת הצעה: לשמור שוב את קובץ ה-PDF בתיקיית הלקוח */
.save-banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  background: #F6EEDF; border: 1px solid #e3d4b5; color: #5C4220; border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; }
.save-banner .help-text { display: block; margin-top: 2px; }
.save-banner-actions { display: flex; gap: 8px; margin: 0; }

/* אזורי הוספה והערות בעריכת הצעה: נפתחים בלחיצה על הכותרת */
.sec-card > summary { font-size: 16px; font-weight: 700; }
.sec-card[open] > summary { margin-bottom: 12px; }

/* עורך ההערות (טקסט עשיר) */
.rte-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px; background: #fbf8f2; border: 1px solid var(--border); border-bottom: 0; border-radius: 8px 8px 0 0; }
.rte-toolbar button { min-width: 32px; height: 32px; padding: 0 8px; border: 1px solid var(--border); background: #fff; border-radius: 6px; cursor: pointer; font-size: 13px; }
.rte-toolbar button:hover { background: #F6EEDF; }
.rte-toolbar select { width: auto; height: 32px; padding: 0 6px; font-size: 13px; }
.rte-toolbar input[type=color] { width: 32px; height: 32px; padding: 2px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.rte-toolbar .rte-swatch { min-width: 22px; width: 22px; height: 22px; padding: 0; border-radius: 50%; }
.rte-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.rte-editor { min-height: 96px; padding: 10px 12px; background: #fff; border: 1px solid var(--border); border-radius: 0 0 8px 8px; line-height: 1.6; outline: none; }
.rte-editor:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(166,124,61,.18); }
.rte-editor:empty::before { content: attr(data-placeholder); color: var(--text-muted); }
.rte-editor ul, .rte-editor ol { margin: 4px 0; padding-right: 24px; padding-left: 0; }

/* ===== קריאות שירות ===== */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { display: flex; flex-direction: column; gap: 2px; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; color: var(--text); text-decoration: none !important; }
a.kpi:hover { border-color: var(--primary); }
.kpi-n { font-size: 26px; font-weight: 800; line-height: 1.1; }
.kpi-l { color: var(--text-muted); font-size: 12.5px; }
.kpi-bad { border-color: #e8b4b4; background: #fdf3f3; } .kpi-bad .kpi-n { color: #b91c1c; }
.kpi-warn { border-color: #e6c98a; background: #fff7e6; } .kpi-warn .kpi-n { color: #b45309; }
.kpi-good .kpi-n { color: #15803d; }
.view-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.view-tabs a { padding: 7px 14px; border-radius: 20px; background: #fff; border: 1px solid var(--border); color: var(--text); font-size: 13px; }
.view-tabs a.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.view-tabs a:hover { text-decoration: none; border-color: var(--primary); }

.sla { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.sla-ok { background: #e7f4ea; color: #166534; } .sla-warn { background: #fff1d6; color: #92400e; }
.sla-overdue { background: #fde2e2; color: #991b1b; } .sla-paused { background: #ece9e1; color: #5b5345; }
.sla-met { background: #e7f4ea; color: #166534; } .sla-missed { background: #fde2e2; color: #991b1b; } .sla-na { color: var(--text-muted); }

.svc-title { margin: -4px 0 14px; }
.svc-title-text { font-size: 19px; font-weight: 700; margin-bottom: 6px; }
.svc-title-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pill-lite { display: inline-block; padding: 3px 10px; border-radius: 20px; background: #f1ece1; color: #5b5345; font-size: 12px; }
.pill-gold { background: #F6EEDF; color: #7A5A2A; font-weight: 700; }
.rich-view { line-height: 1.6; }
.check-inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; cursor: pointer; font-size: 13px; }
.check-inline input { width: auto; margin: 0; }

.tl-form textarea { width: 100%; }
.tl-form-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 8px 0 14px; }
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { position: relative; padding: 10px 16px 10px 0; margin-right: 10px; border-right: 2px solid #e7dfce; }
.tl-item::before { content: ''; position: absolute; right: -6px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: #e7dfce; }
.tl-update::before, .tl-status::before { background: var(--primary); } .tl-note::before { background: #7A5A2A; }
.tl-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.tl-body { margin-top: 3px; line-height: 1.55; white-space: pre-wrap; }
.tl-system .tl-body, .tl-status .tl-body { color: var(--text-muted); font-size: 13px; }
.tl-img { max-width: min(220px, 100%); max-height: 160px; height: auto; object-fit: contain; border-radius: 8px; border: 1px solid var(--border); margin: 6px 0 0 6px; }
.tl-file { display: inline-block; margin-top: 6px; }

.svc-inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.svc-inline-form .form-group { margin-bottom: 0; }
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); gap: 10px; }
.file-card { border: 1px solid var(--border); border-radius: 10px; padding: 8px; text-align: center; background: #fff; }
.file-card img { width: 100%; height: 100px; object-fit: cover; border-radius: 6px; }
.file-ico { font-size: 36px; height: 100px; display: flex; align-items: center; justify-content: center; }
.file-name { font-size: 12px; margin: 6px 0 2px; overflow-wrap: anywhere; }
.file-actions { font-size: 12px; display: flex; gap: 10px; justify-content: center; }

.side-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.side-row label { min-width: 52px; margin: 0; font-weight: 600; }
.side-row select, .side-row input { flex: 1; }
.sla-table { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.sla-table > div { display: flex; justify-content: space-between; gap: 10px; }
.sla-table span { color: var(--text-muted); }
.contact-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.cal-day { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 8px; min-height: 140px; }
.cal-today { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(166,124,61,.2); }
.cal-head { font-weight: 700; font-size: 13px; margin-bottom: 6px; display: flex; justify-content: space-between; }
.cal-head span { color: var(--text-muted); font-weight: 400; }
.cal-item { display: block; border: 1px solid var(--border); border-right: 4px solid var(--primary); border-radius: 6px; padding: 5px 8px; margin-bottom: 6px; color: var(--text); background: #fbf8f2; }
.cal-item:hover { text-decoration: none; background: #F6EEDF; }
.cal-time { font-weight: 700; font-size: 12.5px; display: flex; justify-content: space-between; gap: 6px; }
.cal-title { font-size: 13px; }
.unsched-row { padding: 6px 0; border-bottom: 1px solid var(--border); }
@media (max-width: 1000px) { .cal-grid { grid-template-columns: 1fr; } }

.rep-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; font-size: 13px; }
.bar-label { width: 110px; flex: 0 0 110px; }
.bar-track { flex: 1; height: 10px; background: #f1ece1; border-radius: 6px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--primary); border-radius: 6px; }
.daychart { display: flex; gap: 6px; align-items: flex-end; height: 140px; margin: 6px 0; }
.daycol { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.daybars { flex: 1; display: flex; gap: 2px; align-items: flex-end; width: 100%; justify-content: center; }
.daybars span { width: 42%; min-height: 2px; border-radius: 3px 3px 0 0; }
.b-created { background: #A67C3D; } .b-resolved { background: #15803d; }
.daylbl { font-size: 10.5px; color: var(--text-muted); margin-top: 3px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; } .dot-created { background: #A67C3D; } .dot-resolved { background: #15803d; }

.sig-wrap { border: 2px dashed #c9b78f; border-radius: 10px; background: #fff; touch-action: none; }
.sig-wrap canvas { width: 100%; height: auto; display: block; touch-action: none; cursor: crosshair; }

.cam-btn { cursor: pointer; }

.first-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: flex-start; }
.first-files > a { max-width: 100%; min-width: 0; }
.first-files .tl-img { max-width: min(280px, 100%); max-height: 210px; margin: 0; }
.editor-layout > * { min-width: 0; }
.file-card { min-width: 0; }

/* Field documentation: bounded thumbnails even when the original is a large phone photo. */
.fld-doc, .fld-item { min-width: 0; }
.fld-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.fld-actions form, .fld-tools form { margin: 0; }
.fld-item-head, .fld-item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.fld-item.is-collapsed .fld-item-head { margin-bottom: 0; }
.fld-item-body[hidden] { display: none; }
.fld-toggle { flex: 0 0 auto; }
.whatsapp-icon { width: 20px; height: 20px; vertical-align: middle; flex: 0 0 auto; }
.svc-category-settings { scroll-margin-top: 120px; }
.svc-category-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.svc-category-form > input:not([type="hidden"]) { flex: 1 1 180px; min-width: 0; }
.svc-category-form .check-inline { margin: 0; }
.fld-loc { flex: 1 1 160px; min-width: 0; }
.fld-chev { display: inline-block; font-size: 17px; line-height: 1; transition: transform .15s; }
.fld-item.is-collapsed .fld-chev { transform: rotate(90deg); }
.fld-choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.fld-choice-row > input { flex: 1 1 250px; min-width: 0; }
.fld-choice-row > select { flex: 0 1 220px; min-width: 0; max-width: 100%; }
.fld-n { font-weight: 700; }
.fld-item-meta input { min-width: 0; max-width: 100%; width: auto; }
.fld-item-meta .fld-category { width: 170px; min-width: 0; max-width: 100%; }
.fld-tools { display: flex; gap: 8px; }
.fld-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(180px, 100%), 1fr)); gap: 12px; margin-bottom: 12px; }
.fld-photo { position: relative; min-width: 0; max-width: 100%; }
.fld-photo > a { display: flex; align-items: center; justify-content: center; width: 100%; height: 160px; overflow: hidden; background: var(--bg); border-radius: 8px; }
.fld-photo img { display: block; width: 100%; height: 100%; max-width: 100%; max-height: 160px; object-fit: contain; }
.fld-photo textarea { width: 100%; min-width: 0; margin-top: 6px; }
.fld-photo > form { position: absolute; top: 4px; left: 4px; margin: 0; }
.fld-x { border: 1px solid var(--border); border-radius: 50%; background: #fff; cursor: pointer; padding: 4px 8px; }
.fld-addphoto { display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 160px; border: 2px dashed var(--border); border-radius: 8px; cursor: pointer; }
.fld-note { width: 100%; }
@media (max-width: 600px) {
  .fld-photos { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .fld-photo > a, .fld-addphoto { height: 130px; min-height: 130px; }
  .fld-photo img { max-height: 130px; }
}

.fld-customer-top { font-size: 20px; font-weight: 800; color: #6f5124; margin-bottom: 2px; }
.fld-customer-top a { color: inherit; text-decoration: none; border-bottom: 2px solid #A67C3D; }

.nav-count { display:inline-block; min-width:18px; padding:0 6px; border-radius:99px; background:#A67C3D; color:#fff; font-size:11px; font-weight:800; line-height:18px; text-align:center; margin-right:4px; }
