:root {
  --bg: #f5f7fb;
  --text: #101828;
  --muted: #667085;
  --card: rgba(255, 255, 255, 0.9);
  --primary: #acd037;
  --primary-dark: #0f172a;
  --blue: #2563eb;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,0.05);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; }
h1, h2, h3, p { margin: 0; }

.app-shell {
  max-width: 1100px;
  margin: auto;
  padding: calc(var(--safe-top) + 16px) 16px calc(var(--safe-bottom) + 16px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.glass {
  background: var(--card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

/* Login */
.login-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(245,247,251,0.92);
  z-index: 100;
}
.login-overlay.hidden { display: none; }
.login-card { width: min(560px, 100%); padding: 24px; }
.login-brand { display: flex; gap: 16px; align-items: flex-start; }
.login-brand h2 { font-size: 40px; line-height: 1; margin-top: 2px; }
.login-brand p { margin-top: 12px; color: var(--muted); line-height: 1.5; }
.login-form { margin-top: 20px; }
.login-helper { margin: 4px 0 16px; font-size: 14px; color: var(--muted); }
.login-btn { width: 100%; }

/* Header */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.brand-chip {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: #122245;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.brand-chip img { width: 28px; }
.eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #98a2b3;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.title-wrap h1 {
  font-size: clamp(28px, 3vw, 42px);
  line-height: 0.95;
  letter-spacing: -0.05em;
}
.title-wrap p {
  margin-top: 6px;
  font-size: 14px;
  color: var(--muted);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 42px;
  height: 42px;
  background: #122245;
  color: white;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}
.user-meta {
  display: flex;
  flex-direction: column;
  font-size: 12px;
}
.user-name { font-weight: 700; }
.user-sub { color: var(--muted); }

/* Buttons */
.btn {
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary {
  background: var(--primary);
  color: var(--primary-dark);
}
.btn-secondary {
  background: white;
  border: 1px solid #eee;
  color: var(--text);
}

/* Toolbar */
.toolbar { padding: 14px; }
.toolbar-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.segmented {
  display: flex;
  gap: 6px;
  background: #eee;
  padding: 4px;
  border-radius: 16px;
}
.segmented button {
  border: none;
  padding: 10px 14px;
  border-radius: 12px;
  background: transparent;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}
.segmented button.active {
  background: white;
  color: black;
}
.mini-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #eee;
}
.mini-search input {
  border: none;
  outline: none;
  width: 100%;
  min-width: 120px;
}
.summary-row {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.summary-pill {
  background: white;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  box-shadow: var(--shadow);
}
.summary-label {
  color: var(--muted);
  margin-right: 6px;
}
.summary-value {
  font-weight: 800;
}

/* Main */
.main-grid { display: grid; grid-template-columns: 1fr; }
.queue { padding: 16px; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.panel-head h2 {
  font-size: 20px;
  line-height: 1;
}
.panel-head p {
  margin-top: 6px;
  color: var(--muted);
}
.panel-head-actions {
  display: flex;
  gap: 8px;
}
.chip {
  border: 1px solid #eee;
  background: white;
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
}

.issue-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.issue-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 14px;
  cursor: pointer;
  transition: 0.2s;
}
.issue-card:hover {
  transform: translateY(-2px);
}
.issue-card.active {
  outline: 2px solid rgba(172, 208, 55, 0.35);
}
.issue-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}
.issue-head-left {
  min-width: 0;
  flex: 1;
}
.issue-title {
  font-weight: 700;
  font-size: 18px;
}
.issue-desc {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.issue-meta {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.issue-footer {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.issue-created {
  font-size: 13px;
  color: var(--muted);
}
.action-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.action-mini {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 14px;
  border: 0;
  font-size: 14px;
  font-weight: 700;
  background: #fff;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.status-badge,
.priority-badge,
.meta-badge {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
}
.status-open { background: #e0ecff; color: var(--blue); }
.status-progress { background: #fff4e0; color: var(--amber); }
.status-completed { background: #e0f5e8; color: var(--green); }
.priority-high { background: #ffe4e4; color: var(--red); }
.priority-medium { background: #fff3e0; color: var(--amber); }
.priority-low { background: #e4fbe4; color: var(--green); }
.meta-badge {
  background: #f8fafc;
  color: var(--text);
}

/* Detail overlay */
.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.16);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 60;
}
.detail-overlay.open { display: flex; }
.detail-panel {
  width: min(760px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  padding: 18px;
}
.detail-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}
#detailsPane {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.detail-title {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.04em;
}
.detail-desc {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.5;
}
.detail-image {
  width: 100%;
  display: block;
  margin-top: 14px;
  border-radius: 18px;
}
.detail-tags {
  margin-top: 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.detail-block {
  background: white;
  border-radius: 16px;
  padding: 16px;
}
.detail-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #98a2b3;
  text-transform: uppercase;
}
.detail-value {
  margin-top: 8px;
  font-size: 18px;
  font-weight: 800;
}
.section-title {
  font-size: 17px;
  font-weight: 800;
}
.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.timeline-item {
  background: white;
  border-radius: 16px;
  padding: 15px;
}
.timeline-title {
  font-size: 16px;
  font-weight: 800;
}
.timeline-text {
  margin-top: 6px;
  font-size: 14px;
  color: var(--muted);
}
.timeline-time {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}
.icon-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 14px;
  background: white;
  box-shadow: var(--shadow);
  cursor: pointer;
}

/* Sheet */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.12);
  display: none;
  align-items: flex-end;
  justify-content: flex-end;
  z-index: 50;
}
.sheet-backdrop.open { display: flex; }
.sheet {
  width: min(560px, 100%);
  height: 100%;
  border-radius: 28px 0 0 28px;
  padding: 22px;
  overflow-y: auto;
}
.sheet-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.sheet-form { margin-top: 16px; }
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.field span {
  font-size: 12px;
  font-weight: 800;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.field input,
.field select,
.field textarea {
  min-height: 54px;
  border-radius: 16px;
  border: 1px solid rgba(16,24,40,0.07);
  background: white;
  padding: 14px 16px;
  color: var(--text);
  outline: 0;
  font-size: 15px;
}
.field textarea {
  min-height: 120px;
  resize: vertical;
}
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.image-preview {
  display: none;
  width: 100%;
  margin-top: 8px;
  border-radius: 16px;
  box-shadow: var(--shadow);
}

/* Fab */
.fab-wrap { display: none; }
.fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 64px;
  height: 64px;
  background: var(--primary);
  color: var(--primary-dark);
  border-radius: 20px;
  font-size: 28px;
  font-weight: 800;
  border: none;
  box-shadow: var(--shadow);
}
.muted { color: var(--muted); }

/* Mobile */
@media (max-width: 700px) {
  .topbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
  }

  .topbar-left {
    min-width: 0;
    flex: 1;
  }

  .title-wrap h1 {
    font-size: 20px;
  }

  .title-wrap p {
    display: none;
  }

  .topbar-right {
    width: auto;
    flex-wrap: nowrap;
    justify-content: flex-end;
    align-items: center;
  }

  .user-meta {
    display: none;
  }

  .user-chip {
    padding: 0;
    background: transparent;
    border: none;
  }

  .brand-chip {
    width: 42px;
    height: 42px;
  }

  .brand-chip img {
    width: 26px;
  }

  .user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    font-size: 16px;
  }

  .topbar-right .btn-secondary,
  .topbar-right .btn-primary {
    display: none;
  }

  .mini-search {
    width: 100%;
  }

  .mini-search input {
    min-width: 0;
  }

  .issue-card {
    padding: 12px;
  }

  .issue-title {
    font-size: 16px;
  }

  .issue-desc {
    font-size: 12px;
  }

  .issue-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .status-badge {
    width: auto !important;
    align-self: flex-start;
  }

  .issue-meta {
    gap: 6px;
  }

  .priority-badge,
  .meta-badge,
  .status-badge {
    font-size: 11px;
    padding: 5px 8px;
  }

  .issue-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .action-row {
    width: 100%;
    justify-content: space-between;
  }

  .action-mini {
    flex: 1;
    text-align: center;
    padding: 10px 0;
    font-size: 13px;
  }

  .detail-grid,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .detail-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .detail-panel {
    width: 100%;
    max-height: 94vh;
    border-radius: 28px 28px 0 0;
  }

  .sheet {
    width: 100%;
    height: min(92vh, 900px);
    border-radius: 28px 28px 0 0;
  }

  .fab-wrap {
    display: block;
  }

  .fab {
    bottom: 80px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .issue-head,
  .issue-footer,
  .detail-panel-head,
  .sheet-head {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-head-actions,
  .action-row,
  .sheet-actions {
    width: 100%;
  }

  .action-mini,
  .btn {
    width: 100%;
  }

  .segmented {
    width: 100%;
    justify-content: space-between;
  }

  .segmented button {
    flex: 1;
    padding: 10px 6px;
  }
}

/* ===== FINAL MOBILE POLISH ===== */

/* FIX FAB POSITION */
.fab {
  bottom: 110px !important;
  right: 18px;
  z-index: 10;
}

/* ADD SAFE SCROLL SPACE SO FAB NEVER OVERLAPS */
.list {
  padding-bottom: 140px;
}

/* CLEAN ACTION BUTTONS (NO BLUE LINKS) */
.action-mini {
  background: #f1f3f5;
  color: #1f2937;
  border-radius: 12px;
  font-weight: 600;
  border: none;
}

.action-mini.primary {
  background: #acd037;
  color: #0b1324;
}

/* FIX STATUS + TAG STACKING */
.issue-head {
  gap: 6px;
}

.issue-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* CLEAN STATUS CHIP */
.status-badge {
  background: #e6f0ff;
  color: #2563eb;
  font-weight: 600;
}

/* COMPLETED STATE */
.status-badge.completed {
  background: #e7f7ee;
  color: #1f9254;
}

/* SMALLER TEXT BALANCE */
.issue-meta-line {
  font-size: 12px;
  color: #6b7280;
}

.action-mini {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 14px;
  border: 0;
  font-size: 14px;
  font-weight: 700;
  background: #ffffff;
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.action-complete {
  background: #acd037;
  color: #0f172a;
}