/* Terrain Print - same light, flat, pastel language as the dive planner. */

:root {
  --bg:        #f7f8fa;
  --panel:     #ffffff;
  --ink:       #26303a;
  --ink-soft:  #66727e;
  --line:      #dfe4ea;
  --line-firm: #c2cbd4;
  --accent:    #7fb3d5;
  --accent-dk: #4a86ad;
  --accent-bg: #eaf2f8;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
}

h1 { font-size: 16px; font-weight: 600; margin: 0; white-space: nowrap; }
h2 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px;
     color: var(--ink-soft); margin: 0 0 8px; }

.topbar {
  display: flex; align-items: baseline; gap: 12px;
  height: 48px; padding: 0 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar .sub { font-size: 12px; color: var(--ink-soft); }
.topbar-status { margin-left: auto; font-size: 12px; color: var(--ink-soft); }

.layout { display: grid; grid-template-columns: 1fr 330px; height: calc(100% - 48px); }
.map-wrap { position: relative; }
#map { position: absolute; inset: 0; background: #eef2f5; }

.panel { background: var(--panel); border-left: 1px solid var(--line);
         overflow-y: auto; padding: 14px; }
.block { margin-bottom: 20px; }

.map-hint {
  position: absolute; z-index: 500; left: 50%; transform: translateX(-50%); top: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
  padding: 6px 10px; font-size: 12px; color: var(--ink-soft);
  display: flex; align-items: center; gap: 10px;
}

.btn {
  font: inherit; font-size: 13px; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: 4px;
  background: var(--panel); color: var(--ink); cursor: pointer;
}
.btn:hover { background: #f0f3f6; }
.btn-sm { font-size: 12px; padding: 3px 8px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dk); border-color: var(--accent-dk); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 8px; margin: 4px 0 18px; }
.btn-row .btn { flex: 1; padding: 9px 12px; font-size: 14px; }

.field { display: block; margin-bottom: 11px; }
.field > span { display: block; font-size: 12px; color: var(--ink-soft); margin-bottom: 4px; }
.field output { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
input[type="number"], input[type="text"] {
  font: inherit; width: 100%; padding: 5px 7px;
  border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--ink);
}
input[type="range"] { width: 100%; margin: 0; accent-color: var(--accent-dk); height: 22px; }

.toggle { display: flex; align-items: flex-start; gap: 8px; margin-top: 10px;
          cursor: pointer; font-size: 12px; color: var(--ink-soft); line-height: 1.4; }
.toggle input { width: 15px; height: 15px; margin: 1px 0 0; accent-color: var(--accent-dk); flex: none; }

.hint { font-size: 12px; color: var(--ink-soft); line-height: 1.5; margin: 8px 0 0; }
#area-warn { color: #8a6d3b; background: #fdf6e7; border: 1px solid #ecdcb6;
             border-radius: 4px; padding: 7px 9px; }

.readout {
  font-size: 12px; line-height: 1.7; color: var(--ink);
  background: var(--accent-bg); border: 1px solid var(--line);
  border-radius: 4px; padding: 8px 10px;
}
.readout b { font-variant-numeric: tabular-nums; }

.log {
  font-family: ui-monospace, Consolas, monospace; font-size: 11px; line-height: 1.45;
  background: #fbfcfd; border: 1px solid var(--line); border-radius: 4px;
  padding: 8px; margin: 0; max-height: 260px; overflow: auto;
  white-space: pre-wrap; word-break: break-word; color: var(--ink);
}

.downloads { margin-top: 10px; }
.dl-head { font-size: 12px; color: var(--ink-soft); margin-bottom: 6px; }
.dl {
  display: block; font-size: 12px; padding: 6px 9px; margin-bottom: 5px;
  border: 1px solid var(--line); border-radius: 4px;
  color: var(--accent-dk); text-decoration: none; background: var(--panel);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dl:hover { background: var(--accent-bg); }

.leaflet-container { font-family: inherit; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 380px 1fr; height: auto; }
  .panel { border-left: none; border-top: 1px solid var(--line); }
}

