* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #F7F5F1;
  --surface: #FFFFFF;
  --border: #E6E1D8;
  --text-primary: #14161B;
  --text-secondary: #6E6A61;
  --primary: #D1502F;
  --primary-hover: #B33F22;
  --primary-soft: #FBEAE3;
  --ink: #1A2233;
  --success: #2F7A52;
  --success-soft: #E5F3EA;
  --danger: #C13A3A;
  --danger-hover: #A32E2E;
  --danger-soft: #FBEAEA;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 3px rgba(20, 22, 27, 0.06);
  --shadow-md: 0 10px 28px rgba(20, 22, 27, 0.12);
}

body {
  background-color: var(--bg);
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  padding: 3rem 1.5rem;
  font-size: 15.5px;
}

.page {
  max-width: 640px;
  margin: 0 auto;
}

.page-wide {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0;
}

h1 {
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  font-size: 2.2rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.15;
  margin-bottom: 0.4rem;
  color: var(--ink);
}

.subtitle, .trip-meta {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 1.75rem;
}

.page-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 2.25rem;
}

/* ===== BUTTONS: strict two-color system ===== */
/* Default = Primary: solid accent, white text, same on every button unless .secondary or .danger is applied */
button {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.68rem 1.35rem;
  border: 1.5px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  background: var(--primary);
  color: #FFFDFB;
  transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
  letter-spacing: 0.01em;
  outline: none;
}

button:hover {
  background: var(--primary-hover);
  color: #FFFDFB;
  box-shadow: 0 4px 14px rgba(209, 80, 47, 0.28);
}

button:active {
  transform: scale(0.97);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

button:focus-visible {
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* Secondary: light background, dark text, always stays dark text on hover */
button.secondary {
  background: var(--surface);
  color: var(--text-primary);
  border-color: var(--border);
  box-shadow: none;
}

button.secondary:hover {
  background: #FAF8F4;
  color: var(--text-primary);
  border-color: #D8D0C2;
  box-shadow: none;
}

button.secondary:focus-visible {
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* Danger: necessary exception for destructive actions, same two-tone pattern */
button.danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
  box-shadow: none;
}

button.danger:hover {
  background: var(--danger);
  color: #FFFDFB;
  box-shadow: none;
}

/* Active tab state now reuses Primary instead of a separate dark color, avoiding the white-on-white hover bug */
.trip-tab-btn.active {
  background: var(--primary);
  color: #FFFDFB;
  border-color: var(--primary);
}

.trip-tab-btn.active:hover {
  background: var(--primary-hover);
  color: #FFFDFB;
}

/* Inputs */
input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
select,
textarea {
  font-family: inherit;
  font-size: 0.94rem;
  padding: 0.7rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.add-row {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1.75rem;
}

/* Lists */
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.15rem 1.4rem;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 0.7rem;
  gap: 1rem;
}

.list-row .name {
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.list-row .meta {
  font-size: 0.83rem;
  color: var(--text-secondary);
}

.row-actions {
  display: flex;
  gap: 0.5rem;
}

.row-actions button {
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
}

.empty-state {
  color: var(--text-secondary);
  padding: 3.5rem 0;
  text-align: center;
  font-size: 0.95rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.empty-illustration {
  width: 200px;
  height: 140px;
  margin-bottom: 1rem;
}

.error-banner {
  background: var(--danger-soft);
  color: #8C2E2E;
  padding: 0.85rem 1.15rem;
  margin-bottom: 1.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  border-left: 3px solid var(--danger);
}

/* Header bar */
.header-bar {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 1.1rem 2rem;
  margin: -3rem -1.5rem 3rem -1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 1.25rem;
  font-weight: 550;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.brand-logo {
  display: inline-flex;
  width: 22px;
  height: 22px;
}

.header-nav {
  display: flex;
  gap: 1.75rem;
  flex: 1;
}

.header-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 550;
  transition: color 0.15s ease;
}

.header-nav a:hover {
  color: var(--text-primary);
}

.profile-dropdown {
  position: relative;
}

.profile-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  box-shadow: none;
}

.profile-dropdown-toggle:hover {
  background: #FAF8F4;
  color: var(--text-primary);
  box-shadow: none;
}

.profile-dropdown-chevron {
  font-size: 0.7rem;
  color: var(--text-secondary);
  transition: transform 0.15s ease;
}

.profile-dropdown.open .profile-dropdown-chevron {
  transform: rotate(180deg);
}

.profile-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  min-width: 160px;
  overflow: hidden;
  z-index: 50;
}

.profile-dropdown.open .profile-dropdown-menu {
  display: block;
}

.profile-dropdown-menu a,
.profile-dropdown-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
  background: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  cursor: pointer;
}

.profile-dropdown-menu a:hover,
.profile-dropdown-menu button:hover {
  background: #FAF8F4;
  color: var(--text-primary);
  box-shadow: none;
}

.profile-dropdown-menu .logout-item {
  color: var(--danger);
  border-top: 1px solid var(--border);
}

.profile-dropdown-menu .logout-item:hover {
  color: var(--danger);
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 50%;
  background: var(--primary);
  color: #FFFDFB;
  font-size: 0.9rem;
  font-weight: 650;
}

/* Data table */
table.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

table.data-table th {
  text-align: left;
  font-weight: 600;
  font-size: 0.74rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1.05rem 1.2rem;
  background: #FAF8F4;
  border-bottom: 1px solid var(--border);
}

table.data-table td {
  padding: 1.1rem 1.2rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.data-table tr:last-child td {
  border-bottom: none;
}

table.data-table tr:hover td {
  background: #FBFAF7;
}

/* Drawer */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 27, 0.45);
  display: none;
  z-index: 100;
}

