@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #F9FAFB;
  color: #213646;
  min-height: 100vh;
}

/* Login Screen */
.login-screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: #F9FAFB;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.login-card {
  background: #FFFFFF;
  border: 1px solid #E5E7EB;
  padding: 40px;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(33,54,70,0.08), 0 1px 2px rgba(33,54,70,0.04);
}

.login-card h1 {
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
  color: #2B4C5F;
  font-weight: 700;
}

.login-card p {
  color: #6B7280;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.status-message.error {
  color: #B71C1C;
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.hidden {
  display: none !important;
}

/* Header */
header {
  background: #FFFFFF;
  border-bottom: 1px solid #E5E7EB;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 2px rgba(33,54,70,0.06);
}

header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  color: #2B4C5F;
  letter-spacing: -0.02em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.search-bar {
  flex: 1;
  max-width: 320px;
  min-width: 160px;
}

.search-bar input {
  width: 100%;
  padding: 0.5rem 0.8rem;
  border-radius: 6px;
  border: 1px solid #E5E7EB;
  background: #FFFFFF;
  color: #213646;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

.search-bar input:focus {
  border-color: #4DB8AC;
  box-shadow: 0 0 0 3px rgba(77,184,172,0.30);
}

.view-toggle {
  display: flex;
  border: 1px solid #E5E7EB;
  border-radius: 6px;
  overflow: hidden;
}

.toggle-btn {
  padding: 0.45rem 0.7rem;
  border: none;
  background: transparent;
  color: #9CA3AF;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
}

.toggle-btn.active {
  background: #4DB8AC;
  color: #FFFFFF;
}

.toggle-btn:hover:not(.active) { color: #213646; }

.btn-add {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 1px solid #4DB8AC;
  background: #4DB8AC;
  color: #FFFFFF;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s;
  font-family: inherit;
}

.btn-add:hover {
  background: #3aa99d;
  border-color: #3aa99d;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-details {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}

.user-name-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: #213646;
  white-space: nowrap;
}

.btn-signout {
  background: none;
  border: none;
  color: #9CA3AF;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s;
  font-family: inherit;
}

.btn-signout:hover { color: #B71C1C; }

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #E5E7EB;
}

/* Nav */
nav#categoryNav {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 2rem;
  background: #FFFFFF;
  border-bottom: 1px solid #E5E7EB;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
nav#categoryNav::-webkit-scrollbar { display: none; }

.nav-btn {
  padding: 0.45rem 1rem;
  white-space: nowrap;
  border-radius: 999px;
  border: 1px solid #E5E7EB;
  background: transparent;
  color: #6B7280;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.2s;
  font-family: inherit;
}

.nav-btn:hover { border-color: #4DB8AC; color: #4DB8AC; }
.nav-btn.active { background: #4DB8AC; border-color: #4DB8AC; color: #FFFFFF; }

/* Main */
main {
  padding: 1.5rem 2rem;
}

.category-section { margin-bottom: 1.5rem; }

.section-title {
  font-size: 1.2rem;
  font-weight: 600;
  padding: 0.8rem 1rem;
  background: #FFFFFF;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
  transition: background 0.2s;
  color: #2B4C5F;
  box-shadow: 0 1px 2px rgba(33,54,70,0.06);
}

.section-title:hover { background: #F3F4F6; }

.toggle-icon {
  font-size: 0.7rem;
  transition: transform 0.2s;
  display: inline-block;
}

.collapsed .toggle-icon { transform: rotate(-90deg); }

.badge {
  background: #4DB8AC;
  color: #FFFFFF;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 10px;
  margin-left: auto;
  white-space: nowrap;
}

.section-content { padding: 1rem 0; }
.section-content.hidden { display: none; }

.sub-section { margin: 0.75rem 0 0.75rem 1rem; }

.sub-title {
  font-size: 1rem;
  font-weight: 500;
  padding: 0.6rem 0.8rem;
  background: #F3F4F6;
  border: 1px solid #E5E7EB;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
  transition: background 0.2s;
  color: #213646;
}

.sub-title:hover { background: #E5E7EB; }
.sub-content { padding: 0.75rem 0; }
.sub-content.hidden { display: none; }

/* Card Grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.card {
  background: #FFFFFF;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  padding: 1.2rem;
  transition: all 0.2s;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(33,54,70,0.08), 0 1px 2px rgba(33,54,70,0.04);
}

.card:hover {
  border-color: #4DB8AC;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(33,54,70,0.10), 0 2px 6px rgba(33,54,70,0.05);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.card-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: #213646;
  line-height: 1.3;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-type-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
  margin-left: 0.5rem;
  flex-shrink: 0;
}

.card-tag-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.card-tag-row .card-type-badge { margin-left: 0; }

.card-btn-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.card-btn-row .card-type-badge { margin-left: 0; }
.card-btn-row .verify-btn { margin-left: auto; }

.card-qty {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.65rem;
  font-weight: 600;
  color: #6B7280;
  flex-shrink: 0;
}

.card-qty input {
  width: 3.2rem;
  padding: 0.15rem 0.3rem;
  border: 1px solid #E5E7EB;
  border-radius: 4px;
  font-size: 0.7rem;
  font-family: inherit;
  color: #213646;
  background: #FFFFFF;
}

.card-qty input:focus {
  outline: none;
  border-color: #2B7A72;
}

.card-qty b { color: #213646; }

.qty-edit-btn, .qty-save-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.7rem;
  line-height: 1;
  padding: 0.1rem 0.2rem;
  color: #6B7280;
}

.qty-edit-btn:hover { color: #213646; }

.qty-save-btn {
  border: 1px solid #00695C;
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  background: #E6F1EF;
  color: #00695C;
  font-weight: 600;
}

.qty-save-btn:hover { background: #c8e6e1; }

.asset-tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  background: #FFF7E6;
  color: #92400E;
  border: 1px solid #E8B673;
}

.badge-gige { background: #E6F1EF; color: #00695C; border: 1px solid #00695C; }
.badge-usb  { background: #E8EDF0; color: #2B4C5F; border: 1px solid #2B4C5F; }
.badge-ip   { background: #F3F4F6; color: #6B7280; border: 1px solid #9CA3AF; }
.badge-lens { background: #E6F6F4; color: #2B7A72; border: 1px solid #4DB8AC; }

.btn-delete {
  background: rgba(183,28,28,0.07);
  border: 1px solid #B71C1C;
  color: #B71C1C;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 6px;
  flex-shrink: 0;
  transition: all 0.2s;
  line-height: 1;
  font-family: inherit;
}

.btn-delete:hover {
  color: #FFFFFF;
  background: #B71C1C;
}

.btn-clone {
  background: rgba(43,76,95,0.06);
  border: 1px solid #2B4C5F;
  color: #2B4C5F;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 6px;
  flex-shrink: 0;
  transition: all 0.2s;
  line-height: 1;
  font-family: inherit;
}

.btn-clone:hover {
  color: #FFFFFF;
  background: #2B4C5F;
}

.card-specs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.spec-tag {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  background: #F3F4F6;
  border: 1px solid #E5E7EB;
  border-radius: 4px;
  color: #374151;
}

.card-meta {
  font-size: 0.75rem;
  color: #6B7280;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.card-meta span { display: flex; align-items: center; gap: 0.3rem; }

.card-link {
  display: inline-block;
  margin-top: 0.6rem;
  font-size: 0.75rem;
  color: #4DB8AC;
  text-decoration: none;
}

.card-link:hover { text-decoration: underline; }

.compat-label {
  font-size: 0.7rem;
  color: #6B7280;
  margin-top: 0.6rem;
  margin-bottom: 0.3rem;
}

.compat-list { display: flex; flex-wrap: wrap; gap: 0.3rem; }

.compat-chip {
  font-size: 0.65rem;
  padding: 0.15rem 0.45rem;
  background: #E6F6F4;
  border: 1px solid #4DB8AC;
  border-radius: 4px;
  color: #213646;
}

/* ── List View ─────────────────────────────────── */
.list-table {
  width: 100%;
  border-collapse: collapse;
  display: none;
}

body.list-view .card-grid { display: none; }
body.list-view .list-table { display: table; }

.list-table th,
.list-table td {
  padding: 0.55rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid #E5E7EB;
  font-size: 0.8rem;
}

.list-table th {
  background: #F9FAFB;
  color: #6B7280;
  text-transform: uppercase;
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  font-weight: 600;
  position: sticky;
  top: 0;
  border-bottom: 1px solid #E5E7EB;
}

.list-table tr {
  background: #FFFFFF;
  transition: background 0.15s;
  cursor: pointer;
}

.list-table tr:hover { background: #F3F4F6; }

.list-table .row-name {
  font-weight: 600;
  color: #213646;
}

.list-table .row-badge {
  font-size: 0.6rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.list-table a {
  color: #4DB8AC;
  text-decoration: none;
  font-size: 0.75rem;
}

.list-table a:hover { text-decoration: underline; }

/* ── Modal ─────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden { display: none; }

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(33, 54, 70, 0.45);
}

.modal-content {
  position: relative;
  background: #FFFFFF;
  border: 1px solid #E5E7EB;
  border-radius: 20px;
  padding: 2rem;
  max-width: 700px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  z-index: 1;
  box-shadow: 0 8px 24px rgba(33,54,70,0.10), 0 2px 6px rgba(33,54,70,0.05);
}

.modal-form { max-width: 600px; }

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: #9CA3AF;
  font-size: 1.5rem;
  cursor: pointer;
  font-family: inherit;
}

.modal-close:hover { color: #213646; }

.modal-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: #2B4C5F;
  margin-bottom: 1rem;
}

.modal-section { margin-bottom: 1.2rem; }

.modal-section h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: #6B7280;
  margin-bottom: 0.5rem;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.modal-specs-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}

.modal-spec-item {
  background: #F9FAFB;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  border: 1px solid #E5E7EB;
}

.modal-spec-item .label {
  font-size: 0.65rem;
  color: #6B7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.modal-spec-item .value {
  font-size: 0.9rem;
  color: #213646;
  font-weight: 500;
  margin-top: 0.15rem;
}

.modal-compat { margin-top: 1rem; }

.modal-compat h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: #6B7280;
  margin-bottom: 0.5rem;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.modal-lens-card {
  background: #F9FAFB;
  border: 1px solid #E5E7EB;
  border-radius: 6px;
  padding: 0.8rem;
  margin-bottom: 0.5rem;
}

.modal-lens-name { font-weight: 600; color: #4DB8AC; font-size: 0.85rem; }
.modal-lens-specs { font-size: 0.75rem; color: #6B7280; margin-top: 0.3rem; }
.no-compat { font-size: 0.8rem; color: #9CA3AF; font-style: italic; }

/* ── Add Item Form ─────────────────────────────── */
.form-group {
  margin-bottom: 0.9rem;
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  color: #6B7280;
  margin-bottom: 0.3rem;
  font-weight: 500;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  border: 1px solid #E5E7EB;
  background: #FFFFFF;
  color: #213646;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
  border-color: #4DB8AC;
  box-shadow: 0 0 0 3px rgba(77,184,172,0.30);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.dynamic-fields {
  border-top: 1px solid #E5E7EB;
  padding-top: 0.75rem;
  margin-top: 0.5rem;
}

.dynamic-fields.hidden { display: none; }

.form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.2rem;
}

.btn-cancel {
  padding: 0.5rem 1.2rem;
  border-radius: 6px;
  border: 1px solid #2B4C5F;
  background: #FFFFFF;
  color: #2B4C5F;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-cancel:hover { background: #F3F4F6; }

.btn-submit {
  padding: 0.5rem 1.5rem;
  border-radius: 6px;
  border: none;
  background: #4DB8AC;
  color: #FFFFFF;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
}

.btn-submit:hover { background: #3aa99d; }
.btn-submit:disabled { opacity: 0.5; cursor: not-allowed; }

.form-status {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  text-align: center;
}

.form-status.success { color: #00695C; }
.form-status.error   { color: #B71C1C; }

/* Edit Mode */
.modal-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.btn-edit {
  padding: 0.4rem 1rem;
  border-radius: 6px;
  border: 1px solid #4DB8AC;
  background: transparent;
  color: #4DB8AC;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-edit:hover { background: #4DB8AC; color: #FFFFFF; }

.edit-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.edit-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  align-items: center;
  gap: 0.75rem;
}

.edit-row label {
  font-size: 0.8rem;
  color: #6B7280;
  font-weight: 500;
  text-align: right;
}

.edit-input {
  background: #FFFFFF;
  border: 1px solid #E5E7EB;
  border-radius: 6px;
  padding: 0.45rem 0.7rem;
  color: #213646;
  font-size: 0.85rem;
  width: 100%;
  font-family: inherit;
}
.edit-input:focus {
  outline: none;
  border-color: #4DB8AC;
  box-shadow: 0 0 0 3px rgba(77,184,172,0.30);
}

.edit-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #E5E7EB;
}

/* ── Owner Badges ─────────────────────────────── */
.owner-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 600;
  white-space: nowrap;
}

.owner-dori {
  background: #E8EDF0;
  border: 1px solid #2B4C5F;
  color: #2B4C5F;
}

.owner-customer {
  background: #E6F6F4;
  border: 1px solid #4DB8AC;
  color: #213646;
}

/* ── Verification Status ───────────────────────── */
.verify-btn {
  flex-shrink: 0;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  border: 1px solid;
  font-size: 0.65rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  font-family: inherit;
}

.verify-btn.verified {
  background: #E6F1EF;
  border-color: #00695C;
  color: #00695C;
}

.verify-btn.verified:hover {
  background: #c8e6e1;
}

.verify-btn.not-verified {
  background: #FFF4E5;
  border-color: #FFAB40;
  color: #F59E0B;
}

.verify-btn.not-verified:hover {
  background: #FFE8C0;
}

/* Card verified/not-verified coloring */
.card.card-verified {
  border-left: 3px solid #00695C;
}

.card.card-not-verified {
  border-left: 3px solid #FFAB40;
}

/* List row verified/not-verified coloring */
.list-table tr.row-verified {
  background: #E6F1EF;
}

.list-table tr.row-verified:hover {
  background: #c8e6e1;
}

.list-table tr.row-not-verified {
  background: #FFFFFF;
}

.list-table tr.row-not-verified:hover {
  background: #F3F4F6;
}

/* Responsive */
@media (max-width: 768px) {
  header { padding: 0.75rem 1rem; }
  nav#categoryNav { padding: 0.5rem 1rem; }
  main { padding: 1rem; }
  .card-grid { grid-template-columns: 1fr; }
  .modal-specs-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .header-actions { width: 100%; }
  .search-bar { max-width: none; }
}
