/* ============================================================
   QCOW — Sale & Lot Management
   Design tokens
   ============================================================ */
:root{
  --ink:        #23201b;
  --ink-soft:   #5b5347;
  --paper:      #f6f3ec;
  --paper-dim:  #ece7db;
  --surface:    #ffffff;
  --line:       #ddd6c4;
  --pasture:    #2f4b3c;
  --pasture-dk: #203a2d;
  --tag-gold:   #c08f2c;
  --tag-gold-lt:#f1e2b8;
  --danger:     #a4342a;

  --font-display: 'Zilla Slab', Georgia, serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    'IBM Plex Mono', 'Courier New', monospace;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(35,32,27,0.06), 0 8px 24px -12px rgba(35,32,27,0.18);
}

*{ box-sizing: border-box; }
html,body{ height:100%; overflow:hidden; }
body{
  margin:0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display:flex;
  flex-direction:column;
}

h1,h2,h3{
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0 0 .5em;
  letter-spacing: -0.01em;
}

a{ color: var(--pasture); }

button{ font-family: inherit; }

/* ---------- Layout shells ---------- */
.top-strip{
  padding: 22px 24px 10px;
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: .12em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
}
.top-strip .actions{ display:flex; gap:14px; align-items:center; text-transform:none; letter-spacing:0; font-family: var(--font-body); }
.top-strip .actions a, .top-strip .actions button.link-btn{
  background:none; border:none; cursor:pointer; color: var(--ink-soft); font-size: 13px; text-decoration: underline;
  padding: 0;
}

.brand-photo{
    width:150px;
    height:50px;
}

.brand-photo-login{
    width:150px;
    height:50px;

    display:block;      /* Makes the image a block element */
    margin:0 auto 20px; /* Centers it horizontally and adds space below */
    object-fit:contain; /* Prevents stretching */
}



.center-shell{
  flex: 1 1 auto;
  min-height: 0;
  display:flex;
  align-items:flex-start;
  justify-content:center;
  padding: 24px;
  overflow-y: auto;
  overflow-x: hidden;
}

.card{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 420px;
  padding: 40px 36px;
}
  
.card.wide{ max-width: 620px; }
.card.xwide{ max-width: 1000px; }
.card.xxwide{ max-width: 1360px; }
.card.xxwide.dash-container{ max-width: 1680px; }

/* Wider variants for Create/Edit Sale — wide enough that the form lays out
   in columns instead of one long scrolling stack. */
.card.form-wide{ max-width: 1360px; }
.modal-box.form-wide{ max-width: 1400px; }

.card h2.form-title{
  text-align:center;
  font-size: 26px;
  margin-bottom: 28px;
}

