:root {
  --ink: #1C2B39;
  --ink-soft: #52657A;
  --paper: #EFF3F6;
  --card: #FFFFFF;
  --line: #D9E1E7;
  --mango: #F0A63A;
  --mango-ink: #7A4E0E;
  --teal: #2F8F86;
  --teal-ink: #0F433D;
  --coral: #E0667A;
  --coral-ink: #7A1F30;
  --slate: #52657A;
  --slate-ink: #24313F;
  --good: #2F8F5B;
  --green: #2F8F5B;
  --red: #E5484D;
  --red-ink: #A32D2D;
  --shadow: 0 1px 2px rgba(28,43,57,.06), 0 8px 24px -12px rgba(28,43,57,.18);
  --radius: 18px;
  --radius-sm: 10px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-image:
    radial-gradient(circle at 1px 1px, rgba(28,43,57,.055) 1px, transparent 0);
  background-size: 22px 22px;
}

h1, h2, h3, .display {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

#app {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 20px 80px;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0 18px;
  position: sticky;
  top: 0;
  background: linear-gradient(var(--paper) 78%, transparent);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-tag { font-size: 26px; transform: rotate(-8deg); display: inline-block; }
.brand h1 { font-size: 22px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.conn-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #c8cfd6;
  box-shadow: 0 0 0 3px rgba(28,43,57,.05);
  transition: background .3s;
}
.conn-dot.online { background: var(--good); box-shadow: 0 0 0 3px rgba(47,143,91,.18); }

/* ---------- Buttons ---------- */
.btn {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 14px;
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .15s ease;
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #0f1d29; }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1.5px solid var(--line); }
.btn-ghost:hover { border-color: var(--ink-soft); color: var(--ink); }
.btn-ghost.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: var(--red-ink); }

.back-link {
  background: none; border: none; cursor: pointer;
  font-family: 'Inter', sans-serif; font-weight: 600; font-size: 14px;
  color: var(--ink-soft); padding: 6px 0 14px; margin-top: 4px;
}
.back-link:hover { color: var(--ink); }

/* ---------- View head ---------- */
.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 4px;
}
.view-head h2 { font-size: 28px; line-height: 1.15; }
.editable-title {
  outline: none; border-bottom: 2px dashed transparent; cursor: text;
}
.editable-title:hover, .editable-title:focus { border-bottom-color: var(--line); }
.vacation-actions { display: flex; gap: 10px; position: relative; }

/* ---------- Ticket cards (Urlaubsliste) ---------- */
.ticket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.ticket {
  position: relative;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 20px 18px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border: 1px solid var(--line);
  transition: transform .15s ease, box-shadow .15s ease;
  overflow: hidden;
}
.ticket:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(28,43,57,.08), 0 16px 32px -14px rgba(28,43,57,.22); }
.ticket::before, .ticket::after {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  background: var(--paper);
  border-radius: 50%;
  top: 50%;
  transform: translateY(-50%);
  box-shadow: inset 0 0 0 1px var(--line);
}
.ticket::before { left: -9px; }
.ticket::after { right: -9px; }
.ticket-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.ticket-name { font-size: 19px; font-weight: 600; line-height: 1.2; }
.ticket-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--ink-soft);
}
.ticket-divider {
  border: none;
  border-top: 2px dashed var(--line);
  margin: 0;
}
.ticket-progress-row { display: flex; align-items: center; gap: 12px; }
.ring {
  --pct: 0;
  width: 44px; height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  background: conic-gradient(var(--teal) calc(var(--pct) * 1%), var(--line) 0);
  display: flex; align-items: center; justify-content: center;
}
.ring-inner {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--card);
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; font-weight: 700; color: var(--ink);
}
.ticket-progress-text { font-size: 13px; color: var(--ink-soft); }
.ticket-archive-btn {
  align-self: flex-start;
  font-size: 12px;
  color: var(--ink-soft);
  background: none;
  border: none;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

.empty-state {
  color: var(--ink-soft);
  text-align: center;
  padding: 60px 20px;
  font-size: 15px;
}

.hint-text {
  color: var(--ink-soft);
  font-size: 14px;
  margin: -8px 0 18px;
}

/* ---------- Sort menu ---------- */
.sort-menu {
  position: absolute;
  right: 20px;
  margin-top: 46px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 30;
}
.sort-menu button {
  display: block; width: 100%; text-align: left;
  padding: 10px 16px; background: none; border: none;
  font-family: 'Inter', sans-serif; font-size: 14px; cursor: pointer;
}
.sort-menu button:hover { background: var(--paper); }

/* ---------- Categories (luggage-tag headers) ---------- */
.categories { display: flex; flex-direction: column; gap: 18px; }

.category {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
  border-left: 6px solid var(--cat-color, var(--slate));
}
.category-hole {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--paper);
  box-shadow: inset 0 0 0 1.5px var(--line);
  flex-shrink: 0;
}
.category-name {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 18px;
  flex: 1;
}
.category-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--ink-soft);
}
.category-chevron {
  color: var(--ink-soft);
  transition: transform .2s ease;
  font-size: 12px;
}
.category.collapsed .category-chevron { transform: rotate(-90deg); }

