/* ==========================================================================
   EIMS — Electronics Inventory Management System
   Dark theme stylesheet for Flask web app
   ========================================================================== */

:root {
  --bg: #0f172a;
  --bg-elevated: #1e293b;
  --bg-input: #0f172a;
  --border: #334155;
  --border-input: #475569;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: #1e3a5f;
  --link: #60a5fa;
  --success: #22c55e;
  --success-bg: #14532d;
  --success-text: #bbf7d0;
  --error: #ef4444;
  --error-bg: #7f1d1d;
  --error-text: #fecaca;
  --warning: #fb923c;
  --warning-bg: #7c2d12;
  --warning-text: #fed7aa;
  --sidebar-width: 240px;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-pill: 999px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  --transition: 0.15s ease;
}

/* --------------------------------------------------------------------------
   Reset & base
   -------------------------------------------------------------------------- */

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: #93c5fd;
}

h1, h2, h3, h4 {
  margin: 0 0 0.5em;
  font-weight: 700;
  line-height: 1.25;
}

h2 {
  font-size: 1.75rem;
}

h3 {
  font-size: 1.05rem;
}

p {
  margin: 0 0 1em;
}

code {
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, monospace;
  font-size: 0.9em;
  padding: 2px 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: #93c5fd;
}

strong {
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Layout — sidebar + main
   -------------------------------------------------------------------------- */

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
}

.sidebar h1 {
  font-size: 1.35rem;
  margin: 0 0 24px 8px;
  letter-spacing: -0.02em;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  margin-bottom: 24px;
  padding: 4px 8px;
}

.brand:hover {
  color: var(--text);
}

.brand-logo {
  width: 36px;
  height: 36px;
  max-width: 36px;
  max-height: 36px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.brand-name {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-center {
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.auth-brand {
  margin-bottom: 8px;
}

.auth-brand .brand-logo {
  width: 72px;
  height: 72px;
  max-width: 72px;
  max-height: 72px;
  margin-bottom: 8px;
}

.auth-brand .brand-name {
  font-size: 1.5rem;
}

.section-tagline {
  text-align: center;
  margin: 0 0 20px;
  font-size: 0.9rem;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 32px 40px;
  overflow-x: hidden;
}

.logout {
  margin-top: auto;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.logout p {
  margin: 0 0 8px;
  color: var(--text-muted);
  font-size: 13px;
}

/* --------------------------------------------------------------------------
   Navigation
   -------------------------------------------------------------------------- */

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav a {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14px;
  transition: background var(--transition), color var(--transition);
}

.nav a:hover {
  background: #334155;
  color: var(--text);
}

.nav a.active {
  background: #334155;
  color: var(--text);
  font-weight: 600;
}

/* Low stock alert in sidebar nav */
.nav a.nav-alert-yes {
  color: #fca5a5 !important;
  font-weight: 600;
}

.nav a.nav-alert-yes:hover,
.nav a.nav-alert-yes.active {
  background: rgba(239, 68, 68, 0.15);
  color: #fecaca !important;
}

.nav a.nav-alert-no {
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.card h3 {
  margin: 0 0 12px;
  font-size: 17px;
  color: var(--text);
}

.card:last-child {
  margin-bottom: 0;
}

/* Excel import/export section */
.excel-card {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--bg-elevated) 0%, rgba(59, 130, 246, 0.06) 100%);
}

.excel-path {
  margin-top: 8px;
}

.excel-path code {
  display: inline-block;
  margin-top: 6px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: #93c5fd;
  word-break: break-all;
}

.excel-path-note {
  color: var(--text-muted);
  font-size: 13px;
  margin: 8px 0 0;
}

.activity-log-card .log-table-wrap {
  max-height: 320px;
}

.activity-log-card .log-table-wrap.activity-log-page-wrap {
  max-height: calc(100vh - 420px);
  min-height: 360px;
}

.parts-given-filter-row {
  border-top: 1px solid var(--card-border, #334155);
  margin-top: 4px;
  padding-top: 4px;
}

.part-history-log-wrap {
  max-height: calc(100vh - 480px);
  min-height: 280px;
}

/* --------------------------------------------------------------------------
   Dashboard stat cards
   -------------------------------------------------------------------------- */

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

.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color var(--transition), transform var(--transition);
}

.stat .value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}

.stat .label {
  color: var(--text-muted);
  margin-top: 6px;
  font-size: 13px;
  font-weight: 500;
}

.stat-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.stat-link:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.stat-link:hover .value,
.stat-link:hover .label {
  color: inherit;
}

.stat-alert {
  border-color: var(--error) !important;
  background: linear-gradient(135deg, var(--bg-elevated) 0%, rgba(239, 68, 68, 0.08) 100%);
}

.stat-alert .value {
  color: var(--error);
}

.stat-alert .label {
  color: #fca5a5;
}

/* Low stock dashboard banner */
.notify-banner {
  display: block;
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--error-bg);
  border: 1px solid var(--error);
  border-radius: var(--radius);
  color: var(--error-text);
  font-weight: 600;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}

.notify-banner:hover {
  background: #991b1b;
  color: #fff;
}

/* --------------------------------------------------------------------------
   Dashboard detail panels
   -------------------------------------------------------------------------- */

.dashboard-panels {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 20px;
  margin-top: 24px;
  align-items: start;
}

.dashboard-main-stack,
.dashboard-side-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.dashboard-panel.card {
  padding: 0;
  margin-bottom: 0;
  overflow: hidden;
}

.dashboard-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.dashboard-panel-header h3 {
  margin: 0;
  font-size: 1.05rem;
}

.dashboard-panel .section-note {
  padding: 12px 20px 0;
  margin: 0;
}

.dashboard-panel .empty-note {
  padding: 16px 20px 20px;
  margin: 0;
}

.dashboard-log-wrap {
  max-height: 360px;
}

.dashboard-panel .log-table-wrap {
  border: none;
  border-radius: 0;
  border-top: none;
  max-height: none;
}

.dashboard-panel .dashboard-log-wrap {
  max-height: 360px;
}

.dashboard-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
}

