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

/* ── Theme variables ──────────────────────────────────────────────────────── */
:root {
  --navy:       #1a1d4e;
  --navy-card:  #1e2060;
  --gold:       #c9a428;
  --gold-light: #d4b84a;
  --white:      #ffffff;
  --bg:         #f4f4f8;
  --text:       #1a1d4e;
  --muted:      #6b7280;
  --border:     #e5e7eb;
  --radius:     12px;
  --shadow:     0 4px 24px rgba(26,29,78,0.08);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Navbar ───────────────────────────────────────────────────────────────── */
.navbar {
  background: var(--navy);
  padding: 0 40px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 20px rgba(0,0,0,0.3);
}

.navbar-brand {
  color: var(--white);
  font-size: 1.5rem;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: 0.01em;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
}
.navbar-brand .gold { color: var(--gold); }
.navbar-subtitle {
  color: rgba(255,255,255,0.45);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 2px;
  font-weight: 400;
}

.back-link {
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.2s;
  white-space: nowrap;
}
.back-link:hover { color: var(--gold); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.2s;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.btn-gold-outline {
  background: transparent;
  color: var(--gold);
  border: 2px solid var(--gold);
}
.btn-gold-outline:hover { background: var(--gold); color: var(--navy); }
.btn-gold  { background: var(--gold); color: var(--navy); }
.btn-gold:hover { background: var(--gold-light); }
.btn-navy  { background: var(--navy); color: var(--white); }
.btn-navy:hover  { background: var(--navy-card); }
.btn-danger {
  background: transparent;
  color: #e74c3c;
  border: 2px solid #e74c3c;
}
.btn-danger:hover { background: #e74c3c; color: white; }

/* ── Stats grid ───────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 32px 40px 0;
}
.stat-card {
  background: var(--navy);
  color: var(--white);
  border-radius: var(--radius);
  padding: 24px;
}
.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.45);
  margin-bottom: 10px;
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--gold);
}
.stat-sub {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.35);
  margin-top: 4px;
}

/* ── Main layout ──────────────────────────────────────────────────────────── */
.main { padding: 32px 40px; }

/* ── Toolbar / search ─────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  align-items: center;
}
.search-input {
  flex: 1;
  padding: 11px 16px 11px 42px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 14px center;
  transition: border-color 0.2s;
}
.search-input:focus { outline: none; border-color: var(--gold); }
.filter-select {
  padding: 11px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  background: white;
  cursor: pointer;
  min-width: 170px;
}
.filter-select:focus { outline: none; border-color: var(--gold); }

/* ── Table ────────────────────────────────────────────────────────────────── */
.table-wrap {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead { background: var(--navy); color: white; }
thead th {
  padding: 16px 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-align: left;
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.15s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8f8fc; }
tbody td { padding: 14px 20px; font-size: 0.875rem; vertical-align: middle; }

.part-number {
  font-weight: 700;
  color: var(--navy);
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
}
.tail-number {
  font-family: 'Courier New', monospace;
  font-weight: 600;
  color: var(--muted);
}
.price       { font-weight: 600; }
.price-sale  { color: #16a34a; font-weight: 700; }

/* ── Condition badges ─────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.badge-new           { background: #d1fae5; color: #065f46; }
.badge-serviceable   { background: #dbeafe; color: #1e40af; }
.badge-as-removed    { background: #fef3c7; color: #92400e; }
.badge-repairable    { background: #fde68a; color: #78350f; }
.badge-unserviceable { background: #fee2e2; color: #991b1b; }
.badge-overhauled    { background: #ede9fe; color: #4c1d95; }

/* ── File counts ──────────────────────────────────────────────────────────── */
.file-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--muted);
  margin-right: 6px;
}

/* ── Row actions ──────────────────────────────────────────────────────────── */
.actions { display: flex; gap: 6px; align-items: center; }
.action-btn {
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.action-view   { background: var(--navy); color: white; }
.action-view:hover { opacity: 0.85; }
.action-edit   { background: transparent; color: var(--gold); border: 1.5px solid var(--gold); }
.action-edit:hover { background: var(--gold); color: var(--navy); }
.action-delete { background: transparent; color: #ef4444; border: 1.5px solid #ef4444; }
.action-delete:hover { background: #ef4444; color: white; }

/* ── Empty / loading states ───────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 80px 40px; color: var(--muted); }
.empty-state h3 { font-size: 1.25rem; margin-bottom: 8px; color: var(--navy); }
.loading { text-align: center; padding: 60px; color: var(--muted); }

/* ── Page header ──────────────────────────────────────────────────────────── */
.page-header {
  padding: 36px 40px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.page-title { font-size: 2rem; font-weight: 700; font-family: var(--font-display); color: var(--navy); }
.page-title .gold { color: var(--gold); }
.page-subtitle { color: var(--muted); margin-top: 4px; font-size: 0.875rem; }

/* ── Form cards ───────────────────────────────────────────────────────────── */
.form-container { max-width: 900px; margin: 0 auto; }
.form-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}
.form-card-header {
  background: var(--navy);
  color: white;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.form-card-header h3 { font-size: 1rem; font-weight: 600; font-family: var(--font-display); letter-spacing: 0.01em; }
.form-card-header .icon { color: var(--gold); font-size: 1.1rem; }
.form-card-body { padding: 28px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  background: white;
  color: var(--text);
  transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
}
textarea { resize: vertical; min-height: 90px; }

/* ── Upload zones ─────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--gold);
  background: rgba(201,164,40,0.04);
}
.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.upload-zone-icon { font-size: 2.2rem; margin-bottom: 10px; color: var(--gold); }
.upload-zone h4 { font-size: 0.95rem; color: var(--navy); margin-bottom: 4px; }
.upload-zone p { font-size: 0.78rem; color: var(--muted); }

/* ── File preview grids ───────────────────────────────────────────────────── */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.preview-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--bg);
}
.preview-item img { width: 100%; height: 100%; object-fit: cover; }
.remove-file {
  position: absolute;
  top: 4px; right: 4px;
  width: 20px; height: 20px;
  background: rgba(0,0,0,0.65);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.doc-preview-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.doc-preview-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 0.85rem;
}
.doc-preview-item .doc-icon { color: var(--gold); font-size: 1.1rem; }

/* ── Form actions ─────────────────────────────────────────────────────────── */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 20px 0 32px;
}

/* ── Detail page header ───────────────────────────────────────────────────── */
.detail-header {
  background: var(--navy);
  padding: 40px 40px 36px;
  color: white;
}
.detail-pn {
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-bottom: 8px;
}
.detail-title {
  font-size: 2rem;
  font-weight: 700;
  font-family: var(--font-display);
  margin-bottom: 20px;
  line-height: 1.2;
}
.detail-meta {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
}
.detail-meta-item { display: flex; flex-direction: column; gap: 4px; }
.detail-meta-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: rgba(255,255,255,0.4);
}
.detail-meta-value { font-size: 0.95rem; color: var(--gold); font-weight: 600; }

/* ── Detail body cards ────────────────────────────────────────────────────── */
.detail-body {
  padding: 32px 40px;
  max-width: 1400px;
}
.detail-cols {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  align-items: start;
}
.detail-col { display: flex; flex-direction: column; gap: 20px; }
.detail-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.detail-card-header {
  background: var(--navy);
  padding: 15px 24px;
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-display);
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.detail-card-header .gold { color: var(--gold); }
.detail-card-body { padding: 24px; }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.info-item label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 4px;
  display: block;
}
.info-item .value { font-size: 1rem; font-weight: 600; color: var(--navy); }

/* ── Gallery ──────────────────────────────────────────────────────────────── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.gallery-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 1;
  cursor: pointer;
  background: var(--bg);
}
.gallery-item img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s; }
.gallery-item:hover img { transform: scale(1.06); }
.delete-file-btn {
  position: absolute;
  top: 6px; right: 6px;
  background: rgba(239,68,68,0.9);
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px; height: 24px;
  cursor: pointer;
  font-size: 13px;
  display: none;
  align-items: center;
  justify-content: center;
}
.gallery-item:hover .delete-file-btn { display: flex; }

/* ── Documents list ───────────────────────────────────────────────────────── */
.doc-list { display: flex; flex-direction: column; gap: 10px; }
.doc-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 8px;
}
.doc-icon-wrap {
  width: 36px; height: 36px;
  background: var(--navy);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  font-size: 0.95rem;
  flex-shrink: 0;
}
.doc-name { font-size: 0.85rem; font-weight: 600; flex: 1; }
.doc-actions { display: flex; gap: 6px; }

/* ── Lightbox ─────────────────────────────────────────────────────────────── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.lightbox.active { display: flex; }
.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  object-fit: contain;
}
.lightbox-close {
  position: absolute;
  top: 20px; right: 28px;
  color: white;
  font-size: 2.2rem;
  cursor: pointer;
  background: none;
  border: none;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.2s;
}
.lightbox-close:hover { opacity: 1; }

/* ── Financial values ─────────────────────────────────────────────────────── */
.val-price  { font-size: 1.5rem; font-weight: 700; font-family: var(--font-display); }
.val-profit { font-size: 1.3rem; font-weight: 700; font-family: var(--font-display); }
.val-green  { color: #16a34a; }
.val-red    { color: #dc2626; }

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--navy);
  color: white;
  padding: 14px 20px;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  font-weight: 500;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast-icon { color: var(--gold); font-size: 1.1rem; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .detail-cols { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .navbar, .main, .page-header, .stats-grid,
  .detail-header, .detail-body { padding-left: 16px; padding-right: 16px; }
  .form-grid, .info-grid { grid-template-columns: 1fr; }
  .detail-title { font-size: 1.4rem; }
  .stats-grid { grid-template-columns: 1fr; }
}
