/* ============================================================
   EnviroIT Dashboard — Brand Design System
   Single source of truth. Edit here, every page reflects.
   ============================================================ */

/* ── 1. Brand Palette (CSS custom properties) ───────────────── */

:root {
  /* Core greens */
  --green-primary:   #0F9D3E;
  --green-hover:     #2ECC71;
  --green-mint:      #4CD27D;
  --green-dark:      #1E7F3F;
  --green-pale:      #7ED9A6;

  /* Neutrals */
  --white:           #FFFFFF;
  --bg:              #F5F6F7;
  --bg-offset:       #FAFBFC;
  --border:          #E2E6EA;
  --border-muted:    #C9D1D9;
  --metal:           #B8B8B8;

  /* Text hierarchy */
  --heading:         #111111;
  --body:            #222222;
  --text-secondary:  #3A3A3A;
  --text-muted:      #5C5C5C;
  --text-soft:       #777777;

  /* Sidebar */
  --sidebar-bg:       #2B2B2B;
  --sidebar-text:     #B8B8B8;
  --sidebar-hover:    #3A3A3A;
  --sidebar-active-bg:#0F9D3E;

  /* Laptop metallics */
  --laptop-dark:     #4A4A4A;
  --laptop-mid:      #666666;
  --laptop-light:    #8A8A8A;

  /* Semantic */
  --danger:          #DC2626;
  --warn:            #D97706;
  --info:            #2563EB;

  /* Spacing / decoration */
  --radius:          8px;
  --radius-sm:       6px;
  --shadow:          0 1px 2px rgba(16,24,40,0.04);
  --shadow-hover:    0 2px 8px rgba(16,24,40,0.08);
  --transition:      150ms ease;
}


/* ── 2. Reset & Base ──────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: auto;
  line-height: 1.5;
}


/* ── 3. Layout Grid ───────────────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.content {
  padding: 24px;
  flex: 1;
  min-width: 0;
}


/* ── 4. Sidebar ───────────────────────────────────────────── */

.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 18px 12px;
  position: relative;
  z-index: 100;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  color: var(--white);
  padding: 0 8px 16px;
  border-bottom: 1px solid var(--sidebar-hover);
  margin-bottom: 14px;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 2px;
  border-left: 3px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.sidebar nav a:hover {
  background: var(--sidebar-hover);
  color: var(--white);
  border-left-color: var(--sidebar-hover);
}

.sidebar nav a.active {
  background: var(--sidebar-active-bg);
  color: var(--white);
  border-left-color: var(--green-dark);
  font-weight: 500;
}

.sidebar nav a.nav-sub {
  margin-left: 8px;
  padding-left: 16px;
  font-size: 13px;
}

.sidebar .badge--count {
  background: var(--green-primary);
  color: var(--white);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
  margin-left: auto;
}

.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--heading);
  font-size: 22px;
  cursor: pointer;
  padding: 8px 12px;
}


/* ── 5. Topbar ────────────────────────────────────────────── */

.topbar {
  height: 56px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}

.topbar .who {
  font-size: 13px;
  color: var(--text-muted);
}

.topbar .who strong {
  color: var(--heading);
}

.topbar .logout-btn {
  background: transparent;
  border: 1px solid var(--green-primary);
  color: var(--green-primary);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}

.topbar .logout-btn:hover {
  background: var(--green-primary);
  color: var(--white);
}


/* ── 6. Typography ────────────────────────────────────────── */

h1 {
  margin: 0 0 18px;
  font-size: 24px;
  font-weight: 700;
  color: var(--heading);
}

h2 {
  font-size: 17px;
  font-weight: 600;
  color: var(--heading);
  margin: 24px 0 10px;
}
h2:first-child, .panel h2:first-child, h2.no-margin { margin-top: 0; }

h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--body);
}

.text-muted  { color: var(--text-muted); }
.text-soft   { color: var(--text-soft); }
.text-center { text-align: center; }
.serial {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 12px;
  color: var(--text-muted);
}


