:root {
  --bg-page: #0a0e17;
  --bg-card: #131b2a;
  --bg-card-alt: #1a2336;
  --border: #232f46;
  --border-focus: #38bdf8;
  
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --brand-blue: #2563eb;
  --brand-cyan: #38bdf8;
  --brand-gold: #f59e0b;
  --brand-green: #10b981;
  --brand-purple: #a855f7;
  --brand-red: #ef4444;

  --tier-l: #fb923c;
  --tier-m: #c084fc;
  --tier-s: #38bdf8;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  background-color: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* App container */
.shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem 1rem;
}

/* Header */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.logo {
  height: 42px;
  width: auto;
  display: block;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
}

.user-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.user-dropdown {
  background: transparent;
  border: none;
  color: var(--brand-cyan);
  font-size: 0.82rem;
  font-weight: 700;
  outline: none;
  cursor: pointer;
}

.user-dropdown option {
  background: #131b2a;
  color: #fff;
}

.btn-create {
  background: var(--brand-blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-create:hover {
  opacity: 0.9;
}

/* Sub controls bar */
.controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.25rem 0 1.5rem 0;
}

.tabs {
  display: flex;
  gap: 0.35rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.25rem;
  border-radius: 8px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tab-btn.active {
  background: var(--brand-blue);
  color: #fff;
}

.tab-badge {
  background: rgba(0, 0, 0, 0.3);
  font-size: 0.72rem;
  padding: 0.1rem 0.4rem;
  border-radius: 10px;
}

.meta-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.sync-indicator .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand-green);
}

.btn-text {
  background: transparent;
  border: none;
  color: var(--brand-cyan);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.btn-text:hover {
  text-decoration: underline;
}

/* Panels */
.view-panel {
  display: none;
}

.view-panel.active {
  display: block;
}

/* Orders Grid */
.orders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

@media (max-width: 480px) {
  .orders-grid {
    grid-template-columns: 1fr;
  }
}

/* Order Card */
.order-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  transition: border-color 0.15s;
}

.order-card:hover {
  border-color: #334155;
}

.order-card.fulfilled {
  border-color: rgba(16, 185, 129, 0.4);
}

/* Card Header */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.card-title-group {
  display: flex;
  flex-direction: column;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
}

.card-source {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.card-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tier-pill {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 0.8rem;
}

.tier-pill.L {
  background: rgba(251, 146, 60, 0.15);
  color: var(--tier-l);
  border: 1.5px solid var(--tier-l);
}

.tier-pill.M {
  background: rgba(192, 132, 252, 0.15);
  color: var(--tier-m);
  border: 1.5px solid var(--tier-m);
}

.tier-pill.S {
  background: rgba(56, 189, 248, 0.15);
  color: var(--tier-s);
  border: 1.5px solid var(--tier-s);
}

.btn-del {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 4px;
}

.btn-del:hover {
  color: var(--brand-red);
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.05rem;
  padding: 2px 4px;
  line-height: 1;
}

.btn-icon:hover {
  color: var(--brand-cyan);
}

/* Reward strip */
.reward-strip {
  display: flex;
  justify-content: space-between;
  background: var(--bg-card-alt);
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  font-size: 0.78rem;
}

.reward-col {
  display: flex;
  flex-direction: column;
}

.reward-lbl {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
}

.reward-val {
  font-weight: 700;
  color: var(--brand-gold);
}

/* Progress */
.progress-block {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.82rem;
}

.progress-delivered {
  font-weight: 700;
  color: var(--text-primary);
}

.progress-remaining {
  font-weight: 800;
  color: var(--brand-cyan);
}

.progress-remaining.done {
  color: var(--brand-green);
}

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: #090e18;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.progress-bar-fill {
  height: 100%;
  background: var(--brand-blue);
  border-radius: 4px;
  transition: width 0.25s ease;
}

.progress-bar-fill.done {
  background: var(--brand-green);
}

.progress-foot {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Input / Contribute Row */
.action-zone {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chip-btn {
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.3rem 0.55rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.1s;
}

.chip-btn:hover {
  background: var(--brand-blue);
  color: #fff;
  border-color: var(--brand-blue);
}

.input-action-row {
  display: flex;
  gap: 0.4rem;
}

.input-qty {
  flex: 1;
  min-width: 0;
  background: #090e18;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  outline: none;
}

.input-qty:focus {
  border-color: var(--border-focus);
}

.btn-add {
  background: var(--brand-blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.btn-add:hover {
  opacity: 0.9;
}

.btn-fulfill {
  width: 100%;
  background: rgba(168, 85, 247, 0.15);
  color: var(--brand-purple);
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-radius: 6px;
  padding: 0.45rem;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-fulfill:hover {
  background: var(--brand-purple);
  color: #fff;
}

.btn-fulfill.done {
  background: rgba(16, 185, 129, 0.15);
  color: var(--brand-green);
  border-color: rgba(16, 185, 129, 0.35);
  cursor: default;
}

.btn-fulfill.reopen {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
  cursor: pointer;
}

.btn-fulfill.reopen:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #fff;
  border-color: #f87171;
}

/* Activity Tab View */
.activity-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}

.activity-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.85rem;
}

.activity-head h2 {
  font-size: 1.05rem;
  font-weight: 800;
}

.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.feed-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  background: var(--bg-card-alt);
  padding: 0.55rem 0.75rem;
  border-radius: 6px;
  font-size: 0.82rem;
}

.feed-user {
  font-weight: 700;
  color: var(--brand-cyan);
}

.feed-action {
  color: var(--text-primary);
}

.feed-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
}

.modal-backdrop.open {
  display: flex;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  max-width: 440px;
  padding: 1.25rem;
}

.modal-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.modal-top h3 {
  font-size: 1.1rem;
  font-weight: 800;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.35rem;
  cursor: pointer;
}

.input-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.input-field label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.input-field input, .input-field select {
  background: #090e18;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
  color: #fff;
  font-size: 0.85rem;
  outline: none;
}

.input-field input:focus, .input-field select:focus {
  border-color: var(--border-focus);
}

.input-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.btn-cancel {
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-submit {
  background: var(--brand-blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.45rem 0.95rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
