:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-strong: #eef2f7;
  --text: #18202f;
  --muted: #667085;
  --border: #d7dde7;
  --primary: #0f766e;
  --primary-strong: #0b5d57;
  --accent: #4f46e5;
  --warning: #b45309;
  --danger: #b42318;
  --ok: #15803d;
  --shadow: 0 12px 30px rgba(24, 32, 47, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: #111827;
  color: #ffffff;
}

.brand-block {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-bottom: 26px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--primary);
  font-weight: 800;
}

.brand-block h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
}

.brand-block p,
.auth-panel p {
  margin: 5px 0 0;
  color: #cbd5e1;
  font-size: 13px;
}

.main-nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  padding: 11px 12px;
  color: #dbe4f0;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
}

.nav-item:hover,
.nav-item.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.12);
}

.auth-panel {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.auth-panel label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  color: #e5e7eb;
}

.auth-fields,
.auth-actions,
.auth-session-actions {
  display: grid;
  gap: 8px;
}

.auth-fields {
  margin-bottom: 8px;
}

.auth-actions {
  grid-template-columns: 1fr 1fr;
}

.auth-fields input {
  min-width: 0;
  padding: 9px;
  color: #111827;
  border: 0;
  border-radius: 8px;
}

.auth-actions button,
.auth-session-actions button {
  padding: 9px 10px;
  color: #ffffff;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
}

.auth-actions button + button {
  color: #e5e7eb;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.auth-secondary {
  margin-top: 8px;
}

.auth-secondary button {
  padding: 0;
  color: #cbd5e1;
  text-align: left;
  text-decoration: underline;
  background: transparent;
  border: 0;
}

.auth-panel :disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.auth-panel.signed-in .auth-fields,
.auth-panel.signed-in .auth-actions,
.auth-panel.signed-in .auth-secondary {
  display: none;
}

.auth-panel.signed-in .auth-session-actions {
  display: grid !important;
}

.auth-panel.recovering .auth-actions button + button,
.auth-panel.recovering .auth-secondary {
  display: none;
}

.workspace {
  width: 100%;
  max-width: 1480px;
  padding: 28px;
}

.auth-gate {
  display: grid;
  min-height: calc(100vh - 56px);
  place-items: center;
  color: var(--text);
}

