:root {
  color-scheme: light;
  --ink: #1e1a18;
  --muted: #60564e;
  --muted-2: #8a7f76;
  --canvas: #f5f0e8;
  --panel: #ffffff;
  --accent: #2a6f6f;
  --accent-2: #1b4f57;
  --highlight: #f6d18b;
  --danger: #a34c42;
  --success: #2b6b4a;
  --shadow: 0 16px 40px rgba(30, 26, 24, 0.12);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, "Georgia", serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #f8e7c4, var(--canvas) 45%),
    linear-gradient(120deg, rgba(42, 111, 111, 0.12), transparent 60%);
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

.backdrop {
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, rgba(42, 111, 111, 0.1), transparent 55%),
    radial-gradient(circle at bottom right, rgba(246, 209, 139, 0.35), transparent 60%);
  z-index: -1;
}

.app-shell {
  padding: 32px 36px 48px;
}

.page {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 28px;
  align-items: start;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
}

.topbar-title h1 {
  margin: 4px 0 0;
  font-size: 2.2rem;
  letter-spacing: -0.02em;
}

.topbar-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: flex-end;
}

.meta-card {
  background: rgba(255, 255, 255, 0.75);
  border-radius: 14px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  min-width: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 4px;
}

.meta-card.action {
  min-width: auto;
}

.meta-card.action form {
  margin: 0;
}

.button.compact {
  padding: 8px 12px;
}

.meta-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  display: block;
}

.meta-card strong {
  display: block;
}

.sidebar {
  position: sticky;
  top: 24px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.brand-title {
  font-weight: 700;
}

.brand-subtitle {
  font-size: 0.85rem;
  color: var(--muted);
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  padding: 10px 12px;
  border-radius: 12px;
  background: transparent;
  font-weight: 600;
  color: var(--muted);
  transition: background 0.2s ease, color 0.2s ease;
}

.nav-item.is-active,
.nav-item:hover {
  background: rgba(42, 111, 111, 0.12);
  color: var(--accent-2);
}

.nav-divider {
  margin-top: 12px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted-2);
}

.sidebar-foot {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid rgba(96, 86, 78, 0.15);
}

.main {
  display: grid;
  gap: 24px;
  min-width: 0;
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

@media (max-width: 1400px) {
  .cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .cards {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--panel);
  padding: 18px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 6px;
}

.card-label {
  font-size: 0.85rem;
  color: var(--muted-2);
}

.card-value {
  font-size: 1.6rem;
}

.card-trend {
  font-size: 0.85rem;
  color: var(--muted);
}

.card-trend.up {
  color: var(--success);
}

.card-trend.down {
  color: var(--danger);
}

.no-wrap {
  white-space: nowrap;
}

.panel {
  background: var(--panel);
  padding: 20px 22px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.panel-header h2 {
  margin: 0;
  white-space: nowrap;
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(42, 111, 111, 0.12);
  font-size: 0.8rem;
}

.chip.muted {
  background: rgba(96, 86, 78, 0.12);
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
  margin-top: 24px;
}

.filters+.table-wrap {
  margin-top: 42px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  padding: 12px 10px;
  text-align: center;
  border-bottom: 1px solid rgba(96, 86, 78, 0.12);
  vertical-align: middle;
  white-space: nowrap;
}

/* ID Column Styling */
td:first-child,
th:first-child {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.8rem;
  letter-spacing: -0.01em;
  color: var(--muted);
  text-align: center !important;
  /* Force center alignment */
}

/* ID Pill Styling for Desktop */
@media (min-width: 961px) {
  td:first-child {
    color: var(--ink);
    font-weight: 500;
  }
}

th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-2);
}

.status {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(42, 111, 111, 0.12);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-2);
}

.status.success {
  background: rgba(43, 107, 74, 0.15);
  color: var(--success);
}

.status.warning {
  background: rgba(246, 209, 139, 0.4);
  color: #7a4d0b;
}

.status.danger {
  background: rgba(163, 76, 66, 0.15);
  color: var(--danger);
}

.alert {
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 600;
  background: rgba(246, 209, 139, 0.25);
  border: 1px solid rgba(246, 209, 139, 0.55);
  color: #7a4d0b;
}

.alert.danger {
  background: rgba(163, 76, 66, 0.12);
  border: 1px solid rgba(163, 76, 66, 0.25);
  color: var(--danger);
}

.button {
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  background: rgba(42, 111, 111, 0.15);
  color: var(--accent-2);
}

.button.primary {
  background: var(--accent);
  color: #fff;
}

.button.ghost {
  background: transparent;
  border: 1px solid rgba(42, 111, 111, 0.3);
}


.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.detail-card {
  background: rgba(246, 209, 139, 0.25);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  gap: 6px;
}

