:root {
  --bg: #f6f6f3;
  --panel: #ffffff;
  --ink: #111213;
  --muted: #6c6f73;
  --accent: #c8b98a;
  --border: #e4e6e8;
  font-family: "Manrope", system-ui, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

.app {
  width: 100%;
  margin: 0;
  padding: 8px 14px calc(90px + constant(safe-area-inset-bottom));
  padding: 8px 14px calc(90px + env(safe-area-inset-bottom));
  display: grid;
  gap: 8px;
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: relative;
}

.topbar p { margin: 0; }

.topbar h1 {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 2rem;
}

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

.muted { color: var(--muted); margin: 0; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 600;
}

.btn.primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 0.85rem; }
.btn.action { border-color: rgba(200, 185, 138, 0.55); }
.btn.action:hover { background: rgba(200, 185, 138, 0.12); }

.form {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}

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

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.stat {
  background: #faf9f7;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 6px;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
}

.screen { display: none; }
.screen.active { display: block; }

.list {
  display: grid;
  gap: 10px;
}

.list-scroll {
  max-height: calc(100vh - 360px);
  overflow: auto;
  padding-right: 4px;
}

.list-scroll.is-empty {
  max-height: none;
}

.history-controls,
.earnings-controls {
  display: flex;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.date-filter {
  display: grid;
  gap: 6px;
}

.active-order-card {
  border: 1px solid rgba(200, 185, 138, 0.45);
  background: #fffaf0;
  border-radius: 16px;
  padding: 14px;
  display: grid;
  gap: 10px;
  position: sticky;
  top: 12px;
  z-index: 10;
}

.active-order-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.active-order-title {
  font-weight: 700;
  font-size: 1.05rem;
}

.active-order-info {
  display: grid;
  gap: 6px;
  font-size: 0.95rem;
}

.active-order-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.timer-card {
  border: 1px dashed rgba(200, 185, 138, 0.6);
  border-radius: 14px;
  padding: 12px;
  background: #fffdf7;
  margin-bottom: 10px;
}

#current-empty {
  padding: 8px 2px;
}

.timer-label { color: var(--muted); font-size: 0.85rem; }
.timer-value { font-size: 1.4rem; font-weight: 700; }

.item {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 8px;
  background: #fff;
}

.item.mine { border-color: rgba(200, 185, 138, 0.6); box-shadow: 0 8px 16px rgba(200, 185, 138, 0.12); }
.item.available { border-style: dashed; }

.item-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  background: #faf9f7;
}

.badge.mine { border-color: rgba(200, 185, 138, 0.6); color: #8e7a49; }
.badge.available { border-style: dashed; color: #6c6f73; }

.item-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.item-meta {
  display: grid;
  gap: 4px;
  font-size: 0.9rem;
}

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

.item.compact .item-meta,
.item.compact .item-actions {
  display: none;
}

.item.expandable { cursor: pointer; }

.item .item-detail {
  font-size: 0.9rem;
  color: var(--muted);
}

.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  display: flex;
  gap: 8px;
  padding: 10px 16px calc(14px + constant(safe-area-inset-bottom));
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom));
  background: rgba(246, 246, 243, 0.96);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(8px);
  z-index: 40;
  transform: translateZ(0);
}

.bottom-btn {
  flex: 1;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 14px;
  padding: 8px 10px;
  display: grid;
  gap: 4px;
  justify-items: center;
  font-weight: 600;
  cursor: pointer;
}

.bottom-icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.bottom-icon svg {
  width: 20px;
  height: 20px;
}

.bottom-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.bottom-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(17, 18, 19, 0.08);
  font-size: 0.75rem;
}

.bottom-btn.active .bottom-count {
  background: rgba(255, 255, 255, 0.25);
}

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

.calendar-day {
  padding: 8px 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  text-align: center;
  font-size: 0.85rem;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.calendar-day:hover {
  border-color: rgba(200, 185, 138, 0.7);
  box-shadow: 0 6px 16px rgba(200, 185, 138, 0.18);
  transform: translateY(-1px);
}

.calendar-day.worked {
  background: rgba(85, 168, 108, 0.18);
  border-color: rgba(85, 168, 108, 0.4);
  color: #2f6b46;
}

.earnings-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff8e7;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #111213;
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
  font-size: 0.9rem;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: #b23b3b;
}

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .list-scroll { max-height: calc(100vh - 340px); }
  .active-order-card { top: 6px; }
  .earnings-summary { grid-template-columns: 1fr; }
}
.logout-btn {
  position: absolute;
  right: 0;
  top: 0;
}

@media (max-width: 600px) {
  .app {
    padding: 8px 10px calc(96px + constant(safe-area-inset-bottom));
    padding: 8px 10px calc(96px + env(safe-area-inset-bottom));
    gap: 10px;
  }
  .topbar h1 { font-size: 1.6rem; }
  .eyebrow { letter-spacing: 0.2em; }
  .card { padding: 14px; border-radius: 16px; }
  .btn { padding: 8px 10px; }
  .btn.small { padding: 6px 8px; }
  .active-order-actions { flex-direction: column; align-items: stretch; }
  .list-scroll { max-height: calc(100dvh - 300px); }
  .bottom-bar { gap: 6px; padding: 8px 10px calc(12px + env(safe-area-inset-bottom)); }
  .bottom-btn { padding: 6px 6px; font-size: 0.8rem; }
  .bottom-label { font-size: 0.75rem; }
  .bottom-count { min-width: 18px; height: 18px; font-size: 0.7rem; }
}

@media (max-width: 360px) {
  .topbar h1 { font-size: 1.45rem; }
  .item-title { flex-direction: column; align-items: flex-start; }
  .item-actions { gap: 6px; }
}
