/* Trade Show Tracker — mobile-first dark theme */
:root {
  --bg: #0f172a;
  --bg-2: #1e293b;
  --bg-3: #334155;
  --fg: #f1f5f9;
  --fg-muted: #94a3b8;
  --border: #334155;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --card: #1e293b;
  --input: #0f172a;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px;
}
.brand { color: var(--fg); font-weight: 700; font-size: 17px; }
.topnav { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.topnav a { color: var(--fg-muted); font-size: 14px; }
.topnav a:hover { color: var(--fg); text-decoration: none; }
.topnav a.who { color: var(--fg); font-size: 13px; }

/* Main */
.main { max-width: 960px; margin: 0 auto; padding: 16px; }
.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.page-header h1 { margin: 0; font-size: 1.6rem; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back-link { font-size: 13px; color: var(--fg-muted); }
.section-title { margin: 20px 0 10px; font-size: 14px; color: var(--fg-muted); text-transform: uppercase; letter-spacing: .05em; }
.muted { color: var(--fg-muted); }
.small { font-size: 13px; }

/* Flash */
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; font-size: 14px; }
.flash-error { background: rgba(239,68,68,.15); color: #fca5a5; border: 1px solid rgba(239,68,68,.35); }
.flash-success { background: rgba(34,197,94,.15); color: #86efac; border: 1px solid rgba(34,197,94,.35); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 16px; border: 1px solid transparent; border-radius: 8px;
  cursor: pointer; font-size: 15px; font-weight: 500; text-decoration: none;
  transition: all .15s; white-space: nowrap; gap: 6px;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.big-cta { font-size: 16px; padding: 12px 18px; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg-3); color: var(--fg); border-color: var(--border); }
.btn-secondary:hover { background: #475569; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card-h { margin: 0 0 12px; font-size: 1rem; color: var(--fg-muted); text-transform: uppercase; letter-spacing: .05em; }
.card-h-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-h-row .card-h { margin: 0; }

/* Forms */
.form label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--fg-muted); }
.form input, .form textarea, .form select,
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="tel"], input[type="date"], input[type="search"], textarea, select {
  display: block; width: 100%;
  padding: 10px 12px;
  background: var(--input); color: var(--fg);
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 15px; font-family: inherit;
  margin-top: 4px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); }
textarea { resize: vertical; min-height: 80px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-2 .span-2 { grid-column: span 2; }
@media (max-width: 600px) { .grid-2 { grid-template-columns: 1fr; } .grid-2 .span-2 { grid-column: span 1; } }
.form-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* Auth */
.auth-card {
  max-width: 400px; margin: 60px auto;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow);
}
.auth-card h1 { margin-top: 0; }
.auth-card label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--fg-muted); }
.auth-card button { width: 100%; margin-top: 6px; }

/* Shows grid */
.show-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.show-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 6px;
  color: var(--fg); transition: all .15s;
}
.show-card:hover { text-decoration: none; border-color: var(--primary); transform: translateY(-2px); }
.show-card.archived { opacity: .6; }
.show-name { font-size: 1.1rem; font-weight: 600; }
.show-loc, .show-dates { color: var(--fg-muted); font-size: 13px; }
.show-stats { margin-top: 6px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--bg-3); font-size: 12px; color: var(--fg); }
.archived summary { cursor: pointer; color: var(--fg-muted); margin: 20px 0 10px; }
.empty { text-align: center; padding: 40px 20px; color: var(--fg-muted); }
.empty p { margin-bottom: 16px; }

/* Stats */
.stats-row { display: flex; gap: 12px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; flex: 1; }
.stat-num { font-size: 1.6rem; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--fg-muted); text-transform: uppercase; letter-spacing: .05em; }