.dashboard-table th,
.dashboard-table td {
  padding: 10px 20px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: top;
}

.dashboard-table.compact th,
.dashboard-table.compact td {
  padding: 8px 16px;
}

.dashboard-table th {
  background: var(--bg);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

.dashboard-part-name {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-muted {
  color: var(--text-subtle);
  font-size: 12px;
}

.dashboard-row-alert {
  background: rgba(251, 146, 60, 0.08);
}

.dashboard-row-alert:hover {
  background: rgba(251, 146, 60, 0.12);
}

.stock-qty-low {
  color: var(--warning);
  font-weight: 600;
}

@media (max-width: 1100px) {
  .dashboard-panels {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

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

label.checkbox-label {
  display: flex;
  align-items: center;
  margin: 12px 0 0;
  cursor: pointer;
  color: var(--text);
  font-weight: 500;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0 8px 0 0;
  padding: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-subtle);
}

select {
  cursor: pointer;
  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='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.form-row:last-child {
  margin-bottom: 0;
}

.purpose-field {
  margin-top: 16px;
}

/* Purpose radio grid (Parts Given) */
.purpose-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.purpose-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 0;
  transition: border-color var(--transition), background var(--transition);
}

.purpose-option:hover {
  border-color: var(--border-input);
  background: #162032;
}

.purpose-option input {
  width: auto;
  margin: 0;
}

.purpose-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-block;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  text-align: center;
  line-height: 1.25;
  transition: background var(--transition), opacity var(--transition), transform var(--transition);
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-success {
  background: var(--success);
}

.btn-success:hover:not(:disabled) {
  background: #16a34a;
}

.btn-danger {
  background: var(--error);
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

.btn-secondary {
  background: #475569;
}

.btn-secondary:hover:not(:disabled) {
  background: #64748b;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1.3;
}

/* --------------------------------------------------------------------------
   Messages
   -------------------------------------------------------------------------- */

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

.msg.ok {
  background: var(--success-bg);
  border-color: rgba(34, 197, 94, 0.35);
  color: var(--success-text);
}

.msg.err {
  background: var(--error-bg);
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--error-text);
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.01em;
}

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover {
  background: rgba(51, 65, 85, 0.35);
}

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

.card > table th:first-child,
.card > div > table th:first-child {
  border-radius: var(--radius) var(--radius) 0 0;
}

/* Inventory row — double-click hint */
.inventory-row {
  cursor: pointer;
}

.inventory-row:hover td:first-child {
  color: var(--link);
}

/* Part links */
.part-link {
  color: var(--link);
  font-weight: 600;
  cursor: pointer;
}

.part-link:hover {
  text-decoration: underline;
  color: #93c5fd;
}

/* Part summary (inventory detail) */
.part-summary {
  margin-bottom: 20px;
}

.summary-label {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.summary-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

/* --------------------------------------------------------------------------
   QC status indicators
   -------------------------------------------------------------------------- */

.qc-pass {
  color: var(--success);
  font-weight: 600;
}

.qc-pending {
  color: var(--warning);
  font-weight: bold;
}

.qc-failed {
  color: #f87171;
  font-weight: bold;
}

/* --------------------------------------------------------------------------
   Activity log tables
   -------------------------------------------------------------------------- */

.log-table-wrap {
  display: block;
  overflow-x: auto;
  overflow-y: auto;
  max-height: 280px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.log-table-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.log-table-wrap::-webkit-scrollbar-thumb {
  background: var(--border-input);
  border-radius: 6px;
}

.log-table-wrap::-webkit-scrollbar-track {
  background: var(--bg);
  border-radius: 6px;
}

.log-table {
  min-width: 760px;
  margin: 0;
}

.log-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg);
  box-shadow: 0 1px 0 var(--border);
}

.log-table td {
  font-size: 14px;
}

.log-time {
  white-space: nowrap;
  color: #cbd5e1;
  font-size: 13px;
}

.log-user {
  display: block;
  font-weight: 600;
  color: var(--text);
}

.log-username {
  display: block;
  color: var(--text-subtle);
  font-size: 12px;
}

.log-detail {
  color: var(--text-muted);
  font-size: 13px;
  max-width: 280px;
}

/* Action badges */
.log-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.3;
}

.log-receive_inventory {
  background: var(--success-bg);
  color: var(--success-text);
}

.log-receive_qc_pending {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.log-qc_pass {
  background: #1e3a8a;
  color: #bfdbfe;
}

.log-qc_fail {
  background: var(--error-bg);
  color: var(--error-text);
}

.log-qty_update {
  background: #4c1d95;
  color: #ddd6fe;
}

.log-part_name_update {
  background: rgba(251, 191, 36, 0.18);
  color: #fde68a;
}

.position-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  font-size: 13px;
  letter-spacing: 0.03em;
}

.position-badge:hover {
  filter: brightness(1.08);
  color: #fff;
}

.summary-inline {
  display: inline;
  line-height: 1.45;
}

.summary-inline .icon-edit-btn {
  margin-left: 6px;
}

.icon-edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
  font-size: 13px;
  line-height: 1;
  vertical-align: middle;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.icon-edit-btn:hover {
  background: rgba(59, 130, 246, 0.22);
  border-color: var(--accent);
  color: #dbeafe;
}

.inline-edit-form {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}

.inline-edit-form.is-open {
  display: flex;
}

.inline-edit-form input {
  flex: 1 1 220px;
  min-width: 180px;
}

.log-parts_given {
  background: #713f12;
  color: #fde68a;
}

/* --------------------------------------------------------------------------
   Helper text
   -------------------------------------------------------------------------- */

.section-note,
.empty-note {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 12px;
}

.empty-note {
  font-style: italic;
  padding: 12px 0;
}

/* --------------------------------------------------------------------------
   Auth pages (login / register)
   -------------------------------------------------------------------------- */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(ellipse at top, rgba(59, 130, 246, 0.08) 0%, var(--bg) 60%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  overflow: hidden;
}

.auth-card h1 {
  margin-top: 0;
}

.auth-card form label + input {
  margin-bottom: 0;
}

.auth-card form label:not(:first-of-type) {
  margin-top: 12px;
}

.password-field-wrap {
  position: relative;
}

.password-field-wrap input {
  width: 100%;
  padding-right: 44px;
}

.password-toggle-btn {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.password-toggle-btn:hover,
.password-toggle-btn.is-active {
  color: #e2e8f0;
  background: rgba(148, 163, 184, 0.12);
}

.password-toggle-icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 16px;
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
  }

  .nav a {
    padding: 8px 10px;
    font-size: 13px;
  }

  .logout {
    margin-top: 16px;
    padding-top: 16px;
  }

  .main {
    padding: 24px 20px;
  }

  .log-table {
    min-width: 640px;
  }
}