/* ---------- Forms ---------- */
label{
  display:block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--ink);
}
.field{ margin-bottom: 20px; }
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="number"],
input[type="url"],
select,
textarea{
  width:100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  font-family: inherit;
  font-size: 14.5px;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus{
  outline: none;
  border-color: var(--pasture);
  box-shadow: 0 0 0 3px rgba(47,75,60,0.15);
}
textarea{
  min-height: 140px;
  resize: vertical;
}
.row-3{ display:grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ---------- Create/Edit Sale form — layout ----------
   Left column: sale details grouped into clear field pairs, plus a
   distinct "Buyer Reminders" panel. Right column: a sticky location map
   with the search bar and pin summary layered directly on the map,
   rather than living below it as separate rows. */
.form-two-col{
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 0 40px;
  align-items: stretch;
}
.form-col-main{
  display: flex;
  flex-direction: column;
}
.form-two-col .field{ margin-bottom: 18px; }
.form-two-col .form-col-location .location-field{ margin-bottom: 0; }

/* Right column stretches to match the left column's full height (instead of
   stopping short and leaving dead white space below the map) — the map
   itself grows to fill whatever room is left. Desktop/landscape only; on a
   stacked mobile layout this reverts to a fixed map height. */
@media (min-width: 861px){
  .form-col-location{
    display: flex;
    flex-direction: column;
    height: 100%;
  }
  .form-col-location .location-field{
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
  }
  .form-col-location .map-shell{
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 460px;
  }
  .form-col-location #location-map,
  .form-col-location .location-map{
    flex: 1 1 auto;
    height: auto;
  }
}

/* Two related fields sharing a row (Physical/Online location, Contact/Breed) */
.field-pair{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}
.field-pair .field{ margin-bottom: 18px; }

.field-trio{
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0 16px;
}
.field-trio .field{ margin-bottom: 18px; }

@media (max-width: 760px){
  .field-trio{ grid-template-columns: 1fr; }
}

/* Compact segmented control for Date / Time / TimeZone rows — reads as
   one control instead of three separate boxes bolted together. */
.field-segmented{
  display: flex;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  overflow: hidden;
}
.field-segmented > div{
  flex: 1 1 0;
  min-width: 0;
  padding: 9px 14px 10px;
  transition: background .12s;
}
.field-segmented > div + div{ border-left: 1px solid var(--line); }
.field-segmented > div:focus-within{ background: var(--paper-dim); }
.field-segmented label{
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-soft);
  margin-bottom: 3px;
}
.field-segmented input,
.field-segmented select{
  width: 100%;
  border: none;
  background: transparent;
  padding: 1px 0 0;
  font-size: 14.5px;
  color: var(--ink);
}
.field-segmented input:focus,
.field-segmented select:focus{ outline: none; box-shadow: none; }

/* Section marker above a group of fields — reuses the ear-tag badge shape
   so the form reads in the same visual language as the rest of QCOW. */
.panel-eyebrow{ margin-bottom: 8px; }
.panel-intro{ margin: 0 0 18px; }

/* Buyer Reminders — its own tinted panel so it reads as a distinct step,
   not just a continuation of the sale-details list. */
.reminders-panel{
  background: var(--paper-dim);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 22px 20px;
  margin-top: 6px;
}
.reminders-panel .field:last-child{ margin-bottom: 0; }
.reminders-panel .field-segmented{ background: var(--surface); }

.form-actions{ margin-top: 8px; }
.form-actions.form-actions-corner{
  display:flex; align-items:center; justify-content:flex-end; gap:14px;
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.form-actions.form-actions-corner .error-text{ margin-top:0; }
.form-actions.form-actions-corner .btn{ width: auto; min-width: 180px; }

/* ---------- Create/Edit Sale — page header ---------- */
.card.form-wide{ padding: 0; }
.form-page-header{ padding: 28px 40px 22px; }
.form-page-header h1{ font-size: 25px; margin: 10px 0 4px; }
.form-page-header .sale-meta{ font-family: var(--font-body); font-size: 13.5px; }
.sale-form-body{ padding: 10px 40px 36px; }
.modal-box.form-wide .modal-sub{ font-size: 13px; color: var(--ink-soft); margin: 0 0 20px; }

@media (max-width: 860px){
  .form-two-col{ grid-template-columns: 1fr; gap: 0; }
}
@media (max-width: 600px){
  .field-pair{ grid-template-columns: 1fr; }
  .field-segmented{ flex-direction: column; }
  .field-segmented > div + div{ border-left: none; border-top: 1px solid var(--line); }
  .form-page-header{ padding: 22px 22px 16px; }
  .sale-form-body{ padding: 10px 22px 28px; }
}

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  border: none;
  border-radius: 999px;
  padding: 12px 26px;
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
  transition: transform .12s ease, filter .12s ease, opacity .12s;
}
.btn:active{ transform: translateY(1px); }
.btn:disabled{ opacity:.55; cursor:not-allowed; }
.btn-primary{ background: var(--pasture); color:#fff; }
.btn-primary:hover:not(:disabled){ filter: brightness(1.08); }
.btn-block{ width:100%; }
.btn-ghost{ background: transparent; border:1px solid var(--line); color: var(--ink); }
.btn-ghost:hover{ background: var(--paper-dim); }
.btn-sm{ padding: 8px 16px; font-size: 13px; }
.btn-outline-gold{ background: #fff; border: 1.5px solid var(--tag-gold); color:#8a6a20; }
.btn-outline-gold:hover{ background: var(--tag-gold-lt); }

.helper-text{ font-size: 12.5px; color: var(--ink-soft); margin-top: 6px; }
.error-text{ font-size: 13px; color: var(--danger); margin-top: 10px; min-height: 1em; }
.success-text{ font-size: 13px; color: var(--pasture); margin-top: 10px; min-height: 1em; }

.form-footer{ text-align:center; margin-top: 20px; font-size: 13.5px; color: var(--ink-soft); }
.form-footer a{ font-weight:600; }

/* ---------- Ear-tag badge (signature element) ---------- */
.tag-badge{
  display:inline-flex;
  align-items:center;
  gap: 6px;
  background: var(--pasture);
  color:#fff;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .03em;
  padding: 4px 10px 4px 12px;
  border-radius: 3px 12px 12px 3px;
  position: relative;
}
.tag-badge::before{
  content:"";
  position:absolute;
  left: 4px; top: 50%;
  width: 4px; height: 4px;
  background: rgba(255,255,255,.85);
  border-radius: 50%;
  transform: translateY(-50%);
}
.tag-badge.gold{ background: var(--tag-gold); }

/* ---------- Manage Sale (members / roles) ---------- */
.member-row{
  display:flex;
  align-items:center;
  gap:14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.member-row:last-child{ border-bottom:none; }
.member-main{ flex: 1 1 220px; min-width: 180px; }
.member-main .member-name{ font-weight:700; font-size: 15px; }
.member-main .member-email{ font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.role-select{ width:auto; min-width:140px; }
.role-tag{
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight:600;
  letter-spacing:.03em;
  text-transform:uppercase;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--paper-dim);
  color: var(--ink-soft);
  white-space:nowrap;
}
.role-tag.role-owner{ background: var(--pasture); color:#fff; }
.role-tag.role-manager{ background: var(--tag-gold-lt); color:#8a6a20; }
.add-member-form{
  display:flex;
  gap:10px;
  align-items:flex-end;
  flex-wrap:wrap;
  padding-top: 18px;
  margin-top: 6px;
  border-top: 1px solid var(--line);
}
.add-member-form .field{ margin-bottom:0; flex: 1 1 220px; }
.add-member-form .field.role-field{ flex: 0 1 160px; }
.sale-picker{ margin-bottom: 22px; }
.sale-picker label{ margin-bottom:6px; }

/* ---------- Sale header / list page ---------- */
.sale-header{
  background: var(--paper-dim);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 26px 28px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.sale-header h1{ font-size: 24px; margin:0; }
.sale-header .sale-meta{ font-size: 13px; color: var(--ink-soft); margin-top: 4px; font-family: var(--font-body); font-weight:400;}

/* Keeps the sale title/header (and toolbar row, if present) pinned in place
   while only the lot rows underneath scroll — used on the List of Lots page. */
.card.scroll-card{
  display:flex;
  flex-direction:column;
  max-height: calc(100vh - 48px);
}
.card.scroll-card .sale-header{ flex:0 0 auto; }
.card.scroll-card > .flex-between{ flex:0 0 auto; }
.card.scroll-card .lot-list{ flex:1 1 auto; overflow-y:auto; min-height:0; }
.card.scroll-card .empty-state{ flex:0 0 auto; overflow-y:auto; }

.lot-list{ list-style:none; margin:0; padding:0; }
.lot-row{
  display:flex;
  align-items:center;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.lot-row:last-child{ border-bottom:none; }
.lot-main{ flex: 1 1 220px; min-width: 200px; }
.lot-main .lot-name{ font-weight: 700; font-size: 15.5px; }
.lot-main .lot-reg{ font-size: 13px; color: var(--ink-soft); margin-top: 2px; }

.icon-btn{
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 38px; height: 38px;
  display:inline-flex; align-items:center; justify-content:center;
  cursor:pointer;
  color: var(--ink);
  transition: background .12s, border-color .12s;
}
.icon-btn:hover{ background: var(--paper-dim); border-color: var(--pasture); }
.icon-group{ display:flex; gap:8px; }

.media-row{ display:flex; gap:8px; align-items:center; }
.media-row input{ flex:1; }
.media-row .row-remove{
  background: var(--paper); border:1px solid var(--line); border-radius: 50%;
  width: 34px; height: 34px; flex: 0 0 auto; cursor:pointer; color: var(--danger);
  display:flex; align-items:center; justify-content:center; font-size:16px;
}
.media-row .row-remove:hover{ background: var(--paper-dim); }
.media-rows .media-row + .media-row{ margin-top: 10px; }
.link-btn-inline{
  background:none; border:none; color: var(--pasture); font-weight:600; font-size: 13.5px;
  cursor:pointer; padding: 10px 0 0; text-decoration: underline;
}

/* ---------- Media management (inside Edit Lot modal) ---------- */
.media-manage{ margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.media-manage-title{
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-soft);
  margin: 0 0 12px;
}
.media-manage-list{
  display:flex;
  flex-direction:column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 2px;
}
.media-manage-row{ display:flex; align-items:center; gap:10px; }
.media-thumb{
  width: 48px; height: 48px; flex: 0 0 auto;
  border-radius: 8px;
  overflow: hidden;
  background: var(--paper-dim);
  border: 1px solid var(--line);
  display:flex; align-items:center; justify-content:center;
}
.media-thumb-img, .media-thumb-video{
  width:100%; height:100%;
  object-fit: cover;
  display:block;
}
.media-thumb-fallback{
  width:100%; height:100%;
  display:flex; align-items:center; justify-content:center;
  color: var(--ink-soft);
}
.media-info{ flex:1; min-width:0; display:flex; flex-direction:column; gap:4px; }
.media-label{ font-size: 12px; font-weight:700; color: var(--ink); }
.media-manage-row input{
  flex:1;
  padding: 7px 10px;
  font-size: 12.5px;
}
.media-manage-row .row-remove{ width:30px; height:30px; font-size:15px; flex:0 0 auto; }
.media-manage-row.is-saving input{ opacity:.6; }

.empty-state{
  text-align:center;
  padding: 60px 28px;
  color: var(--ink-soft);
}

/* ---------- Modal ---------- */
.modal-overlay{
  position:fixed; inset:0;
  background: rgba(35,32,27,0.45);
  display:flex; align-items:center; justify-content:center;
  z-index: 100;
  padding: 20px;
}
.modal-overlay[hidden]{ display:none; }
.modal-box{
  background:#fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 380px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 30px 28px;
  position: relative;
}
.modal-box.wide{ max-width: 480px; }
.modal-close{
  position:absolute; top:14px; right:16px;
  background:none; border:none; cursor:pointer;
  font-size: 20px; color: var(--ink-soft); line-height:1;
}
.modal-box h3{ font-size: 19px; margin-bottom: 18px; }

/* ---------- CSV mapping table ---------- */
.mapping-table{ width:100%; border-collapse: collapse; margin-top: 18px; }
.mapping-table thead th{
  text-align:left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-soft);
  background: var(--paper-dim);
  padding: 10px 14px;
}
.mapping-table tbody td{
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.mapping-table tbody td:first-child{ font-weight:600; }

.dropzone{
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 50px 20px;
  text-align:center;
  color: var(--ink-soft);
  cursor:pointer;
  transition: border-color .15s, background .15s;
}
.dropzone.drag-over, .dropzone:hover{ border-color: var(--pasture); background: var(--paper-dim); }
.dropzone input[type=file]{ display:none; }
.file-chip{
  display:inline-flex; align-items:center; gap:8px;
  background: var(--paper-dim); border:1px solid var(--line);
  padding: 6px 12px; border-radius: 999px; font-size: 13px; margin-top: 14px;
}

/* ---------- QR page ---------- */
.qr-wrap{ text-align:center; padding: 30px 10px 10px; }
.qr-wrap img{ width: 240px; height: 240px; border-radius: 8px; border:1px solid var(--line); }
.qr-status{ font-weight:600; margin-bottom: 18px; font-family: var(--font-display); font-size:18px;}
.qr-actions{ display:flex; gap: 12px; justify-content:center; margin-top: 20px; }
.qr-url{ display:block; font-family: var(--font-mono); font-size:12.5px; color: var(--ink-soft); margin-top:14px; word-break: break-all; text-align:center;}

/* spinner */
.spinner{
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 3px solid var(--paper-dim);
  border-top-color: var(--pasture);
  animation: spin .8s linear infinite;
  display:inline-block;
}

  /* Existing media list inside the Edit Lot modal */
  .edit-media-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
  }
  .edit-media-section h4 {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 600;
  }
  .existing-media {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 260px;
    overflow-y: auto;
  }
  .media-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
  }
  .media-item-icon {
    flex: 0 0 auto;
    display: flex;
    color: inherit;
    opacity: 0.7;
  }
  .media-item-link {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
  }
  .media-remove {
    flex: 0 0 auto;
    color: #b91c1c;
  }

  /* Thumbnail preview for photo/video media items */
  .media-thumb{
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(0,0,0,0.05);
    border: 1px solid rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .media-thumb-img, .media-thumb-video{
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }
  .media-thumb-fallback{
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
  }

  /* Confirm-delete modal */
  .confirm-box{
    max-width: 340px;
    text-align: center;
  }
  .confirm-box h3{
    font-size: 18px;
    margin-bottom: 10px;
  }
  .confirm-box p{
    color: var(--ink-soft, #5b5347);
    font-size: 14px;
    margin-bottom: 22px;
  }
  .confirm-actions{
    display: flex;
    gap: 12px;
    justify-content: center;
  }
  .confirm-actions .btn{ flex: 1; }
  .btn-danger{
    background: #a4342a;
    color: #fff;
  }
  .btn-danger:hover:not(:disabled){ filter: brightness(1.08); }

@keyframes spin{ to{ transform: rotate(360deg); } }

/* ---------- 3-dot row menu (My Sales page) ---------- */
.row-menu{ position: relative; }
.btn-icon-kebab{
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 38px; height: 38px;
  display:inline-flex; align-items:center; justify-content:center;
  cursor:pointer;
  color: var(--ink);
  transition: background .12s, border-color .12s;
}
.btn-icon-kebab:hover{ background: var(--paper-dim); border-color: var(--pasture); }
.row-menu-dropdown{
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  min-width: 150px;
  z-index: 20;
  overflow: hidden;
}
.row-menu-dropdown[hidden]{ display:none; }
.row-menu-item{
  display:block;
  padding: 10px 14px;
  font-size: 13.5px;
  color: var(--ink);
  text-decoration:none;
  white-space:nowrap;
}
.row-menu-item:hover{ background: var(--paper-dim); }

/* ---------- Lot status badge & comment (List of Lots page) ---------- */
.tag-badge.status-sold{ background: var(--pasture); }
.tag-badge.status-scratch{ background: var(--danger); }
.lot-main .lot-comment{ font-size: 12.5px; color: var(--ink-soft); font-style: italic; margin-top: 2px; }

/* utility */
.mt-24{ margin-top:24px; }
.flex-between{ display:flex; align-items:center; justify-content:space-between; }
.text-center{ text-align:center; }
.stack-gap-16 > * + *{ margin-top:16px; }

/* ---------- Sale location picker (Create/Edit Sale) ----------
   Search + "use my location" float directly on the map, and the
   selected-address summary sits as a chip along its bottom edge, so the
   map reads as one self-contained control instead of a stack of rows. */
.map-shell{
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
#location-map, .location-map{
  width: 100%;
  height: 460px;
  background: var(--paper-dim);
  position: relative;
  z-index: 0;
  cursor: crosshair;
}
.map-search-overlay{
  position: absolute;
  top: 14px; left: 14px; right: 14px;
  z-index: 10;
  display: flex;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 6px 6px 16px;
  box-shadow: var(--shadow);
}
.map-search-overlay input{
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  padding: 6px 4px;
  font-size: 13.5px;
  background: transparent;
  color: var(--ink);
}
.map-search-overlay input:focus{ outline: none; box-shadow: none; }
.map-icon-btn{
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--paper);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.map-icon-btn:hover{ background: var(--paper-dim); border-color: var(--pasture); }

.map-location-chip{
  position: absolute;
  left: 14px; right: 14px; bottom: 14px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 8px 9px 16px;
  box-shadow: var(--shadow);
}
.map-location-chip .location-preview{
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12.5px;
  font-family: var(--font-mono);
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0;
}
.map-location-chip .location-preview.has-location{ color: var(--pasture); font-weight: 600; }
.map-chip-clear{
  flex: 0 0 auto;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: none;
  background: var(--paper-dim);
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.map-chip-clear:hover{ background: var(--line); color: var(--ink); }

#location-map .leaflet-control-zoom, .location-map .leaflet-control-zoom{ margin-top: 64px !important; }
#location-map .leaflet-control-zoom a, .location-map .leaflet-control-zoom a{
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line) !important;
}
#location-map .leaflet-control-zoom a:hover, .location-map .leaflet-control-zoom a:hover{ background: var(--paper-dim); }
#location-map .leaflet-popup-content-wrapper, .location-map .leaflet-popup-content-wrapper{
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 12.5px;
}

/* ---------- Create/Edit Sale — compact mode ----------
   Shared by the Create Sale page (.card.form-wide) and the Edit Sale
   modal (.modal-box.form-wide) so both look and feel the same. Tighter
   spacing means the whole form is visible with far less scrolling. */
.modal-box.form-wide{
  padding: 22px 26px;
  max-height: calc(100vh - 60px);
}
.modal-box.form-wide h3{ margin-bottom: 4px; }
.modal-box.form-wide .modal-sub{ margin-bottom: 14px; font-size: 13px; color: var(--ink-soft); }

.card.form-wide .form-page-header{ padding: 20px 26px 14px; }
.card.form-wide .form-page-header h1{ font-size: 21px; margin: 6px 0 3px; }
.card.form-wide .sale-form-body{ padding: 6px 26px 26px; }

.modal-box.form-wide .field,
.card.form-wide .field{ margin-bottom: 12px; }
.modal-box.form-wide label,
.card.form-wide label{ margin-bottom: 4px; font-size: 12px; }
.modal-box.form-wide input[type="text"],
.modal-box.form-wide input[type="date"],
.modal-box.form-wide input[type="time"],
.modal-box.form-wide select,
.modal-box.form-wide textarea,
.card.form-wide input[type="text"],
.card.form-wide input[type="date"],
.card.form-wide input[type="time"],
.card.form-wide select,
.card.form-wide textarea{
  padding: 8px 10px;
  font-size: 13.5px;
}
.modal-box.form-wide .field-segmented > div,
.card.form-wide .field-segmented > div{ padding: 6px 10px 7px; }
.modal-box.form-wide .field-trio,
.modal-box.form-wide .field-pair,
.card.form-wide .field-trio,
.card.form-wide .field-pair{ gap: 0 12px; }
.modal-box.form-wide .field-trio .field,
.modal-box.form-wide .field-pair .field,
.card.form-wide .field-trio .field,
.card.form-wide .field-pair .field{ margin-bottom: 12px; }

/* Contact sits alone in its row full-width by default — cap it so it
   doesn't stretch the whole column width for a short phone/email value. */
.modal-box.form-wide input#es-contact,
.card.form-wide input#contact{ max-width: 340px; }

.modal-box.form-wide .toggle-field,
.card.form-wide .toggle-field{ padding: 10px 14px; margin: 0 0 14px; }
.modal-box.form-wide .toggle-title,
.card.form-wide .toggle-title{ font-size: 13px; }
.modal-box.form-wide .helper-text,
.card.form-wide .helper-text{ font-size: 11.5px; margin-top: 3px; }

.modal-box.form-wide .reminders-panel,
.card.form-wide .reminders-panel{ padding: 14px 16px 16px; margin-top: 0; }
.modal-box.form-wide .panel-intro,
.card.form-wide .panel-intro{ margin: 0 0 12px; }
.modal-box.form-wide .reminders-panel textarea,
.card.form-wide .reminders-panel textarea{ min-height: 64px; }
.modal-box.form-wide .reminders-panel textarea#es-email_template,
.card.form-wide .reminders-panel textarea#email_template{ min-height: 76px; }

.modal-box.form-wide .form-actions.form-actions-corner,
.card.form-wide .form-actions.form-actions-corner{ margin-top: 16px; padding-top: 14px; }

/* Map: fixed compact height, then stretched by the flex rules below to
   fill whatever room the left column's height leaves available. */
.modal-box.form-wide .location-map,
.card.form-wide .location-map{ height: 320px; }
.modal-box.form-wide .map-shell,
.card.form-wide .map-shell{ min-height: 320px; }
.modal-box.form-wide .location-field .helper-text,
.card.form-wide .location-field .helper-text{ margin-bottom: 10px; }

@media (min-width: 861px){
  .modal-box.form-wide .form-two-col{ align-items: stretch; }
  .modal-box.form-wide .form-col-location{ height: 100%; }
  .modal-box.form-wide .form-col-location .location-field{ display: flex; flex-direction: column; flex: 1 1 auto; }
  .modal-box.form-wide .form-col-location .map-shell{ flex: 1 1 auto; min-height: 320px; }
  .modal-box.form-wide .form-col-location .location-map{ height: auto; flex: 1 1 auto; }

  .card.form-wide .form-col-location .map-shell{ min-height: 320px; }
  .card.form-wide .form-col-location .location-map{ height: auto; }
}

@media (max-width: 560px){
  .row-3{ grid-template-columns: 1fr; }
  .card{ padding: 30px 22px; }
  .lot-row{ padding: 16px; }
  #location-map, .location-map{ height: 300px; }
  .map-search-overlay{ flex-wrap: wrap; border-radius: var(--radius-sm); }
  .map-location-chip{ border-radius: var(--radius-sm); }
}
/* ============================================================
   Manage Sale — main sub-tabs (User Management / Sale Management)
   Same visual language as a pill-tab nav: pasture-filled active pill
   on a paper track.
   ============================================================ */
.main-tabs{
  display:flex;
  gap:8px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.main-tab{
  background: var(--paper-dim);
  border: none;
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13.5px;
  padding: 9px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.main-tab:hover{ background: var(--line); color: var(--ink); }
.main-tab.active{ background: var(--pasture); color: #fff; }
.main-tab-panel[hidden]{ display:none; }

/* ============================================================
   Sale Management — analytics dashboard
   Ported from the admin Telemetry "Per Sale View" styling so both
   dashboards look and feel the same.
   ============================================================ */
.dash-sale-subtitle{ color: var(--ink-soft); font-size: 12.5px; }

.tracking-scope-bar{
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:10px;
  background: var(--paper-dim);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 18px;
  font-size: 13.5px;
}
.tracking-scope-bar .scope-value{ font-weight:700; }
.tracking-scope-bar .toolbar-spacer{ flex: 1 1 auto; }
.tracking-scope-bar label{ display:inline; margin:0 6px 0 0; font-size:12.5px; font-weight:600; color:var(--ink-soft); }
.tracking-scope-bar select{ width:auto; padding:6px 10px; font-size:13px; }

.admin-loading{ text-align:center; padding: 40px 20px; color: var(--ink-soft); }
.admin-empty{ text-align:center; padding: 50px 20px; color: var(--ink-soft); }

.inline-label{
  display:inline;
  font-size:12.5px;
  font-weight:600;
  color: var(--ink-soft);
  margin: 0 6px 0 0;
}

/* ---------- Stat cards ---------- */
.stat-row{ display:flex; gap:16px; flex-wrap:wrap; margin-bottom: 24px; }
.stat-card{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 22px;
  min-width: 160px;
  flex: 1 1 160px;
}
.stat-card .stat-value{ font-family: var(--font-display); font-size: 30px; font-weight:700; color: var(--pasture); }
.stat-card .stat-label{ font-size: 12px; text-transform:uppercase; letter-spacing:.06em; color: var(--ink-soft); margin-top:2px; }
.stat-row.stat-row-sm{ gap: 12px; margin-bottom: 18px; }
.stat-row.stat-row-sm .stat-card{ padding: 11px 16px; min-width: 128px; }
.stat-row.stat-row-sm .stat-card .stat-value{ font-size: 21px; }
.stat-row.stat-row-sm .stat-card .stat-label{ font-size: 10.5px; margin-top:1px; }

/* ---------- Chart + map row ---------- */
.chart-grid-2{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:16px;
  margin-bottom:24px;
  align-items: stretch;
}
@media (max-width: 900px){
  .chart-grid-2{ grid-template-columns: 1fr; }
}
.chart-card{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.chart-card .chart-canvas-wrap{ position: relative; flex: 1 1 auto; height: 240px; min-height: 240px; max-height: 400px; }

.map-card{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.map-card.mt-0{ margin-top:0; }
.map-card h2{ font-size: 16px; margin-bottom: 12px; flex: 0 0 auto; }
.chart-grid-2 .map-card{ margin-bottom:0; }

#dash-map{
  flex: 1 1 auto;
  height: 240px;
  min-height: 240px;
  max-height: 400px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  overflow: hidden;
  background: var(--paper-dim);
  position: relative;
  z-index: 0;
}
#dash-map-empty{
  text-align:center;
  padding: 16px;
  color: var(--ink-soft);
  font-size: 13px;
}
#dash-map-empty[hidden]{ display:none; }
#dash-map .leaflet-control-zoom a{
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line) !important;
}
#dash-map .leaflet-control-zoom a:hover{ background: var(--paper-dim); }
#dash-map .leaflet-popup-content-wrapper{
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 12.5px;
}
#dash-map .leaflet-popup-content{ margin: 10px 12px; }

/* ---------- Sale dashboard: table + chart/map two-column layout ---------- */
.dash-lower-grid{
  display:grid;
  grid-template-columns: 1.3fr 1fr;
  gap:16px;
  align-items:start;
}
@media (max-width: 1000px){
  .dash-lower-grid{ grid-template-columns: 1fr; }
}
.dash-charts-col{ display:flex; flex-direction:column; gap:16px; }
.dash-charts-col .chart-card .chart-canvas-wrap{ height:200px; min-height:200px; max-height:220px; }
.dash-charts-col .map-card{ margin-bottom:0; }
.dash-charts-col #dash-map{ height:400px; min-height:400px; max-height:480px; }
.dash-lots-panel .tables-panel-body{ max-height: 640px; }

/* ---------- Lots table panel ---------- */
.admin-panel{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.admin-panel-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
  padding:18px 22px;
  background:var(--paper-dim);
  border-bottom:1px solid var(--line);
}
.admin-panel-head h2{ font-size:18px; margin:0; }
.admin-panel-head-controls{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.admin-panel-head-controls .inline-label{ margin:0; }
.admin-panel-head-controls select{ margin-right: 4px; }

.lot-detail-panel{
  padding: 16px 22px 4px;
  background: var(--paper-dim);
  border-bottom: 1px solid var(--line);
}
.lot-detail-head{
  display:flex;
  align-items:baseline;
  gap:10px;
  flex-wrap:wrap;
  margin-bottom: 12px;
}
.lot-detail-head h3{ font-size: 16px; margin:0; }
.lot-detail-reg{ font-size: 12px; color: var(--ink-soft); }
.lot-detail-panel .stat-row{ margin-bottom: 16px; }


.tables-panel-body{ max-height: 420px; overflow-y: auto; }
.tables-panel-body .admin-table thead th{ position: sticky; top: 0; z-index: 1; }

.admin-table{ width:100%; border-collapse:collapse; table-layout:fixed; }
.admin-table thead th{
  text-align:left;
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.07em;
  color:var(--ink-soft);
  padding:14px 22px;
  border-bottom:1px solid var(--line);
  background:var(--paper);
}
.admin-table tbody tr{ min-height:72px; }
.admin-table tbody td{
  padding:14px 22px;
  border-bottom:1px solid var(--line);
  vertical-align:middle;
  font-size:14px;
  min-height:72px;
  box-sizing:border-box;
}
.admin-table tbody tr:last-child td{ border-bottom:none; }
.admin-table tbody tr:hover{ background:rgba(47,75,60,.035); }

@media (max-width: 560px){
  .admin-table thead{ display:none; }
  .admin-table, .admin-table tbody, .admin-table tr, .admin-table td{ display:block; width:100%; }
  .admin-table tr{ padding: 14px 18px; border-bottom: 1px solid var(--line); }
  .admin-table td{ border:none; padding: 4px 0; }
}

/* ---------- Create/Edit Sale: "Buyer Reminders" section heading ----------
   Full-width divider + heading above the reminder date/time/timezone row
   and the email/SMS message fields. */
.form-section-heading{
  font-size: 16px;
  margin: 22px 0 16px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

/* ---------- Create/Edit Sale: "Private Treaty" toggle ----------
   Marks a sale as sold via private treaty (a direct, negotiated sale)
   rather than public auction. Styled as a proper switch inside a
   bordered card, matching the visual weight of the rest of the form
   (a plain checkbox with bold wrapping text read as a stray, unstyled
   control sitting between two form sections). */
.toggle-field{
  background: var(--paper-dim);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 4px 0 20px;
}
.toggle-row{
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.toggle-copy{ flex: 1 1 auto; min-width: 0; }
.toggle-title{
  display: block;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
}
.toggle-copy .helper-text{ margin-top: 3px; }

.switch{
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  width: 40px;
  height: 24px;
  margin-top: 1px;
  cursor: pointer;
}
.switch input{
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.switch-slider{
  position: absolute;
  inset: 0;
  background: #cfc7b0;
  border-radius: 999px;
  transition: background .15s ease;
  pointer-events: none;
}
.switch-slider::before{
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(35,32,27,.3);
  transition: transform .15s ease;
}
.switch input:checked + .switch-slider{ background: var(--pasture); }
.switch input:checked + .switch-slider::before{ transform: translateX(16px); }
.switch input:focus-visible + .switch-slider{ outline: 2px solid var(--pasture); outline-offset: 2px; }
/* ============================================================
   Manage Sale — UI polish pass (scoped to this page's container
   so nothing here touches other pages that share this stylesheet).
   Layout/spacing/responsiveness only — no color or font changes.
   ============================================================ */

.dash-container .manage-header{ margin-bottom: 18px; }
.dash-container .manage-title{ font-size: 24px; margin-bottom: 4px; }
.dash-container .manage-subtitle{ color: var(--ink-soft); font-size: 13.5px; margin: 0; max-width: 640px; }

.dash-container .tab-intro{
  color: var(--ink-soft);
  font-size: 13.5px;
  margin: 0 0 16px;
  max-width: 640px;
}

/* Tab buttons: icon + label, and full-width equal split on mobile so
   both tabs stay easy to tap instead of shrinking unevenly. */
.dash-container .main-tab{
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.dash-container .main-tab-icon{ flex: 0 0 auto; opacity: .9; }

/* Empty states get an icon + centered copy, still inside the same
   dashed-feeling card so they read as a deliberate placeholder rather
   than a stray paragraph. */
.dash-container .empty-state{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--paper-dim);
  padding: 44px 28px;
}
.dash-container .empty-state-icon{ color: var(--ink-soft); opacity: .8; }
.dash-container .empty-state p{ margin: 0; max-width: 420px; }

/* ---------- User Management: members + add-member panels ---------- */
.dash-container .member-panel{
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 18px;
}
.dash-container .member-panel-head{
  padding: 16px 20px 14px;
  background: var(--paper-dim);
  border-bottom: 1px solid var(--line);
}
.dash-container .member-panel-head h3{ font-size: 16px; margin-bottom: 4px; }
.dash-container .member-panel-head .helper-text{ margin: 0; }
.dash-container .member-panel .lot-list{ padding: 4px 20px; }
.dash-container .member-panel #member-error{ padding: 0 20px 14px; }
.dash-container .member-panel #member-error:empty{ padding: 0; }

.dash-container .add-member-panel{
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-dim);
  padding: 16px 20px 18px;
}
.dash-container .add-member-heading{
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-soft);
  margin: 0 0 12px;
}
.dash-container .add-member-form{ border-top: none; padding-top: 0; margin-top: 0; }
.dash-container .add-member-form .field label{ font-size: 12px; }

/* ---------- Sale Management: scope bar ---------- */
.dash-container .scope-bar-title{ display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.dash-container .scope-bar-controls{ display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dash-container .scope-bar-controls label{ margin: 0; }

/* ---------- KPI cards: even grid instead of loose flex-wrap, so cards
   line up cleanly and reflow predictably at every width. ---------- */
.dash-container .stat-row.stat-row-sm{
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}
.dash-container .stat-row.stat-row-sm .stat-card{ min-width: 0; }
@media (max-width: 1180px){
  .dash-container .stat-row.stat-row-sm{ grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 560px){
  .dash-container .stat-row.stat-row-sm{ grid-template-columns: repeat(2, 1fr); }
}

.dash-container .chart-card h2{ font-size: 16px; margin-bottom: 10px; flex: 0 0 auto; }

.dash-container .admin-panel-head-controls .control-group{
  display: flex;
  align-items: center;
  gap: 8px;
}
.dash-container .admin-panel-head-controls .control-group label{ margin: 0; }

#dash-map-empty{
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 16px;
}
#dash-map-empty[hidden]{ display: none; }

/* ---------- Responsive: top strip, tabs, forms, dashboard controls ---------- */
@media (max-width: 720px){
  .top-strip{
    flex-wrap: wrap;
    row-gap: 10px;
    padding: 18px 18px 10px;
  }
  .top-strip .actions{ flex-wrap: wrap; row-gap: 8px; }

  .dash-container .main-tabs{ display: flex; }
  .dash-container .main-tab{ flex: 1 1 0; justify-content: center; }

  .dash-container .add-member-form{ flex-direction: column; align-items: stretch; }
  .dash-container .add-member-form .field,
  .dash-container .add-member-form .field.role-field{ flex: 1 1 auto; }
  .dash-container .add-member-form .btn{ width: 100%; }

  .dash-container .tracking-scope-bar{ align-items: flex-start; }
  .dash-container .scope-bar-controls{ width: 100%; }
  .dash-container .scope-bar-controls select{ flex: 1 1 auto; }

  .dash-container .admin-panel-head{ flex-direction: column; align-items: stretch; }
  .dash-container .admin-panel-head-controls{ flex-direction: column; align-items: stretch; }
  .dash-container .admin-panel-head-controls .control-group{ justify-content: space-between; }
  .dash-container .admin-panel-head-controls select{ flex: 1 1 auto; margin-right: 0; }
}

@media (max-width: 420px){
  .dash-container .stat-row.stat-row-sm{ grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .dash-container .stat-row.stat-row-sm .stat-card{ padding: 10px 12px; }
}