/* ── 7. Buttons ───────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-muted);
  background: var(--white);
  color: var(--body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  line-height: 1.4;
}

.btn:hover {
  background: var(--bg);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0); }
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(15, 157, 62, 0.25);
}

.btn.primary {
  background: var(--green-primary);
  color: var(--white);
  border-color: var(--green-primary);
}
.btn.primary:hover {
  background: var(--green-dark);
  border-color: var(--green-dark);
}

.btn.danger {
  color: var(--danger);
  border-color: #FCA5A5;
  background: var(--white);
}
.btn.danger:hover {
  background: #FEF2F2;
  border-color: var(--danger);
}

.btn.ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn.ghost:hover {
  background: var(--bg);
  color: var(--body);
}

.btn.accent {
  background: var(--green-hover);
  color: var(--white);
  border-color: var(--green-hover);
}
.btn.accent:hover {
  background: var(--green-primary);
  border-color: var(--green-primary);
}

.btn:disabled, .btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-sm {
  min-height: 30px;
  padding: 5px 12px;
  font-size: 12px;
}


/* ── 8. Cards / Panels ────────────────────────────────────── */

.panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}

.panel:hover {
  box-shadow: var(--shadow-hover);
}

.stat {
  background: var(--white);
  border: 1px solid var(--border);
  border-top: 3px solid var(--green-primary);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}

.stat:hover {
  box-shadow: var(--shadow-hover);
}

.stat .label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--heading);
  margin-top: 4px;
}

.stat .value a {
  color: var(--danger);
  text-decoration: none;
}
.stat .value a:hover { text-decoration: underline; }


/* ── 9. Tables ────────────────────────────────────────────── */

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--body);
}

th {
  background: var(--bg);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

tr:last-child td { border-bottom: none; }

tr:nth-child(even) td { background: #FAFAFA; }

tbody tr:hover td { background: #F9F9F9; }

td a { color: var(--info); text-decoration: none; }
td a:hover { text-decoration: underline; }


/* ── 10. Badges ───────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge.admin         { background: #FEE2E2; color: #991B1B; }
.badge.manager       { background: #EDE9FE; color: #5B21B6; }
.badge.technician    { background: #DBEAFE; color: #1E40AF; }
.badge.intern        { background: #F3F4F6; color: #374151; }
.badge.active        { background: #D1FAE5; color: #065F46; }
.badge.inactive      { background: #F3F4F6; color: #6B7280; }

.badge.intake           { background: #7ED9A6; color: #1E7F3F; }
.badge.diagnosed        { background: #DBEAFE; color: #1E40AF; }
.badge.awaiting_parts   { background: #FEF3C7; color: #92400E; }
.badge.in_repair        { background: #EDE9FE; color: #5B21B6; }
.badge.testing          { background: #E0E7FF; color: #3730A3; }
.badge.complete         { background: #D1FAE5; color: #065F46; }
.badge.beyond_repair    { background: #FEE2E2; color: #991B1B; }
.badge.disposed         { background: #F3F4F6; color: #6B7280; }

.badge.auto_matched     { background: #D1FAE5; color: #065F46; }
.badge.serial_mismatch  { background: #FEE2E2; color: #991B1B; }
.badge.no_serial        { background: #FEF3C7; color: #92400E; }
.badge.accepted         { background: #D1FAE5; color: #065F46; }
.badge.manually_mapped  { background: #DBEAFE; color: #1E40AF; }
.badge.rejected         { background: #F3F4F6; color: #6B7280; }


/* ── 11. Forms ────────────────────────────────────────────── */

form.stacked { max-width: 480px; }
.form--wide { max-width: 760px; }

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--body);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  box-sizing: border-box;
}

textarea { min-height: 70px; resize: vertical; }

::placeholder { color: var(--text-soft); }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green-primary);
  box-shadow: 0 0 0 3px rgba(15, 157, 62, 0.15);
}

input[type="checkbox"] {
  accent-color: var(--green-primary);
  width: 16px;
  height: 16px;
  margin-right: 6px;
  vertical-align: middle;
}