@media (max-width: 480px) {
  h2 {
    font-size: 1.4rem;
  }

  .stat .value {
    font-size: 24px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .purpose-grid {
    grid-template-columns: 1fr 1fr;
  }

  th,
  td {
    padding: 10px 8px;
    font-size: 13px;
  }
}

/* IMS confirm popup (Parts Given) */
.ims-modal[hidden] {
  display: none !important;
}

.ims-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.ims-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.75);
}

.ims-modal-card {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  background: var(--card, #1e293b);
  border: 1px solid var(--card-border, #334155);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.ims-modal-card h3 {
  margin: 0 0 12px;
  font-size: 1.25rem;
}

.ims-modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.ims-modal-actions .btn {
  flex: 1 1 140px;
}

.qc-qms-modal-card {
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.qc-action-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.qc-serial-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 16px 0;
}

.qc-serial-row label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.qc-serial-input {
  width: 100%;
}

.qc-qms-url-block {
  margin-top: 8px;
}

.qc-qms-url-block label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.qc-url-hint {
  margin-top: 6px;
  font-size: 12px;
}

.qc-modal-error {
  margin: 12px 0;
}

a.log-badge {
  text-decoration: none;
}

a.log-badge:hover {
  filter: brightness(1.15);
}

/* Quick QC Check */
.quick-qc-dashboard-link {
  display: block;
  margin-top: 20px;
  text-decoration: none;
  color: inherit;
  border-color: var(--accent-soft);
  transition: border-color var(--transition), transform var(--transition);
}

.quick-qc-dashboard-link:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  color: inherit;
}

.quick-qc-dashboard-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}

