:root {
  --bg: #0c1018;
  --bg-2: #121826;
  --panel: #161d2c;
  --panel-2: #1c2638;
  --line: #28344a;
  --text: #e7ecf5;
  --muted: #8e9bb3;
  --accent: #ffb627;       /* Illuminate amber */
  --accent-2: #3da9fc;
  --danger: #ff6b6b;
  --ok: #4ade80;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  font-synthesis: none;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must always win, even over display:grid/flex below. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: radial-gradient(1200px 600px at 70% -10%, #16213a 0%, var(--bg) 55%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2 { font-weight: 600; letter-spacing: .2px; }

button { font-family: inherit; }

input, textarea, select {
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(61,169,252,.18);
}

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.field { margin-bottom: 14px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; }
.muted-tag { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.spot-save-row { margin-top: 8px; }
.link-danger { color: var(--danger); text-decoration: underline; cursor: pointer; }
.link-danger:hover { color: #ff8a8a; }
.req { font-size: 11px; color: var(--bg); background: var(--accent); padding: 2px 7px; border-radius: 999px; vertical-align: middle; margin-left: 6px; font-weight: 700; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .05s, background .15s, opacity .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #1a1300; }
.btn-primary:hover { background: #ffc24d; }
.btn-primary:disabled { background: #3a3a3a; color: #777; cursor: not-allowed; }
.btn-ghost { background: var(--panel-2); color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: #233048; }
.btn-lg { padding: 13px 22px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ---------- Lock screen ---------- */
.lock-screen {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: radial-gradient(900px 500px at 50% 0%, #16213a 0%, var(--bg) 60%);
  z-index: 1000;
}
.lock-card {
  width: min(92vw, 380px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 34px 30px;
  box-shadow: var(--shadow);
  text-align: center;
}
.lock-logo { font-size: 12px; letter-spacing: 3px; color: var(--accent); font-weight: 700; margin-bottom: 16px; }
.lock-card h1 { font-size: 20px; margin: 0 0 6px; }
.lock-sub { color: var(--muted); font-size: 14px; margin: 0 0 22px; }
#pin-form { display: flex; gap: 8px; }
#pin-input { text-align: center; letter-spacing: 4px; }
.pin-error { color: var(--danger); font-size: 13px; margin: 14px 0 0; }

/* ---------- App shell ---------- */
.app { max-width: 1240px; margin: 0 auto; padding: 0 22px 60px; }
.app-header {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 20px 4px 18px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.brand-mark { color: var(--accent); font-size: 18px; }
.brand-name { font-weight: 700; }
.brand-sep { color: var(--muted); }
.brand-page { color: var(--muted); }
.who { display: flex; align-items: center; gap: 10px; }
.who label { margin: 0; white-space: nowrap; }
.who input { width: 220px; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}
@media (max-width: 960px) { .layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.panel h2 {
  font-size: 15px; margin: 0 0 14px;
  padding-bottom: 10px; border-bottom: 1px solid var(--line);
}
.panel h2:not(:first-child) { margin-top: 26px; }

/* ---------- Location ---------- */
.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; }
.addr-results {
  list-style: none; margin: 6px 0 0; padding: 0;
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  background: var(--bg-2);
}
.addr-results li { padding: 9px 12px; cursor: pointer; font-size: 13.5px; border-bottom: 1px solid var(--line); }
.addr-results li:last-child { border-bottom: none; }
.addr-results li:hover { background: var(--panel-2); }
.coord-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; margin-top: 12px; }
.coord-row .btn { height: 40px; }
.map { height: 340px; border-radius: 10px; margin-top: 14px; border: 1px solid var(--line); z-index: 0; }
.resolved-address {
  margin-top: 12px; font-size: 13px; color: var(--muted);
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}

/* ---------- Details ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-2 .field:last-child { grid-column: 1 / -1; max-width: 220px; }

.upload-drop {
  display: grid; place-items: center; text-align: center;
  border: 1.5px dashed var(--line); border-radius: 10px;
  padding: 26px 16px; color: var(--muted); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.upload-drop:hover, .upload-drop.drag { border-color: var(--accent-2); background: rgba(61,169,252,.06); color: var(--text); }
.excl-previews { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 12px; }
.excl-thumb { position: relative; width: 150px; }
.excl-thumb img { width: 150px; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.excl-thumb .thumb-name { display: block; margin-top: 4px; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb-x {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%;
  border: none; cursor: pointer; background: rgba(0,0,0,.65); color: #fff; font-size: 12px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.thumb-x:hover { background: var(--danger); }
.excl-previews .fsdo-warn { flex-basis: 100%; }

/* ---------- FSDO box ---------- */
.fsdo-box { background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.fsdo-box.empty { border-style: dashed; }
.fsdo-empty { margin: 0; color: var(--muted); font-size: 13.5px; }
.fsdo-name { font-size: 16px; font-weight: 700; margin: 0 0 4px; }
.fsdo-name .dist { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 8px; }
.fsdo-addr { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.fsdo-email-row { display: flex; align-items: center; gap: 10px; }
.fsdo-email-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.fsdo-email-display { font-weight: 600; color: var(--text); flex: 1; word-break: break-all; }
.fsdo-email-row input { font-weight: 600; flex: 1; }
.fsdo-warn { margin-top: 10px; font-size: 12.5px; color: var(--accent); background: rgba(255,182,39,.08); border: 1px solid rgba(255,182,39,.3); border-radius: 8px; padding: 8px 10px; }

/* ---------- Actions ---------- */
.actions { margin-top: 24px; }
.actions .btn-lg { width: 100%; }
.validation-msg { color: var(--accent); font-size: 13px; margin: 10px 0 0; text-align: center; min-height: 1em; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(4,7,12,.72); display: grid; place-items: center; z-index: 900; padding: 20px; }
.modal-card {
  width: min(96vw, 680px); max-height: 92vh; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-x { background: none; border: none; color: var(--muted); font-size: 26px; cursor: pointer; line-height: 1; }
.modal-x:hover { color: var(--text); }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.rv-row { display: grid; grid-template-columns: 80px 1fr; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line); align-items: center; }
.rv-row-body { align-items: start; }
.rv-k { color: var(--muted); font-size: 13px; }
.rv-v { font-size: 14px; word-break: break-word; }
.rv-edit { display: flex; align-items: center; gap: 10px; }
.rv-edit em { color: var(--muted); font-style: normal; font-size: 13px; white-space: nowrap; }
#rv-body { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.5; resize: vertical; }
.rv-attach { margin: 0; padding-left: 18px; }
.rv-attach li { font-size: 13.5px; padding: 2px 0; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.modal-foot-btns { display: flex; gap: 10px; margin-left: auto; }
.send-status { font-size: 13.5px; margin: 0; color: var(--muted); }
.send-status.ok { color: var(--ok); }
.send-status.err { color: var(--danger); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow); z-index: 1100; font-size: 14px;
}
.toast.ok { border-color: rgba(74,222,128,.5); }
.toast.err { border-color: rgba(255,107,107,.5); }

/* spinner */
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; margin-right: 7px; }
@keyframes spin { to { transform: rotate(360deg); } }