.field label input[type="checkbox"] {
  display: inline;
  width: auto;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235C5C5C' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}

input.error, select.error, textarea.error,
.field input.error, .field select.error, .field textarea.error {
  border-color: var(--danger);
  background: #FEF2F2;
}
input.error:focus, select.error:focus, textarea.error:focus {
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

.errors, .field .errors {
  color: var(--danger);
  font-size: 13px;
  margin-top: 4px;
}

.form-errors {
  padding: 10px 14px;
  background: #FEF2F2;
  border: 1px solid #FCA5A5;
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 14px;
}

.helptext {
  color: var(--text-soft);
  font-size: 12px;
  margin-top: 4px;
}

input:disabled, select:disabled, textarea:disabled {
  background: var(--bg);
  color: var(--text-muted);
  cursor: not-allowed;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}


/* ── 12. Messages / Alerts ────────────────────────────────── */

.messages { margin-bottom: 14px; }

.msg {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 14px;
  border: 1px solid transparent;
}

.msg.success  { background: #7ED9A6; color: #1E7F3F; border-color: var(--green-primary); }
.msg.error    { background: #FEE2E2; color: #991B1B; border-color: var(--danger); }
.msg.warning  { background: #FEF3C7; color: #92400E; border-color: var(--warn); }
.msg.info     { background: #DBEAFE; color: #1E40AF; border-color: var(--info); }
.msg.debug    { background: #F3F4F6; color: #6B7280; border-color: var(--border-muted); }


/* ── 13. Toolbar & Filters ────────────────────────────────── */

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.toolbar form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 0;
}

.toolbar .spacer { flex: 1; }

.toolbar label {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar select {
  width: auto;
  min-width: 120px;
}

.toolbar input[type="text"],
.toolbar input[type="search"] {
  width: auto;
  min-width: 200px;
}


/* ── 14. Utility Layout Classes ───────────────────────────── */

.grid { display: grid; gap: 14px; }

.grid.stats {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.row { display: flex; gap: 6px; }

.breakdown {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.breakdown .row {
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.breakdown .row:last-child { border-bottom: none; }

.breakdown .row span { color: var(--text-muted); }
.breakdown .row strong { color: var(--body); font-weight: 600; }

.spacer { flex: 1; }

.mt-14 { margin-top: 14px; }
.mt-18 { margin-top: 18px; }
.mb-14 { margin-bottom: 14px; }


/* ── 15. Tabs ─────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 10px 14px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  font-family: inherit;
  transition: color var(--transition), border-color var(--transition);
}

.tab-btn:hover { color: var(--heading); }

.tab-btn.active {
  color: var(--heading);
  border-bottom-color: var(--green-primary);
  font-weight: 600;
}

.tab { display: none; }
.tab.active { display: block; }


/* ── 16. Pagination ───────────────────────────────────────── */

.pagination {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 14px;
}


/* ── 17. Detail Header ────────────────────────────────────── */

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
  gap: 14px;
  flex-wrap: wrap;
}

.detail-header h1 { margin-bottom: 4px; }

.detail-header .meta {
  color: var(--text-muted);
  font-size: 14px;
}

.detail-header .serial-line {
  color: var(--text-muted);
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  margin-top: 2px;
}

.detail-header .actions { text-align: right; }


/* ── 18. Pre / Code / Details ─────────────────────────────── */

pre {
  overflow: auto;
  max-height: 300px;
  background: #F9FAFB;
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

details summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
}


/* ── 19. Login Page ───────────────────────────────────────── */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-card {
  width: 380px;
  background: var(--white);
  border: 1px solid var(--border);
  border-top: 3px solid var(--green-primary);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: var(--shadow);
}

.login-card .logo {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--green-primary);
  margin-bottom: 24px;
}

.login-card .field { margin-bottom: 16px; }

.login-card .field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.login-card .field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  box-sizing: border-box;
}

.login-card .field input:focus {
  outline: none;
  border-color: var(--green-primary);
  box-shadow: 0 0 0 3px rgba(15, 157, 62, 0.15);
}

.login-card button[type="submit"] {
  width: 100%;
  padding: 11px;
  background: var(--green-primary);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}

.login-card button[type="submit"]:hover {
  background: var(--green-dark);
  transform: translateY(-1px);
}

.login-card button[type="submit"]:active { transform: translateY(0); }

.login-card .form-errors {
  font-size: 13px;
  padding: 10px 14px;
  background: #FEF2F2;
  border: 1px solid #FCA5A5;
  border-radius: var(--radius-sm);
  color: var(--danger);
  margin-bottom: 14px;
}

.login-card .errors { color: var(--danger); font-size: 13px; margin-top: 4px; }


/* ── 20. Responsive Breakpoints ──────────────────────────── */

@media (max-width: 1024px) {
  .layout { grid-template-columns: 56px 1fr; }
  .sidebar { padding: 18px 8px; }
  .sidebar .brand { display: none; }
  .sidebar nav a {
    justify-content: center;
    padding: 10px 6px;
    font-size: 0;
    gap: 0;
  }

  .sidebar .badge--count { display: none; }
}

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    display: none;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 240px;
    z-index: 200;
    box-shadow: 4px 0 20px rgba(0,0,0,0.25);
  }
  body.sidebar--open .sidebar { display: block; }
  body.sidebar--open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 199;
  }
  .hamburger { display: block; }
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .grid.stats { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 16px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar form { flex-direction: column; align-items: stretch; }
  .toolbar input[type="text"],
  .toolbar input[type="search"],
  .toolbar select { width: 100%; min-width: 0; }
}

@media (max-width: 400px) {
  .grid.stats { grid-template-columns: 1fr; }
  .panel { overflow-x: auto; }
  table { min-width: 600px; }
  .login-card { width: 100%; margin: 0 16px; }
}

/* ── Kanban Repair Board ────────────────────────────────────── */

.kanban {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 14px;
  min-height: calc(100vh - 180px);
}

.kanban-column {
  flex: 0 0 260px;
  min-width: 260px;
  background: var(--bg-offset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
}

.kanban-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  position: sticky;
  top: 0;
  background: inherit;
  border-bottom: 1px solid var(--border);
}

.kanban-count {
  background: var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  border-radius: 10px;
  padding: 1px 8px;
}

.kanban-cards {
  flex: 1;
  padding: 0 8px 8px;
  min-height: 60px;
}

.kanban-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: grab;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition);
  user-select: none;
}

.kanban-card:hover {
  box-shadow: var(--shadow-hover);
}

.kanban-card:active {
  cursor: grabbing;
}

.kanban-card .card-sku {
  font-size: 13px;
  font-weight: 600;
}

.kanban-card .card-sku a {
  color: var(--heading);
  text-decoration: none;
}

.kanban-card .card-sku a:hover {
  color: var(--info);
}

.kanban-card .card-make {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.kanban-card .card-faults {
  font-size: 11px;
  color: var(--danger);
  margin-top: 4px;
  line-height: 1.3;
}

.kanban-card .card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-soft);
}

.kanban-card .card-swollen {
  font-size: 14px;
  cursor: help;
}

.kanban-empty {
  padding: 16px 8px;
  text-align: center;
  color: var(--text-soft);
  font-size: 12px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
}

.kanban-card.sortable-chosen {
  opacity: 0.7;
}

.kanban-card.sortable-ghost {
  opacity: 0.3;
  border-style: dashed;
}

/* Per-status border tints removed — all columns use the default grey
   border from .kanban-column; status colouring stays on the .badge inside
   the header instead. */

.kanban-card .card-days.days-warn     { color: var(--warn); font-weight: 600; }
.kanban-card .card-days.days-critical { color: var(--danger); font-weight: 700; }

.msg.error {
  background: var(--danger);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
}

.kanban-filter-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.filter-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 4px;
  white-space: nowrap;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  cursor: pointer;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  user-select: none;
  transition: background var(--transition), border-color var(--transition);
}

.filter-chip:hover { background: var(--bg); }

.filter-chip input[type="checkbox"],
.filter-chip input[type="radio"] {
  margin: 0;
  width: 12px;
  height: 12px;
  cursor: pointer;
  accent-color: var(--green-primary);
}

.filter-segment {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  margin: 0;
  border: 0;
}

.device-filter-panel {
  padding: 10px 14px;
  margin-bottom: 18px;
}

.device-filter-toolbar {
  margin-bottom: 0;
}

.device-filter-toolbar form {
  flex: 1;
  gap: 8px;
}

.device-filter-toolbar input[type="text"] {
  max-width: 220px;
}

.empty-table-message {
  padding: 20px;
  text-align: center;
  font-style: italic;
  color: var(--text-muted);
}

/* ── Finance Dashboard ──────────────────────────────────────────── */
.finance-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.finance-header h1 { margin: 0; }

.period-selector {
  display: flex;
  gap: 8px;
  align-items: center;
}
.period-selector select {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--white);
}