.detail-label {
  font-size: 0.78rem;
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.event-table {
  width: 100%;
  table-layout: fixed;
}

.event-table th {
  text-align: center;
}

.event-time,
.event-status {
  white-space: nowrap;
}

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

.timeline {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}

.timeline li {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 10px;
  align-items: center;
}

.timeline-time {
  font-weight: 700;
  color: var(--accent-2);
}

.timeline-note {
  color: var(--muted);
  font-size: 0.85rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.7rem;
  color: var(--muted-2);
  margin: 0;
}

.caption {
  color: var(--muted);
  font-size: 0.85rem;
}

.empty {
  text-align: center;
  color: var(--muted-2);
}

.login {
  min-height: 80vh;
  display: grid;
  place-items: center;
}

.login-card {
  background: rgba(255, 255, 255, 0.92);
  padding: 32px;
  border-radius: 22px;
  box-shadow: var(--shadow);
  width: min(420px, 92vw);
  display: grid;
  gap: 18px;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-form label {
  display: grid;
  gap: 8px;
  font-weight: 600;
}

/* Modern Form Elements */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
select {
  appearance: none;
  -webkit-appearance: none;
  background-color: #fff;
  border: 1px solid #d0c9c0;
  border-radius: 8px;
  padding: 0 14px;
  height: 42px;
  /* Fixed height for alignment */
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
  /* Default to full width per container, adjust in layouts */
  max-width: 100%;
}

select {
  padding-right: 36px;
  background-image: 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='%2360564e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  cursor: pointer;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(42, 111, 111, 0.15);
}

.button {
  height: 42px;
  /* Match input height */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

/* Fix Status Pills */
.status {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
}

/* Fix Meta Card for Signed In User */
.meta-card.user {
  flex: 1 1 auto;
  min-width: 0;
}

.meta-card.user strong {
  font-size: 0.95rem;
  /* Reduce size for email */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  font-weight: 600;
}

/* Filter Layout Fix */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.filters>* {
  flex: 0 0 auto;
  /* Stop stretching weirdly */
}

/* Ensure inputs inside filters don't take full width */
.filters input,
.filters select {
  width: auto;
  min-width: 120px;
}

/* Date inputs might need specific width constraint if they grow too large */
input[type="datetime-local"] {
  width: auto;
  min-width: 200px;
}

/* Mobile Toggle */
.mobile-menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid rgba(42, 111, 111, 0.2);
  border-radius: 8px;
  padding: 6px;
  margin-right: 12px;
  cursor: pointer;
  color: var(--accent);
  transition: background 0.2s;
}

.mobile-menu-toggle:hover {
  background: rgba(42, 111, 111, 0.1);
}

.mobile-menu-toggle svg {
  display: block;
}

/* Responsive Breakpoint */
@media (max-width: 960px) {
  .shell {
    grid-template-columns: 100%;
    gap: 20px;
  }

  /* Sidebar as Off-canvas Drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 1000;
    transform: translateX(-110%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    border-radius: 0 16px 16px 0;
    margin: 0;
  }

  body.nav-open .sidebar {
    transform: translateX(0);
  }

  /* Overlay when sidebar matches */
  body.nav-open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(30, 26, 24, 0.4);
    backdrop-filter: blur(2px);
    z-index: 999;
    animation: fadeIn 0.3s;
  }

  @keyframes fadeIn {
    from {
      opacity: 0;
    }

    to {
      opacity: 1;
    }
  }

  /* Topbar Adjustments */
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .topbar-title {
    display: flex;
    align-items: center;
  }

  .topbar-title h1 {
    font-size: 1.8rem;
  }

  .mobile-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Topbar Meta - No Scroll, cleaner layout */
  .topbar-meta {
    justify-content: flex-start;
    flex-wrap: wrap;
    /* Allow wrapping */
    gap: 12px;
    padding-bottom: 0;
  }

  .meta-card {
    min-width: auto;
    /* Allow shrinking */
    flex: 1 1 calc(50% - 6px);
    /* 2 per row */
    font-size: 0.85rem;
    padding: 10px;
  }

  /* Hide less critical info on mobile to save space */
  .meta-card.hide-mobile {
    display: none;
  }

  .meta-card.action {
    flex: 1 1 100%;
    /* Full width for action */
  }

  .card-value {
    font-size: 1.4rem;
  }

  /* Ensure tables scroll */
  .table-wrap {
    margin: 0 -18px;
    /* Negative margin to pull to edges inside panels */
    padding: 0 18px;
    width: calc(100% + 36px);
  }

  .panel {
    padding: 16px;
  }

  /* Table to Card Transformation */
  table.mobile-card,
  table.mobile-card thead,
  table.mobile-card tbody,
  table.mobile-card th,
  table.mobile-card td,
  table.mobile-card tr {
    display: block !important;
  }

  table.mobile-card thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }

  table.mobile-card tr {
    margin-bottom: 20px;
    background: #fff;
    border: 1px solid rgba(96, 86, 78, 0.15);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(30, 26, 24, 0.06);
  }

  table.mobile-card td {
    border: none !important;
    border-bottom: 1px solid rgba(96, 86, 78, 0.08) !important;
    padding: 16px 14px !important;
    display: flex !important;
    flex-direction: column !important;
    /* Stack Label and Value */
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    width: 100% !important;
    min-height: auto !important;
    white-space: normal !important;
  }

  table.mobile-card td::before {
    content: attr(data-label);
    display: block !important;
    position: static !important;
    width: 100% !important;
    text-align: center !important;
    font-weight: 700 !important;
    color: var(--muted-2) !important;
    font-size: 0.7rem !important;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 6px !important;
  }

  table.mobile-card td:last-child {
    border-bottom: none !important;
  }

  table.mobile-card td .chip,
  table.mobile-card td .status,
  table.mobile-card td a,
  table.mobile-card td span {
    margin: 0 auto !important;
    display: inline-flex !important;
    text-align: center !important;
  }

  /* Force first cell to also be centered and stacked */
  table.mobile-card td:first-child {
    background: rgba(42, 111, 111, 0.05) !important;
    font-weight: 700;
  }
}