body {
  background-image: url('https://zenerrand.com/hero1.jpg');
  background-attachment: fixed;
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  font-family: sans-serif !important;
  margin: 0;
  color: #2b2b2f;
}

.page {
  max-width: 600px;
  margin: auto;
  padding: 0.5em;
}

.card,
.form-wrapper {
  text-align: center;
  background: rgba(255, 255, 255, 0.7);
  padding: 0.5em 0.5em;
  max-width: 600px;
  margin: auto;
  margin-top: 1em;
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(0,0,0,0.3);
}

h1, h2, h3 {
  color: #08085a;
}

.quickadd-btn,
button {
  background-color: #6366F1;
  color: #fff;
  border: none;
  padding: 0.6em 1.2em;
  font-size: 0.9em;
  font-weight: bold;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  display: inline-block;
}

.quickadd-btn:hover,
button:hover {
  background-color: #4F46E5;
}

.quickadd-input,
input[type="text"],
input[type="email"],
input[type="password"] {
  padding: 0.6em;
  font-size: 1em;
  width: 80%;
  max-width: 500px;
  margin: 0.5em auto 1em auto;
  display: block;
  border: 1px solid #ccc;
  border-radius: 5px;
}

.tab-buttons {
  display: flex;
  gap: 0.5em;
  justify-content: center;
  margin-bottom: 1em;
}

.tab-buttons .quickadd-btn,
.tab-buttons button {
  flex: 1;
  font-size: 0.7em;
  font-weight: bold;
  margin: 0;
}

.item-row {
  display: flex;
  gap: 0.5em;
  align-items: center;
  justify-content: space-between;
  padding: 0.5em;
  border-bottom: 1px solid rgba(0,0,0,0.15);
  font-size: 0.9em;
  font-weight: bold;
}

.item-row:last-child {
  border-bottom: none;
}

.item-name {
  flex: 1;
  text-align: left;
}

.item-row form {
  margin: 0;
}

.item-row form[action="/shopping/items/complete"] button {
  background-color: #10B981;
}

.item-row form[action="/shopping/items/complete"] button:hover {
  background-color: #059669;
}

.logout {
  text-align: center;
  margin: 1em auto;
}

.logout button {
  background-color: #6366F1;
}

.error {
  color: #b91c1c;
  font-weight: bold;
}

#barcode-scanner-container {
  position: relative;
  width: 80%;
  max-width: 300px;
  aspect-ratio: 4/3;
  margin: 1em auto;
  display: none;
}

#barcode-scanner-container video,
#barcode-scanner-container canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media screen and (max-width: 600px) {
  .page {
    padding: 0.5em;
  }

  .zenerrand-action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5em;
  }

  .quickadd-btn,
  button {
    width: 100%;
    margin-top: 0.5em;
  }

  .quickadd-input,
  input[type="text"],
  input[type="email"],
  input[type="password"] {
    width: 100%;
  }

  .item-row {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .item-name {
    text-align: center;
  }
}

@media screen and (min-width: 601px) {
  .zenerrand-action-buttons {
    display: inline-flex;
    gap: 0.5em;
  }
}

.order-form {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  margin: 0;
}

.order-input {
  width: 70px !important;
  max-width: 70px !important;
  margin: 0 !important;
  padding: 0.35em !important;
  text-align: center;
}

.order-form button {
  padding: 0.35em 0.6em;
  font-size: 0.75em;
}

@media screen and (max-width: 600px) {
  .order-form {
    width: 100%;
    justify-content: center;
  }

  .order-input {
    width: 100% !important;
    max-width: 120px !important;
  }

  .order-form button {
    width: auto;
  }
}

a.quickadd-btn,
a.quickadd-btn:visited,
a.quickadd-btn:hover,
a.quickadd-btn:active {
  text-decoration: none;
}

.delete-btn {
  background-color: #EF4444;
}

.delete-btn:hover {
  background-color: #DC2626;
}

/* Layout polish: item text left/middle, action buttons right */
.item-row {
  display: flex;
  gap: 0.5em;
  align-items: center;
  justify-content: space-between;
}

.item-name {
  flex: 1;
  text-align: left;
}

.item-actions {
  display: inline-flex;
  gap: 0.5em;
  justify-content: flex-end;
  align-items: center;
}

.order-form-left {
  flex: 0 0 auto;
}

.item-row-active .item-name {
  padding-left: 0.25em;
}

