/* Doroobi Map Editor. Doroobi's own colours (teal, coral, sun) and Lama Sans; no inline styles anywhere (strict CSP). */
@font-face { font-family: 'Lama Sans'; src: url('/assets/fonts/LamaSans-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Lama Sans'; src: url('/assets/fonts/LamaSans-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Lama Sans'; src: url('/assets/fonts/LamaSans-700.woff2') format('woff2'); font-weight: 600 700; font-display: swap; }

:root {
  --teal: #0E7C7B; --teal-dark: #0A5F5E; --teal-light: #3CC2B6; --teal-soft: #DDF2EF; --coral: #FF6A3D; --coral-dark: #D9481F; --coral-soft: #FFE4DA;
  --sun: #FFC93C; --sun-soft: #FFF3CC; --night: #10222B; --bg: #F3F6F6; --surface: #FFFFFF; --ink: #12232B; --muted: #4A5C63; --line: #DCE7E5;
  --line-strong: #C3D3D0; --danger: #C8352B; --danger-soft: #FCE3E1; --ok: #23824F; --ok-soft: #DDF3E6; --warn: #8A5A00; --warn-soft: #FFF1CC;
  --radius: 10px; --toolbar: 56px; --status: 28px; --panel: 380px;
  --shadow: 0 6px 24px rgba(16, 34, 43, .14), 0 1px 3px rgba(16, 34, 43, .08);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: 'Lama Sans', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 14px; line-height: 1.45; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--teal); text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hint { color: var(--muted); font-weight: 400; font-size: 12px; }
.noscript { padding: 24px; }
[lang="ar"] { font-family: 'Lama Sans', 'Geeza Pro', 'Segoe UI', sans-serif; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid transparent; background: var(--surface); cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--teal-dark); }
.btn-coral { background: var(--coral); color: var(--night); }
.btn-coral:hover:not(:disabled) { background: #ff825e; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--bg); }
.btn-danger { background: transparent; color: var(--danger); border-color: #f0c4c0; }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.icon-btn:hover:not(:disabled) { background: var(--bg); }
.icon-btn:disabled { opacity: .4; cursor: default; }
.link { background: none; border: 0; color: var(--teal); cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 2px; }
.ico { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--coral); color: var(--night); font-size: 12px; display: inline-grid; place-items: center; }

/* ---------- sign in ---------- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(ellipse 60% 70% at 70% 20%, rgba(14, 124, 123, .25), transparent 70%), linear-gradient(180deg, #E8F3F1, var(--bg)); }
.auth-card { width: min(420px, 100%); background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); padding: 28px 28px 20px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand > span, .brand > div { display: flex; flex-direction: column; line-height: 1.15; }
.brand [lang="ar"] { color: var(--teal); font-size: 12.5px; }
.brand-lg strong { font-size: 20px; }
.brand-lg [lang="ar"] { font-size: 15px; }
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 12px; margin: 18px 0 14px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.form { display: grid; gap: 12px; }
.form label, .field { display: grid; gap: 4px; font-weight: 600; font-size: 13px; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="number"], input[type="datetime-local"], input:not([type]), select, textarea {
  width: 100%; min-height: 38px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); padding: 6px 10px; font-weight: 400; font-size: 14px;
}
textarea { min-height: 70px; resize: vertical; }
input:disabled, select:disabled, textarea:disabled { background: var(--bg); color: var(--muted); }
.auth-msg { min-height: 1.4em; margin: 12px 0 6px; font-weight: 600; }
.auth-msg.error { color: var(--danger); }
.auth-msg.ok { color: var(--ok); }

/* ---------- layout ---------- */
.app { height: 100%; display: grid; grid-template-columns: var(--panel) 1fr; grid-template-rows: var(--toolbar) 1fr var(--status); grid-template-areas: "top top" "panel map" "status status"; }
.toolbar { grid-area: top; display: flex; align-items: center; gap: 10px; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--line); z-index: 1100; position: relative; }
.toolbar .brand { margin-inline-end: 6px; }
.toolbar .brand strong { font-size: 15px; }
.tools { display: flex; gap: 4px; padding-inline-start: 10px; border-inline-start: 1px solid var(--line); }
.tool { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 11px; border-radius: 10px; border: 1px solid transparent; background: transparent; cursor: pointer; font-weight: 600; color: var(--muted); }
.tool:hover { background: var(--bg); color: var(--ink); }
.tool[aria-pressed="true"] { background: var(--teal-soft); color: var(--teal-dark); border-color: #b9e1db; }
.btn-save { background: var(--coral); color: var(--night); margin-inline-start: 4px; }
.btn-save:not(:disabled):hover { background: #ff825e; }
.btn-save b { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: rgba(16, 34, 43, .14); display: inline-grid; place-items: center; font-size: 12px; }
.btn-save:disabled { background: var(--bg); color: var(--muted); opacity: 1; border-color: var(--line); }
.spacer { flex: 1; }
.search { position: relative; display: flex; align-items: center; width: min(320px, 26vw); }
.search .ico { position: absolute; inset-inline-start: 10px; color: var(--muted); pointer-events: none; }
.search input { padding-inline-start: 34px; border-radius: 999px; background: var(--bg); border-color: var(--line); }
.dropdown { position: relative; }
.menu, .menu-list { position: absolute; top: calc(100% + 6px); inset-inline-start: 0; min-width: 240px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; z-index: 1200; }
.menu-right { inset-inline-start: auto; inset-inline-end: 0; }
.menu label { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.menu label:hover, .menu button:hover { background: var(--bg); }
.menu label small { color: var(--muted); margin-inline-start: auto; }
.menu button { display: block; width: 100%; text-align: start; border: 0; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.menu-title { margin: 6px 8px 2px; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.menu-list { list-style: none; margin: 0; width: 100%; max-height: 60vh; overflow: auto; }
.menu-list li button { display: block; width: 100%; text-align: start; border: 0; background: none; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.menu-list li button:hover, .menu-list li button[aria-selected="true"] { background: var(--teal-soft); }
.menu-list small { display: block; color: var(--muted); }
.user-btn { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 10px 0 4px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--teal); color: #fff; display: grid; place-items: center; font-weight: 700; }
.rank { font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 8px; background: var(--sun-soft); color: var(--warn); }

.panel { grid-area: panel; background: var(--surface); border-inline-end: 1px solid var(--line); overflow-y: auto; z-index: 900; }
.map { grid-area: map; position: relative; background: #E9EEEE; outline: none; }
.status { grid-area: status; display: flex; align-items: center; gap: 14px; padding: 0 12px; background: var(--surface); border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); z-index: 1000; white-space: nowrap; overflow: hidden; }
.status-hover { color: var(--ink); overflow: hidden; text-overflow: ellipsis; }

/* ---------- side panel ---------- */
.p-head { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.p-kicker { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.p-title { font-size: 19px; font-weight: 700; margin: 4px 0 2px; line-height: 1.25; word-break: break-word; }
.p-sub { color: var(--muted); font-size: 13px; }
.p-sub [lang="ar"] { margin-inline-start: 6px; }
.p-body { padding: 14px 18px 24px; display: grid; gap: 14px; }
.p-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.p-close { position: absolute; top: 12px; inset-inline-end: 12px; }
.swatch { width: 12px; height: 12px; border-radius: 4px; display: inline-block; flex: none; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; border: 0; border-inline-end: 1px solid var(--line-strong); background: var(--surface); padding: 8px 4px; cursor: pointer; font-weight: 600; font-size: 13px; display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.seg button:last-child { border-inline-end: 0; }
.seg button small { font-weight: 400; color: var(--muted); font-size: 11px; }
.seg button[aria-pressed="true"] { background: var(--teal); color: #fff; }
.seg button[aria-pressed="true"] small { color: #d7f1ee; }
.seg button:disabled { cursor: default; opacity: .6; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.check input { width: 18px; height: 18px; accent-color: var(--teal); }
.changed > span:first-child::after, .changed.check::after { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--coral); margin-inline-start: 6px; vertical-align: middle; }
.note { padding: 10px 12px; border-radius: 10px; background: var(--bg); color: var(--muted); font-size: 13px; display: flex; gap: 8px; }
.note-warn { background: var(--warn-soft); color: var(--warn); }
.note-error { background: var(--danger-soft); color: var(--danger); }
.note-ok { background: var(--ok-soft); color: var(--ok); }
.note .ico { width: 16px; height: 16px; margin-top: 2px; }
.box { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 10px; }
.box-title { font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; word-break: break-word; }
.ptabs { display: flex; gap: 2px; margin-top: 10px; }
.ptabs button { border: 0; background: none; padding: 6px 10px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); }
.ptabs button[aria-selected="true"] { background: var(--teal-soft); color: var(--teal-dark); }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 4px; background: var(--surface); }
.item.clickable { cursor: pointer; text-align: start; width: 100%; font: inherit; }
.item.clickable:hover, .item.selected { border-color: var(--teal-light); background: #F6FBFA; }
.item-top { display: flex; align-items: baseline; gap: 8px; justify-content: space-between; }
.item-title { font-weight: 600; word-break: break-word; }
.item-meta { color: var(--muted); font-size: 12.5px; }
.chip { font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 8px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.chip-applied { background: var(--ok-soft); color: var(--ok); }
.chip-pending { background: var(--sun-soft); color: var(--warn); }
.chip-rejected, .chip-stale { background: var(--danger-soft); color: var(--danger); }
.chip-reverted, .chip-withdrawn { background: #E6EAEB; color: var(--muted); }
.chip-open { background: var(--coral-soft); color: var(--coral-dark); }
.chip-resolved { background: var(--ok-soft); color: var(--ok); }
.diff { width: 100%; border-collapse: collapse; font-size: 13px; }
.diff th, .diff td { text-align: start; padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: top; word-break: break-word; }
.diff th { color: var(--muted); font-weight: 600; width: 30%; }
.diff .was { color: var(--danger); text-decoration: line-through; }
.diff .now { color: var(--ok); font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 20px 8px; }
.empty img { margin: 0 auto 6px; }
.kbd { display: inline-block; min-width: 22px; padding: 1px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px; font-size: 12px; text-align: center; background: var(--bg); }
.shortcuts { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center; font-size: 13px; }
.ranks { width: 100%; border-collapse: collapse; font-size: 13px; }
.ranks td, .ranks th { padding: 5px 6px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
.ranks th { color: var(--muted); }

.iso-box { background: linear-gradient(180deg, #F7FBFA, #E6EFEE); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.iso { width: 100%; height: 230px; display: block; }

/* ---------- map ---------- */
.leaflet-container { font: inherit; background: #E9EEEE; }
.base-muted .leaflet-tile-pane { filter: grayscale(.85) brightness(1.06) contrast(.88); }
.base-off .leaflet-tile-pane { display: none; }
.map.tool-draw, .map.tool-draw .leaflet-interactive, .map.tool-place, .map.tool-route, .map.tool-building, .map.tool-building .leaflet-interactive { cursor: crosshair; }
.map.tool-draw .leaflet-grab { cursor: crosshair; }
.leaflet-control-attribution { font-size: 11px; }
.map-note { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 800; background: var(--night); color: #fff; padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow); pointer-events: none; white-space: nowrap; }
.map-loading { position: absolute; top: 12px; right: 12px; z-index: 800; background: var(--surface); padding: 5px 10px; border-radius: 999px; font-size: 12px; color: var(--muted); box-shadow: var(--shadow); }
.draw-help { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); z-index: 800; background: var(--surface); padding: 8px 14px; border-radius: 12px; box-shadow: var(--shadow); font-size: 13px; display: flex; gap: 12px; align-items: center; white-space: nowrap; }
.vx { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2.5px solid var(--teal); box-shadow: 0 1px 3px rgba(0, 0, 0, .3); cursor: grab; }
.vx.end { border-color: var(--night); background: var(--sun); cursor: default; }
.vx.mid { width: 10px; height: 10px; border: 2px dashed var(--teal); background: rgba(255, 255, 255, .8); opacity: .85; }
.vx.sel { background: var(--coral); border-color: var(--coral-dark); }
.vx.place { width: 18px; height: 18px; border-color: var(--coral-dark); background: var(--coral); }
.ab { width: 20px; height: 20px; border-radius: 50%; background: var(--night); color: #fff; font-weight: 700; font-size: 11px; display: grid; place-items: center; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); pointer-events: none; }
.turn { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); cursor: pointer; border: 2px solid #fff; }
.turn.allowed { background: var(--ok); }
.turn.banned { background: var(--danger); }
.turn.readonly { cursor: default; opacity: .8; }
.turn svg { width: 18px; height: 18px; stroke: #fff; fill: none; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.turn:hover { transform: scale(1.1); }
.toast { position: fixed; bottom: calc(var(--status) + 14px); left: 50%; transform: translateX(-50%); z-index: 2000; background: var(--night); color: #fff; padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow); max-width: min(560px, 90vw); font-weight: 500; }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--teal-dark); }
.dialog { border: 0; border-radius: 16px; box-shadow: var(--shadow); padding: 0; width: min(440px, 92vw); }
.dialog::backdrop { background: rgba(16, 34, 43, .35); }
.dialog form { padding: 20px; display: grid; gap: 12px; }
.dialog h2 { margin: 0; font-size: 18px; }
.dialog .p-actions { justify-content: flex-end; }

@media (max-width: 1100px) {
  .tool span, #layers-btn span, #issues-btn span, #review-btn span, #buildings-btn span, #user-name, .toolbar .brand > span { display: none; }
  :root { --panel: 340px; }
}
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; grid-template-rows: var(--toolbar) 1fr 42% var(--status); grid-template-areas: "top" "map" "panel" "status"; }
  .panel { border-inline-end: 0; border-top: 1px solid var(--line); }
  .search { display: none; }
  .toolbar { gap: 6px; padding: 0 8px; overflow-x: auto; }
}