.category-progress-track {
  height: 4px;
  background: var(--line);
}
.category-progress-fill {
  height: 100%;
  background: var(--cat-color, var(--slate));
  transition: width .25s ease;
}

.category-body {
  padding: 6px 10px 14px;
}
.category.collapsed .category-body { display: none; }

.item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 8px;
  border-radius: var(--radius-sm);
  transition: background .15s ease;
}
.item-row:hover { background: var(--paper); }
.item-row.status-packed .item-name { color: var(--ink-soft); text-decoration: line-through; text-decoration-color: var(--line); }
.item-row.status-not_needed .item-name { color: var(--red-ink); text-decoration: line-through; text-decoration-color: var(--red); }

.drag-handle {
  color: var(--line);
  cursor: grab;
  font-size: 16px;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}
.drag-handle:active { cursor: grabbing; }

.stamp {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--card);
  flex-shrink: 0;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.stamp svg { opacity: 0; transform: scale(.5); transition: opacity .15s ease, transform .15s ease; }
.stamp:active { transform: scale(0.88); }
.stamp-packed.checked { background: var(--green); border-color: var(--green); }
.stamp-packed.checked svg { opacity: 1; transform: scale(1); }
.stamp-not-needed.checked { background: var(--red); border-color: var(--red); }
.stamp-not-needed.checked svg { opacity: 1; transform: scale(1); }

.item-name {
  flex: 1;
  font-size: 15px;
  padding: 2px 4px;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft);
  opacity: 0;
  transition: opacity .15s ease, color .15s ease, border-color .15s ease;
  flex-shrink: 0;
}
.item-row:hover .icon-btn,
.item-row:focus-within .icon-btn { opacity: 1; }
.edit-btn {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  font-size: 12px;
}
.edit-btn:hover { border-color: var(--ink-soft); color: var(--ink); }
.delete-btn {
  width: 30px; height: 30px;
  font-size: 20px;
  color: var(--red);
}
.delete-btn:hover { color: var(--red-ink); }

.sortable-ghost { opacity: .35; }

.add-item-row {
  display: flex;
  gap: 8px;
  padding: 10px 8px 4px;
}
.add-item-row input {
  flex: 1;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  background: transparent;
  outline: none;
}
.add-item-row input:focus { border-color: var(--cat-color, var(--slate)); border-style: solid; }
.add-item-row button {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  width: 40px;
  font-size: 18px;
  cursor: pointer;
  color: var(--ink-soft);
}
.add-item-row button:hover { color: var(--ink); border-color: var(--ink-soft); }

/* Category color assignment */
.category[data-cat="Marco"]     { --cat-color: var(--teal); }
.category[data-cat="Susanne"]   { --cat-color: var(--coral); }
.category[data-cat="Timm"]      { --cat-color: var(--mango); }
.category[data-cat="Allgemein"] { --cat-color: var(--slate); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(28,43,57,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
}
.modal h3 { font-size: 20px; margin-bottom: 14px; }
.modal-text { font-size: 14px; color: var(--ink-soft); margin: -8px 0 4px; }
.modal input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 15px;
  font-family: 'Inter', sans-serif;
  outline: none;
}
.modal input:focus { border-color: var(--ink); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: var(--shadow);
  z-index: 200;
  animation: toastIn .25s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Mobile ---------- */
@media (max-width: 560px) {
  :root { font-size: 15px; }
  #app { padding: 0 14px 90px; }
  .topbar { padding: 16px 0 14px; }
  .view-head h2 { font-size: 23px; }
  .ticket-grid { grid-template-columns: 1fr; }
  .vacation-actions { width: 100%; justify-content: space-between; }
  .vacation-actions .btn { flex: 1; }
}

/* ---------- Login-Gate ---------- */
.login-gate {
  position: fixed;
  inset: 0;
  background: var(--paper);
  background-image: radial-gradient(circle at 1px 1px, rgba(28,43,57,.055) 1px, transparent 0);
  background-size: 22px 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
}
.login-gate[hidden] { display: none; }
.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 30px;
  width: 100%;
  max-width: 320px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.login-tag { font-size: 40px; transform: rotate(-8deg); display: inline-block; margin-bottom: 4px; }
.login-card h2 { font-size: 24px; }
.login-hint { color: var(--ink-soft); font-size: 14px; margin: 0 0 14px; }
.login-pin-input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 26px;
  letter-spacing: 0.5em;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  outline: none;
  margin-bottom: 16px;
}
.login-pin-input:focus { border-color: var(--ink); }
.login-submit { width: 100%; padding: 12px; font-size: 15px; }
.login-error {
  color: var(--red-ink);
  font-size: 13px;
  margin: 14px 0 0;
}
