/* DrTrack web dashboard - same visual language as the mobile app:
   purple primary, soft-purple surfaces, rounded white cards, pill statuses. */
:root {
  --bg: #fdfbff;
  --ink: #111326;
  --muted: #696d80;
  --border: #e5e1ee;
  --soft: #efe6ff;
  --primary: #7d2df2;
  --deep: #5420c8;
  --grad: linear-gradient(90deg, #8533f4, #5420c8);
  --hero: linear-gradient(135deg, #d343f4, #8847f4, #6424d8);
  --green: #2e7d32;
  --red: #d32f2f;
  --orange: #ef6c00;
  --amber: #f9a825;
  --blue: #1565c0;
  --indigo: #3949ab;
  --surface-2: #f8f6fc;
  --shadow: 0 6px 24px rgba(84, 32, 200, 0.06);
  --radius: 16px;
  --sidebar: 264px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, p { margin: 0; }
.material-icons-outlined { font-size: 20px; line-height: 1; vertical-align: middle; user-select: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.col { display: flex; flex-direction: column; gap: 10px; }
.between { justify-content: space-between; }
.gap-sm { gap: 6px; } .gap-lg { gap: 18px; }
.mt-sm { margin-top: 8px; } .mt { margin-top: 16px; } .mt-lg { margin-top: 28px; }
.mb { margin-bottom: 16px; }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: #fff; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 20px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; background: var(--hero);
  display: grid; place-items: center; color: #fff;
}
.brand-name { font-weight: 900; font-size: 18px; letter-spacing: -0.2px; }
.brand-sub { font-size: 11px; color: var(--muted); font-weight: 700; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-section { font-size: 10px; letter-spacing: 0.8px; font-weight: 900; color: var(--muted); padding: 16px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 14px;
  color: var(--ink); font-weight: 700; font-size: 14px; text-decoration: none;
}
.nav a .material-icons-outlined { color: var(--muted); }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--soft); color: var(--primary); }
.nav a.active .material-icons-outlined { color: var(--primary); }
.nav a .count {
  margin-left: auto; background: var(--primary); color: #fff; border-radius: 10px;
  font-size: 11px; font-weight: 800; padding: 1px 7px;
}
.sidebar-foot { margin-top: auto; padding-top: 16px; }
.userchip {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--soft); color: var(--primary);
  display: grid; place-items: center; font-weight: 800; flex: 0 0 auto;
}
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.avatar.lg { width: 48px; height: 48px; font-size: 16px; }
.userchip .who { min-width: 0; }
.userchip .who b { display: block; font-size: 13px; overflow-wrap: anywhere; }
.userchip .who span { font-size: 11px; color: var(--muted); font-weight: 700; }
.main { min-width: 0; }
.topbar { display: none; }
.content { padding: 28px 32px 60px; max-width: 1440px; margin: 0 auto; }

@media (max-width: 1280px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; left: 0; top: 0; width: min(300px, 86vw); transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  .sidebar-collapse { display: none !important; }
  .sidebar-close { display: inline-grid; }
  .backdrop.show { display: block; position: fixed; inset: 0; background: rgba(17, 19, 38, .5); z-index: 55; }
  .topbar {
    display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: #fff;
    border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40;
  }
}
@media (max-width: 700px) {
  .content { padding: 20px 16px 60px; }
}

/* --------------------------------------------------------- page chrome */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { font-size: 26px; font-weight: 900; letter-spacing: -0.4px; }
.page-sub { color: var(--muted); font-weight: 600; margin-top: 2px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.section-title { font-size: 18px; font-weight: 900; margin: 0 0 12px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 700; margin-bottom: 8px; cursor: pointer; background: none; border: 0; padding: 0; }
.back:hover { color: var(--primary); }

/* ---------------------------------------------------------------- cards */
.card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.card.flat { box-shadow: none; }
.card.soft { background: var(--soft); border-color: rgba(125, 45, 242, .15); box-shadow: none; }
.card.warn { background: #fff8e1; border-color: #ffe0b2; box-shadow: none; }
.card.danger { background: #fef3f2; border-color: #fecdca; box-shadow: none; }
.card-title { font-weight: 900; font-size: 16px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.detail { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.detail { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }

.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.metric {
  background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 16px;
  display: flex; flex-direction: column; gap: 14px; cursor: default; text-align: left;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .02); transition: transform .12s, box-shadow .12s;
}
.metric.link { cursor: pointer; }
.metric.link:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.metric .ico { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; }
.metric .val { font-size: 28px; font-weight: 900; line-height: 1; }
.metric .lbl { font-size: 12px; font-weight: 800; color: var(--muted); margin-top: 6px; }

/* ------------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border); background: #fff; color: var(--ink);
  padding: 10px 16px; border-radius: 12px; font-weight: 800; cursor: pointer;
  transition: background .12s, box-shadow .12s, opacity .12s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 8px 20px rgba(125, 45, 242, .25); }
.btn.primary:hover { filter: brightness(1.05); background: var(--grad); }
.btn.primary:disabled { background: #bdbdc9; box-shadow: none; }
.btn.tonal { background: var(--soft); color: var(--primary); border-color: transparent; }
.btn.danger { background: var(--red); color: #fff; border-color: transparent; }
.btn.danger:hover { background: #b71c1c; }
.btn.outline-danger { color: var(--red); border-color: #f1b4b4; }
.btn.green { background: #25d366; color: #fff; border-color: transparent; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--primary); padding: 8px 10px; }
.btn.ghost:hover { background: var(--soft); }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.lg { padding: 14px 22px; font-size: 16px; border-radius: 16px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border); background: #fff;
  display: inline-grid; place-items: center; cursor: pointer; color: var(--muted);
}
.icon-btn:hover { background: var(--soft); color: var(--primary); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 11px; font-weight: 800; letter-spacing: .4px; color: var(--muted); text-transform: uppercase; }
.input, .select, .textarea {
  width: 100%; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: #fff; outline: none; min-height: 42px;
}
.textarea { min-height: 88px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(125, 45, 242, .12); }
.input.error { border-color: var(--red); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .err { font-size: 12px; color: var(--red); font-weight: 700; }
.search { position: relative; }
.search .material-icons-outlined { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search .input { padding-left: 40px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border); background: #fff; border-radius: 18px; padding: 7px 14px;
  font-weight: 700; font-size: 13px; cursor: pointer; color: var(--ink);
}
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--soft); color: var(--primary); border-color: rgba(125, 45, 242, .35); }
.segmented { display: inline-flex; flex-wrap: wrap; max-width: 100%; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: #fff; }
.segmented button { border: 0; background: transparent; padding: 9px 16px; font-weight: 800; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.segmented button.on { background: var(--soft); color: var(--primary); }

.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 11px; border-radius: 18px;
  font-size: 11px; font-weight: 900; letter-spacing: .2px; text-transform: uppercase; white-space: nowrap;
  background: rgba(125, 45, 242, .12); color: var(--primary);
}
.pill.green { background: rgba(46, 125, 50, .12); color: var(--green); }
.pill.red { background: rgba(211, 47, 47, .12); color: var(--red); }
.pill.grey { background: rgba(105, 109, 128, .14); color: var(--muted); }
.pill.orange { background: rgba(239, 108, 0, .12); color: var(--orange); }
.pill.blue { background: rgba(21, 101, 192, .12); color: var(--blue); }
.pill.amber { background: rgba(249, 168, 37, .18); color: #b26a00; }

.filters {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 16px; padding: 16px; margin-bottom: 18px;
}
.filters .head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 12px; font-weight: 900; letter-spacing: .8px; }
.filters .head .material-icons-outlined { color: var(--primary); }
.filter-row { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 900px) { .filter-row { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .filter-row { grid-template-columns: 1fr; } }

.bulkbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--soft); border: 1px solid rgba(125, 45, 242, .14); border-radius: 16px; padding: 10px 14px; margin-bottom: 14px;
}
.bulkbar b { font-weight: 900; }

/* ---------------------------------------------------------------- table */
.table-wrap { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; overflow-y: hidden; box-shadow: var(--shadow); -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11px; letter-spacing: .6px; text-transform: uppercase; font-weight: 900;
  color: var(--muted); background: var(--surface-2); padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; overflow-wrap: anywhere; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.click { cursor: pointer; }
.table tbody tr.click:hover { background: #faf7ff; }
.table .cell-main { font-weight: 800; overflow-wrap: anywhere; }
.table .cell-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.table .clip { max-width: 280px; white-space: normal; overflow-wrap: anywhere; }
.table td.num, .table th.num { text-align: right; }
@media (max-width: 980px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .table td { border: 0; padding: 4px 0; display: grid; grid-template-columns: 96px minmax(0, 1fr); column-gap: 10px; align-items: start; }
  .table td::before { content: attr(data-label); grid-column: 1; grid-row: 1 / span 3; color: var(--muted); font-weight: 800; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; padding-top: 2px; }
  .table td > * { grid-column: 2; }
  .table td.no-label { display: block; }
  .table td.no-label::before { display: none; }
  .table .clip { max-width: none; white-space: normal; }
}
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--border); flex-wrap: wrap; }

/* ---------------------------------------------------------- detail bits */
.info-line { display: flex; align-items: flex-start; gap: 10px; color: var(--muted); font-weight: 600; margin: 8px 0; }
.info-line .material-icons-outlined { color: var(--muted); margin-top: 1px; }
.info-line span.t { color: var(--ink); font-weight: 600; word-break: break-word; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; }
.kv dt { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .3px; padding-top: 2px; }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }
@media (max-width: 520px) { .kv { grid-template-columns: 1fr; } }

.stepper { display: flex; align-items: flex-start; justify-content: space-between; gap: 4px; padding: 6px 0; overflow-x: auto; }
.step { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 1 1 0; min-width: 72px; position: relative; text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); }
.step .dot { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--border); display: grid; place-items: center; background: #fff; z-index: 1; }
.step.done .dot { background: var(--primary); border-color: var(--primary); color: #fff; }
.step.current .dot { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 6px 16px rgba(125, 45, 242, .35); }
.step.current, .step.done { color: var(--ink); }
.step::before { content: ""; position: absolute; top: 20px; left: -50%; width: 100%; height: 2px; background: var(--border); z-index: 0; }
.step:first-child::before { display: none; }
.step.done::before, .step.current::before { background: var(--primary); }

.timeline { display: flex; flex-direction: column; }
.tl-item { display: grid; grid-template-columns: 14px 1fr; gap: 14px; }
.tl-rail { display: flex; flex-direction: column; align-items: center; }
.tl-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--primary); margin-top: 4px; }
.tl-line { width: 2px; flex: 1; background: var(--border); margin: 4px 0; }
.tl-body { padding-bottom: 18px; }
.tl-body b { font-weight: 800; letter-spacing: .2px; }
.tl-body .meta { color: var(--muted); font-size: 12px; font-weight: 600; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px; }
.media-tile { position: relative; }
.media-thumb {
  width: 100%; aspect-ratio: 4 / 3; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2);
  overflow: hidden; cursor: pointer; display: grid; place-items: center; color: var(--muted);
}
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-title { font-size: 11px; font-weight: 800; text-align: center; margin-top: 6px; overflow-wrap: anywhere; }
.media-x { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--red); color: #fff; border: 0; cursor: pointer; display: grid; place-items: center; }
.media-x .material-icons-outlined { font-size: 14px; }

.banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--soft); border: 1px solid rgba(125, 45, 242, .25); font-weight: 700; font-size: 13px; }
.banner.green { background: #e8f5e9; border-color: #a5d6a7; color: #1b5e20; }
.banner.orange { background: #fff3e0; border-color: #ffcc80; color: #8d4b00; }
.banner.red { background: #fef3f2; border-color: #fecdca; color: #b42318; }
.banner .material-icons-outlined { margin-top: 1px; }

.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty .material-icons-outlined { font-size: 44px; color: #c9bde6; }
.empty h3 { color: var(--ink); font-size: 16px; font-weight: 900; margin: 10px 0 4px; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--soft); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
.loading { display: grid; place-items: center; padding: 50px; }
@keyframes spin { to { transform: rotate(360deg); } }

.donut-wrap { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.legend { display: flex; flex-direction: column; gap: 8px; }
.legend .li { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.legend .sw { width: 12px; height: 12px; border-radius: 4px; }

.people { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.person { width: 84px; text-align: center; flex: 0 0 auto; }
.person .avatar { margin: 0 auto 6px; position: relative; }
.person .dot { position: absolute; right: 0; bottom: 0; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; background: #9e9e9e; }
.person .dot.on { background: #43a047; }
.person span { font-size: 11px; font-weight: 800; display: block; overflow-wrap: anywhere; }

/* ----------------------------------------------------------- modal/toast */
.overlay { position: fixed; inset: 0; background: rgba(17, 19, 38, .5); z-index: 100; display: grid; place-items: center; padding: 20px; overflow-y: auto; }
.modal { background: #fff; border-radius: 20px; width: min(520px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; box-shadow: 0 24px 60px rgba(0, 0, 0, .25); }
.modal.wide { width: min(760px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 8px; }
.modal-head h3 { font-size: 18px; font-weight: 900; }
.modal-body { padding: 8px 22px 6px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px 20px; flex-wrap: wrap; }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 40px)); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); font-weight: 600; display: flex; gap: 10px; align-items: center; animation: slidein .2s ease; }
.toast.error { background: #b71c1c; }
.toast.success { background: #1b5e20; }
@keyframes slidein { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.viewer { position: fixed; inset: 0; z-index: 150; background: rgba(10, 10, 20, .94); display: flex; flex-direction: column; }
.viewer-bar { display: flex; align-items: center; gap: 12px; padding: 12px 18px; color: #fff; }
.viewer-bar b { font-weight: 800; }
.viewer-stage { flex: 1; display: grid; place-items: center; overflow: auto; padding: 10px; }
.viewer-stage img { max-width: 100%; max-height: calc(100vh - 90px); object-fit: contain; transition: transform .1s; }
.viewer-stage iframe { width: min(1000px, 100%); height: calc(100vh - 90px); border: 0; background: #fff; border-radius: 8px; }
.viewer .icon-btn { background: rgba(255, 255, 255, .12); color: #fff; border-color: transparent; }
.viewer .icon-btn:hover { background: rgba(255, 255, 255, .25); }

/* ------------------------------------------------------------------ misc */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero { background: var(--hero); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: center; gap: 22px; }
.login-hero h1 { font-size: 40px; font-weight: 900; letter-spacing: -1px; line-height: 1.1; }
.login-hero p { font-size: 17px; opacity: .92; max-width: 460px; font-weight: 500; }
.login-hero ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; font-weight: 700; }
.login-hero li { display: flex; align-items: center; gap: 10px; }
.login-panel { display: grid; place-items: center; padding: 32px; }
.login-card { width: min(420px, 100%); }
.login-card h2 { font-size: 26px; font-weight: 900; margin-bottom: 4px; }
@media (max-width: 860px) { .login-wrap { grid-template-columns: 1fr; } .login-hero { display: none; } }
.otp-input { letter-spacing: 12px; font-size: 24px; font-weight: 800; text-align: center; }

.map-box { height: 520px; border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }
.map-box.sm { height: 320px; }
.map-pin { width: 34px; height: 34px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); display: grid; place-items: center; color: #fff; border: 2px solid #fff; box-shadow: 0 4px 10px rgba(0, 0, 0, .3); }
.map-pin i { transform: rotate(45deg); font-style: normal; font-weight: 900; font-size: 12px; }

.suggest { position: relative; }
.suggest-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 30; background: #fff; border: 1px solid var(--border); border-radius: 12px; margin-top: 4px; box-shadow: var(--shadow); max-height: 260px; overflow-y: auto; }
.suggest-list button { display: flex; gap: 8px; align-items: flex-start; width: 100%; text-align: left; border: 0; background: none; padding: 10px 12px; cursor: pointer; font-weight: 600; }
.suggest-list button:hover { background: var(--soft); }

.rating { display: inline-flex; gap: 2px; color: #f9a825; }
.sig { max-width: 260px; max-height: 120px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.divider { height: 1px; background: var(--border); margin: 16px 0; border: 0; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.kbd { font-family: ui-monospace, monospace; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; font-size: 12px; }

.doc-row { display: grid; grid-template-columns: 1fr auto; gap: 10px 14px; padding: 12px 0; border-bottom: 1px solid var(--border); align-items: center; }
.doc-row:last-child { border-bottom: 0; }
.doc-row .t { font-weight: 800; }
.doc-row .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
.doc-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 640px) { .doc-row { grid-template-columns: 1fr; } .doc-actions { justify-content: flex-start; } }

.mer-stage { position: relative; display: inline-block; max-width: 100%; border: 1px solid var(--border); background: #fff; user-select: none; touch-action: none; }
.mer-stage canvas { display: block; max-width: 100%; height: auto; }
.mer-ov { position: absolute; border: 1.5px dashed var(--primary); cursor: move; }
.mer-ov.active { border-style: solid; box-shadow: 0 0 0 2px rgba(125, 45, 242, .25); }
.mer-ov.text { background: #fff; display: flex; align-items: center; padding: 0 4px; overflow: hidden; color: #000; }
.mer-ov img { width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
.mer-handle { position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px; background: var(--primary); border-radius: 3px; cursor: nwse-resize; }

.modal-body p { white-space: pre-line; }

.map-box, .leaflet-container { isolation: isolate; position: relative; z-index: 0; }

.map-layout { grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); }
@media (max-width: 900px) { .map-layout { grid-template-columns: 1fr; } }

.modal.xl { width: min(1180px, 100%); }
.mer-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.mer-scroll { overflow: auto; max-height: 68vh; background: var(--surface-2); border-radius: 12px; padding: 12px; text-align: center; }

.brand-logo { width: 40px; height: 40px; border-radius: 22%; object-fit: cover; flex: 0 0 auto; }
.hero-logo { width: 120px; height: 120px; border-radius: 22%; object-fit: cover; box-shadow: 0 14px 36px rgba(0, 0, 0, .28); }

/* ----------------------------------------------------- responsive hardening */
/* Grid children must be allowed to shrink, or one wide child (stepper, table,
   long word) stretches the whole page past the screen. */
.grid > *, .row > .grow, .page-head > *, .card, .modal-body { min-width: 0; }
.card { overflow-wrap: anywhere; }
.stepper { overflow-x: auto; max-width: 100%; }
.page-actions { max-width: 100%; }
.pager { overflow-wrap: normal; }
.kv dd, .info-line span.t, .doc-row .t, .doc-row .s { overflow-wrap: anywhere; }
img, canvas, video, iframe { max-width: 100%; }
.map-box { max-width: 100%; }
@media (max-width: 700px) {
  .page-title { font-size: 22px; }
  .page-actions .btn { flex: 1 1 auto; }
  .modal { border-radius: 16px; }
  .modal-foot .btn { flex: 1 1 auto; }
  .overlay { padding: 10px; }
  .toasts { left: 12px; right: 12px; bottom: 12px; max-width: none; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login-card { width: 100%; }
}
@media (max-width: 380px) {
  .metrics { grid-template-columns: 1fr; }
  .grid.cols-4 { grid-template-columns: 1fr; }
}

@media (max-width: 1500px) {
  .table th, .table td { padding-left: 10px; padding-right: 10px; }
}

.pager .row { flex-wrap: wrap; }
.pager { justify-content: space-between; }

/* ------------------------------------------------------------- sidebar controls */
.brand { gap: 10px; padding: 4px 6px 22px; }
.brand-text { min-width: 0; }
.brand-logo.sm { width: 32px; height: 32px; }
.sidebar-close { display: none; }
.backdrop { display: none; }
body.no-scroll { overflow: hidden; }
@media (min-width: 1281px) {
  .shell { transition: grid-template-columns .18s ease; }
  .shell.collapsed { grid-template-columns: 78px 1fr; }
  .shell.collapsed .sidebar { padding: 20px 10px; }
  .shell.collapsed .brand { flex-direction: column; padding: 4px 0 16px; }
  .shell.collapsed .brand-text, .shell.collapsed .nav-label, .shell.collapsed .nav-section,
  .shell.collapsed .userchip .who, .shell.collapsed .userchip .avatar { display: none; }
  .shell.collapsed .nav a { justify-content: center; padding: 12px 0; position: relative; }
  .shell.collapsed .nav a .count { position: absolute; top: 3px; right: 8px; margin: 0; }
  .shell.collapsed .userchip { justify-content: center; padding: 8px 0; }
}

/* ------------------------------------------------------------ mobile polish */
@media (max-width: 980px) {
  /* each table row becomes its own card instead of one long list */
  .table-wrap { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .table tbody tr { background: #fff; border: 1px solid var(--border); border-radius: 14px; margin-bottom: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
  .table tbody tr:last-child td, .table td { border-bottom: 0; }
  .table tbody tr.click:hover { background: #fff; }
  .pager { background: #fff; border: 1px solid var(--border); border-radius: 14px; }
}
@media (max-width: 700px) {
  .card { padding: 16px; border-radius: 14px; }
  .section-title { font-size: 16px; }
  /* summary tiles: icon beside the number, much shorter */
  .metric { flex-direction: row; align-items: center; gap: 10px; padding: 12px; border-radius: 14px; }
  .metric .ico { flex: 0 0 auto; width: 36px; height: 36px; }
  .metric .val { font-size: 22px; }
  .metric .lbl { margin-top: 2px; font-size: 11px; line-height: 1.2; }
  .metrics { gap: 10px; }
  /* comfortable touch targets, and 16px inputs so iPhones do not zoom on focus */
  .btn { min-height: 42px; }
  .btn.sm { min-height: 38px; padding-left: 12px; padding-right: 12px; }
  .icon-btn { width: 42px; height: 42px; }
  .input, .select, .textarea { font-size: 16px; min-height: 46px; }
  .chip { padding: 9px 14px; }
  .segmented button { flex: 1 1 auto; justify-content: center; padding: 10px 12px; }
  /* page header buttons: tidy two-column grid, primary action full width */
  .page-head { margin-bottom: 16px; }
  .page-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; gap: 10px; }
  .page-actions > .primary, .page-actions > :only-child { grid-column: 1 / -1; }
  .page-actions > .icon-btn { width: 100%; }
  .bulkbar { gap: 8px; padding: 10px 12px; }
  .filters { padding: 12px; }
  /* dialogs slide up from the bottom like a native sheet */
  .overlay { padding: 0; place-items: end stretch; }
  .modal, .modal.wide, .modal.xl { width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0; }
  .modal-head { padding: 16px 16px 6px; }
  .modal-body { padding: 6px 16px; }
  .modal-foot { padding: 12px 16px 18px; }
  .doc-actions .btn { flex: 1 1 auto; }
  .login-panel { padding: 20px 16px; }
  .brand-logo.sm { width: 30px; height: 30px; }
}

/* must come after the base `.sidebar-close { display: none }` above */
@media (max-width: 1280px) {
  .sidebar-close { display: inline-grid; flex: 0 0 auto; }
}

@media (max-width: 700px) {
  .back { min-height: 40px; padding: 6px 10px 6px 2px; font-size: 14px; }
}
