/* Flow Fuel — account dashboard */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue-700: #1d4ed8; --blue-600: #2563eb; --blue-500: #3b82f6; --blue-400: #60a5fa;
  --blue-50: #eff6ff; --silver-50: #f8fafc; --silver-200: #e2e8f0; --silver-300: #cbd5e1;
  --silver-400: #94a3b8; --silver-500: #64748b; --ink: #0f172a; --ink-2: #475569;
}

body { font-family: 'Inter', system-ui, sans-serif; background: var(--silver-50); color: var(--ink); line-height: 1.6; }
html, body { max-width: 100%; overflow-x: hidden; }

/* Top nav */
.acct-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: #fff; border-bottom: 1px solid var(--silver-200);
  position: sticky; top: 0; z-index: 10;
}
.acct-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.acct-logo img { height: 42px; display: block; }
.acct-logo-text { font-size: 1.15rem; font-weight: 800; color: var(--ink); letter-spacing: -.02em; }
.acct-nav-right { display: flex; align-items: center; gap: 16px; }
.acct-hi { font-weight: 600; color: var(--ink-2); font-size: 0.95rem; }
.acct-admin-link { color: var(--blue-600); font-weight: 600; text-decoration: none; font-size: 0.9rem; }
.acct-admin-link:hover { text-decoration: underline; }
.acct-signout {
  background: var(--silver-50); border: 1px solid var(--silver-300); color: var(--ink-2);
  border-radius: 8px; padding: 8px 16px; font-family: inherit; font-weight: 600; font-size: 0.85rem; cursor: pointer;
}
.acct-signout:hover { background: var(--silver-200); }

/* Layout */
.acct-main { max-width: 1120px; margin: 0 auto; padding: 32px 24px 80px; }

.acct-layout { display: grid; grid-template-columns: 300px 1fr; gap: 24px; align-items: start; }
/* Grid/flex children refuse to shrink below their content width unless told —
   without this, long addresses in dropdowns push panels off-screen on mobile */
.acct-layout > *, .acct-sidebar > *, .acct-content > *, .panel { min-width: 0; }
.acct-sidebar { display: flex; flex-direction: column; gap: 20px; position: sticky; top: 84px; }
.acct-content { display: flex; flex-direction: column; gap: 24px; }

@media (max-width: 900px) {
  .acct-layout { grid-template-columns: 1fr; }
  .acct-sidebar { position: static; }
}

