/* admin.css: the TR Orders admin app layout (header, tab bar, screens, login). */

/* iPhone Home Screen app: the phone colours the area behind the clock and battery, and the strip
   below the tab bar, from the page's background (newer iPhones read the body, not just the root).
   So both html and body are the header's dark colour, and the cream lives on the app itself (#app).
   A thin fixed dark strip at the very top also tells the phone the top edge is dark. */
html { height: 100%; background: var(--ink); }
body { min-height: 100%; background: var(--ink); overscroll-behavior-y: none; }
body::before {
  content: ''; position: fixed; top: 0; left: 0; right: 0; z-index: 60; pointer-events: none;
  height: max(var(--safe-top), 2px); background: var(--ink);
}

#app { min-height: 100vh; min-height: 100dvh; background: var(--cream); }

/* ---------- header ---------- */

.app-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--ink); color: var(--cream);
  padding: calc(var(--safe-top) + 8px) calc(var(--gap) + var(--safe-right)) 8px calc(var(--gap) + var(--safe-left));
  display: flex; align-items: center; gap: 12px; min-height: 60px;
}
.app-header img { width: 52px; height: 40px; object-fit: contain; flex: none; }
.app-header .title {
  font-family: var(--font-head); font-weight: 600; font-size: 26px; line-height: 1.1;
  margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.app-header .back {
  min-width: var(--tap); min-height: var(--tap); margin-left: -8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 0; color: var(--gold); font-size: 28px; cursor: pointer;
}

/* ---------- main area ---------- */

.app-main {
  padding: var(--gap) calc(var(--gap) + var(--safe-right)) calc(96px + var(--safe-bottom)) calc(var(--gap) + var(--safe-left));
  max-width: 720px; margin: 0 auto;
}
.section { margin-top: 28px; }
.section:first-child { margin-top: 0; }

.pull-indicator {
  height: 0; overflow: hidden; text-align: center; color: var(--muted); font-size: 15px;
  display: flex; align-items: flex-end; justify-content: center;
}

/* ---------- tab bar ---------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--ink);
  padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
  display: grid; grid-template-columns: repeat(5, 1fr);
  border-top: 1px solid #3a332d;
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 64px; padding: 6px 2px;
  color: rgba(249, 246, 240, 0.78); text-decoration: none;
  font: 500 13px/1.2 var(--font-body);
}
.tabbar a svg { width: 26px; height: 26px; }
.tabbar a[aria-current="page"] { color: var(--gold); }

/* ---------- home ---------- */

.home-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.snapshot { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.snapshot .card { margin: 0; }
.snapshot .num { font-family: var(--font-head); font-size: 30px; font-weight: 600; line-height: 1.1; }

/* ---------- login ---------- */

.login {
  min-height: 100vh; min-height: 100dvh;
  background: var(--ink); color: var(--cream);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(var(--safe-top) + 24px) 24px calc(var(--safe-bottom) + 24px);
}
.login-inner { width: 100%; max-width: 360px; text-align: center; }
.login img { width: 220px; height: auto; aspect-ratio: 916 / 765; margin: 0 auto 8px; display: block; }
.login h1 { color: var(--cream); margin-bottom: 24px; }
.login .field > span { color: var(--cream); text-align: left; }
.login .input { text-align: center; font-size: 24px; letter-spacing: 0.3em; }
.login .error {
  background: var(--cream); color: var(--oxblood); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: var(--gap); font-weight: 500; text-align: left;
}
.login .error:empty { display: none; }

/* ---------- boot / full-page message ---------- */

.boot { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--ink); }
.boot img { width: 120px; height: auto; opacity: 0.9; }

/* ---------- forms and editors (milestone 3) ---------- */

.form-actions {
  position: sticky; z-index: 10;
  bottom: calc(64px + var(--safe-bottom));
  margin: 24px calc(-1 * var(--gap)) 0; padding: 12px var(--gap);
  background: linear-gradient(to bottom, rgba(249, 246, 240, 0.85), var(--cream) 30%);
  display: grid; gap: 10px;
}
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: var(--gap); }
.toolbar .input { flex: 1; }
.toolbar .btn { flex: none; }
.row-actions { display: flex; gap: 6px; flex: none; }
.list-row.button-row { width: 100%; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }
.list-row .title-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.list-row .amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted-row { opacity: 0.6; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }

.line-editor { display: grid; gap: 12px; }
.line-card { background: var(--panel); border-radius: var(--radius); padding: 12px; display: grid; gap: 10px; }
.line-card .line-bottom { display: flex; gap: 8px; align-items: center; }
.line-card .line-bottom .money { flex: 0 1 140px; min-width: 96px; }
.line-card .line-bottom .grow { flex: 1; }
.line-card .dollar { font-weight: 500; color: var(--muted); margin-right: -2px; }
.line-total { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 4px 0; border-top: 2px solid var(--ink); margin-top: 4px; }
.line-total .amount { font-family: var(--font-head); font-size: 28px; font-weight: 600; }

.contact-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 10px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stats .card { margin: 0; padding: 12px; }
.stats .num { font-family: var(--font-head); font-size: 24px; font-weight: 600; line-height: 1.15; }
.notes { white-space: pre-wrap; overflow-wrap: anywhere; }
.badge-repeat { background: transparent; color: var(--ok); border-color: var(--ok); }
.badge-premium { background: var(--ink); color: var(--gold); }
.sheet h2 { margin-bottom: 16px; }
.group-label { margin-top: 24px; }

/* ---------- orders (milestone 4) ---------- */

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin: 0 calc(-1 * var(--gap)); padding-left: var(--gap); padding-right: var(--gap); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: var(--tap); padding: 0 16px; border-radius: 999px; border: 1px solid var(--field);
  background: var(--white); color: var(--ink); font: 500 16px var(--font-body); cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--cream); }

.note-warn {
  background: #FBF3DF; border: 1px solid #E6D29F; border-left: 4px solid var(--gold-text);
  border-radius: var(--radius); padding: 12px 14px; margin: 12px 0;
}
.note-warn p { margin: 0 0 8px; }
.note-warn p:last-child { margin-bottom: 0; }
.row-buttons { display: flex; flex-wrap: wrap; gap: 10px; }

.customer-chosen { display: flex; align-items: center; gap: 12px; }