.finance-kpi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.finance-kpi .card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.finance-kpi .card-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.finance-kpi .card-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--heading);
}
.finance-kpi .card-sub {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 2px;
}

.finance-positive { color: var(--green-primary); }
.finance-negative { color: var(--danger); }

.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
@media (max-width: 900px) {
  .panel-grid { grid-template-columns: 1fr; }
}

.panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.panel h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--heading);
}

.sales-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.sales-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.sales-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.sales-table tr:hover td { background: var(--bg); }
.sales-table .total-row td { font-weight: 600; border-top: 2px solid var(--border); }

.stock-snapshot {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 24px;
}

.text-muted { color: var(--text-muted); font-size: 13px; }

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}
.filter-row input[type="text"],
.filter-row select {
  width: auto;
  flex: 0 1 220px;
}

tr.low-stock { background: #FFF5F5; }
tr.low-stock td:first-child { border-left: 3px solid var(--danger); }

.status-draft  { background: #F3F4F6; color: #6B7280; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.status-sent   { background: #DBEAFE; color: #1E40AF; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.status-paid   { background: #D1FAE5; color: #065F46; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.status-void   { background: #FEE2E2; color: #991B1B; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }

.invoice-section {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.invoice-section-header {
  background: var(--bg);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--heading);
  border-bottom: 1px solid var(--border);
}
.invoice-section-subtotal {
  text-align: right;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}
.invoice-total-row {
  display: flex;
  justify-content: flex-end;
  padding: 14px 0;
  font-size: 20px;
  font-weight: 700;
  border-top: 3px double var(--border);
  margin-top: 8px;
}
.invoice-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
.invoice-meta .bill-to { font-size: 14px; line-height: 1.5; }
.invoice-meta .dates { text-align: right; font-size: 13px; color: var(--text-muted); line-height: 1.6; }
.invoice-device-bar {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 20px;
  font-size: 13px;
}
.invoice-device-bar a { color: var(--info); text-decoration: none; }

.pagination {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-muted);
}
.pagination a { color: var(--info); text-decoration: none; }

/* ── Lifecycle rail ─────────────────────────────────────────────── */
.lifecycle-rail {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 8px 0 14px;
  padding: 14px 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}
.lifecycle-rail .rail-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  min-width: 78px;
  position: relative;
}
.lifecycle-rail .rail-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: #E5E7EB;
  color: #6B7280;
  border: 2px solid #E5E7EB;
}
.lifecycle-rail .rail-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: center;
  font-weight: 600;
}
.lifecycle-rail .rail-step.rail-done .rail-dot {
  background: var(--green-primary);
  color: white;
  border-color: var(--green-primary);
}
.lifecycle-rail .rail-step.rail-done .rail-label { color: var(--text-secondary); }
.lifecycle-rail .rail-step.rail-current .rail-dot {
  background: var(--white);
  color: var(--green-primary);
  border-color: var(--green-primary);
  box-shadow: 0 0 0 4px rgba(15, 157, 62, 0.15);
}
.lifecycle-rail .rail-step.rail-current .rail-label {
  color: var(--green-primary);
  font-weight: 700;
}
.lifecycle-rail .rail-connector {
  flex: 1 1 auto;
  height: 2px;
  background: #E5E7EB;
  min-width: 18px;
  align-self: flex-start;
  margin-top: 14px;
}
.lifecycle-rail .rail-connector.rail-done { background: var(--green-primary); }
.lifecycle-rail.lifecycle-disposal .rail-step.rail-current .rail-dot {
  color: var(--danger);
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12);
}
.lifecycle-rail.lifecycle-disposal .rail-step.rail-current .rail-label {
  color: var(--danger);
}
.lifecycle-rail.lifecycle-disposal .rail-step.rail-done .rail-dot {
  background: var(--danger);
  border-color: var(--danger);
}

