/* LTV Asset Checkout — app layout (brand tokens live in theme.css) */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--green-600); }

/* =====================================================================
   APP SHELL — sidebar + main column
   ===================================================================== */
.app-shell { display: flex; min-height: 100vh; }

/* ---- Sidebar (persistent on desktop, drawer on mobile) ---- */
.sidebar {
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--green-800) 0%, var(--green-900) 100%);
  color: rgba(255, 255, 255, 0.92);
  border-right: 1px solid rgba(0, 0, 0, 0.15);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 1.15rem 1.15rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.brand-mark {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  background: var(--ils-gold);
  color: var(--ils-black);
  font-family: 'Montserrat', sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-title { font-family: 'Montserrat', sans-serif; font-weight: 700; font-size: 1.05rem; color: #fff; }
.brand-sub { font-size: 0.72rem; letter-spacing: 0.04em; text-transform: uppercase; color: rgba(255, 255, 255, 0.6); }

/* nav (JS relies on `nav.tabs button[data-tab]`) */
nav.tabs {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.85rem 0.7rem;
  overflow-y: auto;
  flex: 1 1 auto;
}
nav.tabs button {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0.7rem 0.8rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  color: rgba(255, 255, 255, 0.78);
  border-radius: 9px;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
nav.tabs button .ico { flex: 0 0 auto; width: 19px; height: 19px; opacity: 0.9; }
nav.tabs button:hover { background: rgba(255, 255, 255, 0.09); color: #fff; }
nav.tabs button.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--ils-gold);
}
nav.tabs button.active .ico { opacity: 1; color: var(--ils-gold); }
nav.tabs button:focus-visible { outline: none; box-shadow: var(--ring); }

/* sidebar footer — signed-in user */
.sidebar-foot {
  padding: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.user {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}
.avatar {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.user-meta #userName {
  color: #fff; font-weight: 600; font-size: 0.85rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-meta a { color: var(--ils-gold); text-decoration: none; font-size: 0.78rem; }
.user-meta a:hover { text-decoration: underline; }

.sidebar-scrim { display: none; }

/* ---- Main column ---- */
.main-col { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

/* mobile top bar (hidden on desktop) */
.topbar {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  background: var(--green-800);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 3px solid var(--ils-gold);
}
.menu-btn {
  flex: 0 0 auto;
  display: grid; place-items: center;
  width: 40px; height: 40px;
  background: rgba(255, 255, 255, 0.12);
  border: none; border-radius: 9px;
  color: #fff; cursor: pointer;
  padding: 0;
}
.menu-btn svg { width: 22px; height: 22px; }
.topbar-title { margin: 0; font-size: 1.1rem; color: #fff; font-weight: 700; }

main { flex: 1 1 auto; max-width: 1120px; width: 100%; margin: 0 auto; padding: 1.75rem 1.75rem 3rem; }
.panel { display: none; animation: fade 0.2s ease; }
.panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.page-head { margin-bottom: 1.4rem; }
.page-head h2 { margin: 0 0 0.2rem; color: var(--ils-green); font-size: 1.5rem; }
.page-head p { margin: 0; color: var(--text-muted); font-size: 0.9rem; }

/* =====================================================================
   CARDS
   ===================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.4rem 1.5rem;
  margin-bottom: 1.25rem;
}
.card > h2 { margin-top: 0; margin-bottom: 0.35rem; color: var(--ils-green); font-size: 1.15rem; }
.card > .muted { margin-top: 0; }

/* =====================================================================
   FORMS
   ===================================================================== */
label { display: block; font-weight: 600; font-size: 0.82rem; color: #33403a; margin: 0.9rem 0 0.3rem; }
input, select, textarea {
  width: 100%;
  padding: 0.62rem 0.7rem;
  font: inherit;
  font-size: 16px; /* keeps iOS from zooming on focus */
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:hover, select:hover, textarea:hover { border-color: #b9bdb9; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green-600);
  box-shadow: var(--ring);
}
textarea { min-height: 78px; resize: vertical; }
select { appearance: none; -webkit-appearance: none; background-image:
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b746e' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.7rem center; padding-right: 2rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.1rem; }
@media (max-width: 620px) { .row { grid-template-columns: 1fr; } }

/* =====================================================================
   BUTTONS
   ===================================================================== */
button.primary {
  margin-top: 1.2rem;
  padding: 0.72rem 1.5rem;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  color: var(--ils-black);
  background: var(--ils-gold);
  border: none;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: filter 0.15s, transform 0.05s, box-shadow 0.15s;
}
button.primary:hover { filter: brightness(0.96); box-shadow: var(--shadow); }
button.primary:active { transform: translateY(1px); }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
button.primary:focus-visible { outline: none; box-shadow: var(--ring); }

button.link {
  background: none; border: none; color: var(--green-600);
  font: inherit; font-weight: 600; cursor: pointer; padding: 0; text-decoration: underline;
}
button.link:hover { color: var(--green-800); }

/* small pill action button used in tables */
button.btn-sm {
  font: inherit; font-weight: 600; font-size: 0.82rem;
  padding: 0.35rem 0.75rem; cursor: pointer;
  color: var(--ils-green); background: var(--gold-soft);
  border: 1px solid #f0e2ad; border-radius: 999px;
  white-space: nowrap;
}
button.btn-sm:hover { background: #ffefc0; }

/* =====================================================================
   TABLES  (reflow to stacked cards on mobile)
   ===================================================================== */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead th {
  position: sticky; top: 0;
  background: var(--surface-2); color: #4a534d;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700;
  text-align: left; padding: 0.65rem 0.7rem; border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody td { text-align: left; padding: 0.7rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }

/* inline-editable inventory cells */
td.edit { cursor: pointer; position: relative; }
td.edit:hover { background: var(--gold-soft); box-shadow: inset 0 0 0 1px var(--ils-gold); }
td.edit:focus { outline: none; box-shadow: inset 0 0 0 2px var(--ils-gold); }
td.edit:empty::after { content: '—'; color: var(--text-faint); }
.cell-edit { width: 100%; min-width: 5rem; font: inherit; font-size: 15px; padding: 0.3rem 0.4rem;
  border: 1px solid var(--ils-gold); border-radius: 5px; box-sizing: border-box; background: #fff; }

/* =====================================================================
   BADGES / STATUS PILLS
   ===================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.22rem 0.6rem; border-radius: 999px;
  font-size: 0.74rem; font-weight: 700; letter-spacing: 0.01em; white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.badge.ils { background: var(--ok-bg); color: var(--ok); }
.badge.out { background: var(--warn-bg); color: var(--warn); }
.badge.overdue { background: var(--danger-bg); color: var(--danger); }
.badge.returned { background: #ececec; color: #5a5a5a; }

/* =====================================================================
   ASSET PICKER (checkbox lists)
   ===================================================================== */
.asset-picker {
  max-height: 260px; overflow-y: auto;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 0.35rem; background: var(--surface-2);
}
.asset-picker label {
  display: flex; align-items: center; gap: 0.6rem;
  font-weight: 500; font-size: 0.9rem; margin: 0;
  padding: 0.55rem 0.6rem; border-radius: 7px; cursor: pointer;
}
.asset-picker label:hover { background: #fff; }
.asset-picker input[type=checkbox] { width: 18px; height: 18px; flex: 0 0 auto; accent-color: var(--ils-green); }

/* =====================================================================
   TOAST
   ===================================================================== */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%) translateY(1rem);
  padding: 0.8rem 1.3rem; border-radius: 10px; color: #fff; font-weight: 600; font-size: 0.9rem;
  opacity: 0; transition: opacity 0.25s, transform 0.25s; pointer-events: none; z-index: 90;
  max-width: 90vw; box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: var(--ils-green); }
.toast.err { background: var(--danger); }

.muted { color: var(--text-muted); font-size: 0.88rem; }
.empty { padding: 2rem 1rem; text-align: center; color: var(--text-faint); }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 0.05rem 0.35rem; font-size: 0.85em; }

/* =====================================================================
   DASHBOARD STAT TILES
   ===================================================================== */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
@media (max-width: 760px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.1rem 1.25rem;
  position: relative; overflow: hidden;
}
.stat-tile::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--ils-green);
}
.stat-tile .stat-num { font-family: 'Montserrat', sans-serif; font-size: 2.1rem; font-weight: 800; color: var(--text); line-height: 1.05; }
.stat-tile .stat-label { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-top: 0.25rem; font-weight: 600; }
.stat-tile.good::before { background: var(--ok); }
.stat-tile.critical { background: #fef6f5; border-color: #f3d3d0; }
.stat-tile.critical::before { background: var(--danger); }
.stat-tile.critical .stat-num { color: var(--danger); }

/* =====================================================================
   RESPONSIVE  — drawer + stacked-card tables
   ===================================================================== */
@media (max-width: 900px) {
  .topbar { display: flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100dvh; z-index: 70;
    transform: translateX(-100%); transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .sidebar-scrim {
    display: block; position: fixed; inset: 0; z-index: 65;
    background: rgba(0, 0, 0, 0.45);
  }
  main { padding: 1.15rem 1.1rem 3rem; }
  .page-head h2 { font-size: 1.3rem; }
}

@media (max-width: 720px) {
  /* turn every data table into a stack of labeled cards */
  .table-wrap { overflow: visible; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tbody tr {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    margin-bottom: 0.85rem;
    padding: 0.4rem 0.9rem;
    background: var(--surface);
  }
  tbody tr:hover { background: var(--surface); }
  tbody td {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 0.5rem 0; border-bottom: 1px solid var(--border); text-align: right;
  }
  tbody tr td:last-child { border-bottom: none; }
  tbody td::before {
    content: attr(data-label);
    font-weight: 700; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.03em;
    color: var(--text-muted); text-align: left; flex: 0 0 auto;
  }
  tbody td[data-label=""]::before, tbody td:not([data-label])::before { content: none; }
  tbody td.actioncell { justify-content: flex-end; }
  td.edit { justify-content: space-between; }
  td.edit:empty::after { content: 'Tap to add'; color: var(--text-faint); font-size: 0.85rem; }
  .cell-edit { max-width: 60%; }
  td.empty { text-align: center; display: block; }
  td.empty::before { content: none; }
}

/* =====================================================================
   Avery 5195 label sheet (print only)
   Label 1.75in x 0.666in, 4 across x 15 down, top/bottom margin 0.505in,
   left/right margin 0.3075in, column gap 0.295in, rows contiguous.
   ===================================================================== */
#labelSheet { display: none; }
.label-sheet-inner {
  padding: 0.505in 0.3075in;
  display: grid;
  grid-template-columns: repeat(4, 1.75in);
  column-gap: 0.295in;
  row-gap: 0;
  grid-auto-rows: 0.666in;
}
.label-cell {
  width: 1.75in; height: 0.666in;
  display: flex; align-items: center; box-sizing: border-box;
  padding: 0.03in 0.04in; overflow: hidden;
}
.label-cell.empty { visibility: hidden; }
.label-cell img.qr { width: 0.52in; height: 0.52in; flex: 0 0 auto; }
.label-text { margin-left: 0.06in; min-width: 0; line-height: 1.15; }
.label-text .l1 { font-size: 6pt; font-weight: 700; text-transform: uppercase; letter-spacing: 0.2px; }
.label-text .l2 { font-size: 6.5pt; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label-text .l3 { font-size: 7pt; font-weight: 700; font-family: 'Courier New', monospace; }

@media print {
  .app-shell, .toast { display: none !important; }
  #labelSheet { display: block; }
  body { background: #fff; }
  @page { size: 8.5in 11in; margin: 0; }
}
