/* AlbGIS Terren — field data viewer (on top of app.css) */
body[data-view="terren"] .app-wrap { max-width: none; margin: 0; padding: 28px 28px 56px; }
@media (max-width: 600px) { body[data-view="terren"] .app-wrap { padding: 20px 14px 48px; } }

.tr-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 900px) { .tr-layout { grid-template-columns: minmax(0, 1fr); } }

.tr-plist { display: flex; flex-direction: column; gap: 8px; }
.tr-pitem { text-align: left; width: 100%; padding: 12px 14px; border-radius: var(--r-md); cursor: pointer;
    background: rgba(255,255,255,.03); border: 1px solid var(--border); color: var(--text); font: inherit; }
.tr-pitem:hover { border-color: var(--border-strong); }
.tr-pitem.active { border-color: var(--accent-line); background: var(--accent-soft); }
.tr-pitem .n { font-weight: 700; font-size: 14px; }
.tr-pitem .m { display: flex; gap: 10px; font-size: 12px; color: var(--text-faint); margin-top: 6px; flex-wrap: wrap; }

.tr-role { font: 700 10px/1 Inter,sans-serif; text-transform: uppercase; letter-spacing: .04em;
    padding: 4px 7px; border-radius: 99px; background: var(--surface-2); color: var(--text-muted); }
.tr-role.owner { background: var(--accent-soft); color: var(--accent); }
.tr-role.editor { background: rgba(54,224,143,.12); color: #36e08f; }

#trMap { height: 62vh; min-height: 380px; border-radius: var(--r-lg); border: 1px solid var(--border); background: #0b0d12; }
.tr-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.tr-toolbar .grow { flex: 1; }
.tr-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); margin-top: 10px; }
.tr-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.tr-search { background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text);
    border-radius: 9px; padding: 8px 11px; font: 500 13px/1 Inter,sans-serif; min-width: 200px; }
.tr-table-wrap { overflow-x: auto; max-height: 420px; overflow-y: auto; }
.tr-table tr { cursor: pointer; }
.tr-table tr.sel td { background: var(--accent-soft); }

