:root {
  --bg: #f4f6f8;
  --bg-soft: #eef3f1;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f6;
  --text: #17212f;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --border: #dce4ea;
  --border-strong: #cbd5e1;
  --primary: #1f5f54;
  --primary-2: #3f8b73;
  --primary-dark: #173f39;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --warning: #b7791f;
  --warning-bg: #fff7e6;
  --success: #2f855a;
  --success-bg: #e8f6ee;
  --info: #2563eb;
  --info-bg: #eff6ff;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-md: 0 14px 35px rgba(15, 23, 42, .10);
  --shadow-lg: 0 22px 60px rgba(15, 23, 42, .16);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --sidebar-w: 282px;
  --topbar-h: 72px;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(63,139,115,.12), transparent 30rem),
    linear-gradient(135deg, #f7faf9 0%, #eef3f1 45%, #f5f7fa 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 900;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  padding: 18px;
  color: #e7f3ef;
  background: linear-gradient(180deg, #12332f 0%, #173f39 58%, #102722 100%);
  border-right: 1px solid rgba(255,255,255,.08);
  box-shadow: 18px 0 60px rgba(15,23,42,.16);
  transition: transform .24s ease, box-shadow .24s ease;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px 20px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.brand-copy { min-width: 0; flex: 1; }
.sidebar-collapse-btn {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-color: rgba(255,255,255,.12);
  background: rgba(255,255,255,.08);
  color: rgba(231,243,239,.9);
  box-shadow: none;
}
.sidebar-collapse-btn:hover { background: rgba(255,255,255,.14); color: #fff; }
.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(255,255,255,.1);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.brand-title { font-weight: 800; letter-spacing: -.02em; color: #fff; }
.brand-subtitle { margin-top: 1px; font-size: .78rem; color: rgba(231,243,239,.68); }
.sidebar-nav { display: grid; gap: 7px; padding: 18px 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 14px;
  color: rgba(231,243,239,.82);
  transition: background .2s ease, transform .2s ease, color .2s ease;
}
.nav-item i { width: 20px; text-align: center; color: rgba(231,243,239,.72); }
.nav-item:hover { background: rgba(255,255,255,.09); color: #fff; transform: translateX(2px); }
.nav-primary { background: rgba(63,139,115,.30); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.nav-divider { height: 1px; margin: 10px 4px; background: rgba(255,255,255,.10); }
.sidebar-footer { margin-top: auto; display: grid; gap: 10px; }
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px;
  border-radius: 16px;
  background: rgba(255,255,255,.08);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.user-avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
}
.user-name { font-weight: 750; color: #fff; line-height: 1.2; }
.user-role { font-size: .78rem; color: rgba(231,243,239,.64); }
.logout-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 14px;
  color: #f6d7d4;
  background: rgba(180,35,24,.12);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
}
.logout-link:hover { background: rgba(180,35,24,.18); color: #fff; }

.sidebar-scrim { display: none; }
.app-main { width: 100%; min-width: 0; margin-left: var(--sidebar-w); transition: margin-left .24s ease; }
body.sidebar-collapsed .app-sidebar { transform: translateX(-105%); box-shadow: none; }
body.sidebar-collapsed .app-main { margin-left: 0; }
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 800;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 28px;
  background: rgba(248,250,252,.82);
  border-bottom: 1px solid rgba(203,213,225,.72);
  backdrop-filter: blur(18px);
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.sidebar-toggle { display: none; }
body.sidebar-collapsed .sidebar-toggle { display: inline-grid; }
.topbar-title { display: grid; line-height: 1.15; }
.topbar-title strong { font-size: 1.05rem; letter-spacing: -.02em; }
.topbar-eyebrow { font-size: .75rem; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .08em; }
.topbar-meta {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: .88rem;
  box-shadow: var(--shadow-sm);
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 5px rgba(47,133,90,.12);
}
.app-content { padding: 28px; }

.page-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}
.page-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--primary);
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.page-title {
  margin: 5px 0 5px;
  font-size: clamp(1.65rem, 1.15rem + 1.4vw, 2.35rem);
  line-height: 1.08;
  letter-spacing: -.04em;
}
.page-subtitle { margin: 0; color: var(--muted); max-width: 760px; }
.page-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 0 0 18px;
}
.metric-card {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(220,228,234,.84);
  border-radius: var(--radius);
  background: rgba(255,255,255,.86);
  box-shadow: var(--shadow-sm);
}
.metric-card::after {
  content: '';
  position: absolute;
  right: -34px;
  top: -34px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(31,95,84,.08);
}
.metric-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 14px;
  background: var(--bg-soft);
  color: var(--primary);
}
.metric-label { color: var(--muted); font-size: .82rem; font-weight: 700; }
.metric-value { margin-top: 2px; font-size: 1.6rem; font-weight: 850; letter-spacing: -.04em; }
.metric-text {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.05rem;
}


.panel {
  border: 1px solid rgba(220,228,234,.86);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.90);
  box-shadow: var(--shadow-sm);
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.panel-title { margin: 0; font-size: 1rem; letter-spacing: -.01em; }
.panel-subtitle { margin: 2px 0 0; color: var(--muted); font-size: .86rem; }
.panel-body { padding: 18px; }

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,.82);
  margin-bottom: 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.65);
}
.toolbar-left {
  display: grid;
  grid-template-columns: minmax(260px, 1.45fr) repeat(auto-fit, minmax(190px, .72fr));
  gap: 10px;
  align-items: center;
  min-width: 0;
}
.toolbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: max-content;
}
.toolbar-left > * { min-width: 0; }
.search-control { position: relative; min-width: 0; }
.search-control i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted-2); pointer-events: none; }
.search-control input { padding-left: 38px; }
.toolbar select, .toolbar input { min-height: 42px; }
.row-counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: .86rem;
  font-weight: 750;
  white-space: nowrap;
}