/* ── Next-action panel ─────────────────────────────────────────── */
.next-action {
  margin-bottom: 14px;
  border-left: 4px solid var(--green-primary);
}
.next-action.next-action-beyond_repair,
.next-action.next-action-disposed { border-left-color: var(--danger); }
.next-action.next-action-sold { border-left-color: #16A34A; }
.next-action-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.next-action-header h2 {
  font-size: 16px;
}
.next-action-hint {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 6px 0 12px;
}
.next-action .action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.next-action .danger-row { margin-top: 14px; }
.next-action .danger-row .btn.danger {
  border-color: var(--danger);
  color: var(--danger);
}
.next-action .action-modal {
  margin-top: 10px;
  padding: 12px;
  background: var(--bg);
  border: 1px dashed var(--border-muted);
  border-radius: var(--radius-sm);
}
.next-action .action-modal label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.next-action .action-modal textarea,
.next-action .action-modal input[type="text"] {
  width: 100%;
  margin-bottom: 8px;
}

/* ── Sold summary tile inside next-action ───────────────────────── */
.sold-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 10px 0;
}
.sold-summary > div { display: flex; flex-direction: column; gap: 2px; }
.sold-summary .meta-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}
.sold-summary strong { font-size: 14px; }

/* ── Admin status fallback (collapsed) ──────────────────────────── */
.admin-status-fallback summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  user-select: none;
}
.admin-status-fallback summary:hover { color: var(--text-secondary); }

