/* Lords Control — used one-handed on a phone far more than on a desktop.
   The model is a phone's own Settings app: grouped inset lists, a value
   readable at arm's length without tapping into it, and every control
   shaped like the thing it does. */

:root {
  --bg: #f2f4f8;
  --surface: #ffffff;
  --surface-2: #eaeef4;
  --line: #d8dfe9;
  --text: #101620;
  --muted: #5f6d81;
  --accent: #2f6fd0;
  --ok: #24a86e;
  --warn: #c8801f;
  --danger: #d24347;
  --radius: 18px;
  --tap: 44px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0f14;
    --surface: #161b23;
    --surface-2: #1e242e;
    --line: #2b3340;
    --text: #e7ecf3;
    --muted: #8d9aae;
    --accent: #4f8ef7;
    --ok: #35c48a;
    --warn: #e0a13c;
    --danger: #e5595d;
  }
}

:root[data-theme="dark"] {
  --bg: #0c0f14;
  --surface: #161b23;
  --surface-2: #1e242e;
  --line: #2b3340;
  --text: #e7ecf3;
  --muted: #8d9aae;
  --accent: #4f8ef7;
  --ok: #35c48a;
  --warn: #e0a13c;
  --danger: #e5595d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

main { max-width: 640px; margin: 0 auto; padding: 8px 16px 40px; }

h1 { font-size: 1.55rem; font-weight: 700; letter-spacing: -.022em; margin: 16px 0 4px; }
h2 { font-size: 1.02rem; margin: 0 0 12px; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); font-size: .89rem; }
.back { display: inline-block; margin-top: 14px; font-size: .93rem; font-weight: 500; }