.quick-qc-scan-card {
  max-width: 640px;
}

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

.quick-qc-input-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.quick-qc-input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
}

.quick-qc-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.quick-qc-result-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.quick-qc-scanned {
  font-family: ui-monospace, monospace;
  font-size: 14px;
  color: var(--text-muted);
  word-break: break-all;
}

.quick-qc-details {
  display: grid;
  gap: 10px;
  margin: 0 0 16px;
}

.quick-qc-details div {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px;
  align-items: baseline;
}

.quick-qc-details dt {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-subtle);
}

.quick-qc-details dd {
  margin: 0;
  font-size: 14px;
  color: var(--text);
}

.quick-qc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.quick-qc-empty {
  max-width: 640px;
  margin-top: 16px;
}

.quick-qc-desktop-note {
  display: block;
}

.quick-qc-mobile-note {
  display: none;
}

.quick-qc-camera-btn {
  display: none;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  margin: 0;
}

.quick-qc-camera-btn.is-disabled {
  pointer-events: none;
  opacity: 0.65;
}

.quick-qc-camera-photo-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.quick-qc-scan-feedback {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-input, #334155);
}

.quick-qc-scan-preview {
  display: block;
  width: 100%;
  max-width: 220px;
  max-height: 160px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-input);
  background: #0f172a;
  margin-bottom: 10px;
}

.quick-qc-scan-status {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
}

.quick-qc-scan-status.is-loading {
  color: var(--accent, #3b82f6);
}

.quick-qc-scan-status.is-error {
  color: #f87171;
}

@media (hover: none) and (pointer: coarse) {
  .quick-qc-desktop-note {
    display: none;
  }

  .quick-qc-mobile-note {
    display: block;
  }

  .quick-qc-camera-btn {
    display: inline-flex;
  }

  .quick-qc-input-row {
    flex-wrap: wrap;
    position: relative;
  }

  .quick-qc-input {
    flex: 1 1 100%;
  }
}

/* --------------------------------------------------------------------------
   Rack Locations map
   -------------------------------------------------------------------------- */

.rack-page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 16px;
}

.rack-subtitle {
  color: #94a3b8;
  margin: 6px 0 0;
}