.tr-members .row { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tr-members .row .e { flex: 1; min-width: 180px; font-size: 14px; }
.tr-members .row .e small { display: block; color: var(--text-faint); font-size: 12px; }
.tr-members select, .tr-add select, .tr-add input { background: var(--surface-2); border: 1px solid var(--border-strong);
    color: var(--text); border-radius: 9px; padding: 8px 10px; font: 500 13px/1 Inter,sans-serif; }
.tr-add { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.tr-pick { position: relative; flex: 1; min-width: 220px; display: flex; }
.tr-pick input { flex: 1; width: 100%; }
.tr-drop { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 1000; max-height: 280px; overflow-y: auto;
    background: #1e222d; border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow-md); padding: 4px; }
.tr-ditem { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text); cursor: pointer;
    padding: 8px 10px; border-radius: 7px; font: 13px/1.35 Inter,sans-serif; }
.tr-ditem:hover:not([disabled]) { background: var(--accent-soft); }
.tr-ditem[disabled] { opacity: .45; cursor: default; }
.tr-ditem small { display: block; color: var(--text-faint); font-size: 12px; }
.tr-dnote { padding: 10px; color: var(--text-muted); font-size: 13px; }

/* web GIS editor */
.tr-edit { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; padding: 10px 12px;
    background: rgba(255,255,255,.03); border: 1px solid var(--border); border-radius: var(--r-md); }
.tr-edit .lbl { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.tr-edit select { background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text);
    border-radius: 9px; padding: 8px 10px; font: 500 13px/1 Inter,sans-serif; max-width: 260px; }
.tr-edit .sep { width: 1px; height: 24px; background: var(--border-strong); margin: 0 2px; }
.tr-edit .btn[disabled] { opacity: .4; pointer-events: none; }
.tr-edit .hint { flex-basis: 100%; font-size: 12px; color: var(--text-faint); }
.tr-lg { display: inline-flex; align-items: center; gap: 0; cursor: pointer; }
.tr-lg input { margin: 0 6px 0 0; accent-color: var(--accent); }
.tr-pacts { display: flex; gap: 6px; margin-top: 8px; }
.tr-pacts .btn { padding: 6px 10px; font-size: 12px; }

.tr-modal { position: fixed; inset: 0; z-index: 5000; background: rgba(5,7,12,.6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.tr-mbox { width: 100%; max-width: 440px; max-height: 88vh; overflow-y: auto; background: #181b24; border: 1px solid var(--border-strong);
    border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow-md); }
.tr-mbox h3 { font: 700 17px/1.3 Sora,Inter,sans-serif; margin-bottom: 14px; }
.tr-mbox .field select { background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text);
    border-radius: 10px; padding: 11px 12px; font: 500 14px/1 Inter,sans-serif; }
.tr-mbtns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.tr-addf { display: flex; gap: 8px; margin-top: 6px; }
.tr-addf input { flex: 1; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text);
    border-radius: 9px; padding: 8px 10px; font: 500 13px/1 Inter,sans-serif; min-width: 0; }

.tr-mbox.wide { max-width: 680px; }
.tr-mbox .field input[type=number], .tr-mbox .field input[type=date], .tr-mbox .field input[type=text] { width: 100%; }
.tr-lrow { display: flex; gap: 10px; flex-wrap: wrap; }
.tr-flabel { display: block; font-size: 12px; color: var(--text-muted); font-weight: 600; margin: 6px 0 6px; }
.tr-ftable-wrap { overflow-x: auto; margin-bottom: 8px; }
.tr-ftable { width: 100%; border-collapse: collapse; font-size: 13px; }
.tr-ftable th { text-align: left; font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; padding: 4px 6px; }
.tr-ftable td { padding: 4px 4px; }
.tr-ftable input, .tr-ftable select { width: 100%; min-width: 90px; background: var(--surface-2); border: 1px solid var(--border-strong);
    color: var(--text); border-radius: 8px; padding: 8px 9px; font: 500 13px/1 Inter,sans-serif; }
.tr-ftable input[disabled] { opacity: .35; }
.tr-ftable td.acts { white-space: nowrap; }
.tr-ftable td.acts button { background: none; border: 1px solid var(--border-strong); color: var(--text-muted); border-radius: 7px;
    width: 28px; height: 30px; cursor: pointer; margin-left: 2px; }
.tr-ftable td.acts button:disabled { opacity: .25; cursor: default; }
.tr-ftable td.acts button.rm:hover { color: #ff8da1; border-color: rgba(240,71,106,.5); }
.tr-photos { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tr-photos label.btn { cursor: pointer; }
.tr-photos .tr-thumbs { flex-basis: 100%; }
.tr-thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tr-thumbs img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid rgba(255,255,255,.12); display: block; }
.tr-th { position: relative; }
.tr-th button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0;
    background: #b3263f; color: #fff; cursor: pointer; font-size: 13px; line-height: 22px; padding: 0; }
.tr-th.busy { width: 72px; height: 72px; display: flex; align-items: center; justify-content: center; border-radius: 8px; background: var(--surface-2); }
.tr-pop .tr-thumbs img { width: 64px; height: 64px; }

/* photo viewer */
[data-ph] { cursor: zoom-in; }
.tr-viewer { position: fixed; inset: 0; z-index: 7000; background: rgba(4,6,10,.92); display: flex; flex-direction: column; }
.tr-vtop { display: flex; align-items: center; gap: 8px; padding: 12px 16px; color: #e8eaf0; font: 600 14px/1 Inter,sans-serif; }
.tr-vtop .grow { flex: 1; }
.tr-vstage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 0 12px 16px; }
.tr-vstage img { max-width: calc(100% - 120px); max-height: 100%; object-fit: contain; border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,.6); cursor: default; }
.tr-vnav { flex: none; width: 48px; height: 64px; border: 0; border-radius: 12px; background: rgba(255,255,255,.08); color: #fff;
    font: 300 40px/1 Inter,sans-serif; cursor: pointer; }
.tr-vnav:hover { background: rgba(255,255,255,.16); }
@media (max-width: 600px) { .tr-vstage img { max-width: calc(100% - 80px); } .tr-vnav { width: 34px; } }

.tr-toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 6000; padding: 10px 16px;
    background: #1f7a4d; color: #fff; border-radius: 10px; font: 600 13px/1.3 Inter,sans-serif; box-shadow: var(--shadow-md); }
.tr-toast.err { background: #b3263f; }

/* popups on the dark theme */
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #181b24; color: #e8eaf0; }
.leaflet-popup-content { margin: 12px 14px; font: 13px/1.45 Inter,sans-serif; }
.tr-pop table { border-collapse: collapse; }
.tr-pop td { padding: 3px 8px 3px 0; vertical-align: top; }
.tr-pop td:first-child { color: #9aa2b2; white-space: nowrap; }
.tr-pop .meta { margin-top: 8px; padding-top: 6px; border-top: 1px solid rgba(255,255,255,.08); color: #6a7283; font-size: 11px; }
