:root {
  --purple: #D5A790;
  --purple-light: #E3C2AE;
  --purple-deep: #3D5267;
  --purple-pale: #2E2F34;
  --purple-dark: #E3C2AE;
  --on-purple: #101A24;
  --bg: #101A24;
  --surface: #17222E;
  --border: #2A3846;
  --text: #FFFFFF;
  --text-secondary: #C7CED6;
  --text-muted: #7C8894;
  --danger: #FF8A8A;
  --danger-pale: #3A1E28;
  --success: #7ED99C;
  --success-pale: #17301F;
  --amber: #F5C877;
  --amber-pale: #3B2C14;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Host Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 32px 16px;
}

#app {
  width: 100%;
  max-width: 400px;
}

.phone {
  background: var(--surface);
  border-radius: 24px;
  border: 1px solid var(--border);
  overflow: hidden;
  min-height: 640px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 28px rgba(0,0,0,0.55);
  position: relative;
}

.phone::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 33%;
  background-image: url("logo.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 65% auto;
  opacity: 0.12;
  pointer-events: none;
  z-index: 0;
}

.appbar {
  background: var(--purple);
  color: var(--on-purple);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.appbar h1 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  flex: 1;
}

.appbar button.icon {
  background: none;
  border: none;
  color: var(--on-purple);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.appbar .sub {
  font-size: 12px;
  color: var(--on-purple);
  opacity: 0.8;
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  position: relative;
  z-index: 1;
}

/* Login */
.login-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 48px 24px;
}
.login-wrap h1 {
  color: var(--purple);
  font-size: 24px;
  margin: 0 0 4px;
  text-align: center;
}
.login-wrap p.tag {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  margin: 0 0 20px;
}

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 6px;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--purple-light);
}

.field { margin-bottom: 14px; }

button.primary {
  background: var(--purple);
  color: var(--on-purple);
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}
button.primary:hover { background: var(--purple-deep); color: #fff; }
button.primary:disabled { opacity: 0.5; cursor: default; }

button.secondary {
  background: var(--surface);
  color: var(--purple);
  border: 1px solid var(--purple-light);
  border-radius: 10px;
  padding: 11px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

button.text-link {
  background: none;
  border: none;
  color: var(--purple);
  font-size: 13px;
  cursor: pointer;
  padding: 4px;
}

.error-box {
  background: var(--danger-pale);
  color: var(--danger);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* Region grid */
.region-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px 10px;
}
.region-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
}
.region-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--purple-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.region-cell span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  line-height: 1.3;
}

/* Item list */
.item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
}
/* The text block needs min-width:0 so flexbox will actually let it shrink and wrap
   instead of overflowing past the card edge (its default min-width is the length of
   the longest unbreakable string, e.g. a long "Updated ..." timestamp). */
.item-card > div:first-child {
  min-width: 0;
  flex: 1;
}
.item-card .name,
.item-card .meta,
.item-card .extra,
.item-card .timestamp {
  overflow-wrap: break-word;
  word-break: break-word;
}
.item-card .name { font-size: 15px; font-weight: 600; margin: 0 0 2px; }
.item-card .meta { font-size: 12px; color: var(--text-secondary); margin: 0; }
.item-card.for-sale { border-color: var(--amber); background: var(--amber-pale); }
.badge.for-sale { background: var(--amber); color: var(--on-purple); }
.item-card.queued { border-color: var(--purple); background: var(--purple-pale); }
.badge.queued { background: var(--purple); color: var(--on-purple); }
.item-card.kit-incomplete { border-color: var(--danger); background: var(--danger-pale); }
.item-card .extra { font-size: 12px; color: var(--text-muted); margin: 2px 0 0; }

.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40%;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}
.badge.pool { background: var(--purple-pale); color: var(--purple-dark); }
.badge.personal { background: var(--success-pale); color: var(--success); }
.badge.out_for_demo { background: var(--amber-pale); color: var(--amber); }
.badge.sold { background: var(--border); color: var(--text-secondary); }
.badge.transferred { background: var(--border); color: var(--text-secondary); }
.badge.pending_sale { background: var(--amber-pale); color: var(--amber); }
.badge.pending_transfer { background: var(--amber-pale); color: var(--amber); }
.badge.pending_handoff { background: var(--amber-pale); color: var(--amber); }
.badge.pending { background: var(--amber-pale); color: var(--amber); }
.badge.approved { background: var(--success-pale); color: var(--success); }
.badge.denied { background: var(--danger-pale); color: var(--danger); }

.timestamp {
  font-size: 11px;
  color: var(--text-muted);
  margin: 2px 0 0;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 40px 20px;
}

/* Bottom sheet */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.sheet {
  background: var(--surface);
  width: 100%;
  max-width: 400px;
  border-radius: 20px 20px 0 0;
  padding: 20px;
  max-height: 80vh;
  overflow-y: auto;
}
.sheet h2 { font-size: 16px; margin: 0 0 2px; }
.sheet .sub { font-size: 13px; color: var(--text-secondary); margin: 0 0 18px; }
.sheet-action {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  margin-bottom: 8px;
  font-family: inherit;
}
.sheet-action.danger { color: var(--danger); }
.sheet-action:hover { border-color: var(--purple-light); }

/* Coordinator menu */
.coord-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
}
.coord-menu-item .arrow { color: var(--text-muted); }

.person-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--purple-pale);
  color: var(--purple-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.person-row .name { font-size: 14px; font-weight: 600; margin: 0; }
.person-row .role { font-size: 12px; color: var(--text-secondary); margin: 0; }

.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  margin: 4px 0 10px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--purple-deep);
  color: #fff;
  padding: 10px 18px;
  border-radius: 30px;
  font-size: 13px;
  z-index: 100;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}

.notify-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  cursor: pointer;
  animation: notifySlideDown 0.35s ease-out;
}
.notify-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--purple);
  flex-shrink: 0;
  box-shadow: 0 0 0 4px var(--purple-pale);
}
.notify-text { flex: 1; }
.notify-title { font-size: 14px; font-weight: 700; margin: 0; color: var(--text); }
.notify-sub { font-size: 12px; color: var(--text-secondary); margin: 2px 0 0; }
.notify-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

@keyframes notifySlideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.center-msg {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 13px;
}