/* --- top bar --- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; color: var(--text); letter-spacing: -.01em; }
.topbar nav { display: flex; align-items: center; gap: 12px; }
.who { color: var(--muted); font-size: .84rem; }

/* --- cards & banners --- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin: 16px 0;
}
.card.narrow { max-width: 400px; margin: 56px auto; }

.banner {
  padding: 13px 15px; border-radius: 14px; margin: 12px 0;
  background: var(--surface-2); border: 1px solid var(--line); font-size: .9rem;
}
.banner.block { display: block; color: inherit; }
.banner.error { border-color: var(--danger);
                background: color-mix(in srgb, var(--danger) 12%, var(--surface)); }
.banner.ok    { border-color: var(--ok);
                background: color-mix(in srgb, var(--ok) 12%, var(--surface)); }
.banner.warn  { border-color: var(--warn);
                background: color-mix(in srgb, var(--warn) 12%, var(--surface)); }

/* --- account list --- */
.accounts { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 10px; }
.account {
  display: grid; gap: 3px; padding: 15px 17px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--text);
  transition: transform .12s cubic-bezier(.2,.7,.3,1), background .15s;
}
.account:active { transform: scale(.985); background: var(--surface-2); }
.account .name { font-weight: 600; font-size: 1.02rem; }
.account .meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.account .igg { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.stale { color: var(--warn); font-size: .78rem; }

/* --- pills --- */
.pill {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .05em;
  font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.pill.big { font-size: .78rem; padding: 6px 13px; }
.pill.caution   { color: var(--warn);   border-color: var(--warn); }
.pill.dangerous { color: var(--danger); border-color: var(--danger); }
.pill.pending, .pill.claimed { color: var(--warn); border-color: var(--warn); }
.pill.applied   { color: var(--ok);     border-color: var(--ok); }
.pill.failed    { color: var(--danger); border-color: var(--danger); }

/* --- category tiles --- */
.account-head { margin: 18px 0 2px; }
.account-head h1 { margin: 0; }
.tiles { display: grid; gap: 12px; margin: 20px 0; }

.tile {
  display: grid; grid-template-columns: 46px 1fr auto;
  align-items: center; gap: 14px;
  padding: 14px 16px; min-height: 76px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--text);
  transition: transform .12s cubic-bezier(.2,.7,.3,1), background .15s;
}
.tile:active { transform: scale(.978); background: var(--surface-2); }

.tile-icon {
  display: grid; place-items: center; width: 46px; height: 46px;
  border-radius: 13px; color: #fff;
  background: linear-gradient(160deg,
    color-mix(in srgb, var(--tile-accent) 88%, white), var(--tile-accent));
  box-shadow: 0 4px 12px -5px color-mix(in srgb, var(--tile-accent) 75%, transparent);
}
.tile-icon svg { width: 24px; height: 24px; }
.tile-body { display: grid; gap: 2px; min-width: 0; }
.tile-title { font-size: 1.02rem; font-weight: 600; letter-spacing: -.012em; }
.tile-summary {
  font-size: .86rem; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tile-right { display: flex; align-items: center; gap: 9px; }
.tile-go { color: var(--line); font-size: 1.4rem; line-height: 1; }

.badge {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  font-size: .72rem; font-weight: 700; font-variant-numeric: tabular-nums;
}

.accent-green { --tile-accent: #30b980; }
.accent-blue  { --tile-accent: #4f8ef7; }
.accent-red   { --tile-accent: #e5595d; }
.accent-amber { --tile-accent: #dd9b32; }
.accent-grey  { --tile-accent: #7f8ca2; }
.accent-violet{ --tile-accent: #9b7bf0; }

/* --- category page --- */
.section-head { display: flex; align-items: center; gap: 14px; margin: 18px 0 6px; }
.section-head h1 { margin: 0; font-size: 1.32rem; }
.section-head p { margin: 1px 0 0; }

/* --- grouped list --- */
.group {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; margin: 16px 0;
}
.row {
  display: grid; grid-template-columns: 1fr auto;
  align-items: center; gap: 16px;
  padding: 13px 16px; min-height: 58px; position: relative;
}
/* Separators inset past the label, so a group reads as one object. */
.row + .row::before {
  content: ""; position: absolute; top: 0; left: 16px; right: 0;
  height: 1px; background: var(--line);
}
/* Long labels get their own line. Squeezed into the ~140px left beside a
   stepper, a 44-character label wraps one word per line. */
.row.stacked { grid-template-columns: 1fr; gap: 11px; justify-items: start; }
.row.stacked .row-label { max-width: 100%; }
.row.stacked .stepper,
.row.stacked .segmented { justify-self: start; }
.row.locked { opacity: .45; }
.row-label { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-label label { font-weight: 500; text-wrap: pretty; hyphens: none; }
.row-note { grid-column: 1 / -1; color: var(--muted); font-size: .79rem; margin: 5px 0 0; }

/* --- switch --- */
.switch { position: relative; display: inline-block; width: 51px; height: 31px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; cursor: pointer; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  transition: background .2s cubic-bezier(.2,.7,.3,1), border-color .2s;
}
.slider::before {
  content: ""; position: absolute; height: 27px; width: 27px; left: 1px; top: 1px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0,0,0,.28);
  transition: transform .2s cubic-bezier(.2,.7,.3,1);
}
.switch input:checked + .slider { background: var(--ok); border-color: var(--ok); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch input:disabled + .slider { opacity: .5; cursor: not-allowed; }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 3px; }

/* --- stepper --- */
.stepper {
  display: grid; grid-template-columns: 40px minmax(86px, auto) 40px;
  align-items: center; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 13px; padding: 3px;
}
.stepper button {
  width: 40px; height: 38px; min-height: 38px; padding: 0;
  display: grid; place-items: center;
  background: transparent; border: 0; border-radius: 10px;
  color: var(--accent); font-size: 1.35rem; font-weight: 500; line-height: 1;
}
.stepper button:active { background: var(--surface); }
.stepper button:disabled { color: var(--line); }
.stepper .value {
  display: flex; align-items: baseline; justify-content: center; gap: 4px;
  min-width: 0;
}
.stepper input {
  width: 100%; min-width: 0; padding: 0; text-align: center;
  background: none; border: 0; color: var(--text);
  font-size: 1.05rem; font-weight: 650; font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus { outline: none; }
.stepper:focus-within { border-color: var(--accent); }
.stepper .unit { color: var(--muted); font-size: .75rem; white-space: nowrap; }

/* --- segmented control --- */
.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 13px;
}
.segmented label {
  position: relative; margin: 0; padding: 8px 14px; min-height: 38px;
  display: grid; place-items: center; border-radius: 10px;
  font-size: .87rem; font-weight: 500; color: var(--muted);
  cursor: pointer; white-space: nowrap; transition: background .15s, color .15s;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) {
  background: var(--surface); color: var(--text); font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.segmented label:has(input:disabled) { opacity: .5; cursor: not-allowed; }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- chip toggles --- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  position: relative; margin: 0; display: inline-grid; place-items: center;
  padding: 9px 15px; min-height: 40px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--muted); font-size: .87rem; font-weight: 500;
  cursor: pointer; user-select: none;
  transition: transform .1s cubic-bezier(.2,.7,.3,1), background .15s, color .15s;
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:active { transform: scale(.94); }
.chip:has(input:checked) { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip:has(input:disabled) { opacity: .5; cursor: not-allowed; }
.chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- amount rows (the five-resource tables) ---
   One line per resource so the name is never squeezed against the number,
   and tabular figures so the columns line up as the amounts change. */
.amounts { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.amount {
  display: grid; grid-template-columns: 5.5rem 1fr; align-items: center;
  gap: 10px; margin: 0;
}
.amount-name { color: var(--muted); font-size: .9rem; font-weight: 500; }
.amount input {
  width: 100%; min-height: var(--tap); padding: 10px 14px; text-align: center;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 13px;
  font-size: 16px; font-weight: 650; font-variant-numeric: tabular-nums;
}
.amount input:disabled { opacity: .5; }

/* --- long option lists ---
   A native picker, styled to match the steppers rather than the browser. */
select {
  width: 100%; min-height: var(--tap); padding: 10px 38px 10px 14px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 13px;
  font-size: 16px; font-weight: 600; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 18px center, right 13px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
select:disabled { opacity: .5; }

/* --- text-ish inputs --- */
input[type="time"] {
  min-height: var(--tap); padding: 9px 13px; text-align: center;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 13px;
  font-size: 1rem; font-weight: 650; font-variant-numeric: tabular-nums;
}
input[type="email"] {
  width: 100%; min-height: var(--tap); padding: 12px 14px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 13px; font-size: 16px;
}
input:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* --- buttons --- */
button, .btn {
  min-height: 50px; padding: 13px 20px; font-size: 1rem; font-weight: 600;
  border-radius: 15px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text);
  cursor: pointer; font-family: inherit;
  transition: transform .1s cubic-bezier(.2,.7,.3,1), filter .15s;
}
button:active, .btn:active { transform: scale(.985); }
.btn { display: grid; place-items: center; text-align: center; }
button.primary, .btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff; width: 100%;
}
button.ghost { background: transparent; }
button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
button.link { background: none; border: none; color: var(--accent);
              padding: 0; min-height: auto; font-weight: 500; }
button:disabled, .btn:disabled { opacity: .45; cursor: not-allowed; }

/* --- sticky bars --- */
.actions { position: sticky; bottom: 0; z-index: 5; padding: 14px 0 18px;
           background: linear-gradient(to top, var(--bg) 68%, transparent); }
.actions .muted { text-align: center; margin: 8px 0 0; }
.actions .pair { display: grid; grid-template-columns: auto 1fr; gap: 10px; }

.applybar { position: sticky; bottom: 0; z-index: 6; margin-top: 22px;
            padding: 14px 0 18px;
            background: linear-gradient(to top, var(--bg) 68%, transparent); }
.applybar .inner {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px;
  padding: 12px 14px 12px 18px;
  background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius);
  box-shadow: 0 12px 32px -16px color-mix(in srgb, var(--accent) 70%, transparent);
}
.applybar .count { font-weight: 650; }
.applybar .hint { color: var(--muted); font-size: .8rem; }
.applybar .btn { min-height: 44px; padding: 11px 18px; border-radius: 12px; }

/* --- review --- */
.review-group { margin: 18px 0; }
.review-group h2 {
  font-size: .76rem; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; margin: 0 0 8px; padding-left: 4px;
}
.review-row {
  display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center;
  padding: 13px 16px; min-height: 56px; position: relative;
}
.review-row + .review-row::before {
  content: ""; position: absolute; top: 0; left: 16px; right: 0;
  height: 1px; background: var(--line);
}
.review-value { display: flex; align-items: center; gap: 9px;
                font-variant-numeric: tabular-nums; text-align: right; }
.review-value .was { color: var(--muted); text-decoration: line-through; font-size: .88rem; }
.review-value .arrow { color: var(--line); }
.review-value .now { color: var(--ok); font-weight: 650; }

/* --- job view --- */
.status-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.jobs { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.jobs a { display: flex; align-items: center; gap: 10px; padding: 11px 0;
          color: var(--text); font-size: .9rem; }
.jobs .when { color: var(--muted); }
.jobs .what { margin-left: auto; color: var(--muted); }

form { margin: 0; }

@media (min-width: 620px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