.drawer-overlay.open {
  display: block;
}

.drawer {
  position: fixed;
  top: 0;
  right: -420px;
  width: 380px;
  height: 100%;
  background: var(--surface);
  box-shadow: -6px 0 32px rgba(20, 22, 27, 0.16);
  padding: 2.5rem 2rem;
  transition: right 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 101;
  overflow-y: auto;
}

.drawer.open {
  right: 0;
}

.drawer h2 {
  font-family: Georgia, serif;
  font-size: 1.4rem;
  font-weight: 500;
  margin-bottom: 1.75rem;
}

.drawer input, .drawer select {
  width: 100%;
  margin-bottom: 0.75rem;
}

.drawer .form-actions {
  margin-top: 0.5rem;
}

.drawer .form-actions button {
  width: 100%;
  margin-bottom: 0.5rem;
}

/* Trip overview cards */
.trip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.25rem;
}

.trip-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.6rem;
  cursor: pointer;
  position: relative;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  border-top: 3px solid var(--primary);
  outline: none;
}

.trip-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.trip-card:focus-visible {
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.trip-card h3 {
  font-family: Georgia, serif;
  font-size: 1.2rem;
  font-weight: 500;
  margin-bottom: 0.6rem;
  padding-right: 4rem;
  color: var(--ink);
}

.trip-card .date-range {
  font-size: 0.84rem;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 1.1rem;
}

.trip-card .stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.83rem;
  color: var(--text-secondary);
  padding: 0.5rem 0;
  border-top: 1px solid var(--border);
}

.trip-status-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 650;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  margin-bottom: 0.7rem;
}

.trip-status-badge.status-upcoming {
  background: var(--success-soft);
  color: #205C3B;
}

.trip-status-badge.status-past {
  background: #F0ECE3;
  color: var(--text-secondary);
}

.trip-card .card-delete-btn {
  position: absolute;
  top: 1.4rem;
  right: 1.4rem;
  padding: 0.32rem 0.7rem;
  font-size: 0.72rem;
}

.trip-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.75rem;
}

.trip-tab-btn {
  padding: 0.55rem 1.25rem;
  font-size: 0.88rem;
}

/* Login page hero */
.login-hero {
  max-width: 440px;
  margin: 2rem auto 0;
}

.login-hero .brand-mark {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: Georgia, serif;
  font-size: 1.05rem;
  font-weight: 550;
  color: var(--primary);
  letter-spacing: 0.02em;
  margin-bottom: 1.75rem;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2.5rem;
  border-top: 4px solid var(--primary);
}

.login-card h1 {
  font-size: 1.9rem;
}

/* Timeline icons */
.timeline-marker svg {
  width: 18px;
  height: 18px;
}

.event-summary-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}