.rack-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.rack-stat {
  background: var(--bg-elevated, #1e293b);
  border: 1px solid var(--card-border, #334155);
  border-radius: 10px;
  padding: 12px 16px;
  min-width: 90px;
  text-align: center;
}

.rack-stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent, #38bdf8);
}

.rack-stat-label {
  display: block;
  font-size: 12px;
  color: #94a3b8;
  margin-top: 2px;
}

.rack-search-card {
  margin-bottom: 16px;
}

.rack-search-label {
  display: block;
  font-size: 13px;
  color: #94a3b8;
  margin-bottom: 8px;
}

.rack-search-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.rack-search-row input {
  flex: 1;
  min-width: 220px;
}

.rack-search-results {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--card-border, #334155);
}

.rack-result-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rack-result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.55);
  border-radius: 8px;
  border: 1px solid #334155;
}

.rack-result-locate {
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  animation: rackPulseBtn 1.4s ease-in-out infinite;
}

.rack-result-none {
  color: #64748b;
  font-size: 13px;
}

.rack-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  margin-bottom: 16px;
  padding: 12px 16px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #94a3b8;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.legend-empty {
  background: #1e293b;
  border: 1px solid #475569;
}

.legend-occupied {
  background: linear-gradient(135deg, #164e63, #1e3a5f);
  border: 1px solid #0891b2;
}

.legend-active {
  background: #f59e0b;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.8);
}

.rack-floor-wrap {
  overflow-x: auto;
  padding-bottom: 8px;
}

.rack-floor-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  margin-bottom: 16px;
}

.rack-floor {
  display: flex;
  gap: 14px;
  min-width: max-content;
  padding: 8px 4px 12px;
  align-items: flex-end;
}

.rack-unit {
  flex: 0 0 118px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.rack-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding: 0 4px;
}

.rack-letter {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--accent, #38bdf8);
}

.rack-meta {
  font-size: 11px;
  color: #64748b;
}

.rack-frame {
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  border: 2px solid #334155;
  border-radius: 12px 12px 8px 8px;
  padding: 10px 8px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.25);
  min-height: 120px;
}

.rack-slots {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rack-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  min-height: 56px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: rgba(15, 23, 42, 0.8);
  color: #e2e8f0;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.rack-slot:hover {
  transform: translateY(-1px);
  border-color: #64748b;
}

.rack-slot.is-empty {
  background: rgba(15, 23, 42, 0.45);
  border-style: dashed;
}

.rack-slot.is-occupied {
  background: linear-gradient(135deg, rgba(8, 145, 178, 0.22), rgba(99, 102, 241, 0.18));
  border-color: #0891b2;
}

.rack-slot.is-multi {
  background: linear-gradient(135deg, rgba(8, 145, 178, 0.32), rgba(99, 102, 241, 0.26));
  border-color: #22d3ee;
}

.rack-slot.is-highlight {
  border-color: #f59e0b !important;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.35), 0 0 24px rgba(245, 158, 11, 0.45);
  z-index: 2;
}

.rack-slot.is-pulse {
  animation: rackSlotPulse 1.1s ease-in-out infinite;
}

.slot-code {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #94a3b8;
}

.slot-count {
  font-size: 11px;
  color: #67e8f9;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.slot-part-chips {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  margin-top: 2px;
}

.slot-chip {
  display: block;
  width: 100%;
  padding: 4px 6px;
  border-radius: 5px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(103, 232, 249, 0.25);
  font-size: 10px;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot-chip-more {
  text-align: center;
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.35);
}

.slot-empty-label {
  font-size: 12px;
  color: #475569;
  font-style: italic;
  margin-top: 8px;
}

.slot-empty-hint {
  font-size: 10px;
  color: #64748b;
}

.rack-footer {
  margin-top: 8px;
  text-align: center;
  font-size: 11px;
  color: #64748b;
}

.rack-slot-detail {
  margin-top: 16px;
}

.rack-detail-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rack-detail-item {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: rgba(15, 23, 42, 0.55);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease;
}

.rack-detail-item:hover {
  border-color: var(--accent, #38bdf8);
}

.rack-detail-item span {
  color: #94a3b8;
  font-size: 13px;
}

.rack-detail-item em {
  font-style: normal;
  font-size: 12px;
  color: #67e8f9;
}

@keyframes rackSlotPulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.35), 0 0 18px rgba(245, 158, 11, 0.35); }
  50% { box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.65), 0 0 32px rgba(245, 158, 11, 0.75); }
}

@keyframes rackPulseBtn {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

@media (max-width: 900px) {
  .rack-floor {
    gap: 10px;
  }

  .rack-unit {
    flex-basis: 100px;
  }
}