.btn, .action-btn, .button-link, button[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 9px 13px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-weight: 750;
  line-height: 1.1;
  box-shadow: 0 8px 18px rgba(31,95,84,.14);
  transition: transform .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.btn:hover, .action-btn:hover, button[type="submit"]:hover { transform: translateY(-1px); background: var(--primary-dark); box-shadow: 0 12px 22px rgba(31,95,84,.18); }
.btn-outline, .button-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-outline:hover, .button-ghost:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.btn-sm { min-height: 32px; padding: 7px 10px; border-radius: 10px; font-size: .86rem; }
.action-delete, .btn-danger, .remove-btn { background: var(--danger); color: #fff; }
.action-delete:hover, .btn-danger:hover, .remove-btn:hover { background: #8f1d14; }
.action-seen { background: #2563eb; }
.action-resolved { background: var(--success); }
.btn-archive, .btn-restore { background: #334155; }
.disabled { color: var(--muted-2); }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
textarea { min-height: 78px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: rgba(31,95,84,.55);
  box-shadow: 0 0 0 4px rgba(31,95,84,.10);
}
label { display: inline-block; margin-bottom: 7px; font-weight: 750; color: #334155; }
.form-row { display: grid; gap: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }

.table-wrapper {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 13px 14px;
  background: #f8fafc;
  color: #475569;
  font-size: .76rem;
  font-weight: 850;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: .055em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 13px 14px;
  vertical-align: top;
  border-bottom: 1px solid #edf2f7;
  color: #243244;
}
tbody tr { transition: background .18s ease; }
tbody tr:hover { background: #fbfdfc; }
tbody tr:last-child td { border-bottom: 0; }
.status-new td:first-child { box-shadow: inset 4px 0 0 var(--warning); }
.status-seen td:first-child { box-shadow: inset 4px 0 0 var(--info); }
.status-resolved td:first-child { box-shadow: inset 4px 0 0 var(--success); }
.issue-seq {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: #334155;
  font-weight: 850;
  font-size: .82rem;
}
.status-badge, .mention-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 6px 9px;
  border-radius: 999px;
  font-weight: 800;
  font-size: .78rem;
  white-space: nowrap;
}
.status-badge.new { color: #8a4b0f; background: var(--warning-bg); }
.status-badge.seen { color: #1d4ed8; background: var(--info-bg); }
.status-badge.resolved { color: var(--success); background: var(--success-bg); }
.mention-badge { margin-top: 8px; color: var(--danger); background: var(--danger-bg); }
.thumb {
  width: 64px;
  height: 52px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.comments { display: grid; gap: 8px; }
.comment {
  padding: 8px 10px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  font-size: .88rem;
}
.comment small { color: var(--muted); display: block; margin-bottom: 2px; }
.open-comments-btn.has-comment { background: var(--info); color: #fff; }
.open-comments-btn.flash { animation: flash-btn 1s ease-in-out infinite; }
@keyframes flash-btn { 0%, 100% { box-shadow: 0 0 0 0 rgba(37,99,235,.24); } 50% { box-shadow: 0 0 0 8px rgba(37,99,235,.08); } }

.modal {
  display: none;
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: rgba(15,23,42,.68);
  backdrop-filter: blur(7px);
  z-index: 2200;
  padding: 22px;
}
.modal.active { display: flex; }
.modal-img { max-width: min(92vw, 1120px); max-height: 88vh; border-radius: 18px; box-shadow: var(--shadow-lg); }
.modal-close {
  position: absolute;
  top: 18px;
  right: 24px;
  color: #fff;
  font-size: 2rem;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
}
.modal-content {
  position: relative;
  width: min(520px, 100%);
  max-height: 84vh;
  overflow: auto;
  padding: 22px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.modal-content .modal-close { color: var(--text); top: 10px; right: 16px; font-size: 1.5rem; }
.modal-content h3, .modal-content h2 { margin: 0 0 14px; color: var(--text); }
.modal-comments { display: grid; gap: 8px; margin: 12px 0 16px; max-height: 320px; overflow: auto; }
#modalCommentForm { display: flex; gap: 8px; }
#modalCommentForm input { flex: 1; }
#mentionBox {
  border: 1px solid var(--border) !important;
  box-shadow: var(--shadow-md) !important;
  border-radius: 12px !important;
}

.empty-state {
  padding: 38px 18px;
  text-align: center;
  color: var(--muted);
}
.empty-state i { display: block; margin-bottom: 10px; font-size: 1.8rem; color: var(--primary); }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .app-sidebar { transform: translateX(-105%); }
  body.sidebar-open .app-sidebar { transform: translateX(0); }
  body.sidebar-collapsed .app-sidebar { transform: translateX(-105%); }
  .sidebar-scrim {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 850;
    background: rgba(15,23,42,.44);
    backdrop-filter: blur(3px);
  }
  body.sidebar-open .sidebar-scrim { display: block; }
  .app-main, body.sidebar-collapsed .app-main { margin-left: 0; }
  .sidebar-collapse-btn { display: none; }
  .sidebar-toggle,
  body.sidebar-collapsed .sidebar-toggle { display: inline-grid; }
  .app-content { padding: 20px; }
  .page-hero { flex-direction: column; }
  .page-actions { justify-content: flex-start; }
}

@media (max-width: 760px) {
  .app-topbar { height: 64px; padding: 0 14px; }
  .topbar-meta { display: none; }
  .metric-grid { grid-template-columns: 1fr; }
  .toolbar { grid-template-columns: 1fr; align-items: stretch; }
  .toolbar-left { grid-template-columns: 1fr; }
  .toolbar-right { justify-content: flex-start; min-width: 0; }
  .toolbar-left, .toolbar-right, .search-control { width: 100%; }
  .toolbar select, .toolbar input, .row-counter { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .table-wrapper { overflow: visible; border: 0; background: transparent; box-shadow: none; }
  .issues-table, .issues-table thead, .issues-table tbody, .issues-table th, .issues-table td, .issues-table tr { display: block; width: 100%; }
  .issues-table thead { display: none; }
  .issues-table tbody { display: grid; gap: 12px; }
  .issues-table tr {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }
  .issues-table td {
    display: grid;
    grid-template-columns: minmax(120px, 38%) 1fr;
    gap: 10px;
    align-items: start;
    padding: 11px 13px;
    border-bottom: 1px solid #edf2f7;
  }
  .issues-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: .75rem;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: .05em;
  }
  .issues-table td:last-child { border-bottom: 0; }
  .status-new td:first-child, .status-seen td:first-child, .status-resolved td:first-child { box-shadow: none; }
  .page-title { font-size: 1.55rem; }
  #modalCommentForm { flex-direction: column; }
}

@media (max-width: 480px) {
  .app-content { padding: 14px; }
  .panel-header { flex-direction: column; align-items: flex-start; }
  .metric-card { padding: 14px; }
}