.mask-list { list-style: none; padding: 0; margin: 8px 0 0; }
.mask-list li { display: flex; gap: 6px; margin-bottom: 5px; }
.mask-list input { flex: 1; min-width: 0; font: inherit; font-size: 12px;
  padding: 4px 6px; border: 1px solid var(--line); border-radius: 4px; }

.preview { display: block; width: 100%; height: auto; border: 1px solid var(--line);
  border-radius: 4px; background: var(--panel); image-rendering: auto; }

/* ---- account (top bar) ---- */
.account { margin-left: 14px; display: flex; align-items: center; }
.login { display: flex; gap: 6px; align-items: center; margin: 0; }
.login input { font: inherit; font-size: 12px; width: 120px; padding: 4px 6px;
  border: 1px solid var(--line); border-radius: 4px; }
.login-err { font-size: 12px; color: #a94442; margin-left: 4px; }
#whoami { display: flex; gap: 8px; align-items: center; font-size: 12px; }
#whoami-name { font-weight: 600; }

/* ---- advanced ---- */
details.advanced summary { font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .6px; color: var(--ink-soft); cursor: pointer; margin-bottom: 8px; }
select { font: inherit; width: 100%; padding: 5px 7px; border: 1px solid var(--line);
  border-radius: 4px; background: #fff; color: var(--ink); }
.btn-row.slim { margin: 4px 0 10px; }
.btn-row.slim .btn { padding: 5px 10px; font-size: 12px; }

/* ---- my runs ---- */
.runs { list-style: none; padding: 0; margin: 0; }
.runs li { border: 1px solid var(--line); border-radius: 4px; padding: 8px 9px; margin-bottom: 8px; font-size: 12px; }
.runs li .btn { margin: 6px 0; }
.run-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.run-state { font-weight: 600; text-transform: uppercase; font-size: 10px; letter-spacing: .5px;
  padding: 1px 6px; border-radius: 3px; background: var(--accent-bg); color: var(--accent-dk); }
.run-state.failed { background: #fbeaea; color: #a94442; }
.run-state.done { background: #e7f3ea; color: #2f7a45; }

/* ---- preview modal ---- */
.modal { position: fixed; inset: 0; z-index: 2000; background: var(--bg);
  display: flex; flex-direction: column; }
.modal-bar { display: flex; gap: 8px; align-items: center; padding: 8px 14px;
  background: var(--panel); border-bottom: 1px solid var(--line); }
.modal-bar .spacer { flex: 1; }
.modal-bar .hint { margin: 0; }
.modal-body { flex: 1; display: grid; grid-template-columns: 1fr 300px; min-height: 0; }
.modal-side { background: var(--panel); border-left: 1px solid var(--line); padding: 14px; overflow-y: auto; }
.stage { position: relative; display: flex; align-items: center; justify-content: center;
  padding: 12px; overflow: hidden; }
.stage img { max-width: 100%; max-height: 100%; width: auto; height: auto; display: block;
  border: 1px solid var(--line); background: #fff; }
.stage svg { position: absolute; pointer-events: none; }
.stage.drawing { cursor: crosshair; }
.mask-poly { fill: rgba(192, 57, 43, .18); stroke: #c0392b; stroke-width: 2; vector-effect: non-scaling-stroke; }
.mask-draft { fill: none; stroke: #c0392b; stroke-width: 2; stroke-dasharray: 6 3; vector-effect: non-scaling-stroke; }
.mask-dot { fill: #c0392b; }

@media (max-width: 900px) {
  .modal-body { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .account { display: none; }
}

/* ---- preview: 3D + zoomable flat view ---- */
.stage-wrap { position: relative; min-height: 0; min-width: 0; }
.stage3d, .stage-wrap .stage { position: absolute; inset: 0; }
.stage3d canvas { display: block; }
.stage-wrap .stage { padding: 0; cursor: grab; }
.stage-wrap .stage.drawing { cursor: crosshair; }
.zoomer { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.zoomer img { display: block; max-width: none; max-height: none; border: 1px solid var(--line); user-select: none; }
.zoomer svg { position: absolute; left: 0; top: 0; pointer-events: none; }
.stage-help { position: absolute; left: 12px; bottom: 10px; font-size: 12px; color: var(--ink-soft);
  background: rgba(255,255,255,.85); border: 1px solid var(--line); border-radius: 4px; padding: 3px 8px; }
.seg { display: inline-flex; }
.seg .btn { border-radius: 0; margin-left: -1px; }
.seg .btn:first-child { border-radius: 4px 0 0 4px; margin-left: 0; }
.seg .btn:last-child { border-radius: 0 4px 4px 0; }
.seg .btn.active { background: var(--accent-bg); border-color: var(--accent); color: var(--accent-dk); }
.mask-poly.seabed { fill: rgba(211, 132, 27, .2); stroke: #d3841b; }
.mask-kind { font-size: 10px; text-transform: uppercase; letter-spacing: .4px; padding: 2px 5px;
  border-radius: 3px; background: #fbeaea; color: #a94442; align-self: center; }
.mask-kind.seabed { background: #fdf0dc; color: #9a5d0c; }

/* ---- signed out ---- */
.welcome { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 20px; }
.welcome-card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 26px 28px; width: 100%; max-width: 380px; }
.welcome-card h1 { font-size: 20px; margin-bottom: 6px; }
.welcome-card .btn-row { margin: 14px 0 6px; }
.login-msg { font-size: 12px; color: #8a6d3b; min-height: 16px; margin: 8px 0 0; line-height: 1.5; }
a { color: var(--accent-dk); }

/* ---- top bar navigation ---- */
.account { margin-left: 14px; display: flex; align-items: center; gap: 12px; font-size: 12px; }
.account a { text-decoration: none; }
.account a:hover { text-decoration: underline; }
#whoami-name { font-weight: 600; }

/* ---- map toolbar ---- */
.map-hint .preset { font-size: 12px; padding: 3px 6px; width: auto; max-width: 190px; }
.map-hint .hint-text { white-space: nowrap; }
.btn.active { background: var(--accent-dk); border-color: var(--accent-dk); color: #fff; }

/* ---- dialogs ---- */
.dialog { position: fixed; inset: 0; z-index: 3000; background: rgba(38, 48, 58, .35);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.dialog-card { position: relative; background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; padding: 24px 28px; width: 100%; max-width: 440px; }
.dialog-card.wide { max-width: 760px; }
.dialog-card h1 { font-size: 18px; margin: 0 0 12px; white-space: normal; }
.dialog-card h2 { margin: 18px 0 6px; }
.dialog-card p, .dialog-card li { font-size: 13px; line-height: 1.55; color: var(--ink); }
.dialog-card ul { padding-left: 18px; margin: 6px 0; }
.dialog-close { position: absolute; top: 14px; right: 14px; }
textarea { font: inherit; width: 100%; padding: 6px 7px; border: 1px solid var(--line); border-radius: 4px; resize: vertical; }
input[type="password"] { font: inherit; width: 100%; padding: 5px 7px; border: 1px solid var(--line);
  border-radius: 4px; background: #fff; color: var(--ink); }

/* ---- admin table ---- */
.users { width: 100%; border-collapse: collapse; font-size: 12px; }
.users th, .users td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.users th { color: var(--ink-soft); font-weight: 600; }
.users td .btn { margin: 0 4px 2px 0; }
.st-pending { color: #9a5d0c; font-weight: 600; }
.st-approved { color: #2f7a45; }
.st-disabled { color: #a94442; }

@media (max-width: 900px) {
  .account { display: flex; gap: 8px; }
  .account a { display: none; }
  .map-hint .hint-text { display: none; }
  .topbar .sub { display: none; }
}

.toggle-row { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 4px; }
.modal-side { overflow-y: auto; }
#modal-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; margin-bottom: 14px; }
#modal-controls .field.slim { margin-top: 4px; }
#modal-controls .field.slim span { font-size: 11px; line-height: 1.2; }
#modal-controls input[type=number] { padding: 3px 6px; }
.toggle-row .toggle { margin: 0; }

.poi-form { display: flex; gap: 6px; margin-top: 6px; }
.poi-form input { flex: 1; min-width: 0; font: inherit; font-size: 12px; padding: 4px 6px; }
.poi-form input#poi-name { flex: 0 0 34%; }
.mask-list .poi-where { font-size: 11px; color: var(--ink-soft); white-space: nowrap; align-self: center; }