/* ── Sold badge ────────────────────────────────────────────────── */
.badge.sold {
  background: #D1FAE5;
  color: #065F46;
}

/* ── Mark-as-paid preview ──────────────────────────────────────── */
.paid-preview {
  margin: 18px 0 8px;
  border-left: 4px solid var(--green-primary);
  background: #F0FDF4;
}
.paid-preview h3 { margin-top: 0; }
.paid-preview-list { margin: 0; padding-left: 18px; }
.paid-preview-list li { margin-bottom: 8px; }
.paid-preview-list ul { margin: 4px 0 0; padding-left: 18px; font-size: 13px; }

.paid-confirmed {
  background: #F0FDF4;
  border-color: #86EFAC;
  margin-top: 24px;
}

.populate-toast {
  background: #DBEAFE;
  color: #1E40AF;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 8px;
  animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.line-empty-state td {
  background: #F9FAFB;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 18px;
}

#source-device-filter {
  margin-bottom: 6px;
}

.parts-needed-box {
  margin: 12px 0;
  padding: 12px;
  background: #F9FAFB;
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
}
.parts-needed-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.parts-needed-header h3 {
  margin: 0;
  font-size: 14px;
}
.parts-needed-table {
  margin-bottom: 10px;
}
.parts-needed-add summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--green-primary);
}
.parts-needed-add form {
  margin-top: 10px;
}

/* Quick-add inventory part panel, revealed inline under the picker */
.quick-add-toggle {
  margin-top: 6px;
}
.quick-add-toggle .btn {
  font-size: 12px;
  padding: 4px 10px;
}
.quick-add-inventory {
  border: 1px dashed var(--border-muted);
  border-radius: var(--radius-sm);
  background: #FAFAF8;
  padding: 12px 14px;
  margin: 12px 0;
}
.quick-add-inventory legend {
  font-size: 12px;
  font-weight: 700;
  color: var(--green-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 6px;
}
.quick-add-inventory .helptext {
  margin: 0 0 10px;
}
#requirement-part-filter {
  margin-bottom: 6px;
}
.empty-guidance {
  color: var(--text-muted);
  font-size: 13px;
  margin: 4px 0 10px;
}
.blocked-action {
  background: #FFF7ED;
  border: 1px solid #FED7AA;
  border-radius: 8px;
  color: #9A3412;
  display: inline-block;
  font-weight: 700;
  padding: 10px 12px;
}
.stock-ok {
  color: #15803D;
  font-weight: 600;
}
.stock-low {
  color: #B45309;
  font-weight: 600;
}

/* ── Device attachments ──────────────────────────────────────── */
.attachment-upload-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.attachment-upload-row .upload-label { cursor: pointer; }
.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 6px;
}
.attachment-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.attachment-card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}
.attachment-pdf {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  height: 140px;
  background: var(--bg-offset);
  border: 0;
  border-radius: 4px;
  text-decoration: none;
  color: var(--body);
  cursor: zoom-in;
  transition: background 0.15s ease, transform 0.15s ease;
}
.attachment-pdf:hover {
  background: #eef0f3;
  transform: translateY(-1px);
}
.attachment-pdf:focus-visible {
  outline: 2px solid var(--green-primary);
  outline-offset: 2px;
}
.attachment-pdf-icon {
  background: var(--danger);
  color: var(--white);
  font-weight: 700;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}
.attachment-pdf-name {
  font-size: 11px;
  color: var(--text-muted);
  word-break: break-all;
  margin-top: 8px;
  padding: 0 8px;
}
.attachment-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Parts picker (repair-log + harvest) ─────────────────────── */
.parts-picker-wrapper {
  background: var(--bg-offset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
}
.parts-picker-search {
  display: flex;
  gap: 8px;
  align-items: stretch;
  flex-wrap: wrap;
}
.parts-picker-search input[type="search"] {
  flex: 1 1 240px;
  min-width: 200px;
}
.parts-picker-search select {
  flex: 1 1 100%;
  font-family: inherit;
  font-size: 13px;
}
.parts-picker-search button { align-self: flex-start; }

/* ── Pending diagnostics polish ──────────────────────────────── */
.pending-summary {
  display: flex;
  gap: 10px;
  margin: 6px 0 12px;
  flex-wrap: wrap;
}
.pending-summary .count-badge {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--bg-offset);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.row-unresolved { background: rgba(217, 119, 6, 0.05); }
.row-unresolved:hover { background: rgba(217, 119, 6, 0.10); }

.diagnostic-action-card {
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--white);
}
.diagnostic-action-card.match-ok {
  background: #f0fdf4;
  border-color: #bbf7d0;
}
.diagnostic-action-card.match-warn {
  background: #fffbeb;
  border-color: #fde68a;
}

