*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Auth Bar ── */
.auth-bar {
  background: var(--navy-dark);
  border-bottom: 1px solid rgba(201,168,76,0.2);
  padding: 0.35rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.8rem;
}
#auth-status {
  font-size: 0.72rem;
  color: #888;
  letter-spacing: 0.05em;
}
.auth-btn {
  background: none;
  border: 1px solid #444;
  border-radius: 4px;
  color: #888;
  font-size: 0.72rem;
  padding: 0.2rem 0.7rem;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: all 0.15s;
}
.auth-btn:hover { border-color: var(--gold); color: var(--gold); }
.auth-btn.logged-in { border-color: #2a6a2a; color: #6dbf6d; }
.auth-btn.logged-in:hover { border-color: #c0392b; color: #c0392b; }

:root {
  --navy:       #1a2744;
  --navy-dark:  #111c33;
  --gold:       #c9a84c;
  --gold-light: #e8c96a;
  --bg:         #f5f4f0;
  --surface:    #ffffff;
  --border:     #ddd9cc;
  --text:       #1a1a1a;
  --muted:      #666;
  --green:      #1e7d4f;
  --red:        #c0392b;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Banner ── */
.banner {
  background: linear-gradient(135deg, #b22234 0%, #1a2744 50%, #3c3b6e 100%);
  padding: 24px 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  border-bottom: 4px solid #c9a84c;
  flex-wrap: wrap;
  text-align: center;
}
.banner-mascot {
  height: 110px;
  width: 110px;
  object-fit: cover;
  border-radius: 50%;
  border: 4px solid #c9a84c;
  box-shadow: 0 0 20px rgba(201,168,76,0.6), 0 4px 16px rgba(0,0,0,0.6);
  flex-shrink: 0;
}
.banner-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.banner-svg {
  width: 100%;
  max-width: 680px;
  display: block;
}
.banner-sub {
  font-size: 0.85rem;
  color: #c9a84c;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.banner-stars {
  font-size: 3.5rem;
  flex-shrink: 0;
}

/* ── Header ── */
header {
  background: var(--navy);
  color: white;
  padding: 1.1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}

header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: .02em;
}

.spot-price-control label {
  display: block;
  font-size: .7rem;
  color: #99a;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .35rem;
}

.spot-input-group {
  display: flex;
  align-items: center;
  gap: .4rem;
}

.spot-input-group > span {
  color: var(--gold);
  font-weight: 700;
  font-size: 1rem;
}

.spot-input-group input {
  width: 110px;
  padding: .4rem .6rem;
  border: 1px solid #3a4a6a;
  border-radius: 4px;
  background: #243060;
  color: white;
  font-size: .95rem;
}

.spot-input-group button {
  padding: .4rem .85rem;
  background: var(--gold);
  color: var(--navy);
  border: none;
  border-radius: 4px;
  font-weight: 700;
  font-size: .82rem;
  cursor: pointer;
  transition: background .15s;
}

.spot-input-group button:hover { background: var(--gold-light); }

/* ── Main layout ── */
main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem 2rem;
}

/* ── Summary cards ── */
.summary-bar {
  display: flex;
  gap: .9rem;
  margin-bottom: 1.4rem;
  flex-wrap: wrap;
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .9rem 1.4rem;
  flex: 1;
  min-width: 150px;
}

.summary-card .label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: .35rem;
}

.summary-card .value {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--navy);
}

.summary-card .value.positive { color: var(--green); }
.summary-card .value.negative { color: var(--red); }

/* ── Actions bar ── */
.actions-bar { margin-bottom: 1rem; }

.btn-primary {
  background: var(--navy);
  color: white;
  border: none;
  padding: .58rem 1.2rem;
  border-radius: 6px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

.btn-primary:hover { background: var(--navy-dark); }

/* ── Table ── */
.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

thead {
  background: var(--navy);
  color: white;
}

thead th {
  padding: .7rem 1rem;
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #faf9f5; }

tbody td {
  padding: .65rem 1rem;
  white-space: nowrap;
}

.positive { color: var(--green); font-weight: 600; }
.negative { color: var(--red);   font-weight: 600; }

.btn-edit, .btn-delete {
  padding: .28rem .65rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: .78rem;
  font-weight: 600;
}

.btn-edit  { background: #e8f0fe; color: #1a56db; margin-right: .35rem; }
.btn-edit:hover  { background: #d0e0fc; }
.btn-delete { background: #fde8e8; color: var(--red); }
.btn-delete:hover { background: #fcccc8; }

.notes-cell {
  white-space: normal;
  max-width: 220px;
  font-size: .82rem;
  color: var(--muted);
}

.form-group textarea {
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: .92rem;
  color: var(--text);
  background: white;
  resize: vertical;
  font-family: inherit;
}

.form-group textarea:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 2px rgba(26,39,68,.15);
}

/* ── Coin thumbnails (table) ── */
.photo-pair-cell {
  display: flex;
  gap: .3rem;
  align-items: center;
}

.coin-thumb {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--border);
  display: block;
  transition: opacity .15s;
}
.coin-thumb:hover { opacity: .8; }

.no-image {
  width: 52px;
  height: 52px;
  border-radius: 4px;
  border: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .6rem;
  color: #ccc;
  text-align: center;
  line-height: 1.3;
}

/* ── Image upload area (form) ── */
.image-upload-area {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .5rem;
}

.image-preview {
  width: 160px;
  height: 120px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.image-upload-label {
  display: inline-block;
  padding: .45rem .9rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--navy);
  cursor: pointer;
  transition: background .15s;
}
.image-upload-label:hover { background: #eceae3; }

#imageFile { display: none; }

.btn-remove-img {
  background: none;
  border: none;
  font-size: .78rem;
  color: var(--red);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

/* ── Lightbox ── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.lightbox.hidden { display: none; }

.lightbox img {
  max-width: 90vw;
  max-height: 88vh;
  border-radius: 6px;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
  object-fit: contain;
}

#lightboxClose {
  position: fixed;
  top: 1.2rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: white;
  font-size: 2.2rem;
  line-height: 1;
  cursor: pointer;
  opacity: .8;
}
#lightboxClose:hover { opacity: 1; }

/* ── Modal scrollable for taller form ── */
.modal-content {
  max-height: 92vh;
  overflow-y: auto;
}

.empty-state {
  text-align: center;
  padding: 3.5rem;
  color: var(--muted);
  font-size: .95rem;
}

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.hidden { display: none; }

.modal-content {
  background: white;
  border-radius: 10px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1.05rem;
  color: var(--navy);
}

#modalClose {
  background: none;
  border: none;
  font-size: 1.55rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1.4rem 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.form-group-full { grid-column: 1 / -1; }

.form-group label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.form-group input,
.form-group select {
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: .92rem;
  color: var(--text);
  background: white;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 2px rgba(26,39,68,.15);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

.form-actions button[type="button"] {
  padding: .52rem 1.1rem;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .9rem;
  cursor: pointer;
}

.form-actions button[type="button"]:hover { background: var(--bg); }