@media screen and (max-width: 600px) {
  .item-row {
    flex-direction: row;
    align-items: center;
  }

  .item-actions {
    flex: 0 0 auto;
  }

  .item-actions button,
  .order-form button {
    width: auto;
  }

  .item-name {
    text-align: left;
  }
}

.order-form-left {
  min-width: 72px;
}

.order-form-left .order-input {
  margin-bottom: 0 !important;
}

/* Hide number input up/down spinners */
.order-input::-webkit-outer-spin-button,
.order-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.order-input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* Make active shopping rows feel closer to old QuickAdd table */
.order-input {
  background: transparent !important;
  border: none !important;
  color: #fff !important;
  font-weight: bold;
  width: 42px !important;
  max-width: 42px !important;
  text-align: left;
  padding: 0.25em !important;
}

.order-input:focus {
  outline: 1px solid rgba(255,255,255,0.65);
  background: rgba(255,255,255,0.15) !important;
}

.item-row-active {
  background: rgba(99, 102, 241, 0.18);
}

.item-row-active .item-name {
  color: #fff;
  font-weight: bold;
}

.item-row-active .order-form-left {
  min-width: 44px;
}

/* Keep active shopping rows transparent like completed rows */
.item-row-active {
  background: transparent !important;
}

.item-row-active .order-input {
  color: #2b2b2f !important;
}

.item-row-active .item-name {
  color: #2b2b2f !important;
}

.nav-logout {
  margin: 0.5em auto 0 auto;
}

.nav-logout button {
  width: auto;
}

.logout-link-form {
  text-align: right;
  margin: 0.25em 0 0 0;
}

.logout-link {
  background: transparent !important;
  color: #08085a !important;
  border: none !important;
  padding: 0 !important;
  font-size: 0.85em !important;
  font-weight: bold;
  text-decoration: underline;
  cursor: pointer;
  width: auto !important;
  margin: 0 !important;
}

.logout-link:hover {
  background: transparent !important;
  color: #4F46E5 !important;
}

/* Better nav wrapping now that Settings exists */
.tab-buttons {
  flex-wrap: wrap;
}

.tab-buttons .quickadd-btn {
  min-width: 120px;
}

@media screen and (max-width: 600px) {
  .tab-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5em;
  }

  .tab-buttons .quickadd-btn {
    width: 100%;
    min-width: 0;
    margin-top: 0;
  }
}

/* Mobile overflow fixes */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  overflow-x: hidden;
}

.page,
.card {
  width: 100%;
  max-width: 100%;
}

.card {
  overflow: hidden;
}

input,
button,
.quickadd-btn {
  max-width: 100%;
}

.quickadd-input,
input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100% !important;
}

.tab-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5em;
  width: 100%;
}

.tab-buttons .quickadd-btn {
  width: 100%;
  min-width: 0;
  margin: 0;
}

@media screen and (max-width: 600px) {
  .page {
    padding-left: 1em;
    padding-right: 1em;
  }

  .card {
    padding-left: 1em;
    padding-right: 1em;
  }
}

@media screen and (max-width: 600px) {
  .page {
    padding-top: 0.75em;
  }

  .card {
    margin-top: 0.75em;
    padding-top: 1em;
    padding-bottom: 1em;
  }

  h1 {
    font-size: 2.1em;
    margin-bottom: 0.4em;
  }

  h2 {
    font-size: 1.6em;
  }

  .quickadd-input,
  input[type="text"],
  input[type="email"],
  input[type="password"] {
    font-size: 1em;
    padding: 0.55em;
  }
}

/* Fix shopping item row layout on mobile */
.item-row-active {
  display: grid !important;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 0.5em;
  align-items: center;
  width: 100%;
}

.item-row-active .order-form-left {
  width: 48px;
  min-width: 48px;
  text-align: left;
}

.item-row-active .item-name {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: left !important;
}

.item-row-active .item-actions {
  justify-self: end;
  white-space: nowrap;
}

.zenerrand-action-buttons {
  display: flex !important;
  flex-direction: row !important;
  gap: 0.5em;
  align-items: center;
  justify-content: flex-end;
}

.zenerrand-action-buttons form {
  margin: 0;
}

.zenerrand-action-buttons button {
  width: auto !important;
  min-width: 0;
  padding-left: 0.8em;
  padding-right: 0.8em;
}

@media screen and (max-width: 600px) {
  .item-row {
    width: 100%;
  }

  .item-row:not(.item-row-active) {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5em;
    align-items: center;
  }
}