/* Filter row */
.filter-row { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-row input[type="search"] { flex: 2; min-width: 160px; margin: 0; }
.filter-row select { flex: 1; min-width: 140px; margin: 0; }

/* Order list */
.order-list { display: flex; flex-direction: column; gap: 10px; }
.order-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px;
  color: var(--fg); border-left-width: 4px;
}
.order-card:hover { text-decoration: none; border-color: var(--primary); }
.order-card.status-placed { border-left-color: var(--warning); }
.order-card.status-confirmed { border-left-color: var(--success); }
.order-card.status-cancelled { border-left-color: var(--danger); opacity: .6; }
.order-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.vendor { font-weight: 600; font-size: 1.05rem; }
.order-meta { font-size: 13px; color: var(--fg-muted); }
.order-foot { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 4px; gap: 10px; flex-wrap: wrap; }
.order-total { font-weight: 700; font-size: 1.1rem; }

/* Status pills */
.status-pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
}
.status-pill.status-placed { background: rgba(245,158,11,.2); color: #fbbf24; }
.status-pill.status-confirmed { background: rgba(34,197,94,.2); color: #4ade80; }
.status-pill.status-cancelled { background: rgba(239,68,68,.2); color: #fca5a5; }
.status-pill.status-sent { background: rgba(34,197,94,.2); color: #4ade80; }
.status-pill.status-failed { background: rgba(239,68,68,.2); color: #fca5a5; }

/* Items */
.item-row {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px; margin-bottom: 8px;
}
.item-line-1 { display: flex; gap: 8px; align-items: center; }
.item-line-2 { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.item-field { margin: 0; font-size: 14px; padding: 8px 10px; }
.item-field.flex-grow { flex: 1; }
.item-field.qty { width: 80px; flex: none; }
.item-field.unit { width: 80px; flex: none; }
.item-field.price { width: 110px; flex: none; }
.item-total { font-weight: 600; min-width: 80px; text-align: right; font-family: ui-monospace, monospace; }
.notes-field { margin-top: 8px; font-size: 13px; background: transparent; border-color: var(--border); }
.item-del { background: none; border: 1px solid var(--border); color: var(--danger); width: 32px; height: 32px; border-radius: 6px; font-size: 18px; cursor: pointer; flex-shrink: 0; }
.item-del:hover { background: rgba(239,68,68,.15); }
.items-total { display: flex; justify-content: space-between; padding: 12px 4px 0; font-size: 1.1rem; font-weight: 700; border-top: 1px solid var(--border); margin-top: 8px; }

@media (max-width: 600px) {
  .item-line-2 { flex-wrap: wrap; }
  .item-field.qty, .item-field.unit { width: calc(50% - 4px); }
  .item-field.price { width: 100%; }
  .item-total { width: 100%; text-align: left; }
}

/* Photos */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-top: 10px; }
.photo-tile { position: relative; aspect-ratio: 1; background: var(--bg); border-radius: 8px; overflow: hidden; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-del { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.7); color: white; border: none; width: 24px; height: 24px; border-radius: 50%; cursor: pointer; font-size: 16px; line-height: 1; }

/* Voice button active */
.voice-recording { background: var(--danger) !important; color: white !important; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .7; } }

/* Save indicator */
.save-indicator { font-size: 12px; color: var(--fg-muted); margin-top: 8px; display: inline-block; }
.save-indicator.saving { color: var(--warning); }
.save-indicator.saved { color: var(--success); }

/* Email log */
.email-log { list-style: none; padding: 0; margin: 0; }
.email-log li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.email-log li:last-child { border-bottom: none; }
.email-when { color: var(--fg-muted); font-size: 13px; }

/* Modal */
.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 1000; align-items: flex-start; justify-content: center; padding: 20px; overflow-y: auto; }
.modal.active { display: flex; }
.modal-box { background: var(--card); border-radius: var(--radius); padding: 24px; max-width: 500px; width: 100%; margin-top: 40px; border: 1px solid var(--border); }
.modal-box h3 { margin-top: 0; }
.modal-box label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--fg-muted); }

/* Tables */
.list-table { width: 100%; border-collapse: collapse; }
.list-table th, .list-table td { padding: 10px; text-align: left; border-bottom: 1px solid var(--border); }
.list-table th { color: var(--fg-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-admin { background: rgba(59,130,246,.2); color: #93c5fd; }

/* code */
code { background: var(--bg-3); padding: 1px 6px; border-radius: 4px; font-family: ui-monospace, monospace; font-size: 13px; }