.sidebar-user { display: flex; align-items: center; gap: 12px; padding: 4px; }
.sidebar-avatar {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--blue-600), var(--blue-700)); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.05rem;
}
.sidebar-user-info { min-width: 0; }
.sidebar-name { font-weight: 800; font-size: 1rem; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-email { font-size: 0.8rem; color: var(--silver-500); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.panel { background: #fff; border: 1px solid var(--silver-200); border-radius: 18px; padding: 28px; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.panel--primary { border: 2px solid var(--blue-500); box-shadow: 0 8px 32px rgba(37,99,235,.12); }
.panel h2 { font-size: 1.25rem; font-weight: 800; letter-spacing: -.01em; margin-bottom: 4px; }
.panel-sub { color: var(--silver-500); font-size: 0.9rem; margin-bottom: 20px; }

/* Fields */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 0.72rem; font-weight: 600; color: var(--silver-500); text-transform: uppercase; letter-spacing: .05em; }
.field input, .field select, .field textarea {
  background: #fff; border: 1.5px solid var(--silver-300); border-radius: 8px; padding: 11px 13px;
  font-family: inherit; font-size: 0.95rem; color: var(--ink); outline: none; transition: border .2s; width: 100%;
  min-width: 0; max-width: 100%;
}
.field select { text-overflow: ellipsis; }
.field { min-width: 0; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue-500); }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible { outline: 2px solid var(--blue-400); outline-offset: 1px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* Buttons */
.btn-primary {
  width: 100%; background: linear-gradient(135deg, var(--blue-600), var(--blue-700)); color: #fff;
  border: none; border-radius: 10px; padding: 14px; font-family: inherit; font-size: 1rem; font-weight: 700;
  cursor: pointer; box-shadow: 0 8px 24px rgba(29,78,216,.3); transition: all .2s; margin-top: 4px;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 32px rgba(29,78,216,.4); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.btn-outline {
  background: #fff; border: 1.5px solid var(--blue-500); color: var(--blue-700); border-radius: 9px;
  padding: 10px 18px; font-family: inherit; font-weight: 600; font-size: 0.9rem; cursor: pointer; transition: all .2s;
}
.btn-outline:hover { background: var(--blue-50); }

.note { font-size: 0.8rem; color: var(--silver-500); text-align: center; margin-top: 12px; }
.hint { font-size: 0.78rem; color: var(--silver-500); }

/* Item lists (addresses, vehicles) */
.item-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.item {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 13px 16px; background: var(--silver-50); border: 1px solid var(--silver-200); border-radius: 10px;
}
.item-info { min-width: 0; }
.item-title { font-weight: 700; font-size: 0.92rem; }
.item-desc { color: var(--silver-500); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-tag {
  display: inline-block; margin-top: 6px; font-size: 0.68rem; font-weight: 700;
  background: var(--blue-50); color: var(--blue-700); padding: 2px 9px; border-radius: 100px;
}
.item-notes { margin-top: 5px; font-size: 0.78rem; color: var(--silver-500); font-style: italic; line-height: 1.4; overflow-wrap: break-word; }
.item-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.item-remove {
  background: none; border: none; color: #ef4444; cursor: pointer; font-weight: 600; font-size: 0.82rem;
  padding: 6px 10px; border-radius: 6px; flex-shrink: 0;
}
.item-remove:hover { background: rgba(239,68,68,.08); }
.item-edit {
  background: none; border: none; color: var(--blue-600); cursor: pointer; font-weight: 600; font-size: 0.82rem;
  padding: 6px 10px; border-radius: 6px; flex-shrink: 0;
}
.item-edit:hover { background: var(--blue-50); }
.btn-cancel-edit {
  background: none; border: none; color: var(--silver-500); cursor: pointer; font-weight: 600;
  font-size: 0.85rem; padding: 10px 14px; margin-left: 6px; font-family: inherit;
}
.btn-cancel-edit:hover { color: var(--ink); text-decoration: underline; }

/* Invoices */
.item-total { font-weight: 800; font-size: 0.95rem; color: var(--blue-700); margin-top: 4px; }
.invoice-chip {
  font-size: 0.68rem; font-weight: 700; padding: 3px 10px; border-radius: 100px; white-space: nowrap;
}
.invoice-chip--unpaid { background: var(--blue-50); color: var(--blue-700); border: 1px solid #bfdbfe; }
.invoice-chip--paid { background: var(--blue-600); color: #fff; font-weight: 800; }
.btn-pay {
  background: var(--blue-600); color: #fff; border: none; border-radius: 8px;
  padding: 7px 14px; font-family: inherit; font-weight: 700; font-size: 0.8rem; cursor: pointer;
}
.btn-pay:hover { background: var(--blue-700); }
.empty { color: var(--silver-400); font-size: 0.9rem; font-style: italic; padding: 4px 0 16px; }

.add-form { border-top: 1px dashed var(--silver-300); padding-top: 18px; }

/* Order form — asset checklist (batch fueling).
   Rules are scoped under .asset-checklist so they outrank the generic
   `.field input`/`.field select` styling (this list lives inside a .field). */
.asset-checklist { display: flex; flex-direction: column; gap: 8px; }
.asset-checklist .asset-pick {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1.5px solid var(--silver-200); border-radius: 10px;
  background: var(--silver-50); transition: border .15s, background .15s;
}
.asset-checklist .asset-pick.on { border-color: var(--blue-500); background: var(--blue-50); }
.asset-checklist .asset-main {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; cursor: pointer;
  text-transform: none; letter-spacing: 0; font-weight: 700; font-size: 0.9rem; color: var(--ink);
}
.asset-checklist .asset-check {
  width: 18px; height: 18px; flex: 0 0 auto; margin: 0; padding: 0;
  accent-color: var(--blue-600); cursor: pointer;
}
.asset-checklist .asset-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-checklist .asset-tank { font-weight: 600; font-size: 0.72rem; color: var(--silver-500); }
.asset-checklist .asset-fuel {
  flex: 0 0 auto; width: auto; max-width: 46%; background: #fff; border: 1.4px solid var(--silver-300);
  border-radius: 8px; padding: 8px 9px; font-family: inherit; font-size: 0.8rem; color: var(--ink);
  outline: none; min-width: 0;
}
.asset-checklist .asset-fuel:focus { border-color: var(--blue-500); }
.asset-count { margin-top: 8px; font-weight: 700; color: var(--blue-700); }

/* Fuel-amount tier picker — three selectable range cards on the request form. */
.fuel-tiers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.fuel-tier {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 14px 8px; border: 1.5px solid var(--silver-200); border-radius: 12px;
  background: var(--silver-50); cursor: pointer; font-family: inherit;
  transition: border .15s, background .15s, box-shadow .15s;
}
.fuel-tier:hover { border-color: var(--blue-400); }
.fuel-tier.is-active {
  border-color: var(--blue-500); background: var(--blue-50);
  box-shadow: 0 2px 10px rgba(37,99,235,.12);
}
.fuel-tier-amt { font-weight: 800; font-size: 1.05rem; color: var(--ink); line-height: 1.1; }
.fuel-tier.is-active .fuel-tier-amt { color: var(--blue-700); }
.fuel-tier-unit { font-size: 0.72rem; font-weight: 600; color: var(--silver-500); text-transform: uppercase; letter-spacing: .04em; }

/* Messages */
.msg { border-radius: 10px; padding: 12px 15px; font-size: 0.88rem; margin-bottom: 16px; display: none; }
.msg.error   { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.msg.success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }

.save-flash { color: #15803d; font-weight: 600; font-size: 0.85rem; margin-left: 12px; }
.hidden { display: none !important; }

/* Mandatory phone gate */
.phone-gate {
  position: fixed; inset: 0; z-index: 50; background: rgba(15,23,42,.6);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.phone-gate-card {
  background: #fff; border-radius: 20px; padding: 36px; max-width: 420px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.phone-gate-card h1 { font-size: 1.4rem; font-weight: 800; letter-spacing: -.01em; margin-bottom: 8px; }
.phone-gate-card .panel-sub { margin-bottom: 22px; }

@media (max-width: 640px) {
  .grid2 { grid-template-columns: 1fr; }
  .acct-main { padding: 20px 14px 60px; }
  .acct-layout { gap: 16px; }
  .acct-sidebar { gap: 16px; }
  .acct-content { gap: 16px; }
  .panel { padding: 20px 16px; border-radius: 14px; }
}

/* Narrow phones: the top bar can't fit logo + wordmark + greeting + sign-out.
   The greeting is redundant (name is in the sidebar), so drop it first. */
@media (max-width: 560px) {
  .acct-nav { padding: 12px 16px; }
  .acct-hi { display: none; }
  .acct-logo-text { font-size: 1.05rem; }
}

/* =====================================================================
   Native app only: bottom tab bar (account.html as the Capacitor shell).
   Every rule below is scoped under body.is-native-tabs, a class only
   mobile/tabs.js ever adds — the website (no such class) is unaffected.
   ===================================================================== */

/* On the website the wrappers must be layout-invisible: the sidebar/content
   columns space their children via flex gap, which only reaches direct
   children — display:contents keeps the original layout byte-for-byte. */
.tab-view { display: contents; }
body.is-native-tabs .tab-view { display: none; }
body.is-native-tabs .tab-view.tab-view--active { display: flex; flex-direction: column; gap: 20px; }

body.is-native-tabs .acct-layout { display: block; }
body.is-native-tabs .acct-sidebar { position: static; }
body.is-native-tabs .acct-main { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
body.is-native-tabs .acct-admin-link { display: none; }

/* App-only brand-blue backdrop (the approved mockup): gradient behind
   everything, white cards on top. Painted on a fixed pseudo-element because
   background-attachment:fixed is unreliable in mobile WebViews. */
body.is-native-tabs { background: #1d4ed8; }
body.is-native-tabs::before {
  content: ''; position: fixed; inset: 0; z-index: -1;
  background: linear-gradient(160deg, #1d4ed8 0%, #2563eb 55%, #3b82f6 100%);
}
body.is-native-tabs .acct-nav {
  background: linear-gradient(160deg, #1d4ed8, #2563eb);
  border-bottom: 1px solid rgba(255,255,255,.18);
}
body.is-native-tabs .acct-logo-text { color: #fff; }
body.is-native-tabs .acct-hi { color: rgba(255,255,255,.85); }
body.is-native-tabs .acct-signout {
  background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.3); color: #fff;
}
body.is-native-tabs .sidebar-avatar { background: #fff; color: var(--blue-700); }
body.is-native-tabs .sidebar-name { color: #fff; }
body.is-native-tabs .sidebar-email { color: rgba(255,255,255,.75); }
/* Text that sits directly on the blue backdrop (not inside a white card) */
body.is-native-tabs .sort-wrap label { color: rgba(255,255,255,.8); }
body.is-native-tabs .orders-empty,
body.is-native-tabs .orders-loading { color: rgba(255,255,255,.85); }

body.is-native-tabs .tab-bar {
  display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: #fff; border-top: 1px solid var(--silver-200);
  padding: 7px 4px calc(7px + env(safe-area-inset-bottom));
  justify-content: space-around;
}
.tab-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: none; color: var(--silver-500); font-family: inherit;
  font-size: 0.66rem; font-weight: 700; padding: 5px 2px; cursor: pointer;
}
.tab-icon { font-size: 1.2rem; line-height: 1; }
.tab-btn.active { color: var(--blue-600); }

/* Orders tab (ported from orders.html) */
.orders-main { max-width: 900px; margin: 0 auto; padding: 8px 4px 0; }
.orders-controls {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 20px;
}
.status-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.status-tab {
  background: #fff; border: 1.5px solid var(--silver-300); color: var(--ink-2);
  border-radius: 100px; padding: 7px 16px; font-family: inherit; font-weight: 600;
  font-size: 0.85rem; cursor: pointer; transition: all .15s;
}
.status-tab:hover { border-color: var(--blue-400); }
.status-tab.active { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }
.sort-wrap { display: flex; align-items: center; gap: 8px; }
.sort-wrap label { font-size: 0.78rem; font-weight: 600; color: var(--silver-500); text-transform: uppercase; letter-spacing: .05em; }
.sort-wrap select {
  background: #fff; border: 1.5px solid var(--silver-300); border-radius: 8px;
  padding: 8px 12px; font-family: inherit; font-size: 0.88rem; color: var(--ink); outline: none;
}

.order-card { margin-bottom: 14px; padding: 20px 22px; }
.order-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.order-who { min-width: 0; }
.order-name { font-weight: 800; font-size: 1.02rem; }
.order-contact { font-size: 0.82rem; color: var(--silver-500); overflow-wrap: break-word; }
.order-contact a { color: var(--blue-600); text-decoration: none; }
.order-contact a:hover { text-decoration: underline; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 100px;
  padding: 4px 13px; font-size: 0.75rem; font-weight: 700; white-space: nowrap;
}
.chip-new       { background: var(--blue-50);  color: var(--blue-700); border: 1px solid #bfdbfe; }
.chip-completed { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.chip-invoiced  { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.chip-paid      { background: var(--blue-600); color: #fff; border: 1px solid var(--blue-700); font-weight: 800; }

.order-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px 20px; margin: 14px 0;
  padding: 14px 16px; background: var(--silver-50); border: 1px solid var(--silver-200); border-radius: 10px;
}
.order-field-label { font-size: 0.68rem; font-weight: 700; color: var(--silver-400); text-transform: uppercase; letter-spacing: .05em; }
.order-field-value { font-size: 0.9rem; font-weight: 600; overflow-wrap: break-word; }
.order-field-value.urgent { color: #b91c1c; }
.order-notes { font-size: 0.82rem; color: var(--silver-500); font-style: italic; margin-top: -6px; margin-bottom: 12px; overflow-wrap: break-word; }

.order-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.order-actions .btn-primary { width: auto; padding: 10px 20px; font-size: 0.9rem; margin-top: 0; }
.link-action {
  background: none; border: none; color: var(--silver-500); cursor: pointer;
  font-family: inherit; font-weight: 600; font-size: 0.82rem; padding: 6px 4px;
}
.link-action:hover { color: var(--ink); text-decoration: underline; }
.invoice-ref { font-size: 0.82rem; color: var(--silver-500); font-family: monospace; }

.orders-empty { text-align: center; color: var(--silver-400); padding: 48px 0; font-style: italic; }
.orders-loading { text-align: center; color: var(--silver-500); padding: 48px 0; }
.refresh-btn { margin-left: 8px; }

/* Send Invoice tab: total preview (light theme, re-themed from invoice.html) */
.total-preview {
  background: var(--blue-50); border: 1px solid #bfdbfe; border-radius: 10px;
  padding: 14px 16px; display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.total-preview span { font-size: 0.85rem; color: var(--blue-700); }
.total-preview strong { font-size: 1.25rem; color: var(--blue-700); font-weight: 800; }
.line-row { margin-bottom: 16px; }
