/* Nomad page layout. Components come from g-system; this file only places them. */
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text-primary); }

.nm-app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 448px;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh; height: 100dvh;
  overflow: hidden;
}
.nm-head {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: var(--sp-4);
  min-height: var(--h-5); box-sizing: border-box;
  padding: var(--sp-2) var(--gutter);
  /* the rule is a shadow so the bar stays 48 tall and its row stays on whole pixels */
  box-shadow: inset 0 -1px 0 var(--border-subtle);
  background: var(--surface-1);
}
.nm-brand { font-weight: 600; font-size: 15px; line-height: var(--lh-2); }
.nm-base { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.nm-k { color: var(--text-secondary); font-size: 12px; line-height: var(--lh-1); }
.nm-base-name { font-size: var(--font-size-ui); line-height: var(--lh-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.nm-updated { margin-left: auto; color: var(--text-secondary); font-size: 12px; line-height: var(--lh-1); white-space: nowrap; }

.nm-base-pop { width: min(360px, calc(100vw - 32px)); padding: var(--sp-4); margin: 0; inset: auto; }
.nm-base-pop:popover-open { position: fixed; top: calc(var(--h-5) + var(--sp-2)); left: var(--gutter); }

.nm-stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--bg); }
#globe { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#globe.is-dragging { cursor: grabbing; }
#globe.is-hot { cursor: pointer; }
.nm-legend {
  position: absolute; left: var(--gutter); bottom: var(--sp-4);
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: 12px; line-height: var(--lh-1); color: var(--text-secondary);
  pointer-events: none;
}
.nm-ramp {
  display: block; width: 96px; height: var(--sp-2); border-radius: var(--radius-full);
  background: linear-gradient(to right, var(--chart-3), var(--chart-4) 70%, var(--chart-5));
}
.nm-tip {
  position: absolute; pointer-events: none; z-index: 2;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-sm);
  background: var(--surface-2); box-shadow: var(--shadow-overlay);
  font-size: 12px; line-height: var(--lh-1); white-space: nowrap;
}

.nm-pane {
  display: flex; flex-direction: column; min-height: 0;
  border-left: 1px solid var(--border-subtle);
  background: var(--surface-1);
}
.nm-lists { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.nm-lists > .tabs { flex: none; padding: var(--sp-2) var(--sp-3) 0; }
.nm-panel { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: var(--sp-2) var(--sp-3) var(--sp-5); }
.nm-panel[hidden] { display: none; }

/* deal rows: one table, two cells, so phones never scroll sideways */
.nm-rows { width: 100%; }
.nm-rows tbody tr { cursor: pointer; }
.nm-rows tbody tr[data-active] { background: var(--fill-active); }
/* the 1px rule comes out of the bottom padding, so each row is a multiple of 4 */
.nm-rows td { vertical-align: top; padding-top: var(--sp-2); padding-bottom: calc(var(--sp-2) - 1px); }
.nm-rows tr:last-child td { padding-bottom: var(--sp-2); }
.nm-row-meta .badge { height: var(--lh-2); }
.nm-rows td.r { white-space: nowrap; }
.nm-row-main { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
.nm-row-title { font-weight: 500; line-height: var(--lh-2); }
.nm-row-meta { display: flex; flex-wrap: wrap; align-items: center; column-gap: var(--sp-3); row-gap: var(--sp-1); color: var(--text-secondary); font-size: 12px; line-height: var(--lh-1); }
.nm-price { font-size: 15px; font-weight: 500; line-height: var(--lh-2); }
.nm-below { color: var(--ok-text); font-size: 12px; line-height: var(--lh-1); }
.nm-rows a.btn { text-decoration: none; }
.nm-d-actions a.btn { text-decoration: none; }
.nm-row-side { display: flex; flex-direction: column; align-items: flex-end; gap: var(--sp-1); }

.nm-budget { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) 0 var(--sp-3); }
.nm-budget .input { width: 112px; }
#costs-table tbody tr { cursor: pointer; }
#costs-table td, #costs-table th { white-space: nowrap; }
.nm-up { color: var(--ok-text); }
.nm-down { color: var(--danger-text); }
.nm-none { color: var(--text-placeholder); }

.nm-detail { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: var(--sp-2) var(--sp-4) var(--sp-5); }
.nm-detail-head { display: flex; align-items: center; margin-left: calc(-1 * var(--sp-2)); padding-bottom: var(--sp-2); }
.nm-d-title { font-size: 20px; line-height: var(--lh-4); font-weight: 600; margin: 0; }
.nm-d-sub { color: var(--text-secondary); font-size: var(--font-size-ui); line-height: var(--lh-2); margin: 0 0 var(--sp-4); }
.nm-stats { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); margin-bottom: var(--sp-5); }
.nm-stat { display: flex; flex-direction: column; gap: var(--sp-1); padding: var(--sp-3); }
.nm-stat .nm-k { display: block; }
.nm-stat .nm-v { font-size: 17px; line-height: var(--lh-3); font-weight: 500; }
.nm-d-section { font-size: var(--font-size-ui); line-height: var(--lh-2); font-weight: 600; margin: 0 0 var(--sp-2); }
.nm-d-actions { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-5); }

/* phones: globe on top, the pane below as the scrolling sheet */
@media (max-width: 860px) {
  .nm-app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 44dvh minmax(0, 1fr); }
  .nm-pane { border-left: none; border-top: 1px solid var(--border-subtle); border-radius: var(--radius-card) var(--radius-card) 0 0; margin-top: calc(-1 * var(--sp-3)); position: relative; z-index: 1; }
  .nm-head { gap: var(--sp-3); flex-wrap: wrap; row-gap: var(--sp-1); }
  .nm-brand { display: none; }
  .nm-base { flex: 1 1 auto; }
  .nm-legend { top: var(--sp-3); bottom: auto; left: auto; right: var(--gutter); }
  .nm-ramp { width: 64px; }
  .nm-updated { margin-left: 0; width: 100%; }
  .nm-stats { grid-template-columns: 1fr 1fr; }
}

/* sign-in page */
.nm-login { min-height: 100dvh; display: grid; place-items: center; padding: var(--gutter); box-sizing: border-box; }
.nm-login-card { width: min(360px, 100%); padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-3); box-sizing: border-box; }
.nm-login-title { margin: 0; font-size: 20px; line-height: var(--lh-4); font-weight: 600; }
.nm-login-sub { margin: 0; color: var(--text-secondary); font-size: var(--font-size-ui); line-height: var(--lh-2); }
.nm-login-error { margin: 0; min-height: var(--lh-2); color: var(--danger-text); font-size: var(--font-size-ui); line-height: var(--lh-2); }