/* Restore desktop QuickAdd-style width while keeping mobile fixed */
@media screen and (min-width: 801px) {
  .page {
    max-width: 600px !important;
    margin: 0 auto !important;
    padding: 0.5em !important;
  }

  .card {
    max-width: 600px !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  .tab-buttons {
    display: flex !important;
    grid-template-columns: none !important;
  }

  .tab-buttons .quickadd-btn {
    flex: 1;
    width: auto !important;
  }

  .quickadd-input,
  input[type="text"],
  input[type="email"],
  input[type="password"] {
    width: 80% !important;
    max-width: 500px !important;
  }
}

.settings-row {
  display: flex;
  justify-content: space-between;
  gap: 1em;
  padding: 0.55em 0;
  border-bottom: 1px solid rgba(0,0,0,0.15);
  text-align: left;
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-row span {
  text-align: right;
  overflow-wrap: anywhere;
}

.status-ok {
  color: #059669;
  font-weight: bold;
}

.status-error {
  color: #DC2626;
  font-weight: bold;
}

@media screen and (max-width: 600px) {
  .settings-row {
    flex-direction: column;
    gap: 0.15em;
  }

  .settings-row span {
    text-align: left;
  }
}

.calendar-notes {
  min-height: 90px;
  resize: vertical;
}

.event-notes {
  margin: 0.35em 0 0;
  opacity: 0.85;
  white-space: normal;
}

.calendar-date-group {
  margin-top: 1em;
}

.calendar-date-heading {
  margin: 1em 0 0.5em;
  padding-bottom: 0.35em;
  border-bottom: 1px solid rgba(0,0,0,0.15);
  text-align: left;
}

.calendar-event-row {
  align-items: flex-start;
}

.event-time {
  margin-top: 0.25em;
  font-size: 0.95em;
  opacity: 0.75;
}

#runboard-calendar {
  width: 100%;
  text-align: left;
}

.fc {
  font-size: 0.9em;
}

.fc .fc-toolbar-title {
  font-size: 1.25em;
}

.fc .fc-button {
  background: #6366F1;
  border-color: #6366F1;
}

.fc .fc-button:hover,
.fc .fc-button:focus {
  background: #4F46E5;
  border-color: #4F46E5;
}

.fc .fc-daygrid-event {
  white-space: normal;
}

@media screen and (max-width: 600px) {
  .fc .fc-toolbar {
    flex-direction: column;
    gap: 0.5em;
  }

  .fc .fc-toolbar-title {
    font-size: 1.1em;
  }

  .fc {
    font-size: 0.82em;
  }
}

.calendar-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1em;
}

.calendar-modal[hidden] {
  display: none;
}

.calendar-modal-card {
  width: min(420px, 100%);
  background: rgba(255,255,255,0.96);
  border-radius: 14px;
  padding: 1.25em;
  position: relative;
  box-shadow: 0 12px 35px rgba(0,0,0,0.25);
  text-align: left;
}

.calendar-modal-close {
  position: absolute;
  top: 0.5em;
  right: 0.65em;
  border: none;
  background: transparent;
  font-size: 1.8em;
  line-height: 1;
  cursor: pointer;
}

.calendar-modal-detail {
  display: flex;
  justify-content: space-between;
  gap: 1em;
  padding: 0.45em 0;
  border-bottom: 1px solid rgba(0,0,0,0.12);
}

.calendar-modal-detail span {
  text-align: right;
}

.calendar-modal-notes-wrap {
  margin-top: 0.85em;
}

.calendar-modal-notes-wrap p {
  margin: 0.35em 0 0;
  white-space: pre-wrap;
}

.calendar-modal-actions {
  margin-top: 1em;
  text-align: right;
}

.calendar-modal-edit-form {
  margin-top: 0.75em;
}

.secondary-button {
  background: #E5E7EB;
  color: #111827;
  border: none;
  border-radius: 8px;
  padding: 0.55em 0.85em;
  cursor: pointer;
}

.secondary-button:hover {
  background: #D1D5DB;
}

.calendar-list-event {
  cursor: pointer;
}

.calendar-list-event:hover {
  background: rgba(255,255,255,0.45);
}

.dashboard-actions {
  margin: 0.75em 0 1em;
}

.dashboard-add-event-button {
  display: inline-block;
  text-decoration: none;
}

.dashboard-view-calendar-button {
  display: inline-block;
  text-decoration: none;
}

.calendar-actions {
  margin: 0.75em 0 1em;
  text-align: center;
}

.section-toggle {
  width: 100%;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: bold;
  font-size: 1.15em;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.section-toggle span {
  font-size: 0.85em;
  opacity: 0.7;
}