/* ── Pending diagnostic status badges (fallback colours) ─────── */
.badge.auto_matched { background: #dcfce7; color: #166534; }
.badge.serial_mismatch { background: #fef3c7; color: #92400e; }
.badge.no_serial { background: #fee2e2; color: #991b1b; }
.badge.accepted { background: #dcfce7; color: #166534; }
.badge.manually_mapped { background: #dbeafe; color: #1e40af; }
.badge.rejected { background: #f3f4f6; color: #374151; }

/* ── UI refresh: calmer operational layout ───────────────────── */
.content {
  width: 100%;
  max-width: 1540px;
  margin: 0 auto;
  padding: 28px 32px 40px;
}

.page-shell {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
}

.device-page {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel {
  box-shadow: none;
}

.panel:hover {
  box-shadow: none;
}

.detail-header {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 0;
}

.detail-header .actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  text-align: right;
}

.detail-header .actions .btn,
.detail-header .actions form {
  margin-top: 0 !important;
}

.inline-upload {
  display: inline-flex;
}

.upload-action {
  border: 1px dashed var(--green-primary);
  color: var(--green-dark);
  font-weight: 600;
}

.upload-action:hover {
  border-color: var(--green-dark);
  background: #EAF7EF;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.96);
  padding: 5px;
  margin-bottom: 0;
  backdrop-filter: blur(8px);
}

.tab-btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  min-height: 34px;
  font-size: 13px;
}

.tab-btn.active {
  background: #EAF7EF;
  border-color: #B7E4C7;
  color: var(--green-dark);
  border-bottom-color: #B7E4C7;
}

.repair-work-panel {
  margin-top: 10px;
}

.field-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.field-heading label {
  margin-bottom: 0;
}

.repair-parts-field {
  margin-top: 16px;
}

.parts-picker-wrapper {
  display: grid;
  grid-template-columns: minmax(300px, 0.95fr) minmax(420px, 1.25fr);
  gap: 14px;
  align-items: start;
  background: #F7F9FA;
  border-color: var(--border);
  padding: 14px;
}

.parts-picker-browser,
.selected-parts-panel {
  min-width: 0;
}

.parts-picker-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 10px;
}

.parts-picker-toolbar input[type="search"] {
  min-height: 38px;
}

.native-part-select {
  min-height: 152px;
}

.parts-picker-wrapper.is-enhanced .native-part-select {
  display: none;
}

.parts-option-list {
  display: grid;
  gap: 6px;
  max-height: 314px;
  overflow: auto;
  padding-right: 3px;
}

.part-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--body);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.part-option:hover,
.part-option:focus-visible {
  border-color: #A7D7B8;
  background: #F4FBF6;
  outline: none;
}

.part-option.is-selected {
  border-color: var(--green-primary);
  background: #EAF7EF;
  box-shadow: inset 3px 0 0 var(--green-primary);
}

.part-option-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.part-option-main strong {
  overflow: hidden;
  color: var(--heading);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.part-option-main span,
.part-option-stock,
.part-option-cost {
  color: var(--text-muted);
  font-size: 12px;
}

.part-option-stock {
  white-space: nowrap;
}

.part-option-cost {
  min-width: 62px;
  color: var(--heading);
  font-weight: 700;
  text-align: right;
}

.selected-parts-panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.selected-parts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  background: #FBFCFD;
}

.selected-parts-header h3 {
  margin: 0;
  font-size: 13px;
}

.selected-parts-header strong {
  font-size: 15px;
  color: var(--green-dark);
}

.repair-parts-table th:nth-child(2),
.repair-parts-table td:nth-child(2) {
  width: 76px;
}

.repair-parts-table th:nth-child(n+3),
.repair-parts-table td:nth-child(n+3) {
  width: 86px;
  white-space: nowrap;
}

.repair-parts-table input.part-qty {
  min-height: 32px;
  padding: 5px 8px;
}

.empty-selection {
  padding: 13px 12px;
  color: var(--text-muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
  background: #FBFCFD;
}

.btn.icon {
  width: 30px;
  height: 30px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

@media (max-width: 980px) {
  .parts-picker-wrapper {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 800px) {
  .content {
    padding: 16px;
  }

  .detail-header {
    padding: 14px;
  }

  .detail-header .actions {
    justify-content: flex-start;
    text-align: left;
  }

  .tabs {
    position: static;
  }
}

@media (max-width: 620px) {
  .parts-picker-toolbar {
    grid-template-columns: 1fr;
  }

  .part-option {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .part-option-stock {
    grid-column: 1;
  }

  .part-option-cost {
    grid-column: 2;
    grid-row: 1 / span 2;
  }
}

/* ── Attachment thumbnails (button-shaped, click → lightbox) ───── */
.attachment-thumb {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  border-radius: 4px;
  overflow: hidden;
}
.attachment-thumb:focus-visible {
  outline: 2px solid var(--green-primary);
  outline-offset: 2px;
}
.attachment-thumb img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
  transition: transform 0.18s ease;
}
.attachment-thumb:hover img { transform: scale(1.03); }

/* ── Image lightbox (full-screen viewer) ──────────────────────── */
body.lightbox-open { overflow: hidden; }
.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  animation: lightbox-fade 0.15s ease-out;
}
/* Has to come AFTER the .image-lightbox block above so it wins the
   specificity tie and the lightbox stays hidden until JS opens it. */
.image-lightbox[hidden] { display: none !important; }
@keyframes lightbox-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.image-lightbox__toolbar {
  position: absolute;
  top: 16px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 1;
}
.image-lightbox__open-new {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.10);
  transition: background 0.15s ease;
}
.image-lightbox__open-new:hover {
  background: rgba(255, 255, 255, 0.20);
  color: #fff;
}
.image-lightbox__close {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.15s ease;
}
.image-lightbox__close:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: scale(1.05);
}
.image-lightbox__close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
.image-lightbox__figure {
  margin: 0;
  max-width: min(100%, 1400px);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.image-lightbox__img,
.image-lightbox__frame {
  max-width: 100%;
  max-height: calc(100vh - 120px);
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  background: #1a1a1a;
}
.image-lightbox__img { object-fit: contain; }
.image-lightbox__frame {
  /* PDF preview needs intrinsic dimensions — iframes don't auto-size to
     content. Use 90% of viewport so the controls bar stays visible. */
  width: min(100%, 1100px);
  height: calc(100vh - 120px);
  border: 0;
  display: block;
}
.image-lightbox__img[hidden],
.image-lightbox__frame[hidden] { display: none; }
/* In PDF mode the figure should expand to give the iframe its width. */
.image-lightbox--pdf .image-lightbox__figure { width: min(100%, 1100px); }
.image-lightbox__caption {
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  text-align: center;
  max-width: 100%;
  word-break: break-word;
  padding: 0 8px;
}
.image-lightbox__caption:empty { display: none; }

/* ── QR Code modal ──────────────────────────────────────────── */
.qr-modal {
  width: min(360px, calc(100vw - 32px));
  border: 0;
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0,0,0,0.22);
}

.qr-modal::backdrop {
  background: rgba(17,24,39,0.46);
  backdrop-filter: blur(2px);
}

.qr-modal h3 {
  margin: 0 0 14px;
  font-size: 1rem;
}

.qr-modal img {
  display: block;
  width: 240px;
  height: 240px;
  margin: 0 auto 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
}

.qr-modal__url {
  margin-bottom: 14px;
  color: var(--text-muted);
  font-size: 0.8rem;
  word-break: break-all;
}

.qr-modal__actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

#qr-download { text-decoration: none; }

/* ── Public QR device page ─────────────────────────────────── */
.public-device-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 28px 16px 44px;
  background: var(--bg);
}

.public-device-page .device-card {
  margin-bottom: 14px;
}

.public-header {
  text-align: center;
  margin-bottom: 22px;
}

.public-header h1 {
  margin: 10px 0 4px;
  font-size: clamp(1.45rem, 5vw, 2rem);
  line-height: 1.15;
}

.public-header .sku {
  color: var(--text-muted);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.85rem;
}

.sold-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 4px 12px;
  border: 1px solid #B7E4C7;
  border-radius: 999px;
  background: #EAF7EF;
  color: var(--green-dark);
  font-size: 0.8rem;
  font-weight: 700;
}

.public-footer {
  margin-top: 22px;
  text-align: center;
  color: var(--text-soft);
  font-size: 0.78rem;
}

.public-footer p {
  margin: 4px 0;
}