.auth-gate > div {
  width: min(520px, 100%);
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-gate h2 {
  margin: 0 0 10px;
  font-size: 28px;
}

.auth-gate p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

body.requires-auth:not(.has-session) .topbar,
body.requires-auth:not(.has-session) .metrics-grid,
body.requires-auth:not(.has-session) .view {
  display: none;
}

body.requires-auth:not(.has-session) .main-nav {
  opacity: 0.45;
  pointer-events: none;
}

.topbar,
.section-heading,
.calendar-toolbar,
.filters-row,
.inline-actions,
.view-toggle,
.market-search {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar,
.section-heading {
  justify-content: space-between;
}

.topbar {
  margin-bottom: 18px;
}

.topbar h2,
.section-heading h3,
.dialog-form h3 {
  margin: 0;
}

.topbar h2 {
  font-size: 28px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.primary-button,
.secondary-button,
.ghost-button,
.text-button,
.icon-button {
  min-height: 38px;
  border-radius: 8px;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  padding: 0 16px;
  color: #ffffff;
  background: var(--primary);
  border: 1px solid var(--primary);
}

.primary-button:hover {
  background: var(--primary-strong);
}

.secondary-button,
.ghost-button,
.icon-button {
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
}

.secondary-button,
.ghost-button {
  padding: 0 13px;
}

.text-button {
  min-height: auto;
  padding: 0;
  color: var(--primary);
  background: transparent;
  border: 0;
}

.view-toggle {
  justify-content: flex-start;
  margin: 12px 0;
}

.toggle-button {
  min-height: 34px;
  padding: 0 12px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.toggle-button.active {
  color: #ffffff;
  background: var(--primary);
  border-color: var(--primary);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  padding: 0;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric-card,
.surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 16px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin-top: 7px;
  font-size: 25px;
}

.metric-card.warning strong {
  color: var(--warning);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.summary-layout,
.contractor-layout,
.checklist-layout,
.inventory-layout,
.documents-layout,
.investments-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(360px, 0.7fr);
  gap: 16px;
}

.surface {
  padding: 16px;
}

.event-stack,
.alert-stack,
.contractor-list,
.assignment-list,
.reminder-list,
.checklist-list,
.readiness-list,
.equipment-list,
.conflict-list,
.booking-list,
.attachment-list,
.attachment-summary-list,
.investment-list,
.investment-summary-list,
.market-results-list,
.market-options-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.event-card,
.alert-item,
.contractor-item,
.assignment-item,
.reminder-item,
.checklist-item,
.readiness-item,
.equipment-item,
.conflict-item,
.booking-item,
.attachment-item,
.attachment-summary-item,
.investment-item,
.investment-summary-item,
.market-result-item,
.market-option-item {
  display: grid;
  gap: 8px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.event-card header,
.alert-item header,
.contractor-item header,
.assignment-item header,
.reminder-item header,
.checklist-item header,
.readiness-item header,
.equipment-item header,
.conflict-item header,
.booking-item header,
.attachment-item header,
.attachment-summary-item header,
.investment-item header,
.investment-summary-item header,
.market-result-item header,
.market-option-item header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.event-card h4,
.alert-item h4,
.contractor-item h4,
.assignment-item h4,
.reminder-item h4,
.checklist-item h4,
.readiness-item h4,
.equipment-item h4,
.conflict-item h4,
.booking-item h4,
.attachment-item h4,
.attachment-summary-item h4,
.investment-item h4,
.investment-summary-item h4,
.market-result-item h4,
.market-option-item h4 {
  margin: 0;
  font-size: 16px;
}

.compact-heading {
  margin-top: 18px;
}

.market-search {
  align-items: stretch;
  flex-wrap: wrap;
  margin-top: 14px;
}

.market-search select,
.market-search input {
  min-height: 40px;
  padding: 0 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.market-search select {
  min-width: 180px;
}

.market-search input {
  flex: 1;
  min-width: 220px;
}

.market-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.meta-line {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 8px;
  color: #273244;
  background: var(--surface-strong);
  font-size: 12px;
}

.tag.ok {
  color: #ffffff;
  background: var(--ok);
}

.tag.warn {
  color: #ffffff;
  background: var(--warning);
}

.tag.deal {
  color: #ffffff;
  background: #0f766e;
}

.tag.danger {
  color: #ffffff;
  background: var(--danger);
}

.calendar-toolbar {
  justify-content: center;
  margin: 6px 0 16px;
}

.calendar-toolbar strong {
  min-width: 240px;
  text-align: center;
  font-size: 20px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.weekday-row {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  text-transform: uppercase;
}

.calendar-day {
  min-height: 126px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.calendar-day.outside {
  opacity: 0.45;
}

.calendar-day.today {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.day-number {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.day-event {
  width: 100%;
  margin-top: 6px;
  padding: 7px;
  text-align: left;
  color: #ffffff;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  font-size: 12px;
}

.day-event.auction {
  background: var(--warning);
}

.day-event.sports {
  background: #2563eb;
}

.day-event.concert {
  background: #be185d;
}

.filters-row {
  margin-bottom: 12px;
}

.filters-row input,
.filters-row select {
  min-height: 40px;
  padding: 0 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.filters-row input {
  flex: 1;
  min-width: 260px;
}

.table-shell {
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

th,
td {
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #fbfcfe;
}

tbody tr:hover {
  background: #f8fafc;
}

.amount-positive {
  color: var(--ok);
  font-weight: 700;
}

.amount-negative {
  color: var(--danger);
  font-weight: 700;
}

.progress-track {
  width: 100%;
  height: 9px;
  overflow: hidden;
  background: var(--surface-strong);
  border-radius: 8px;
}

.progress-track span {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: inherit;
}

.empty-state {
  margin: 0;
  padding: 18px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.hidden {
  display: none !important;
}

dialog {
  width: min(760px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 26px 70px rgba(15, 23, 42, 0.28);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.48);
}

.dialog-form header,
.dialog-form footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.dialog-form footer {
  border-top: 1px solid var(--border);
  border-bottom: 0;
}

.dialog-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

.field {
  display: grid;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: var(--muted);
  font-size: 13px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .main-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .summary-layout,
  .contractor-layout,
  .checklist-layout,
  .inventory-layout,
  .documents-layout,
  .investments-layout,
  .metrics-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 680px) {
  .workspace {
    padding: 18px;
  }

  .topbar,
  .section-heading,
  .filters-row,
  .inline-actions,
  .view-toggle,
  .market-search {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .inline-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .main-nav,
  .metrics-grid,
  .summary-layout,
  .contractor-layout,
  .checklist-layout,
  .inventory-layout,
  .documents-layout,
  .investments-layout,
  .dialog-body {
    grid-template-columns: 1fr;
  }

  .calendar-grid {
    gap: 4px;
  }

  .calendar-day {
    min-height: 92px;
    padding: 7px;
  }

  .day-event {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