.item-card { background: var(--panel); border-radius: var(--radius); padding: 14px; margin-bottom: 16px; display: grid; gap: 12px; }
.item-head { display: flex; justify-content: space-between; align-items: center; }
.item-head .label { margin: 0; }
.danger-link { color: var(--oxblood); }
.item-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item-meta .grow { flex: 1; }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper .qty-value { min-width: 36px; text-align: center; font-weight: 600; font-size: 20px; }
.order-lines { display: grid; gap: 10px; }
.order-line { background: var(--cream); border-radius: var(--radius); padding: 10px; display: grid; gap: 8px; }
.order-line .line-bottom, .discount-box .line-bottom { display: flex; align-items: center; gap: 8px; }
.order-line .line-bottom .grow, .discount-box .line-bottom .grow { flex: 1; }
.order-line .money, .discount-box .money { flex: 0 1 140px; min-width: 100px; }
.order-line .dollar, .discount-box .dollar { font-weight: 500; color: var(--muted); }
.line-tag { font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--gold-text); }
.item-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.item-total { display: flex; justify-content: space-between; align-items: baseline; border-top: 2px solid var(--ink); padding-top: 10px; font-weight: 500; }
.item-total .amount { font-family: var(--font-head); font-size: 24px; font-weight: 600; }
.item-details { border-top: 1px solid var(--line); padding-top: 12px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.spots { display: grid; gap: 10px; }
.spot-card { background: var(--cream); border-radius: var(--radius); padding: 12px; display: grid; gap: 8px; }
.spot-head { display: flex; align-items: flex-start; gap: 8px; }
.spot-head .grow { flex: 1; }
.spot-card .toggle-row { min-height: 48px; padding: 0; }
.patch-pick {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; width: 100%; min-height: var(--control); padding: 10px 14px;
  border: 1px solid var(--field); border-radius: var(--radius); background: var(--white); color: var(--ink);
  font: 400 17px var(--font-body); text-align: left; cursor: pointer;
}
.patch-pick .chev { margin-left: auto; color: var(--muted); font-size: 22px; }
.list-row.selected { background: #FBF3DF; }

.totals { display: grid; gap: 8px; }
.totals-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.totals-row.grand { border-top: 2px solid var(--ink); padding-top: 10px; font-weight: 600; }
.totals-row.grand .amount { font-family: var(--font-head); font-size: 28px; }
.discount-box { display: grid; gap: 8px; padding: 10px; background: var(--cream); border-radius: var(--radius); }
.more-options { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 12px; }
.more-options summary { min-height: var(--tap); display: flex; align-items: center; font-weight: 500; cursor: pointer; color: var(--gold-text); }

.item-view { display: grid; gap: 8px; }
.line-list, .spot-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.line-list li { display: flex; justify-content: space-between; gap: 12px; font-size: 16px; }
.details-view p { margin: 4px 0; }

/* ---------- order page (milestone 6) ---------- */

.form-actions.two { grid-template-columns: 1fr 1fr; }
.big-toggle .segmented button { min-height: 56px; font-size: 19px; }
.progress-card { display: grid; gap: 6px; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.check {
  width: 100%; display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 4px;
  background: none; border: 0; border-radius: var(--radius); color: var(--ink); font: 400 17px/1.3 var(--font-body);
  text-align: left; cursor: pointer;
}
.check .grow { flex: 1; display: grid; }
.check .box {
  flex: none; width: 32px; height: 32px; border-radius: 8px; border: 2px solid var(--ink); background: var(--white);
  display: inline-flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; color: var(--cream);
}
.check.done .box { background: var(--ok); border-color: var(--ok); }
.check.done .grow > span:first-child { color: var(--muted); }
.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--line); display: grid; gap: 12px; }
.timeline li { position: relative; }
.timeline li::before { content: ''; position: absolute; left: -23px; top: 7px; width: 12px; height: 12px; border-radius: 50%; background: var(--gold-text); }
.danger-row { color: var(--oxblood); }
.struck { text-decoration: line-through; color: var(--muted); }
.error-text { color: var(--oxblood); font-weight: 500; margin: 0 0 8px; }
.error-text:empty { display: none; }
.item-buttons .btn { font-size: 17px; padding: 0 10px; line-height: 1.2; }

/* "Update ready" banner (shown instead of reloading while editing) */
.update-banner {
  position: fixed; left: 12px; right: 12px; z-index: 95;
  bottom: calc(76px + var(--safe-bottom));
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  background: var(--ink); color: var(--cream); border-radius: var(--radius); padding: 10px 12px 10px 16px;
  box-shadow: 0 6px 24px rgba(32, 28, 25, 0.3);
}
.update-banner .btn { min-height: var(--tap); padding: 0 16px; flex: none; }

/* ---------- home dashboard, photos (milestone 7) ---------- */

.needs-group + .needs-group { margin-top: 16px; }
.needs-title { font: 600 17px var(--font-body); margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.needs-title .count { background: var(--ink); color: var(--cream); border-radius: 999px; font-size: 13px; padding: 1px 9px; }
.stat-card { color: inherit; text-decoration: none; display: block; }
.stat-card .num { font-size: 26px; }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.photo-thumb { aspect-ratio: 1; padding: 0; border: 0; border-radius: var(--radius); overflow: hidden; background: var(--panel); cursor: pointer; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-full-wrap { min-height: 120px; display: flex; align-items: center; justify-content: center; }
.photo-full { width: 100%; height: auto; border-radius: var(--radius); }
.patch-photo-wrap { margin-bottom: 8px; }
.patch-photo { max-width: 160px; max-height: 160px; border-radius: var(--radius); display: block; }
.app-main:focus { outline: none; }

/* ---------- profit tracking (costs, time, Profit screen) ---------- */
.row-button { width: 100%; border: 0; background: transparent; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.row-button:active { background: rgba(32, 28, 25, 0.05); }
.section h3.needs-title { margin-top: 20px; }
.profit-card .totals-row, .profit-hero .totals-row { padding: 3px 0; }
.profit-card .totals-row.grand, .profit-hero .totals-row.grand { margin-top: 6px; }
.profit-card .totals-row.grand .amount { font-size: 24px; }
.totals-row.strong { font-weight: 600; }
.amount.loss, .profit-big.loss { color: var(--oxblood); }
.profit-hero .label { margin-bottom: 2px; }
.profit-big { font-family: var(--font-head); font-size: 44px; font-weight: 600; line-height: 1.1; font-variant-numeric: lining-nums tabular-nums; }
.per-hour { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line); }
.period-picker .segmented button { font-size: 15px; padding: 0 4px; }
.cat-bar { height: 6px; background: var(--line); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.cat-bar span { display: block; height: 100%; background: var(--gold-text); border-radius: 3px; }
.cost-qty-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cost-qty-row .input { max-width: none !important; }
.hours-row { display: flex; align-items: center; gap: 8px; }
.hours-row .input { width: 84px; text-align: center; }
.quick-times { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.quick-times .btn { min-height: var(--tap); padding: 0 12px; font-size: 16px; }
.totals-row .amount { white-space: nowrap; }
.totals-row > span:first-child { min-width: 0; }
.period-picker { margin-bottom: 16px; }
