:root {
  --bg: #eef4fb;
  --surface: #ffffff;
  --text: #14213d;
  --muted: #667085;
  --primary: #0f6c81;
  --primary-dark: #064a5b;
  --accent: #f6a623;
  --green: #2e9d6b;
  --red: #d64545;
  --blue: #3066be;
  --border: #dbe4ef;
  --shadow: 0 18px 40px rgba(20, 33, 61, 0.12);
  --radius: 18px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, rgba(15,108,129,.15), transparent 34%), var(--bg);
  color: var(--text);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 290px;
  background: linear-gradient(180deg, #073b4c, #0f6c81);
  color: white;
  padding: 26px 18px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 26px; }
.brand-mark {
  width: 52px; height: 52px; border-radius: 16px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.16);
  font-size: 30px;
}
.brand h1 { font-size: 20px; margin: 0; }
.brand p { margin: 2px 0 0; color: rgba(255,255,255,.72); }
.nav-tabs { display: grid; gap: 8px; }
.nav-btn {
  width: 100%;
  border: 0;
  color: rgba(255,255,255,.8);
  background: transparent;
  text-align: left;
  padding: 13px 14px;
  border-radius: 14px;
  transition: .2s;
}
.nav-btn.active, .nav-btn:hover { background: rgba(255,255,255,.16); color: #fff; }
.sidebar-footer { margin-top: auto; display: grid; gap: 10px; }
.main { flex: 1; padding: 24px; min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 22px;
}
.eyebrow { color: var(--primary); text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 800; margin: 0; }
.topbar h2 { margin: 4px 0 0; font-size: 32px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.status-pill, .chip {
  padding: 7px 11px;
  border-radius: 999px;
  background: #e6f4f8;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
}
.chip.green { background: #e9f8f1; color: var(--green); }
.chip.blue { background: #eaf0ff; color: var(--blue); }
.grid { display: grid; gap: 18px; }
.two-col { grid-template-columns: minmax(0, 1fr) minmax(340px, .85fr); }
.wide-left { grid-template-columns: minmax(0, 1.15fr) minmax(340px, .65fr); }
.card {
  background: rgba(255,255,255,.9);
  border: 1px solid rgba(219,228,239,.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  backdrop-filter: blur(10px);
}
.card + .card { margin-top: 18px; }
.card-header { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 16px; }
.card-header h3 { margin: 0; font-size: 19px; }
.form-grid { display: grid; gap: 14px; margin-bottom: 14px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
label { display: grid; gap: 7px; color: #344054; font-size: 13px; font-weight: 700; margin-bottom: 14px; }
input, select {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
  outline: none;
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(15,108,129,.11); }
.primary-btn, .secondary-btn, .ghost-btn, .danger-ghost-btn, .file-btn {
  border: 0;
  border-radius: 12px;
  padding: 11px 14px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.primary-btn { background: var(--primary); color: #fff; }
.secondary-btn { background: #e6f4f8; color: var(--primary-dark); }
.ghost-btn { background: #f3f6fa; color: #334155; }
.danger-ghost-btn { background: rgba(214,69,69,.12); color: var(--red); }
.file-btn { background: #f3f6fa; color: #334155; cursor: pointer; }
.file-btn input { display: none; }
.full { width: 100%; }
.small { padding: 6px 10px; border-radius: 9px; font-size: 12px; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.button-row.tight { gap: 8px; }
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.stat {
  background: linear-gradient(135deg, #f6fbfd, #fff);
  border: 1px solid var(--border);
  padding: 18px;
  border-radius: 16px;
}
.stat strong { display: block; font-size: 28px; color: var(--primary-dark); }
.stat span { color: var(--muted); font-size: 13px; }
.notice { margin-top: 16px; padding: 14px; background: #fff8ea; border: 1px solid #ffe3ac; border-radius: 14px; color: #735100; }
.workflow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.workflow div { background: #f7fafc; border: 1px solid var(--border); border-radius: 16px; padding: 16px; }
.workflow span { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: white; font-weight: 900; margin-bottom: 10px; }
.workflow b { display: block; }
.workflow p { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.35; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.signature-block { margin: 15px 0; }
.signature-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 800; }
canvas { width: 100%; height: 160px; border-radius: 14px; border: 1px dashed #9ca3af; background: #fff; touch-action: none; }
.seat-map { display: grid; grid-template-columns: repeat(8, minmax(38px, 1fr)); gap: 8px; align-items: center; }
.seat-map.compact { grid-template-columns: repeat(4, minmax(52px, 1fr)); max-height: 470px; overflow: auto; padding-right: 4px; }
.seat {
  border: 1px solid var(--border);
  padding: 10px 8px;
  min-height: 42px;
  border-radius: 12px;
  background: #fff;
  font-weight: 900;
  color: #334155;
}
.seat.available { border-color: #a6dbc0; background: #effaf4; color: #166534; }
.seat.selected { border-color: var(--accent); background: #fff6df; color: #7a4d00; box-shadow: 0 0 0 3px rgba(246,166,35,.2); }
.seat.occupied { border-color: #f0b7b7; background: #fff0f0; color: #991b1b; cursor: not-allowed; }
.seat.reserved { border-color: #b6c8ff; background: #eef3ff; color: #1d4ed8; }
.seat.unavailable { border-color: #d1d5db; background: #f3f4f6; color: #6b7280; cursor: not-allowed; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; color: var(--muted); font-size: 12px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 5px; vertical-align: middle; }
.legend .available { background: #2e9d6b; }
.legend .selected { background: #f6a623; }
.legend .occupied { background: #d64545; }
.legend .unavailable { background: #9ca3af; }
.sticky-card { position: sticky; top: 24px; align-self: start; }
.helper-text { color: var(--muted); font-size: 13px; margin-top: 0; }
.seat-admin-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seat-admin-controls input { min-width: 150px; }
.table-wrap { overflow: auto; border-radius: 14px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 13px; vertical-align: middle; }
th { background: #f7fafc; color: #344054; font-weight: 900; }
tfoot td { font-weight: 900; }
.signature-preview { max-width: 120px; height: 42px; object-fit: contain; }
.report-header { text-align: center; margin: 8px 0 18px; }
.report-header h2 { margin: 0 0 8px; }
.report-header p { margin: 0; color: #344054; }
.manifest-closing { margin-top: 18px; line-height: 1.6; }
.signature-lines { display: grid; grid-template-columns: repeat(2, 1fr); gap: 60px; margin-top: 42px; }
.signature-lines span { display: block; border-bottom: 1px solid #111827; height: 32px; }
.signature-lines b { display: block; text-align: center; font-size: 13px; margin-top: 8px; }
.signature-lines em { font-style: normal; }
.summary-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.summary-grid h4 { margin: 0 0 8px; }
.small-table { max-height: 240px; overflow: auto; }
.delete-btn { background: rgba(214,69,69,.1); color: var(--red); border: 0; border-radius: 8px; padding: 6px 8px; }
.ticket-print { width: 3in; min-height: 3in; padding: .15in; border: 1px solid #111; font-family: Arial, sans-serif; color: #000; }
.ticket-print h2 { text-align: center; margin: 0 0 8px; font-size: 14px; }
.ticket-row { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dotted #aaa; padding: 3px 0; font-size: 10px; }
.ticket-row b { flex: 0 0 auto; }
.ticket-row span { text-align: right; }
.ticket-row.total { font-size: 12px; font-weight: bold; border-bottom: 2px solid #111; }
.ticket-footer { margin: 8px 0 0; font-size: 9px; text-align: center; }
@media (max-width: 1000px) {
  .app-shell { flex-direction: column; }
  .sidebar { position: relative; width: 100%; height: auto; }
  .nav-tabs { grid-template-columns: repeat(3, 1fr); }
  .two-col, .wide-left, .summary-grid, .workflow { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
  .form-grid.two, .form-grid.three { grid-template-columns: 1fr; }
}
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .no-print, .nav-tabs, .card-header .button-row, .button-row, .helper-text { display: none !important; }
  .main { padding: 0; }
  .tab-panel { display: none !important; }
  .tab-panel.active { display: block !important; }
  .card { box-shadow: none; border: none; padding: 0; }
  table { font-size: 10px; }
  th, td { padding: 5px; font-size: 10px; }
  .signature-lines { break-inside: avoid; }
}


/* Tablet-friendly upgrades */
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
body {
  min-width: 320px;
  overscroll-behavior-y: none;
}
button,
input,
select,
.file-btn {
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
button { touch-action: manipulation; }
input, select, textarea { font-size: 16px; }
.table-wrap { -webkit-overflow-scrolling: touch; }
.seat-map { -webkit-overflow-scrolling: touch; }
canvas { touch-action: none; }

@media (hover: none) and (pointer: coarse) {
  .nav-btn:hover { background: transparent; color: rgba(255,255,255,.8); }
  .nav-btn.active { background: rgba(255,255,255,.18); color: #fff; }
  .seat { min-height: 48px; padding: 12px 8px; }
}

@media (max-width: 1180px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 50;
    padding: max(14px, env(safe-area-inset-top)) 16px 14px;
    border-bottom-left-radius: 22px;
    border-bottom-right-radius: 22px;
  }
  .brand { margin-bottom: 12px; }
  .brand-mark { width: 44px; height: 44px; border-radius: 14px; font-size: 24px; }
  .brand h1 { font-size: 18px; }
  .brand p { font-size: 12px; }
  .nav-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .nav-tabs::-webkit-scrollbar { display: none; }
  .nav-btn {
    flex: 0 0 auto;
    width: auto;
    white-space: nowrap;
    min-height: 42px;
    padding: 11px 13px;
    background: rgba(255,255,255,.08);
  }
  .sidebar-footer {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 10px;
  }
  .main { padding: 18px; }
  .topbar {
    align-items: stretch;
    margin-bottom: 16px;
  }
  .topbar-actions { justify-content: flex-start; }
  .two-col, .wide-left, .summary-grid { grid-template-columns: 1fr; }
  .workflow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sticky-card { position: static; }
  .seat-map.compact {
    grid-template-columns: repeat(6, minmax(54px, 1fr)) !important;
    max-height: none;
  }
}

@media (max-width: 760px) {
  .main { padding: 12px; }
  .topbar h2 { font-size: 25px; }
  .card { padding: 15px; border-radius: 16px; }
  .card-header { flex-direction: column; align-items: flex-start; }
  .button-row, .seat-admin-controls, .topbar-actions { width: 100%; }
  .button-row > *, .seat-admin-controls > *, .topbar-actions > * { flex: 1 1 100%; }
  .form-grid.two, .form-grid.three { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .workflow { grid-template-columns: 1fr; }
  .seat-map,
  .seat-map.compact {
    grid-template-columns: repeat(4, minmax(58px, 1fr)) !important;
    gap: 7px;
  }
  .seat { font-size: 12px; }
  .signature-lines { grid-template-columns: 1fr; gap: 26px; }
  th, td { white-space: nowrap; }
}

@media (min-width: 761px) and (max-width: 1180px) {
  .form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .button-row > *, .seat-admin-controls > * { flex: 0 1 auto; }
}
